Skip to content

Commit

Permalink
Require density argument for openfast turbine types (#1031)
Browse files Browse the repository at this point in the history
* use get() instead of query()
* basic density checks for OpenFAST turbines
* log output for cases that cannot be checked
  • Loading branch information
mbkuhn authored Apr 30, 2024
1 parent 8791588 commit 0592eba
Showing 1 changed file with 98 additions and 1 deletion.
99 changes: 98 additions & 1 deletion amr-wind/wind_energy/actuator/turbine/fast/turbine_fast_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "amr-wind/wind_energy/actuator/actuator_ops.H"
#include "amr-wind/wind_energy/actuator/actuator_utils.H"
#include "amr-wind/wind_energy/actuator/FLLCOp.H"
#include "amr-wind/utilities/IOManager.H"

namespace amr_wind {
namespace actuator {
Expand All @@ -22,7 +23,13 @@ struct ReadInputsOp<TurbineFast, SrcTrait>
auto& tdata = data.meta();

// Get density value for normalization
pp.query("density", tdata.density);
pp.get("density", tdata.density);

// Check if user wants to override density checks
bool override_density_check = false;
pp.query("override_density_check", override_density_check);
// Check if simulation is a restart
bool is_restart = data.sim().io_manager().is_restart();

// Initialize OpenFAST specific data
const auto& tinfo = data.info();
Expand Down Expand Up @@ -69,6 +76,9 @@ struct ReadInputsOp<TurbineFast, SrcTrait>
tf.chkpt_interval = time.chkpt_interval();

perform_checks(data);

perform_density_checks(
tdata.density, override_density_check, is_restart);
}

void perform_checks(typename TurbineFast::DataType& data)
Expand All @@ -77,6 +87,93 @@ struct ReadInputsOp<TurbineFast, SrcTrait>
// Ensure that we are using fixed timestepping scheme
AMREX_ALWAYS_ASSERT(!time.adaptive_timestep());
}

// Check other density parsing arguments against turbine air density
void perform_density_checks(
const amrex::Real rho_tdef, const bool no_check, const bool is_rst)
{
// Check if other arguments are in input file
amrex::ParmParse pp_incflo("incflo");
amrex::ParmParse pp_cstdns("ConstValue.density");
bool is_incflo = pp_incflo.contains("density");
bool is_cstdns = pp_cstdns.contains("value");
// Flags for detecting conflicts
bool cft_incflo = false;
bool cft_cstdns = false;

// Do warnings or aborts depending on values
const amrex::Real tiny = std::numeric_limits<amrex::Real>::epsilon();
if (is_incflo) {
amrex::Real rho_incflo = 1.0;
pp_incflo.query("density", rho_incflo);
if (std::abs(rho_incflo - rho_tdef) > tiny) {
cft_incflo = true;
if (!no_check) {
amrex::Abort(
"Density conflict detected between TurbineFast "
"density and incflo.density.\n----- Values are " +
std::to_string(rho_tdef) + " and " +
std::to_string(rho_incflo) +
", respectively. Check the problem setup and the "
"turbine definition.\n----- If this difference is "
"intended, set the override_density_check flag to "
"true.\n");
} else {
amrex::Print()
<< "WARNING: Density conflict detected between FAST "
"Turbine density and incflo.density.\n----- Values "
"are " +
std::to_string(rho_tdef) + " and " +
std::to_string(rho_incflo) +
", respectively. Abort overridden by flag.\n";
}
}
}
if (is_cstdns) {
amrex::Real rho_cstdns = 1.0;
pp_cstdns.query("value", rho_cstdns);
if (std::abs(rho_cstdns - rho_tdef) > tiny) {
cft_cstdns = true;
if (!no_check) {
amrex::Abort(
"Density conflict detected between TurbineFast "
"density and ConstValue.density.value.\n----- Values "
"are " +
std::to_string(rho_tdef) + " and " +
std::to_string(rho_cstdns) +
", respectively. Check the problem setup and the "
"turbine definition.\n----- If this difference is "
"intended, set the override_density_check flag to "
"true.\n");
} else {
amrex::Print()
<< "WARNING: Density conflict detected between "
"TurbineFast "
"density and "
"ConstValue.density.value.\n----- Values are " +
std::to_string(rho_tdef) + " and " +
std::to_string(rho_cstdns) +
", respectively. Abort overridden by flag.\n";
}
}
}
if (!is_incflo && !is_cstdns) {
amrex::Print()
<< "TurbineFast: no density conflict detected, but no density "
"arguments found to check against.\n";
} else if (!cft_incflo && !cft_cstdns) {
amrex::Print() << "TurbineFast: no density conflict detected.\n";
}
if (is_rst) {
amrex::Print()
<< "TurbineFast: simulation begins using a checkpoint file, "
"density compatibility must be manually confirmed between "
"the precursor simulation and the specified TurbineFast "
"density, " +
std::to_string(rho_tdef)
<< ".\n";
}
}
};

template <>
Expand Down

0 comments on commit 0592eba

Please sign in to comment.