GRINS-0.8.0
averaged_turbine_base.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // This class
28 
29 // GRINS
32 
33 namespace GRINS
34 {
35 
36  template<class Mu>
37  AveragedTurbineBase<Mu>::AveragedTurbineBase( const std::string& physics_name, const GetPot& input )
38  : IncompressibleNavierStokesBase<Mu>(physics_name,
39  PhysicsNaming::incompressible_navier_stokes(), /* "core" Physics name */
40  input),
41  base_velocity_function(""),
42  local_vertical_function(""),
43  lift_function(""),
44  drag_function(""),
45  torque_function(""),
46  chord_function(""),
47  area_swept_function(""),
48  aoa_function(""),
49  _var(GRINSPrivate::VariableWarehouse::get_variable_subclass<ScalarVariable>(VariablesParsing::scalar_variable_name(input,physics_name,VariablesParsing::PHYSICS)))
50  {
51  this->read_input_options(input);
52  }
53 
54  template<class Mu>
55  void AveragedTurbineBase<Mu>::set_time_evolving_vars( libMesh::FEMSystem* system )
56  {
57  system->time_evolving(this->fan_speed_var(), 1);
58 
60  }
61 
62 
63  template<class Mu>
64  void AveragedTurbineBase<Mu>::read_input_options( const GetPot& input )
65  {
66  this->set_parameter(base_velocity_function, input,
67  "Physics/"+PhysicsNaming::averaged_turbine()+"/base_velocity",
68  this->zero_vector_function);
69 
70  if (base_velocity_function.expression() == this->zero_vector_function)
71  libmesh_error_msg("Error! Zero AveragedTurbine specified!" <<
72  std::endl);
73 
74  this->set_parameter(local_vertical_function, input,
75  "Physics/"+PhysicsNaming::averaged_turbine()+"/local_vertical",
76  this->zero_vector_function);
77 
78  if (local_vertical_function.expression() == this->zero_vector_function)
79  libmesh_error_msg("Error! Zero LocalVertical specified!" <<
80  std::endl);
81 
82  this->set_parameter(lift_function, input,
83  "Physics/"+PhysicsNaming::averaged_turbine()+"/lift",
84  "0");
85 
86  if (lift_function.expression() == "0")
87  std::cout << "Warning! Zero lift function specified!" << std::endl;
88 
89  this->set_parameter(drag_function, input,
90  "Physics/"+PhysicsNaming::averaged_turbine()+"/drag",
91  "0");
92 
93  if (drag_function.expression() == "0")
94  std::cout << "Warning! Zero drag function specified!" << std::endl;
95 
96  this->set_parameter(chord_function, input,
97  "Physics/"+PhysicsNaming::averaged_turbine()+"/chord_length",
98  "0");
99 
100  if (chord_function.expression() == "0")
101  libmesh_error_msg("Error! Zero chord function specified!" <<
102  std::endl);
103 
104  this->set_parameter(area_swept_function, input,
105  "Physics/"+PhysicsNaming::averaged_turbine()+"/area_swept",
106  "0");
107 
108  if (area_swept_function.expression() == "0")
109  libmesh_error_msg("Error! Zero area_swept_function specified!" <<
110  std::endl);
111 
112  this->set_parameter(aoa_function, input,
113  "Physics/"+PhysicsNaming::averaged_turbine()+"/angle_of_attack",
114  "00000");
115 
116  if (aoa_function.expression() == "00000")
117  libmesh_error_msg("Error! No angle-of-attack specified!" <<
118  std::endl);
119 
120  this->set_parameter(torque_function, input,
121  "Physics/"+PhysicsNaming::averaged_turbine()+"/torque",
122  "0");
123 
124  if (torque_function.expression() == "0")
125  std::cout << "Warning! Zero torque function specified!" << std::endl;
126 
127  this->set_parameter
128  (this->moment_of_inertia, input,
129  "Physics/"+PhysicsNaming::averaged_turbine()+"/moment_of_inertia",
130  libMesh::Number(0));
131 
132  if (!moment_of_inertia)
133  libmesh_error_msg(
134  "Error! Zero AveragedTurbine moment of inertia specified!" <<
135  std::endl);
136 
137  this->set_parameter
138  (this->initial_speed, input,
139  "Physics/"+PhysicsNaming::averaged_turbine()+"/initial_speed",
140  libMesh::Number(0));
141  }
142 
143  template<class Mu>
145  ( const libMesh::Point& point,
146  const libMesh::Real time,
147  const libMesh::NumberVectorValue& U,
148  libMesh::Number s,
149  libMesh::NumberVectorValue& U_B_1,
150  libMesh::NumberVectorValue& F,
151  libMesh::NumberTensorValue *dFdU,
152  libMesh::NumberVectorValue *dFds)
153  {
154  // Find base velocity of moving fan at this point
155  libMesh::DenseVector<libMesh::Number> output_vec(3);
156 
157  base_velocity_function(point, time, output_vec);
158 
159  U_B_1(0) = output_vec(0);
160  U_B_1(1) = output_vec(1);
161  U_B_1(2) = output_vec(2);
162 
163  const libMesh::NumberVectorValue U_B = U_B_1 * s;
164 
165  const libMesh::Number U_B_size = U_B.norm();
166 
167  // If there's no base velocity there's no fan
168  if (!U_B_size)
169  return false;
170 
171  // Normal in fan velocity direction
172  const libMesh::NumberVectorValue N_B =
173  libMesh::NumberVectorValue(U_B/U_B_size);
174 
175  local_vertical_function(point, time, output_vec);
176 
177  // Normal in fan vertical direction
178  const libMesh::NumberVectorValue N_V(output_vec(0),
179  output_vec(1),
180  output_vec(2));
181 
182  // Normal in radial direction (or opposite radial direction,
183  // for fans turning clockwise!)
184  const libMesh::NumberVectorValue N_R = N_B.cross(N_V);
185 
186  // Fan-wing-plane component of local relative velocity
187  const libMesh::NumberVectorValue U_P = U - (U*N_R)*N_R - U_B;
188 
189  const libMesh::Number U_P_size = U_P.norm();
190 
191  // If there's no flow in the fan's frame of reference, there's no
192  // lift or drag. FIXME - should we account for drag in the
193  // out-of-plane direction?
194  if (!U_P_size)
195  return false;
196 
197  // Direction opposing drag
198  const libMesh::NumberVectorValue N_drag =
199  libMesh::NumberVectorValue(-U_P/U_P_size);
200 
201  // Direction opposing lift
202  const libMesh::NumberVectorValue N_lift = N_drag.cross(N_R);
203 
204  // "Forward" velocity
205  const libMesh::Number u_fwd = -(U_P * N_B);
206 
207  // "Upward" velocity
208  const libMesh::Number u_up = U_P * N_V;
209 
210  // If there's no forward or upward velocity we should have already
211  // returned false
212  libmesh_assert (u_up || u_fwd);
213 
214  // Angle WRT fan velocity direction
215  const libMesh::Number part_angle = std::atan2(u_up, u_fwd);
216 
217  // Angle WRT fan chord
218  const libMesh::Number angle = part_angle +
219  aoa_function(point, time);
220 
221  const libMesh::Number C_lift = lift_function(point, angle);
222  const libMesh::Number C_drag = drag_function(point, angle);
223 
224  const libMesh::Number chord = chord_function(point, time);
225  const libMesh::Number area = area_swept_function(point, time);
226 
227  const libMesh::Number v_sq = U_P*U_P;
228 
229  const libMesh::Number LDfactor = 0.5 * this->_rho * v_sq * chord / area;
230  const libMesh::Number lift = C_lift * LDfactor;
231  const libMesh::Number drag = C_drag * LDfactor;
232 
233  // Force
234  F = lift * N_lift + drag * N_drag;
235 
236  if (dFdU)
237  {
238  const libMesh::NumberVectorValue LDderivfactor =
239  (N_lift*C_lift+N_drag*C_drag) *
240  this->_rho * chord / area;
241 
242  const libMesh::Number sfactor = -(U_P*U_B_1);
243 
244  (*dFds) = LDderivfactor * sfactor;
245 
246  for (unsigned int i=0; i != 3; ++i)
247  for (unsigned int j=0; j != 3; ++j)
248  (*dFdU)(i,j) = LDderivfactor(i) * U_P(j);
249  }
250 
251  return true;
252  }
253 
254 } // namespace GRINS
255 
256 // Instantiate
257 INSTANTIATE_INC_NS_SUBCLASS(AveragedTurbineBase);
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Sets turbine_speed and velocity variables to be time-evolving.
Physics class for Incompressible Navier-Stokes.
INSTANTIATE_INC_NS_SUBCLASS(AveragedTurbineBase)
GRINS namespace.
static PhysicsName averaged_turbine()
Variables with a single SCALAR component.
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Sets velocity variables to be time-evolving.
bool compute_force(const libMesh::Point &point, const libMesh::Real time, const libMesh::NumberVectorValue &U, libMesh::Number s, libMesh::NumberVectorValue &U_B_1, libMesh::NumberVectorValue &F, libMesh::NumberTensorValue *dFdU=NULL, libMesh::NumberVectorValue *dFds=NULL)
void read_input_options(const GetPot &input)
Read options from GetPot input file.

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1