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

Move the Mach/VCAS conversion methods to FGAtmosphere #881

Merged
merged 3 commits into from
Apr 8, 2023

Conversation

bcoconni
Copy link
Member

@bcoconni bcoconni commented Apr 8, 2023

Following the on-going process of removing static variables and methods as motivated by the issue #666, this PR moves the conversion methods between the Mach number and the calibrated airspeed (VCAS) to the FGAtmosphere class. This allows StdDaySLsoundspeed no longer being a static member and removes 4 static methods from FGJSBBase.

In addition the conversion methods VcalibratedFromMach and MachFromVcalibrated now use the altitude rather than the ambient pressure as an input parameter. This change makes the methods consistent with other methods from FGAtmosphere. In particular this avoids interrogating the FGAtmosphere class for the ambient pressure before calling a static method from FGJSBBase which simplifies the code in FGInitialConditions.

"Magic" constants have also been replaced by their expression using the specific heat ratio $\gamma$ as found in classical textbooks. Most of these computations use constexpr meaning that the constant is computed at compile time. These changes have therefore no performance impact in most cases (as the compiled code use a constant) but this improve the code legibility and allows to document how the constants are computed.

Finally the unit tests for these conversion methods have been rewritten and now check that the computation made by the conversion methods are consistent with thermodynamics:

  • Mass conservation $\rho_1u_1=\rho_2u_2$
  • Momentum conservation $p_1+\rho_1u_1^2=p_2+\rho_2u_2^2$
  • Energy conservation $C_pt_1+\frac{1}{2}u_1^2=C_pt_2+\frac{1}{2}u_2^2$

where $p$ and $t$ are static pressure and static temperature. This allows removing the usage of hardcoded values and therefore testing a greater range of values and scenarios.

@codecov
Copy link

codecov bot commented Apr 8, 2023

Codecov Report

Merging #881 (6368b22) into master (4f3c0e6) will decrease coverage by 0.18%.
The diff coverage is 87.80%.

@@            Coverage Diff             @@
##           master     #881      +/-   ##
==========================================
- Coverage   23.24%   23.06%   -0.18%     
==========================================
  Files         167      167              
  Lines       19607    19611       +4     
==========================================
- Hits         4557     4524      -33     
- Misses      15050    15087      +37     
Impacted Files Coverage Δ
src/FGJSBBase.cpp 72.22% <ø> (-15.28%) ⬇️
src/FGJSBBase.h 90.32% <ø> (ø)
src/models/FGAtmosphere.h 100.00% <ø> (ø)
src/models/FGAuxiliary.cpp 61.18% <0.00%> (-0.92%) ⬇️
src/models/FGAuxiliary.h 84.90% <ø> (ø)
src/initialization/FGInitialCondition.cpp 44.85% <50.00%> (-0.50%) ⬇️
src/FGFDMExec.cpp 41.20% <100.00%> (-0.20%) ⬇️
src/models/FGAtmosphere.cpp 94.58% <100.00%> (+0.97%) ⬆️

... and 16 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@seanmcleod
Copy link
Member

Glancing at the diffs it looks good.

@bcoconni bcoconni merged commit 92fa1ea into JSBSim-Team:master Apr 8, 2023
@bcoconni
Copy link
Member Author

bcoconni commented Apr 8, 2023

Glancing at the diffs it looks good.

Thanks ! The PR is merged.

@bcoconni bcoconni deleted the Mach+VCAS_to_FGAtmosphere_1 branch April 8, 2023 11:11
bcoconni added a commit to bcoconni/jsbsim that referenced this pull request Apr 8, 2023
)

* Remove `static` methods and members
* Replace magic constants with their expression
* Use altitude to compute VCAS or Mach instead of ambient pressure
* Improved unit test
demonixis pushed a commit to demonixis/jsbsim that referenced this pull request Apr 16, 2023
)

* Remove `static` methods and members
* Replace magic constants with their expression
* Use altitude to compute VCAS or Mach instead of ambient pressure
* Improved unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants