Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable FSI ramping parameters #1210

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions include/aero/aero_utils/DeflectionRamping.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
namespace fsi {

double KOKKOS_FORCEINLINE_FUNCTION
linear_ramp_span(const double spanLocation, const double zeroRampDistance)
linear_ramp_span(
const double spanLocation,
const double zeroRampDistance,
const bool useRamp = true)
{
return 1.0 - stk::math::max(
(zeroRampDistance - spanLocation) / zeroRampDistance, 0.0);
(zeroRampDistance - spanLocation) / zeroRampDistance, 0.0) *
static_cast<double>(useRamp);
}

double KOKKOS_FORCEINLINE_FUNCTION
Expand All @@ -27,7 +31,8 @@ linear_ramp_theta(
const vs::Vector& root,
const vs::Vector& position,
const double rampSpan,
const double zeroRampLoc)
const double zeroRampLoc,
const bool useRamp = true)
{
auto v1 = (root - hub.position_).normalize();
auto v2 = (position - hub.position_).normalize();
Expand All @@ -42,17 +47,24 @@ linear_ramp_theta(
const auto angle = vs::angle(v1, v2);

return stk::math::min(
1.0, stk::math::max(0.0, (zeroRampLoc - angle) / rampSpan));
1.0, stk::math::max(
static_cast<double>(!useRamp), (zeroRampLoc - angle) / rampSpan));
}

//! ramp from 0 to 1 to allow turbines to only experience rigid body blade
//! motion until time == startRamp, then linearly ramp to full bladeDeflections
//! over the time window startRamp to endRamp
double KOKKOS_FORCEINLINE_FUNCTION
temporal_ramp(const double time, const double startRamp, const double endRamp)
temporal_ramp(
const double time,
const double startRamp,
const double endRamp,
const bool useRamp = true)
{
const double denom = stk::math::max(endRamp - startRamp, 1e-12);
return stk::math::max(0.0, stk::math::min(1.0, (time - startRamp) / denom));
return stk::math::max(
static_cast<double>(!useRamp),
stk::math::min(1.0, (time - startRamp) / denom));
}

} // namespace fsi
Expand Down
3 changes: 3 additions & 0 deletions include/aero/fsi/FSIturbine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ struct DeflectionRampingParams
double thetaRampSpan_{10.0};
double startTimeTemporalRamp_{0.0};
double endTimeTemporalRamp_{0.0};
bool enableSpanRamping_{true};
bool enableThetaRamping_{true};
bool enableTemporalRamping_{true};
};

// TODO(psakiev) find a better place for this
Expand Down
31 changes: 22 additions & 9 deletions src/aero/fsi/FSIturbine.C
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,22 @@ fsiTurbine::fsiTurbine(int iTurb, const YAML::Node& node)
double* zeroTheta = &defParams.zeroRampLocTheta_;
double* thetaRamp = &defParams.thetaRampSpan_;
// clang-format off
get_required(defNode, "temporal_ramp_start", defParams.startTimeTemporalRamp_);
get_required(defNode, "temporal_ramp_end", defParams.endTimeTemporalRamp_);
get_required(defNode, "span_ramp_distance", defParams.spanRampDistance_);
get_if_present(defNode, "zero_theta_ramp_angle", *zeroTheta, *zeroTheta);
get_if_present(defNode, "theta_ramp_span", *thetaRamp, *thetaRamp);
// defaults of all are true from struct defintion
get_if_present(defNode, "enable_theta_ramping", defParams.enableThetaRamping_);
get_if_present(defNode, "enable_span_ramping", defParams.enableSpanRamping_);
get_if_present(defNode, "enable_temporal_ramping", defParams.enableTemporalRamping_);

