ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_NullWindFarm.H
Go to the documentation of this file.
1 #ifndef ERF_NULLWINDFARM_H
2 #define ERF_NULLWINDFARM_H
3 
4 #include <ERF_DataStruct.H>
5 #include <AMReX_Geometry.H>
6 #include <AMReX_MultiFab.H>
7 #include <AMReX_Gpu.H>
8 
9 /**
10  * Height above the ground of the horizontal face kf at the center of column (i,j). With
11  * z_phys_nd (zp) it is the mean of the four nodes of the face minus that of the bottom face
12  * klo; without it, the uniform spacing dz above the domain bottom. Wind farm hub heights are
13  * measured from the ground, as in WindFarm::fill_SMark_multifab*.
14  */
15 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
16 amrex::Real windfarm_face_height_above_ground (const amrex::Array4<const amrex::Real>& zp,
17  int i, int j, int kf, int klo, amrex::Real dz) noexcept
18 {
19  if (zp) {
20  auto zface = [&] (int k) {
21  return amrex::Real(0.25) * (zp(i,j,k) + zp(i+1,j,k) + zp(i,j+1,k) + zp(i+1,j+1,k));
22  };
23  return zface(kf) - zface(klo);
24  }
25  return (kf - klo) * dz;
26 }
27 
28 class NullWindFarm {
29 
30 public:
31 
33 
34  virtual ~NullWindFarm () = default;
35 
36  virtual void advance (const amrex::Geometry& a_geom,
37  const double& dt_advance,
38  amrex::MultiFab& cons_in,
39  amrex::MultiFab& mf_vars_windfarm,
40  amrex::MultiFab& U_old,
41  amrex::MultiFab& V_old,
42  amrex::MultiFab& W_old,
43  const amrex::MultiFab& mf_Nturb,
44  const amrex::MultiFab& mf_SMark,
45  const amrex::MultiFab* z_phys_nd,
46  const amrex::MultiFab* z_phys_cc,
47  const double& time) = 0;
48 
49  virtual void set_turb_spec (const amrex::Real& rotor_rad, const amrex::Real& hub_height,
50  const amrex::Real& thrust_coeff_standing, const amrex::Vector<amrex::Real>& wind_speed,
51  const amrex::Vector<amrex::Real>& thrust_coeff,
52  const amrex::Vector<amrex::Real>& power)
53  {
54  m_rotor_rad = rotor_rad;
55  m_hub_height = hub_height;
56  m_thrust_coeff_standing = thrust_coeff_standing;
57  m_wind_speed = wind_speed;
58  m_thrust_coeff = thrust_coeff;
59  m_power = power;
60  }
61 
62  virtual void set_turb_loc (const amrex::Vector<amrex::Real>& xloc,
63  const amrex::Vector<amrex::Real>& yloc)
64  {
65  m_xloc = xloc;
66  m_yloc = yloc;
67  }
68 
69  //! Ground elevation under each turbine (the hub is hub_height above it)
70  virtual void set_turb_zloc (const amrex::Vector<amrex::Real>& zloc)
71  {
72  m_zloc = zloc;
73  }
74 
75  virtual void set_turb_disk_angle (const amrex::Real& turb_disk_angle)
76  {
77  m_turb_disk_angle = turb_disk_angle;
78  }
79 
80  virtual void set_blade_spec (const amrex::Vector<amrex::Real>& bld_rad_loc,
81  const amrex::Vector<amrex::Real>& bld_twist,
82  const amrex::Vector<amrex::Real>& bld_chord)
83  {
84  m_bld_rad_loc = bld_rad_loc;
85  m_bld_twist = bld_twist;
86  m_bld_chord = bld_chord;
87  }
88 
89  virtual void set_blade_airfoil_spec (const amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_aoa,
90  const amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cl,
91  const amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cd)
92  {
93  m_bld_airfoil_aoa = bld_airfoil_aoa;
94  m_bld_airfoil_Cl = bld_airfoil_Cl;
95  m_bld_airfoil_Cd = bld_airfoil_Cd;
96  }
97 
98  virtual void set_turb_spec_extra (const amrex::Vector<amrex::Real>& velocity,
99  const amrex::Vector<amrex::Real>& C_P,
100  const amrex::Vector<amrex::Real>& C_T,
101  const amrex::Vector<amrex::Real>& rotor_RPM,
102  const amrex::Vector<amrex::Real>& blade_pitch)
103  {
104  m_velocity = velocity;
105  m_C_P = C_P;
106  m_C_T = C_T;
107  m_rotor_RPM = rotor_RPM;
108  m_blade_pitch = blade_pitch;
109  }
110 
111  void get_turb_spec (amrex::Real& rotor_rad, amrex::Real& hub_height,
112  amrex::Real& thrust_coeff_standing, amrex::Vector<amrex::Real>& wind_speed,
113  amrex::Vector<amrex::Real>& thrust_coeff, amrex::Vector<amrex::Real>& power)
114  {
115  rotor_rad = m_rotor_rad;
116  hub_height = m_hub_height;
117  thrust_coeff_standing = m_thrust_coeff_standing;
118  wind_speed = m_wind_speed;
119  thrust_coeff = m_thrust_coeff;
120  power = m_power;
121  }
122 
123  void get_turb_loc (amrex::Vector<amrex::Real>& xloc,
124  amrex::Vector<amrex::Real>& yloc)
125  {
126  xloc = m_xloc;
127  yloc = m_yloc;
128  }
129 
130  void get_turb_disk_angle (amrex::Real& turb_disk_angle)
131  {
132  turb_disk_angle = m_turb_disk_angle;
133  }
134 
135  void get_blade_spec (amrex::Vector<amrex::Real>& bld_rad_loc,
136  amrex::Vector<amrex::Real>& bld_twist,
137  amrex::Vector<amrex::Real>& bld_chord)
138  {
139  bld_rad_loc = m_bld_rad_loc;
140  bld_twist = m_bld_twist;
141  bld_chord = m_bld_chord;
142  }
143 
144  void get_blade_airfoil_spec (amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_aoa,
145  amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cl,
146  amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cd)
147  {
148  bld_airfoil_aoa = m_bld_airfoil_aoa;
149  bld_airfoil_Cl = m_bld_airfoil_Cl;
150  bld_airfoil_Cd = m_bld_airfoil_Cd;
151  }
152 
153  void get_turb_spec_extra (amrex::Vector<amrex::Real>& velocity,
154  amrex::Vector<amrex::Real>& C_P,
155  amrex::Vector<amrex::Real>& C_T,
156  amrex::Vector<amrex::Real>& rotor_RPM,
157  amrex::Vector<amrex::Real>& blade_pitch)
158  {
159  velocity = m_velocity;
160  C_P = m_C_P;
161  C_T = m_C_T;
162  rotor_RPM = m_rotor_RPM;
163  blade_pitch = m_blade_pitch;
164  }
165 
166 static AMREX_GPU_DEVICE
167 bool find_if_marked (amrex::Real x1, amrex::Real x2, amrex::Real y1, amrex::Real y2,
168  amrex::Real x0, amrex::Real y0, amrex::Real nx, amrex::Real ny,
169  amrex::Real d_hub_height, amrex::Real d_rotor_rad,
170  amrex::Real z)
171 {
172 
173  // Plane is (x-x0)*nx + (y-y0)*ny = zero And the planes to intersect are
174  // x = x1, x = x2, y = y1, y = y2. The intersections are
175  // (xval1,y1), (xval2,y2), (x1,yval1) and (x2,yval2)
176 
177  amrex::Real xval1 = x0 - (y1-y0)*ny/(nx+amrex::Real(1e-10));
178  amrex::Real xval2 = x0 - (y2-y0)*ny/(nx+amrex::Real(1e-10));
179 
180  amrex::Real yval1 = y0 - (x1-x0)*nx/(ny+amrex::Real(1e-10));
181  amrex::Real yval2 = y0 - (x2-x0)*nx/(ny+amrex::Real(1e-10));
182 
183  if( xval1 >=x1 and xval1 <=x2 ) {
184  if(std::pow((xval1-x0)*(xval1-x0) + (y1-y0)*(y1-y0) + (z-d_hub_height)*(z-d_hub_height),myhalf) < d_rotor_rad ) {
185  return true;
186  }
187  }
188  if( xval2 >=x1 and xval2 <=x2 ) {
189  if(std::pow((xval2-x0)*(xval2-x0) + (y2-y0)*(y2-y0) + (z-d_hub_height)*(z-d_hub_height),myhalf) < d_rotor_rad ) {
190  return true;
191  }
192  }
193  if (yval1 >=y1 and yval1 <=y2) {
194  if(std::pow((x1-x0)*(x1-x0) + (yval1-y0)*(yval1-y0) + (z-d_hub_height)*(z-d_hub_height),myhalf) < d_rotor_rad ) {
195  return true;
196  }
197  }
198  if (yval2 >=y1 and yval2 <=y2) {
199  if(std::pow((x2-x0)*(x2-x0) + (yval2-y0)*(yval2-y0) + (z-d_hub_height)*(z-d_hub_height),myhalf) < d_rotor_rad ) {
200  return true;
201  }
202  }
203 
204  return false;
205 }
206 
207 protected:
208 
209  amrex::Vector<amrex::Real> m_xloc, m_yloc, m_zloc;
210  amrex::Real m_turb_disk_angle;
212  amrex::Vector<amrex::Real> m_wind_speed, m_thrust_coeff, m_power;
213  amrex::Vector<amrex::Real> m_bld_rad_loc, m_bld_twist, m_bld_chord;
214  amrex::Vector<amrex::Vector<amrex::Real>> m_bld_airfoil_aoa, m_bld_airfoil_Cl, m_bld_airfoil_Cd;
215  amrex::Vector<amrex::Real> m_velocity, m_C_P, m_C_T, m_rotor_RPM, m_blade_pitch;
216 };
217 
218 
219 #endif
220 
@ zface
Definition: ERF_EBStruct.H:29
const int nx
Definition: ERF_InitCustomPertVels_CloudChamber.H:14
const int ny
Definition: ERF_InitCustomPertVels_CloudChamber.H:15
const int klo
Definition: ERF_InitCustomPert_KE.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real windfarm_face_height_above_ground(const amrex::Array4< const amrex::Real > &zp, int i, int j, int kf, int klo, amrex::Real dz) noexcept
Definition: ERF_NullWindFarm.H:16
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
Definition: ERF_NullWindFarm.H:28
amrex::Real m_rotor_rad
Definition: ERF_NullWindFarm.H:211
virtual ~NullWindFarm()=default
void get_turb_spec(amrex::Real &rotor_rad, amrex::Real &hub_height, amrex::Real &thrust_coeff_standing, amrex::Vector< amrex::Real > &wind_speed, amrex::Vector< amrex::Real > &thrust_coeff, amrex::Vector< amrex::Real > &power)
Definition: ERF_NullWindFarm.H:111
amrex::Vector< amrex::Real > m_bld_rad_loc
Definition: ERF_NullWindFarm.H:213
amrex::Vector< amrex::Real > m_C_P
Definition: ERF_NullWindFarm.H:215
amrex::Real m_turb_disk_angle
Definition: ERF_NullWindFarm.H:210
amrex::Vector< amrex::Real > m_bld_twist
Definition: ERF_NullWindFarm.H:213
static AMREX_GPU_DEVICE bool find_if_marked(amrex::Real x1, amrex::Real x2, amrex::Real y1, amrex::Real y2, amrex::Real x0, amrex::Real y0, amrex::Real nx, amrex::Real ny, amrex::Real d_hub_height, amrex::Real d_rotor_rad, amrex::Real z)
Definition: ERF_NullWindFarm.H:167
amrex::Real m_thrust_coeff_standing
Definition: ERF_NullWindFarm.H:211
amrex::Vector< amrex::Real > m_C_T
Definition: ERF_NullWindFarm.H:215
virtual void advance(const amrex::Geometry &a_geom, const double &dt_advance, amrex::MultiFab &cons_in, amrex::MultiFab &mf_vars_windfarm, amrex::MultiFab &U_old, amrex::MultiFab &V_old, amrex::MultiFab &W_old, const amrex::MultiFab &mf_Nturb, const amrex::MultiFab &mf_SMark, const amrex::MultiFab *z_phys_nd, const amrex::MultiFab *z_phys_cc, const double &time)=0
amrex::Vector< amrex::Real > m_power
Definition: ERF_NullWindFarm.H:212
amrex::Vector< amrex::Vector< amrex::Real > > m_bld_airfoil_aoa
Definition: ERF_NullWindFarm.H:214
amrex::Vector< amrex::Real > m_zloc
Definition: ERF_NullWindFarm.H:209
virtual void set_turb_spec(const amrex::Real &rotor_rad, const amrex::Real &hub_height, const amrex::Real &thrust_coeff_standing, const amrex::Vector< amrex::Real > &wind_speed, const amrex::Vector< amrex::Real > &thrust_coeff, const amrex::Vector< amrex::Real > &power)
Definition: ERF_NullWindFarm.H:49
void get_turb_spec_extra(amrex::Vector< amrex::Real > &velocity, amrex::Vector< amrex::Real > &C_P, amrex::Vector< amrex::Real > &C_T, amrex::Vector< amrex::Real > &rotor_RPM, amrex::Vector< amrex::Real > &blade_pitch)
Definition: ERF_NullWindFarm.H:153
amrex::Vector< amrex::Real > m_thrust_coeff
Definition: ERF_NullWindFarm.H:212
amrex::Vector< amrex::Vector< amrex::Real > > m_bld_airfoil_Cd
Definition: ERF_NullWindFarm.H:214
void get_turb_loc(amrex::Vector< amrex::Real > &xloc, amrex::Vector< amrex::Real > &yloc)
Definition: ERF_NullWindFarm.H:123
amrex::Vector< amrex::Real > m_yloc
Definition: ERF_NullWindFarm.H:209
amrex::Vector< amrex::Real > m_wind_speed
Definition: ERF_NullWindFarm.H:212
amrex::Vector< amrex::Real > m_blade_pitch
Definition: ERF_NullWindFarm.H:215
amrex::Real m_nominal_power
Definition: ERF_NullWindFarm.H:211
virtual void set_turb_loc(const amrex::Vector< amrex::Real > &xloc, const amrex::Vector< amrex::Real > &yloc)
Definition: ERF_NullWindFarm.H:62
virtual void set_blade_spec(const amrex::Vector< amrex::Real > &bld_rad_loc, const amrex::Vector< amrex::Real > &bld_twist, const amrex::Vector< amrex::Real > &bld_chord)
Definition: ERF_NullWindFarm.H:80
void get_blade_airfoil_spec(amrex::Vector< amrex::Vector< amrex::Real >> &bld_airfoil_aoa, amrex::Vector< amrex::Vector< amrex::Real >> &bld_airfoil_Cl, amrex::Vector< amrex::Vector< amrex::Real >> &bld_airfoil_Cd)
Definition: ERF_NullWindFarm.H:144
void get_turb_disk_angle(amrex::Real &turb_disk_angle)
Definition: ERF_NullWindFarm.H:130
void get_blade_spec(amrex::Vector< amrex::Real > &bld_rad_loc, amrex::Vector< amrex::Real > &bld_twist, amrex::Vector< amrex::Real > &bld_chord)
Definition: ERF_NullWindFarm.H:135
amrex::Vector< amrex::Real > m_xloc
Definition: ERF_NullWindFarm.H:209
virtual void set_turb_zloc(const amrex::Vector< amrex::Real > &zloc)
Ground elevation under each turbine (the hub is hub_height above it)
Definition: ERF_NullWindFarm.H:70
amrex::Vector< amrex::Real > m_bld_chord
Definition: ERF_NullWindFarm.H:213
amrex::Vector< amrex::Real > m_rotor_RPM
Definition: ERF_NullWindFarm.H:215
amrex::Vector< amrex::Vector< amrex::Real > > m_bld_airfoil_Cl
Definition: ERF_NullWindFarm.H:214
virtual void set_turb_disk_angle(const amrex::Real &turb_disk_angle)
Definition: ERF_NullWindFarm.H:75
amrex::Real m_hub_height
Definition: ERF_NullWindFarm.H:211
virtual void set_turb_spec_extra(const amrex::Vector< amrex::Real > &velocity, const amrex::Vector< amrex::Real > &C_P, const amrex::Vector< amrex::Real > &C_T, const amrex::Vector< amrex::Real > &rotor_RPM, const amrex::Vector< amrex::Real > &blade_pitch)
Definition: ERF_NullWindFarm.H:98
NullWindFarm()
Definition: ERF_NullWindFarm.H:32
virtual void set_blade_airfoil_spec(const amrex::Vector< amrex::Vector< amrex::Real >> &bld_airfoil_aoa, const amrex::Vector< amrex::Vector< amrex::Real >> &bld_airfoil_Cl, const amrex::Vector< amrex::Vector< amrex::Real >> &bld_airfoil_Cd)
Definition: ERF_NullWindFarm.H:89
amrex::Vector< amrex::Real > m_velocity
Definition: ERF_NullWindFarm.H:215
@ dz
Definition: ERF_AdvanceWDM6.cpp:273