/home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/disk/uniform_ct_ops.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/disk/uniform_ct_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
uniform_ct_ops.H
Go to the documentation of this file.
1#ifndef UNIFORM_CT_OPS_H_
2#define UNIFORM_CT_OPS_H_
3
9namespace uniformct {
10
11void parse_and_gather_params(const utils::ActParser& pp, UniformCtData& data);
13} // namespace uniformct
14
15template <>
25
26template <>
28{
29 void operator()(typename UniformCt::DataType& data)
30 {
31 if (!data.sim().helics().is_activated()) {
32 return;
33 }
34
35#ifdef AMR_WIND_USE_HELICS
36
37 const amrex::Real wind_direction =
38 -data.sim().helics().m_turbine_yaw_to_amrwind[data.info().id] +
39 90.0;
40 const amrex::Real wind_direction_radian =
41 amr_wind::utils::radians(wind_direction);
42
43 auto& meta = data.meta();
44
45 meta.normal_vec[0] = std::cos(wind_direction_radian);
46 meta.normal_vec[1] = std::sin(wind_direction_radian);
47 meta.normal_vec[2] = 0.0;
48
49 meta.sample_vec[0] = meta.normal_vec[0];
50 meta.sample_vec[1] = meta.normal_vec[1];
51 meta.sample_vec[2] = meta.normal_vec[2];
52
53 if (data.info().is_root_proc) {
54 std::cout << "turbine " << data.info().id
55 << " normal: " << meta.normal_vec[0] << ' '
56 << meta.normal_vec[1] << std::endl;
57 }
58
60#endif
61 }
62};
63// compute the total force over a given radial section
64// this will then be spread uniformly over that area in the
65// projection step
66template <>
68{
70 {
71 auto& grid = data.grid();
72 auto& ddata = data.meta();
73 const auto& normal = ddata.normal_vec;
74 const amrex::Real uInfSqr = base::compute_reference_velocity_sqr(ddata);
75 base::set_thrust_coefficient(ddata, uInfSqr);
76
77 const int npts = ddata.num_force_pts;
78 const amrex::Real rho = ddata.density;
79 const amrex::Real aeroPressure = 0.5 * uInfSqr * rho * ddata.current_ct;
80 const amrex::Real dr = ddata.dr;
81
82 for (int ip = 0; ip < npts; ++ip) {
83 const amrex::Real r = (ip + 0.5) * dr;
84 const amrex::Real rp = r + dr * 0.5;
85 const amrex::Real rm = r - dr * 0.5;
86 const amrex::Real a = ::amr_wind::utils::pi() * (rp * rp - rm * rm);
87 // disk force should always point in direction of the normal
88 grid.force[ip] = (aeroPressure * a) * normal;
89 }
90#ifdef AMR_WIND_USE_HELICS
91
92 if (data.info().is_root_proc && data.sim().helics().is_activated()) {
93
94 const amrex::Real ct = ddata.current_ct;
95 std::cout << "turbine" << data.info().id << " thrust: " << ct
96 << std::endl;
97 const amrex::Real cp = 0.5 * (ct + ct * std::sqrt(1.0 - ct));
98 const amrex::Real area =
99 amr_wind::utils::pi() * 0.25 * ddata.diameter * ddata.diameter;
100 const amrex::Real power =
101 cp * 0.5 * rho * std::pow(uInfSqr, 1.5) * area;
102
103 data.sim().helics().m_turbine_power_to_controller[data.info().id] =
104 power;
105 const amrex::Real turbine_angle = std::atan2(
106 ddata.reference_velocity[1], ddata.reference_velocity[0]);
107 data.sim()
108 .helics()
110 -amr_wind::utils::degrees(turbine_angle) + 270.0;
111 }
112#endif
113 }
114};
115
116template <>
125template <>
127{
128private:
129 // cppcheck-suppress uninitMemberVarPrivate
132 std::string m_out_dir;
133
135 std::string m_nc_filename;
136
138 int m_out_freq{10};
139
140public:
142 const UniformCt::DataType& data)
143 : m_data(data)
144 {}
145 void operator()(UniformCt::DataType& /*unused*/) {}
147 {
148 pp.query("output_frequency", m_out_freq);
149 }
150 void prepare_outputs(const std::string& out_dir)
151 {
152 m_nc_filename = out_dir + "/" + m_data.info().label + ".nc";
154 m_nc_filename, m_data.meta(), m_data.info(), m_data.grid());
155 }
157 {
158 const auto& time = m_data.sim().time();
159 const int tidx = time.time_index();
160 if (tidx % m_out_freq != 0) {
161 return;
162 }
163
165 m_nc_filename, m_data.meta(), m_data.info(), m_data.grid(),
166 time.new_time());
167 }
168};
169} // namespace amr_wind::actuator::ops
170
171#endif /* UNIFORM_CT_OPS_H_ */
HelicsStorage & helics()
Definition CFDSim.H:101
SimTime & time()
Return simulation time control.
Definition CFDSim.H:58
amrex::Vector< amrex::Real > m_turbine_wind_direction_to_controller
Definition helics.H:36
amrex::Vector< amrex::Real > m_turbine_yaw_to_amrwind
Definition helics.H:37
amrex::Vector< amrex::Real > m_turbine_power_to_controller
Definition helics.H:35
bool is_activated() const
Definition helics.H:23
AMREX_FORCE_INLINE int time_index() const
Definition SimTime.H:114
Definition actuator_types.H:184
CFDSim & sim()
Definition actuator_types.H:211
ActTrait::GridType & grid()
Definition actuator_types.H:217
ActTrait::InfoType & info()
Definition actuator_types.H:214
ActTrait::MetaType & meta()
Definition actuator_types.H:220
Definition MultiParser.H:18
void query(const std::string &name, vs::Vector &value) const
Definition MultiParser.H:57
void prepare_netcdf_file(const std::string &name, const DiskBaseData &data, const ActInfo &info, const ActGrid &grid)
Definition disk_ops.cpp:6
void write_netcdf(const std::string &name, const DiskBaseData &data, const ActInfo &info, const ActGrid &, const amrex::Real time)
Definition disk_ops.cpp:70
void set_thrust_coefficient(DiskBaseData &data, const amrex::Real &uInfSqr)
Definition disk_ops.H:127
void allocate_basic_grid_quantities(typename T::DataType &data)
Definition disk_ops.H:77
amrex::Real compute_reference_velocity_sqr(DiskBaseData &data)
Definition disk_ops.H:114
void do_parse_based_computations(ActDataHolder< T > &data)
Definition disk_ops.H:90
void parse_and_gather_params(const utils::ActParser &pp, UniformCtData &data)
Definition uniform_ct_ops.cpp:50
void update_disk_points(UniformCt::DataType &data)
Definition uniform_ct_ops.cpp:62
Definition ActSrcLineOp.H:9
::amr_wind::utils::MultiParser ActParser
Definition ActParser.H:8
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real degrees(const amrex::Real rad_val)
Convert from radians to degrees.
Definition trig_ops.H:42
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr amrex::Real pi()
Return as an amrex::Real.
Definition trig_ops.H:16
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real radians(const amrex::Real deg_val)
Convert from degrees to radians.
Definition trig_ops.H:35
Definition actuator_types.H:53
Definition UniformCt.H:12
ActDataHolder< UniformCt > DataType
Definition UniformCt.H:16
void operator()(UniformCt::DataType &data)
Definition uniform_ct_ops.H:69
Definition actuator_ops.H:61
void operator()(typename UniformCt::DataType &data)
Definition uniform_ct_ops.H:119
Definition actuator_ops.H:32
void operator()(UniformCt::DataType &)
Definition uniform_ct_ops.H:145
void read_io_options(const utils::ActParser &pp)
Definition uniform_ct_ops.H:146
const UniformCt::DataType & m_data
Definition uniform_ct_ops.H:130
std::string m_nc_filename
NetCDF output filename for this turbine.
Definition uniform_ct_ops.H:135
void prepare_outputs(const std::string &out_dir)
Definition uniform_ct_ops.H:150
std::string m_out_dir
Path to the output directory (specified by Actuator physics class)
Definition uniform_ct_ops.H:132
Definition actuator_ops.H:71
void operator()(UniformCt::DataType &data, const utils::ActParser &pp)
Definition uniform_ct_ops.H:18
Definition actuator_ops.H:19
void operator()(typename UniformCt::DataType &data)
Definition uniform_ct_ops.H:29
Definition actuator_ops.H:43