-
Notifications
You must be signed in to change notification settings - Fork 450
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
Do not make direct calls to FGAtmosphere
#885
Conversation
Codecov Report
@@ Coverage Diff @@
## master #885 +/- ##
==========================================
+ Coverage 23.06% 23.10% +0.03%
==========================================
Files 167 167
Lines 19611 19613 +2
==========================================
+ Hits 4524 4532 +8
+ Misses 15087 15081 -6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Hmm, although I gave the thumbs up for PR - #881, I'm now in two minds about where it would be best to perform the velocity calculations, i.e. in the auxiliary class or the atmosphere class. Partially thinking about the required inputs for the two approaches and what it means for someone developing a new atmosphere model that they want to include. Should they need to concern themselves with velocity calculations versus simply returning atmospheric state? So atmosphere developers now need to handle and process Hmm, so while composing this and checking the code a bit more I just realised there is an So now I don't really mind 😉 |
I agree with you that neither option is the perfect location for the computation of the CAS. However I've given more thoughts to this PR since I submitted it a week ago: whatever the choice we will make, The reason is that I am currently working on restoring the MSIS atmosphere1 in JSBSim (see the So
Not sure the alternatives are much compelling: the computation of the total pressure needs to call the method
I made the choice of using the first option for this PR but the other options can also be considered.
Yes, that's really the idea. The parameters used by these formulas might be modified by atmospheric models but the formulas themselves remain valid for any atmospheric model. So the point is to save developers of atmospheric models the trouble of duplicating this code. Footnotes
|
PR cancelled because it has been superseded by #898. |
This PR is somewhat an opinionated one 😄
Going back almost 12 years ago the mediator programming pattern was introduced in JSBSim by @jonsberndt via the commit 3c05fee. In JSBSim the mediator object is the
FGFDMExec
class and the current architecture of JSBSim is that all communications between models (i.e. classes inheriting fromFGModel
) are made viaFGFDMExec
(more specifically by the methodFGFDMExec::LoadInputs
). Following the merge of the PR #881 this is no longer the case asFGAuxiliary
makes direct calls toFGAtmosphere
. The purpose of this PR is therefore to restore a "pure" mediator pattern.In that purpose this PR moves the computation of the calibrated airspeed, total pressure and total temperature to
FGAtmosphere
where the routines required to perform these calculations are located. This change is absolutely not mandatory as JSBSim works perfectly well in its current state but the current state is a small breach in the overall architecture.In order to compute calibrated airspeed and the total pressure and temperature
FGAtmosphere
need to get the aircraft aerodynamic velocity which includes getting access to the wind velocity. CurrentlyFGWinds
is evaluated afterFGAtmosphere
which means thatFGAtmosphere
uses a wind velocity that lags one time step behind. I have considered swapping the order in whichFGWinds
andFGAtmosphere
were called but I have dropped this idea because I was finding it too intrusive1 while I don't see much problem in using the wind velocity from the previous time step. I don't expect the wind velocity changing much between 2 time steps (especially if the main loop runs at 120Hz).The total temperature computation is also moved to$\gamma$ (i.e.
$$T_0=T\left(1+\frac{\gamma-1}{2}M^2\right)$$
FGAtmosphere
as its formula actually depends on the specific heat ratioFGAtmosphere::SHRatio
):This PR is a bit questionable in that computing a velocity in the class
FGAtmosphere
is not an obvious move. It is rather dictated by programming considerations (vcas
uses methods fromFGAtmosphere
) rather than common sense. On the other hand, the calibrated airspeed is tightly linked to the atmospheric properties in which the aircraft flying, so... I'm submitting this PR and waiting for your comments/opinions.Footnotes
See commits 51f8b3e, 88b7def and 9f775fe to convince yourself that changing the order in which models are evaluated is as much an art as a science. ↩