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 class NullWindFarm {
10 
11 public:
12 
14 
15  virtual ~NullWindFarm() = default;
16 
17  virtual void advance (const amrex::Geometry& a_geom,
18  const amrex::Real& dt_advance,
19  amrex::MultiFab& cons_in,
20  amrex::MultiFab& mf_vars_windfarm,
21  amrex::MultiFab& U_old,
22  amrex::MultiFab& V_old,
23  amrex::MultiFab& W_old,
24  const amrex::MultiFab& mf_Nturb,
25  const amrex::MultiFab& mf_SMark,
26  const amrex::Real& time) = 0;
27 
28  virtual void set_turb_spec(const amrex::Real& rotor_rad, const amrex::Real& hub_height,
29  const amrex::Real& thrust_coeff_standing, const amrex::Vector<amrex::Real>& wind_speed,
30  const amrex::Vector<amrex::Real>& thrust_coeff,
31  const amrex::Vector<amrex::Real>& power)
32  {
33  m_rotor_rad = rotor_rad;
34  m_hub_height = hub_height;
35  m_thrust_coeff_standing = thrust_coeff_standing;
36  m_wind_speed = wind_speed;
37  m_thrust_coeff = thrust_coeff;
38  m_power = power;
39  }
40 
41  virtual void set_turb_loc (const amrex::Vector<amrex::Real>& xloc,
42  const amrex::Vector<amrex::Real>& yloc)
43  {
44  m_xloc = xloc;
45  m_yloc = yloc;
46  }
47 
48  virtual void set_turb_disk_angle (const amrex::Real& turb_disk_angle)
49  {
50  m_turb_disk_angle = turb_disk_angle;
51  }
52 
53  virtual void set_blade_spec(const amrex::Vector<amrex::Real>& bld_rad_loc,
54  const amrex::Vector<amrex::Real>& bld_twist,
55  const amrex::Vector<amrex::Real>& bld_chord)
56  {
57  m_bld_rad_loc = bld_rad_loc;
58  m_bld_twist = bld_twist;
59  m_bld_chord = bld_chord;
60  }
61 
62  virtual void set_blade_airfoil_spec(const amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_aoa,
63  const amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cl,
64  const amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cd)
65  {
66  m_bld_airfoil_aoa = bld_airfoil_aoa;
67  m_bld_airfoil_Cl = bld_airfoil_Cl;
68  m_bld_airfoil_Cd = bld_airfoil_Cd;
69  }
70 
71  virtual void set_turb_spec_extra(const amrex::Vector<amrex::Real>& velocity,
72  const amrex::Vector<amrex::Real>& C_P,
73  const amrex::Vector<amrex::Real>& C_T,
74  const amrex::Vector<amrex::Real>& rotor_RPM,
75  const amrex::Vector<amrex::Real>& blade_pitch)
76  {
77  m_velocity = velocity;
78  m_C_P = C_P;
79  m_C_T = C_T;
80  m_rotor_RPM = rotor_RPM;
81  m_blade_pitch = blade_pitch;
82  }
83 
84  void get_turb_spec (amrex::Real& rotor_rad, amrex::Real& hub_height,
85  amrex::Real& thrust_coeff_standing, amrex::Vector<amrex::Real>& wind_speed,
86  amrex::Vector<amrex::Real>& thrust_coeff, amrex::Vector<amrex::Real>& power)
87  {
88  rotor_rad = m_rotor_rad;
89  hub_height = m_hub_height;
90  thrust_coeff_standing = m_thrust_coeff_standing;
91  wind_speed = m_wind_speed;
92  thrust_coeff = m_thrust_coeff;
93  power = m_power;
94  }
95 
96  void get_turb_loc (amrex::Vector<amrex::Real>& xloc,
97  amrex::Vector<amrex::Real>& yloc)
98  {
99  xloc = m_xloc;
100  yloc = m_yloc;
101  }
102 
103  void get_turb_disk_angle (amrex::Real& turb_disk_angle)
104  {
105  turb_disk_angle = m_turb_disk_angle;
106  }
107 
108  void get_blade_spec(amrex::Vector<amrex::Real>& bld_rad_loc,
109  amrex::Vector<amrex::Real>& bld_twist,
110  amrex::Vector<amrex::Real>& bld_chord)
111  {
112  bld_rad_loc = m_bld_rad_loc;
113  bld_twist = m_bld_twist;
114  bld_chord = m_bld_chord;
115  }
116 
117  void get_blade_airfoil_spec(amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_aoa,
118  amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cl,
119  amrex::Vector<amrex::Vector<amrex::Real>>& bld_airfoil_Cd)
120  {
121  bld_airfoil_aoa = m_bld_airfoil_aoa;
122  bld_airfoil_Cl = m_bld_airfoil_Cl;
123  bld_airfoil_Cd = m_bld_airfoil_Cd;
124  }
125 
126  void get_turb_spec_extra(amrex::Vector<amrex::Real>& velocity,
127  amrex::Vector<amrex::Real>& C_P,
128  amrex::Vector<amrex::Real>& C_T,
129  amrex::Vector<amrex::Real>& rotor_RPM,
130  amrex::Vector<amrex::Real>& blade_pitch)
131  {
132  velocity = m_velocity;
133  C_P = m_C_P;
134  C_T = m_C_T;
135  rotor_RPM = m_rotor_RPM;
136  blade_pitch = m_blade_pitch;
137  }
138 
139 static AMREX_GPU_DEVICE
140 bool find_if_marked(amrex::Real x1, amrex::Real x2, amrex::Real y1, amrex::Real y2,
141  amrex::Real x0, amrex::Real y0, amrex::Real nx, amrex::Real ny,
142  amrex::Real d_hub_height, amrex::Real d_rotor_rad,
143  amrex::Real z)
144 {
145 
146  // Plane is (x-x0)*nx + (y-y0)*ny = 0. And the planes to intersect are
147  // x = x1, x = x2, y = y1, y = y2. The intersections are
148  // (xval1,y1), (xval2,y2), (x1,yval1) and (x2,yval2)
149 
150  amrex::Real xval1 = x0 - (y1-y0)*ny/(nx+1e-10);
151  amrex::Real xval2 = x0 - (y2-y0)*ny/(nx+1e-10);
152 
153  amrex::Real yval1 = y0 - (x1-x0)*nx/(ny+1e-10);
154  amrex::Real yval2 = y0 - (x2-x0)*nx/(ny+1e-10);
155 
156  if( xval1 >=x1 and xval1 <=x2 ) {
157  if(std::pow((xval1-x0)*(xval1-x0) + (y1-y0)*(y1-y0) + (z-d_hub_height)*(z-d_hub_height),0.5) < d_rotor_rad ) {
158  return true;
159  }
160  }
161  if( xval2 >=x1 and xval2 <=x2 ) {
162  if(std::pow((xval2-x0)*(xval2-x0) + (y2-y0)*(y2-y0) + (z-d_hub_height)*(z-d_hub_height),0.5) < d_rotor_rad ) {
163  return true;
164  }
165  }
166  if (yval1 >=y1 and yval1 <=y2) {
167  if(std::pow((x1-x0)*(x1-x0) + (yval1-y0)*(yval1-y0) + (z-d_hub_height)*(z-d_hub_height),0.5) < d_rotor_rad ) {
168  return true;
169  }
170  }
171  if (yval2 >=y1 and yval2 <=y2) {
172  if(std::pow((x2-x0)*(x2-x0) + (yval2-y0)*(yval2-y0) + (z-d_hub_height)*(z-d_hub_height),0.5) < d_rotor_rad ) {
173  return true;
174  }
175  }
176 
177  return false;
178 }
179 
180 protected:
181 
182  amrex::Vector<amrex::Real> m_xloc, m_yloc;
183  amrex::Real m_turb_disk_angle;
185  amrex::Vector<amrex::Real> m_wind_speed, m_thrust_coeff, m_power;
186  amrex::Vector<amrex::Real> m_bld_rad_loc, m_bld_twist, m_bld_chord;
187  amrex::Vector<amrex::Vector<amrex::Real>> m_bld_airfoil_aoa, m_bld_airfoil_Cl, m_bld_airfoil_Cd;
188  amrex::Vector<amrex::Real> m_velocity, m_C_P, m_C_T, m_rotor_RPM, m_blade_pitch;
189 };
190 
191 
192 #endif
193 
Definition: ERF_NullWindFarm.H:9
amrex::Real m_rotor_rad
Definition: ERF_NullWindFarm.H:184
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:84
amrex::Vector< amrex::Real > m_bld_rad_loc
Definition: ERF_NullWindFarm.H:186
amrex::Vector< amrex::Real > m_C_P
Definition: ERF_NullWindFarm.H:188
amrex::Real m_turb_disk_angle
Definition: ERF_NullWindFarm.H:183
amrex::Vector< amrex::Real > m_bld_twist
Definition: ERF_NullWindFarm.H:186
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:140
amrex::Real m_thrust_coeff_standing
Definition: ERF_NullWindFarm.H:184
amrex::Vector< amrex::Real > m_C_T
Definition: ERF_NullWindFarm.H:188
amrex::Vector< amrex::Real > m_power
Definition: ERF_NullWindFarm.H:185
virtual void advance(const amrex::Geometry &a_geom, const amrex::Real &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::Real &time)=0
amrex::Vector< amrex::Vector< amrex::Real > > m_bld_airfoil_aoa
Definition: ERF_NullWindFarm.H:187
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:28
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:126
amrex::Vector< amrex::Real > m_thrust_coeff
Definition: ERF_NullWindFarm.H:185
amrex::Vector< amrex::Vector< amrex::Real > > m_bld_airfoil_Cd
Definition: ERF_NullWindFarm.H:187
void get_turb_loc(amrex::Vector< amrex::Real > &xloc, amrex::Vector< amrex::Real > &yloc)
Definition: ERF_NullWindFarm.H:96
amrex::Vector< amrex::Real > m_yloc
Definition: ERF_NullWindFarm.H:182
amrex::Vector< amrex::Real > m_wind_speed
Definition: ERF_NullWindFarm.H:185
amrex::Vector< amrex::Real > m_blade_pitch
Definition: ERF_NullWindFarm.H:188
amrex::Real m_nominal_power
Definition: ERF_NullWindFarm.H:184
virtual void set_turb_loc(const amrex::Vector< amrex::Real > &xloc, const amrex::Vector< amrex::Real > &yloc)
Definition: ERF_NullWindFarm.H:41
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:53
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:117
void get_turb_disk_angle(amrex::Real &turb_disk_angle)
Definition: ERF_NullWindFarm.H:103
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:108
amrex::Vector< amrex::Real > m_xloc
Definition: ERF_NullWindFarm.H:182
amrex::Vector< amrex::Real > m_bld_chord
Definition: ERF_NullWindFarm.H:186
amrex::Vector< amrex::Real > m_rotor_RPM
Definition: ERF_NullWindFarm.H:188
amrex::Vector< amrex::Vector< amrex::Real > > m_bld_airfoil_Cl
Definition: ERF_NullWindFarm.H:187
virtual void set_turb_disk_angle(const amrex::Real &turb_disk_angle)
Definition: ERF_NullWindFarm.H:48
amrex::Real m_hub_height
Definition: ERF_NullWindFarm.H:184
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:71
NullWindFarm()
Definition: ERF_NullWindFarm.H:13
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:62
amrex::Vector< amrex::Real > m_velocity
Definition: ERF_NullWindFarm.H:188