ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_WindFarm.H
Go to the documentation of this file.
1 #ifndef ERF_WINDFARM_H
2 #define ERF_WINDFARM_H
3 
4 #include <ERF_DataStruct.H>
5 #include <AMReX_Geometry.H>
6 #include <AMReX_MultiFab.H>
7 
8 #include "ERF_NullWindFarm.H"
9 #include "ERF_Fitch.H"
10 #include "ERF_EWP.H"
11 #include "ERF_SimpleAD.H"
12 #include "ERF_GeneralAD.H"
13 
14 class WindFarm : public NullWindFarm {
15 
16 public:
17 
18  WindFarm (){}
19 
20  virtual ~WindFarm () = default;
21 
22  WindFarm (int nlev,
23  const WindFarmType& a_windfarm_type)
24  {
25  m_windfarm_model.resize(nlev);
26  if (a_windfarm_type == WindFarmType::Fitch) {
27  SetModel<Fitch>();
28  amrex::Print() << "Fitch windfarm model!\n";
29  }
30  else if (a_windfarm_type == WindFarmType::EWP) {
31  SetModel<EWP>();
32  amrex::Print() << "EWP windfarm model!\n";
33  }
34  else if (a_windfarm_type == WindFarmType::SimpleAD) {
35  SetModel<SimpleAD>();
36  amrex::Print() << "Simplified actuator disk windfarm model!\n";
37  }
38  else if (a_windfarm_type == WindFarmType::GeneralAD) {
39  SetModel<GeneralAD>();
40  amrex::Print() << "Generalized actuator disk windfarm model!\n";
41  }
42  else {
43  amrex::Abort("WindFarm: Dont know this windfarm_type!") ;
44  }
45  }
46 
47  void read_tables (std::string windfarm_loc_table,
48  std::string windfarm_spec_table,
49  bool x_y, bool lat_lon,
50  const amrex::Real windfarm_x_shift = 0.0,
51  const amrex::Real windfarm_y_shift = 0.0);
52 
53  void init_windfarm_lat_lon (const std::string windfarm_loc_table,
54  const amrex::Real windfarm_x_shift,
55  const amrex::Real windfarm_y_shift);
56 
57  void init_windfarm_x_y (const std::string windfarm_loc_table);
58 
59  void read_windfarm_locations_table (const std::string windfarm_loc_table,
60  bool x_y, bool lat_lon,
61  const amrex::Real windfarm_x_shift = 0.0,
62  const amrex::Real windfarm_y_shift = 0.0);
63 
64  void read_windfarm_spec_table (const std::string windfarm_spec_table);
65 
66  void read_windfarm_blade_table (const std::string windfarm_blade_table);
67 
68  void read_windfarm_airfoil_tables (const std::string windfarm_airfoil_tables,
69  const std::string windfarm_blade_table);
70 
71  void read_windfarm_spec_table_extra (const std::string windfarm_spec_table_extra);
72 
73  void fill_Nturb_multifab (const amrex::Geometry& geom,
74  amrex::MultiFab& mf_Nturb,
75  std::unique_ptr<amrex::MultiFab>& z_phys_nd);
76 
77  void fill_SMark_multifab (const amrex::Geometry& geom,
78  amrex::MultiFab& mf_SMark,
79  const amrex::Real& sampling_distance_by_D,
80  const amrex::Real& turb_disk_angle,
81  std::unique_ptr<amrex::MultiFab>& z_phys_cc);
82 
83  void fill_SMark_multifab_mesoscale_models (const amrex::Geometry& geom,
84  amrex::MultiFab& mf_SMark,
85  const amrex::MultiFab& mf_Nturb,
86  std::unique_ptr<amrex::MultiFab>& z_phys_cc);
87 
89 
90  void write_actuator_disks_vtk (const amrex::Geometry& geom,
91  const amrex::Real& sampling_distance_by_D);
92 
93  void advance (const amrex::Geometry& a_geom,
94  const amrex::Real& dt_advance,
95  amrex::MultiFab& cons_in,
96  amrex::MultiFab& mf_vars_windfarm,
97  amrex::MultiFab& U_old,
98  amrex::MultiFab& V_old,
99  amrex::MultiFab& W_old,
100  const amrex::MultiFab& mf_Nturb,
101  const amrex::MultiFab& mf_SMark,
102  const amrex::Real& time) override
103  {
104  m_windfarm_model[0]->advance(a_geom, dt_advance, cons_in, mf_vars_windfarm,
105  U_old, V_old, W_old, mf_Nturb, mf_SMark, time);
106  }
107 
108  void set_turb_spec (const amrex::Real& a_rotor_rad, const amrex::Real& a_hub_height,
109  const amrex::Real& a_thrust_coeff_standing, const amrex::Vector<amrex::Real>& a_wind_speed,
110  const amrex::Vector<amrex::Real>& a_thrust_coeff,
111  const amrex::Vector<amrex::Real>& a_power) override
112  {
113  m_windfarm_model[0]->set_turb_spec(a_rotor_rad, a_hub_height, a_thrust_coeff_standing,
114  a_wind_speed, a_thrust_coeff, a_power);
115  }
116 
117  void set_turb_loc (const amrex::Vector<amrex::Real>& a_xloc,
118  const amrex::Vector<amrex::Real>& a_yloc) override
119  {
120  m_windfarm_model[0]->set_turb_loc(a_xloc, a_yloc);
121  }
122 
123  void set_turb_disk_angle (const amrex::Real& a_turb_disk_angle) override
124  {
125  m_windfarm_model[0]->set_turb_disk_angle(a_turb_disk_angle);
126  }
127 
128  void set_blade_spec (const amrex::Vector<amrex::Real>& a_bld_rad_loc,
129  const amrex::Vector<amrex::Real>& a_bld_twist,
130  const amrex::Vector<amrex::Real>& a_bld_chord) override
131  {
132  m_windfarm_model[0]->set_blade_spec(a_bld_rad_loc, a_bld_twist, a_bld_chord);
133  }
134 
135  void set_blade_airfoil_spec (const amrex::Vector<amrex::Vector<amrex::Real>>& a_bld_airfoil_aoa,
136  const amrex::Vector<amrex::Vector<amrex::Real>>& a_bld_airfoil_Cl,
137  const amrex::Vector<amrex::Vector<amrex::Real>>& a_bld_airfoil_Cd) override
138  {
139  m_windfarm_model[0]->set_blade_airfoil_spec(a_bld_airfoil_aoa, a_bld_airfoil_Cl, a_bld_airfoil_Cd);
140  }
141 
142  void set_turb_spec_extra (const amrex::Vector<amrex::Real>& a_velocity,
143  const amrex::Vector<amrex::Real>& a_C_P,
144  const amrex::Vector<amrex::Real>& a_C_T,
145  const amrex::Vector<amrex::Real>& a_rotor_RPM,
146  const amrex::Vector<amrex::Real>& a_blade_pitch) override
147  {
148  m_windfarm_model[0]->set_turb_spec_extra(a_velocity, a_C_P, a_C_T, a_rotor_RPM, a_blade_pitch);
149  }
150 
151 protected:
152 
153  amrex::Vector<amrex::Real> xloc, yloc, zloc;
154  amrex::Real my_turb_disk_angle;
156  amrex::Vector<amrex::Real> wind_speed, thrust_coeff, power;
157  amrex::Vector<amrex::Real> bld_rad_loc, bld_twist, bld_chord;
158  amrex::Vector<amrex::Vector<amrex::Real>> bld_airfoil_aoa, bld_airfoil_Cl, bld_airfoil_Cd;
160  amrex::Vector<amrex::Real> velocity, C_P, C_T, rotor_RPM, blade_pitch;
161 
162  /*! \brief Create and set the specified windfarm model */
163  template<class NewWindFarmModel>
164  void SetModel ()
165  {
166  for (int lev(0); lev<m_windfarm_model.size(); ++lev) {
167  m_windfarm_model[lev] = std::make_unique<NewWindFarmModel>();
168  }
169  }
170 
171 private:
172  amrex::Vector<std::unique_ptr<NullWindFarm>> m_windfarm_model; /*!< windfarm model */
173 };
174 
175 #endif
176 
Definition: ERF_NullWindFarm.H:9
Definition: ERF_WindFarm.H:14
amrex::Real my_turb_disk_angle
Definition: ERF_WindFarm.H:154
amrex::Vector< amrex::Real > yloc
Definition: ERF_WindFarm.H:153
virtual ~WindFarm()=default
amrex::Vector< amrex::Vector< amrex::Real > > bld_airfoil_Cl
Definition: ERF_WindFarm.H:158
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) override
Definition: ERF_WindFarm.H:93
amrex::Vector< amrex::Real > blade_pitch
Definition: ERF_WindFarm.H:160
WindFarm()
Definition: ERF_WindFarm.H:18
void read_windfarm_locations_table(const std::string windfarm_loc_table, bool x_y, bool lat_lon, const amrex::Real windfarm_x_shift=0.0, const amrex::Real windfarm_y_shift=0.0)
Definition: ERF_WindFarm.cpp:35
void set_turb_spec_extra(const amrex::Vector< amrex::Real > &a_velocity, const amrex::Vector< amrex::Real > &a_C_P, const amrex::Vector< amrex::Real > &a_C_T, const amrex::Vector< amrex::Real > &a_rotor_RPM, const amrex::Vector< amrex::Real > &a_blade_pitch) override
Definition: ERF_WindFarm.H:142
void read_tables(std::string windfarm_loc_table, std::string windfarm_spec_table, bool x_y, bool lat_lon, const amrex::Real windfarm_x_shift=0.0, const amrex::Real windfarm_y_shift=0.0)
Definition: ERF_WindFarm.cpp:19
void read_windfarm_spec_table_extra(const std::string windfarm_spec_table_extra)
Definition: ERF_WindFarm.cpp:257
amrex::Vector< amrex::Vector< amrex::Real > > bld_airfoil_aoa
Definition: ERF_WindFarm.H:158
amrex::Vector< amrex::Real > velocity
Definition: ERF_WindFarm.H:160
void read_windfarm_blade_table(const std::string windfarm_blade_table)
Definition: ERF_WindFarm.cpp:224
amrex::Vector< amrex::Real > wind_speed
Definition: ERF_WindFarm.H:156
void set_turb_loc(const amrex::Vector< amrex::Real > &a_xloc, const amrex::Vector< amrex::Real > &a_yloc) override
Definition: ERF_WindFarm.H:117
void set_blade_spec(const amrex::Vector< amrex::Real > &a_bld_rad_loc, const amrex::Vector< amrex::Real > &a_bld_twist, const amrex::Vector< amrex::Real > &a_bld_chord) override
Definition: ERF_WindFarm.H:128
void SetModel()
Create and set the specified windfarm model.
Definition: ERF_WindFarm.H:164
amrex::Vector< amrex::Real > C_P
Definition: ERF_WindFarm.H:160
amrex::Real hub_height
Definition: ERF_WindFarm.H:155
amrex::Vector< amrex::Real > zloc
Definition: ERF_WindFarm.H:153
amrex::Vector< amrex::Real > bld_twist
Definition: ERF_WindFarm.H:157
void fill_SMark_multifab_mesoscale_models(const amrex::Geometry &geom, amrex::MultiFab &mf_SMark, const amrex::MultiFab &mf_Nturb, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
Definition: ERF_WindFarm.cpp:481
void write_actuator_disks_vtk(const amrex::Geometry &geom, const amrex::Real &sampling_distance_by_D)
Definition: ERF_WindFarm.cpp:656
amrex::Vector< amrex::Vector< amrex::Real > > bld_airfoil_Cd
Definition: ERF_WindFarm.H:158
amrex::Vector< amrex::Real > C_T
Definition: ERF_WindFarm.H:160
amrex::Vector< amrex::Real > thrust_coeff
Definition: ERF_WindFarm.H:156
void read_windfarm_spec_table(const std::string windfarm_spec_table)
Definition: ERF_WindFarm.cpp:176
int n_bld_sections
Definition: ERF_WindFarm.H:159
WindFarm(int nlev, const WindFarmType &a_windfarm_type)
Definition: ERF_WindFarm.H:22
amrex::Real nominal_power
Definition: ERF_WindFarm.H:155
void set_blade_airfoil_spec(const amrex::Vector< amrex::Vector< amrex::Real >> &a_bld_airfoil_aoa, const amrex::Vector< amrex::Vector< amrex::Real >> &a_bld_airfoil_Cl, const amrex::Vector< amrex::Vector< amrex::Real >> &a_bld_airfoil_Cd) override
Definition: ERF_WindFarm.H:135
void init_windfarm_x_y(const std::string windfarm_loc_table)
Definition: ERF_WindFarm.cpp:154
amrex::Vector< amrex::Real > bld_chord
Definition: ERF_WindFarm.H:157
void init_windfarm_lat_lon(const std::string windfarm_loc_table, const amrex::Real windfarm_x_shift, const amrex::Real windfarm_y_shift)
Definition: ERF_WindFarm.cpp:55
void set_turb_spec(const amrex::Real &a_rotor_rad, const amrex::Real &a_hub_height, const amrex::Real &a_thrust_coeff_standing, const amrex::Vector< amrex::Real > &a_wind_speed, const amrex::Vector< amrex::Real > &a_thrust_coeff, const amrex::Vector< amrex::Real > &a_power) override
Definition: ERF_WindFarm.H:108
amrex::Real thrust_coeff_standing
Definition: ERF_WindFarm.H:155
amrex::Vector< amrex::Real > xloc
Definition: ERF_WindFarm.H:153
void fill_Nturb_multifab(const amrex::Geometry &geom, amrex::MultiFab &mf_Nturb, std::unique_ptr< amrex::MultiFab > &z_phys_nd)
Definition: ERF_WindFarm.cpp:376
void read_windfarm_airfoil_tables(const std::string windfarm_airfoil_tables, const std::string windfarm_blade_table)
Definition: ERF_WindFarm.cpp:296
amrex::Real rotor_rad
Definition: ERF_WindFarm.H:155
void fill_SMark_multifab(const amrex::Geometry &geom, amrex::MultiFab &mf_SMark, const amrex::Real &sampling_distance_by_D, const amrex::Real &turb_disk_angle, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
Definition: ERF_WindFarm.cpp:537
void write_turbine_locations_vtk()
Definition: ERF_WindFarm.cpp:637
amrex::Vector< amrex::Real > rotor_RPM
Definition: ERF_WindFarm.H:160
amrex::Vector< amrex::Real > power
Definition: ERF_WindFarm.H:156
amrex::Vector< amrex::Real > bld_rad_loc
Definition: ERF_WindFarm.H:157
void set_turb_disk_angle(const amrex::Real &a_turb_disk_angle) override
Definition: ERF_WindFarm.H:123
amrex::Vector< std::unique_ptr< NullWindFarm > > m_windfarm_model
Definition: ERF_WindFarm.H:172