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 
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 
76  void fill_SMark_multifab(const amrex::Geometry& geom,
77  amrex::MultiFab& mf_SMark,
78  const amrex::Real& sampling_distance_by_D,
79  const amrex::Real& turb_disk_angle);
80 
82 
83  void write_actuator_disks_vtk(const amrex::Geometry& geom);
84 
85  void advance (const amrex::Geometry& a_geom,
86  const amrex::Real& dt_advance,
87  amrex::MultiFab& cons_in,
88  amrex::MultiFab& mf_vars_windfarm,
89  amrex::MultiFab& U_old,
90  amrex::MultiFab& V_old,
91  amrex::MultiFab& W_old,
92  const amrex::MultiFab& mf_Nturb,
93  const amrex::MultiFab& mf_SMark,
94  const amrex::Real& time) override
95  {
96  m_windfarm_model[0]->advance(a_geom, dt_advance, cons_in, mf_vars_windfarm,
97  U_old, V_old, W_old, mf_Nturb, mf_SMark, time);
98  }
99 
100  void set_turb_spec(const amrex::Real& a_rotor_rad, const amrex::Real& a_hub_height,
101  const amrex::Real& a_thrust_coeff_standing, const amrex::Vector<amrex::Real>& a_wind_speed,
102  const amrex::Vector<amrex::Real>& a_thrust_coeff,
103  const amrex::Vector<amrex::Real>& a_power) override
104  {
105  m_windfarm_model[0]->set_turb_spec(a_rotor_rad, a_hub_height, a_thrust_coeff_standing,
106  a_wind_speed, a_thrust_coeff, a_power);
107  }
108 
109  void set_turb_loc (const amrex::Vector<amrex::Real>& a_xloc,
110  const amrex::Vector<amrex::Real>& a_yloc) override
111  {
112  m_windfarm_model[0]->set_turb_loc(a_xloc, a_yloc);
113  }
114 
115  void set_turb_disk_angle (const amrex::Real& a_turb_disk_angle) override
116  {
117  m_windfarm_model[0]->set_turb_disk_angle(a_turb_disk_angle);
118  }
119 
120  void set_blade_spec (const amrex::Vector<amrex::Real>& a_bld_rad_loc,
121  const amrex::Vector<amrex::Real>& a_bld_twist,
122  const amrex::Vector<amrex::Real>& a_bld_chord) override
123  {
124  m_windfarm_model[0]->set_blade_spec(a_bld_rad_loc, a_bld_twist, a_bld_chord);
125  }
126 
127  void set_blade_airfoil_spec (const amrex::Vector<amrex::Vector<amrex::Real>>& a_bld_airfoil_aoa,
128  const amrex::Vector<amrex::Vector<amrex::Real>>& a_bld_airfoil_Cl,
129  const amrex::Vector<amrex::Vector<amrex::Real>>& a_bld_airfoil_Cd) override
130  {
131  m_windfarm_model[0]->set_blade_airfoil_spec(a_bld_airfoil_aoa, a_bld_airfoil_Cl, a_bld_airfoil_Cd);
132  }
133 
134  void set_turb_spec_extra (const amrex::Vector<amrex::Real>& a_velocity,
135  const amrex::Vector<amrex::Real>& a_C_P,
136  const amrex::Vector<amrex::Real>& a_C_T,
137  const amrex::Vector<amrex::Real>& a_rotor_RPM,
138  const amrex::Vector<amrex::Real>& a_blade_pitch) override
139  {
140  m_windfarm_model[0]->set_turb_spec_extra(a_velocity, a_C_P, a_C_T, a_rotor_RPM, a_blade_pitch);
141  }
142 
143 protected:
144 
145  amrex::Vector<amrex::Real> xloc, yloc;
146  amrex::Real my_turb_disk_angle;
148  amrex::Vector<amrex::Real> wind_speed, thrust_coeff, power;
149  amrex::Vector<amrex::Real> bld_rad_loc, bld_twist, bld_chord;
150  amrex::Vector<amrex::Vector<amrex::Real>> bld_airfoil_aoa, bld_airfoil_Cl, bld_airfoil_Cd;
152  amrex::Vector<amrex::Real> velocity, C_P, C_T, rotor_RPM, blade_pitch;
153 
154  /*! \brief Create and set the specified windfarm model */
155  template<class NewWindFarmModel>
156  void SetModel ()
157  {
158  for (int lev(0); lev<m_windfarm_model.size(); ++lev) {
159  m_windfarm_model[lev] = std::make_unique<NewWindFarmModel>();
160  }
161  }
162 
163 private:
164  amrex::Vector<std::unique_ptr<NullWindFarm>> m_windfarm_model; /*!< windfarm model */
165 };
166 
167 #endif
168 
Definition: ERF_NullWindFarm.H:9
Definition: ERF_WindFarm.H:14
amrex::Real my_turb_disk_angle
Definition: ERF_WindFarm.H:146
amrex::Vector< amrex::Real > yloc
Definition: ERF_WindFarm.H:145
virtual ~WindFarm()=default
amrex::Vector< amrex::Vector< amrex::Real > > bld_airfoil_Cl
Definition: ERF_WindFarm.H:150
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:85
amrex::Vector< amrex::Real > blade_pitch
Definition: ERF_WindFarm.H:152
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_InitWindFarm.cpp:34
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:134
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_InitWindFarm.cpp:18
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)
Definition: ERF_InitWindFarm.cpp:401
void read_windfarm_spec_table_extra(const std::string windfarm_spec_table_extra)
Definition: ERF_InitWindFarm.cpp:234
amrex::Vector< amrex::Vector< amrex::Real > > bld_airfoil_aoa
Definition: ERF_WindFarm.H:150
amrex::Vector< amrex::Real > velocity
Definition: ERF_WindFarm.H:152
void read_windfarm_blade_table(const std::string windfarm_blade_table)
Definition: ERF_InitWindFarm.cpp:201
amrex::Vector< amrex::Real > wind_speed
Definition: ERF_WindFarm.H:148
void set_turb_loc(const amrex::Vector< amrex::Real > &a_xloc, const amrex::Vector< amrex::Real > &a_yloc) override
Definition: ERF_WindFarm.H:109
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:120
void SetModel()
Create and set the specified windfarm model.
Definition: ERF_WindFarm.H:156
amrex::Vector< amrex::Real > C_P
Definition: ERF_WindFarm.H:152
amrex::Real hub_height
Definition: ERF_WindFarm.H:147
amrex::Vector< amrex::Real > bld_twist
Definition: ERF_WindFarm.H:149
amrex::Vector< amrex::Vector< amrex::Real > > bld_airfoil_Cd
Definition: ERF_WindFarm.H:150
amrex::Vector< amrex::Real > C_T
Definition: ERF_WindFarm.H:152
amrex::Vector< amrex::Real > thrust_coeff
Definition: ERF_WindFarm.H:148
void read_windfarm_spec_table(const std::string windfarm_spec_table)
Definition: ERF_InitWindFarm.cpp:153
int n_bld_sections
Definition: ERF_WindFarm.H:151
WindFarm(int nlev, const WindFarmType &a_windfarm_type)
Definition: ERF_WindFarm.H:22
amrex::Real nominal_power
Definition: ERF_WindFarm.H:147
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:127
void init_windfarm_x_y(const std::string windfarm_loc_table)
Definition: ERF_InitWindFarm.cpp:131
amrex::Vector< amrex::Real > bld_chord
Definition: ERF_WindFarm.H:149
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_InitWindFarm.cpp:54
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:100
amrex::Real thrust_coeff_standing
Definition: ERF_WindFarm.H:147
amrex::Vector< amrex::Real > xloc
Definition: ERF_WindFarm.H:145
void read_windfarm_airfoil_tables(const std::string windfarm_airfoil_tables, const std::string windfarm_blade_table)
Definition: ERF_InitWindFarm.cpp:273
amrex::Real rotor_rad
Definition: ERF_WindFarm.H:147
void fill_Nturb_multifab(const amrex::Geometry &geom, amrex::MultiFab &mf_Nturb)
Definition: ERF_InitWindFarm.cpp:353
void write_turbine_locations_vtk()
Definition: ERF_InitWindFarm.cpp:485
amrex::Vector< amrex::Real > rotor_RPM
Definition: ERF_WindFarm.H:152
amrex::Vector< amrex::Real > power
Definition: ERF_WindFarm.H:148
void write_actuator_disks_vtk(const amrex::Geometry &geom)
Definition: ERF_InitWindFarm.cpp:504
amrex::Vector< amrex::Real > bld_rad_loc
Definition: ERF_WindFarm.H:149
void set_turb_disk_angle(const amrex::Real &a_turb_disk_angle) override
Definition: ERF_WindFarm.H:115
amrex::Vector< std::unique_ptr< NullWindFarm > > m_windfarm_model
Definition: ERF_WindFarm.H:164