[#2699] Extrapolate sea level atmospheric conditions if launch site altitude is above 0 & [#2677] Limit launch site altitude to Troposphere #2712
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes 2 issues:
Fixes #2699, where air temperature and pressure interpolation failed if the launch site altitude was above 0. The issue was caused by
ExtendedISAModelsettinglayer[0]to the launch site conditions, affecting interpolation inInterpolatingAtmosphericModel. WhenInterpolatingAtmosphericModelruns thecomputeLayersmethod, it does so by calculating the atmospheric conditions at 500 m incrementing air layers, starting at sea level (altitude = 0 m), and ending at the maximum altitude for the model.If you set the launch site altitude to 250 m, so in the middle of an air layer (between level 0 m and level 500 m),
InterpolatingAtmosphericModel.getConditionswill calculate the temperature and pressure at that altitude using interpolation of the level below it (0 m) and above it (500 m). However, for 0 m,ExtendedISAModel.getExactConditionswould return the temperature and pressure of the launch site (250 m) because the lowest layer of the model,layer[0]was set to the launch site conditions and ingetExactConditions, the altitude would get clampedaltitude = MathUtil.clamp(altitude, layer[0], layer[layer.length - 1]);.The result is a 50% interpolation between the 250 m (should be 0 m) and 500 m conditions, whereas you want the 250 m conditions.
To fix this, if the launch site altitude is > 0, I do not replace
layer[0]with the launch site conditions. Instead, I add the launch site conditions as a new layer betweenlayer[0]andlayer[1], and extrapolate the conditions at sea level (altitude 0) tolayer[0]. Now,InterpolatingAtmosphericModel.getConditionswill still interpolate between level 0 m and 500 m, but the resulting interpolation at 250 m is the same as the original launch site conditions (well, almost, there is a very slight difference for the pressure because of rounding errors or something).Added unit tests for the atmospheric models. I also prepared our Gradle build setting somewhat for Gradle version 9.0, as I kept getting warnings.
Before (pressure at the launch site is much lower than the set 990.66 mbar):

After (correct starting pressure):

Fixes #2677, where the user could enter a launch site altitude greater than what
ExtendedISAModelcould interpolate, i.e. if the launch site altitude is > 11 km (entering the Tropopause;layer[1]). The altitude is now limited both in the UI and in theSimulationOptions.