Skip to content

Commit

Permalink
Revert to use of cos^2 in LiftDrag plugin
Browse files Browse the repository at this point in the history
In response to #2189 (comment)

As suggested by @srmainwaring I also renamed cosSweepAngle ->
cos2SweepAngle to prevent further confusion.

Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 committed Dec 27, 2023
1 parent 67850c4 commit a645be8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/systems/lift_drag/LiftDrag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm)
spanwiseI.Dot(velI), minRatio, maxRatio);

// get cos from trig identity
double cosSweepAngle = sqrt(1.0 - sinSweepAngle * sinSweepAngle);
double cos2SweepAngle = 1.0 - sinSweepAngle * sinSweepAngle;
double sweep = std::asin(sinSweepAngle);

// truncate sweep to within +/-90 deg
Expand Down Expand Up @@ -390,20 +390,20 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm)
{
cl = (this->cla * this->alphaStall +
this->claStall * (alpha - this->alphaStall)) *
cosSweepAngle;
cos2SweepAngle;
// make sure cl is still great than 0
cl = std::max(0.0, cl);
}
else if (alpha < -this->alphaStall)
{
cl = (-this->cla * this->alphaStall +
this->claStall * (alpha + this->alphaStall))
* cosSweepAngle;
* cos2SweepAngle;

Check warning on line 401 in src/systems/lift_drag/LiftDrag.cc

View check run for this annotation

Codecov / codecov/patch

src/systems/lift_drag/LiftDrag.cc#L401

Added line #L401 was not covered by tests
// make sure cl is still less than 0
cl = std::min(0.0, cl);
}
else
cl = this->cla * alpha * cosSweepAngle;
cl = this->cla * alpha * cos2SweepAngle;

// modify cl per control joint value
if (controlJointPosition && !controlJointPosition->Data().empty())
Expand All @@ -421,16 +421,16 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm)
{
cd = (this->cda * this->alphaStall +
this->cdaStall * (alpha - this->alphaStall))
* cosSweepAngle;
* cos2SweepAngle;
}
else if (alpha < -this->alphaStall)
{
cd = (-this->cda * this->alphaStall +
this->cdaStall * (alpha + this->alphaStall))
* cosSweepAngle;
* cos2SweepAngle;
}
else
cd = (this->cda * alpha) * cosSweepAngle;
cd = (this->cda * alpha) * cos2SweepAngle;

// make sure drag is positive
cd = std::fabs(cd);
Expand All @@ -444,20 +444,20 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm)
{
cm = (this->cma * this->alphaStall +
this->cmaStall * (alpha - this->alphaStall))
* cosSweepAngle;
* cos2SweepAngle;

Check warning on line 447 in src/systems/lift_drag/LiftDrag.cc

View check run for this annotation

Codecov / codecov/patch

src/systems/lift_drag/LiftDrag.cc#L447

Added line #L447 was not covered by tests
// make sure cm is still great than 0
cm = std::max(0.0, cm);
}
else if (alpha < -this->alphaStall)
{
cm = (-this->cma * this->alphaStall +
this->cmaStall * (alpha + this->alphaStall))
* cosSweepAngle;
* cos2SweepAngle;

Check warning on line 455 in src/systems/lift_drag/LiftDrag.cc

View check run for this annotation

Codecov / codecov/patch

src/systems/lift_drag/LiftDrag.cc#L455

Added line #L455 was not covered by tests
// make sure cm is still less than 0
cm = std::min(0.0, cm);
}
else
cm = this->cma * alpha * cosSweepAngle;
cm = this->cma * alpha * cos2SweepAngle;

// Take into account the effect of control surface deflection angle to cm
if (controlJointPosition && !controlJointPosition->Data().empty())
Expand Down

0 comments on commit a645be8

Please sign in to comment.