ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_AdvanceGeneralAD.cpp File Reference
#include <ERF_GeneralAD.H>
#include <ERF_IndexDefines.H>
#include <ERF_LengthScaleCellSize.H>
#include <ERF_Interpolation_1D.H>
#include <cmath>
#include <ERF_NumericalConstants.H>
Include dependency graph for ERF_AdvanceGeneralAD.cpp:

Functions

AMREX_FORCE_INLINE AMREX_GPU_DEVICE int find_rad_loc_index (const Real rad, const Real *bld_rad_loc, const int n_bld_sections)
 
AMREX_FORCE_INLINE AMREX_GPU_DEVICE std::array< Real, 2 > compute_source_terms_Fn_Ft (const Real rad, const Real avg_vel, const Real *bld_rad_loc, const Real *bld_twist, const Real *bld_chord, int n_bld_sections, const Real *bld_airfoil_aoa, const Real *bld_airfoil_Cl, const Real *bld_airfoil_Cd, const int n_pts_airfoil, const Real *velocity, const Real *rotor_RPM, const Real *blade_pitch, const int n_spec_extra)
 

Function Documentation

◆ compute_source_terms_Fn_Ft()

AMREX_FORCE_INLINE AMREX_GPU_DEVICE std::array<Real,2> compute_source_terms_Fn_Ft ( const Real  rad,
const Real  avg_vel,
const Real *  bld_rad_loc,
const Real *  bld_twist,
const Real *  bld_chord,
int  n_bld_sections,
const Real *  bld_airfoil_aoa,
const Real *  bld_airfoil_Cl,
const Real *  bld_airfoil_Cd,
const int  n_pts_airfoil,
const Real *  velocity,
const Real *  rotor_RPM,
const Real *  blade_pitch,
const int  n_spec_extra 
)
231 {
232 
233  Real rpm = interpolate_1d(velocity, rotor_RPM, avg_vel, n_spec_extra);
234  Real pitch = interpolate_1d(velocity, blade_pitch, avg_vel, n_spec_extra);
235 
236  Real Omega = rpm/Real(60.0)*two*PI;
237  Real rho = Real(1.226);
238 
239  Real B = three;
240  Real rhub = two;
241  Real rtip = Real(63.5);
242 
243  Real twist = interpolate_1d(bld_rad_loc, bld_twist, rad, n_bld_sections);
244  Real c = interpolate_1d(bld_rad_loc, bld_chord, rad, n_bld_sections);
245 
246  // Iteration procedure
247 
248  Real s = myhalf*c*B/(PI*rad);
249 
250  Real at, an, V1, Vt, Vr, psi, L, D, Cn, Ct;
251  Real ftip, fhub, F, Cl, Cd, at_new, an_new;
252 
253  at = Real(0.1);
254  an = Real(0.1);
255 
256  bool is_converged = false;
257 
258  for(int i=0;i<100;i++) {
259  V1 = avg_vel*(1-an);
260  Vt = Omega*(one+at)*rad;
261  Vr = std::pow(V1*V1+Vt*Vt,myhalf);
262 
263  psi = std::atan2(V1,Vt);
264 
265  Real aoa = psi*Real(180.0)/PI - twist + pitch;
266 
267  Cl = interpolate_1d(bld_airfoil_aoa, bld_airfoil_Cl, aoa, n_pts_airfoil);
268  Cd = interpolate_1d(bld_airfoil_aoa, bld_airfoil_Cd, aoa, n_pts_airfoil);
269 
270  //Cl = Real(1.37);
271  //Cd = Real(0.014);
272 
273  //printf("rad, aoa, Cl, Cd = %0.15g %0.15g %0.15g %0.15g\n", rad, aoa, Cl, Cd);
274 
275  Cn = Cl*std::cos(psi) + Cd*std::sin(psi);
276  Ct = Cl*std::sin(psi) - Cd*std::cos(psi);
277 
278  ftip = B*(rtip-rad)/(two*rad*std::sin(psi)+Real(1e-10));
279  fhub = B*(rad-rhub)/(two*rad*std::sin(psi)+Real(1e-10));
280 
281  AMREX_ALWAYS_ASSERT(std::fabs(std::exp(-fhub))<=one);
282  AMREX_ALWAYS_ASSERT(std::fabs(std::exp(-ftip))<=one);
283 
284  F = two/PI*(std::acos(std::exp(-ftip)) + std::acos(std::exp(-fhub)) );
285 
286  at_new = one/ ( Real(4.0)*F*std::sin(psi)*std::cos(psi)/(s*Ct+Real(1e-10)) - one );
287  an_new = one/ ( one + Real(4.0)*F*amrex::Math::powi<2>(std::sin(psi))/(s*Cn + Real(1e-10)) );
288  at_new = std::max(Real(0.), at_new);
289 
290  if(std::fabs(at_new-at) < Real(1e-5) and std::fabs(an_new-an) < Real(1e-5)) {
291  //printf("Converged at, an = %d %0.15g %0.15g %0.15g\n",i, at, an, psi);
292  at = at_new;
293  an = an_new;
294  is_converged = true;
295  break;
296  }
297  at = at_new;
298  an = an_new;
299  //printf("Iteration, at, an = %0.15g %0.15g %0.15g\n",at, an, psi);
300  }
301 
302  if(!is_converged) {
303  Abort("The iteration procedure for the generalized actuator disk did not converge. Exiting...");
304  }
305 
306  // Iterations converged. Now compute Ft, Fn
307 
308  L = myhalf*rho*Vr*Vr*c*Cl;
309  D = myhalf*rho*Vr*Vr*c*Cd;
310 
311  Real Fn = L*std::cos(psi) + D*std::sin(psi);
312  Real Ft = L*std::sin(psi) - D*std::cos(psi);
313 
314  //printf("Fn and Ft %0.15g %0.15g %0.15g %0.15g\n", L, D, std::cos(psi), std::sin(psi));
315 
316  std::array<Real, 2> Fn_and_Ft;
317  Fn_and_Ft[0] = Fn;
318  Fn_and_Ft[1] = Ft;
319 
320  return Fn_and_Ft;
321 
322  //exit(0);
323 }
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real interpolate_1d(const amrex::Real *alpha, const amrex::Real *beta, const amrex::Real alpha_interp, const int alpha_size)
Definition: ERF_Interpolation_1D.H:15
constexpr amrex::Real three
Definition: ERF_NumericalConstants.H:39
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
@ rho
Definition: ERF_Kessler.H:25

Referenced by GeneralAD::source_terms_cellcentered().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_rad_loc_index()

AMREX_FORCE_INLINE AMREX_GPU_DEVICE int find_rad_loc_index ( const Real  rad,
const Real *  bld_rad_loc,
const int  n_bld_sections 
)
187 {
188  // Find the index of the radial location
189  int index=-1;
190  Real rhub = two;
191  Real rad_from_hub = rad - rhub;
192  if(rad_from_hub < zero) {
193  index = 0;
194  }
195  else {
196  for(int i=0;i<n_bld_sections;i++){
197  if(bld_rad_loc[i] > rad) {
198  index = i;
199  break;
200  }
201  }
202  }
203  if(index == -1 and rad > bld_rad_loc[n_bld_sections-1]) {
204  index = n_bld_sections-1;
205  }
206  if(index == -1) {
207  //printf("The radial section is at %0.15g m\n",rad);
208  Abort("Could not find index of the radial section.");
209  }
210 
211  return index;
212 }
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36

Referenced by GeneralAD::source_terms_cellcentered().

Here is the caller graph for this function: