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

Add support for setting ic/vw-mag-fps #1093

Merged
merged 3 commits into from
May 18, 2024
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
5 changes: 3 additions & 2 deletions src/initialization/FGInitialCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ FGColumnVector3 FGInitialCondition::GetWindNEDFpsIC(void) const {

//******************************************************************************

double FGInitialCondition::GetWindFpsIC(void) const
double FGInitialCondition::GetWindMagFpsIC(void) const
{
const FGMatrix33& Tb2l = orientation.GetTInv();
FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
Expand Down Expand Up @@ -1519,7 +1519,8 @@ void FGInitialCondition::bind(FGPropertyManager* PropertyManager)
PropertyManager->Tie("ic/vw-down-fps", this,
&FGInitialCondition::GetWindDFpsIC);
PropertyManager->Tie("ic/vw-mag-fps", this,
&FGInitialCondition::GetWindFpsIC);
&FGInitialCondition::GetWindMagFpsIC,
&FGInitialCondition::SetWindMagFpsIC);
PropertyManager->Tie("ic/vw-dir-deg", this,
&FGInitialCondition::GetWindDirDegIC,
&FGInitialCondition::SetWindDirDegIC);
Expand Down
6 changes: 5 additions & 1 deletion src/initialization/FGInitialCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ class JSBSIM_API FGInitialCondition : public FGJSBBase
@param wD Initial wind velocity in local down direction, feet/second */
void SetWindNEDFpsIC(double wN, double wE, double wD);

/** Sets the initial total wind speed.
@param mag Initial wind velocity magnitude in feet/second */
void SetWindMagFpsIC(double mag) { SetWindMagKtsIC(mag * fpstokts); }

/** Sets the initial total wind speed.
@param mag Initial wind velocity magnitude in knots */
void SetWindMagKtsIC(double mag);
Expand Down Expand Up @@ -505,7 +509,7 @@ class JSBSIM_API FGInitialCondition : public FGJSBBase

/** Gets the initial total wind velocity in feet/sec.
@return Initial wind velocity in feet/second */
double GetWindFpsIC(void) const;
double GetWindMagFpsIC(void) const;

/** Gets the initial wind direction.
@return Initial wind direction in feet/second */
Expand Down
11 changes: 8 additions & 3 deletions tests/unit_tests/FGInitialConditionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FGInitialConditionTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(ic.GetBetaDegIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetBetaDegIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetBetaRadIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetWindFpsIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetWindMagFpsIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetWindDirDegIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetWindUFpsIC(), 0.0);
TS_ASSERT_EQUALS(ic.GetWindVFpsIC(), 0.0);
Expand Down Expand Up @@ -356,10 +356,10 @@ class FGInitialConditionTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 1.0, epsilon);
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 2.0, epsilon);
TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon);
TS_ASSERT_DELTA(ic.GetWindFpsIC(), sqrt(5.0), epsilon);
TS_ASSERT_DELTA(ic.GetWindMagFpsIC(), sqrt(5.0), epsilon);
TS_ASSERT_DELTA(ic.GetWindDirDegIC(), atan2(2.0, 1.0)*180./M_PI, epsilon);

double mag = ic.GetWindFpsIC();
double mag = ic.GetWindMagFpsIC();
ic.SetWindDirDegIC(30.);
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 0.5*mag*sqrt(3.0), epsilon);
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 0.5*mag, epsilon);
Expand All @@ -369,5 +369,10 @@ class FGInitialConditionTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 3.5*sqrt(3.0)*ktstofps, epsilon);
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 3.5*ktstofps, epsilon);
TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon);

ic.SetWindMagFpsIC(7.0);
TS_ASSERT_DELTA(ic.GetWindNFpsIC(), 3.5 * sqrt(3.0), epsilon);
TS_ASSERT_DELTA(ic.GetWindEFpsIC(), 3.5, epsilon);
TS_ASSERT_DELTA(ic.GetWindDFpsIC(), 3.0, epsilon);
}
};
Loading