if(defParams.enableTemporalRamping_){
get_required(defNode, "temporal_ramp_start", defParams.startTimeTemporalRamp_);
get_required(defNode, "temporal_ramp_end", defParams.endTimeTemporalRamp_);
}
if(defParams.enableSpanRamping_){
get_required(defNode, "span_ramp_distance", defParams.spanRampDistance_);
}
if(defParams.enableThetaRamping_){
get_if_present(defNode, "zero_theta_ramp_angle", *zeroTheta, *zeroTheta);
get_if_present(defNode, "theta_ramp_span", *thetaRamp, *thetaRamp);
}
// clang-format on
// ---------- conversionions ----------
defParams.zeroRampLocTheta_ = utils::radians(defParams.zeroRampLocTheta_);
Expand Down Expand Up @@ -1347,7 +1358,8 @@ fsiTurbine::mapDisplacements(double time)

const DeflectionRampingParams& defParams = deflectionRampParams_;
const double temporalDeflectionRamp = fsi::temporal_ramp(
time, defParams.startTimeTemporalRamp_, defParams.endTimeTemporalRamp_);
time, defParams.startTimeTemporalRamp_, defParams.endTimeTemporalRamp_,
defParams.endTimeTemporalRamp_);

auto& meta = bulk_->mesh_meta_data();
VectorFieldType* modelCoords =
Expand Down Expand Up @@ -1450,8 +1462,9 @@ fsiTurbine::mapDisplacements(double time)
spanLocI + *dispMapInterpNode * (spanLocIp1 - spanLocI);

double deflectionRamp =
temporalDeflectionRamp *
fsi::linear_ramp_span(spanLocation, defParams.spanRampDistance_);
temporalDeflectionRamp * fsi::linear_ramp_span(
spanLocation, defParams.spanRampDistance_,
defParams.enableSpanRamping_);

// things for theta mapping
const aero::SixDOF hubPos(brFSIdata_.hub_ref_pos.data());
Expand All @@ -1460,7 +1473,7 @@ fsiTurbine::mapDisplacements(double time)

deflectionRamp *= fsi::linear_ramp_theta(
hubPos, rootPos.position_, nodePosition, defParams.thetaRampSpan_,
defParams.zeroRampLocTheta_);
defParams.zeroRampLocTheta_, defParams.enableThetaRamping_);

*stk::mesh::field_data(*deflectionRamp_, node) = deflectionRamp;

Expand Down
38 changes: 38 additions & 0 deletions unit_tests/aero/UnitTestDeflectionRamping.C
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,42 @@ TEST(DeflectionRamping, temporalRampingPhases)
EXPECT_DOUBLE_EQ(1.0, fsi::temporal_ramp(endRamp, startRamp, endRamp));
EXPECT_DOUBLE_EQ(1.0, fsi::temporal_ramp(5.0, startRamp, endRamp));
}

TEST(DeflectionRamping, booleanDisablesTemporal)
{
const double startRamp = 1.0;
const double endRamp = 2.0;
const double time = 0.0;
EXPECT_DOUBLE_EQ(1.0, fsi::temporal_ramp(time, startRamp, endRamp, false));
EXPECT_DOUBLE_EQ(0.0, fsi::temporal_ramp(time, startRamp, endRamp, true));
}

TEST(DeflectionRamping, booleanDisablesTheta)
{
const double theta = utils::radians(90.0);
const double rampSpan = utils::radians(20.0);
const double thetaZero = utils::radians(60.0);

const aero::SixDOF hub(vs::Vector::zero(), vs::Vector::ihat());
const vs::Vector root(vs::Vector::one());
const auto rotation = wmp::create_wm_param(vs::Vector::ihat(), theta);

const auto pClockWise = wmp::rotate(rotation, root);
EXPECT_DOUBLE_EQ(
0.0,
fsi::linear_ramp_theta(hub, root, pClockWise, rampSpan, thetaZero, true));
EXPECT_DOUBLE_EQ(
1.0,
fsi::linear_ramp_theta(hub, root, pClockWise, rampSpan, thetaZero, false));
}

TEST(DeflectionRamping, booleanDisablesSpan)
{
const double spanLocation = 0.3;
const double zeroRampLocation = 0.4;
EXPECT_DOUBLE_EQ(
0.75, fsi::linear_ramp_span(spanLocation, zeroRampLocation, true));
EXPECT_DOUBLE_EQ(
1.0, fsi::linear_ramp_span(spanLocation, zeroRampLocation, false));
}
} // namespace
Loading