Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Attention: The newest changes should be on top -->

### Changed

- ENH: Resolve pressure_ISA discretization bounds TODO [#1056](https://github.com/RocketPy-Team/RocketPy/pull/1056)
- ENH: Refactor flight.py latitude/longitude to use inverted_haversine [#1055](https://github.com/RocketPy-Team/RocketPy/pull/1055)

### Deprecated
Expand Down
4 changes: 3 additions & 1 deletion rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2553,7 +2553,9 @@ def pressure_function(h):
return P

# Discretize this Function to speed up the trajectory simulation
altitudes = np.linspace(0, 80000, 100) # TODO: should be -2k instead of 0
min_height = geopotential_height_to_geometric_height(-2000, earth_radius)
max_height = geopotential_height_to_geometric_height(80000, earth_radius)
altitudes = np.linspace(min_height, max_height, 100)
Comment thread
Gui-FernandesBR marked this conversation as resolved.
Outdated
pressures = [pressure_function(h) for h in altitudes]

return np.column_stack([altitudes, pressures])
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/environment/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,27 @@ def test_pressure_conversion_factor_autodetect_by_model(
None, None, model
)
assert factor == expected_factor


def test_pressure_isa_discretization_bounds(example_plain_env):
"""Test that pressure_ISA contains the expected range of altitudes
starting from the minimum geopotential height (-2000m) converted to
geometric height, up to the maximum (80000m) geopotential height converted to
geometric height.
"""
from rocketpy.tools import geopotential_height_to_geometric_height

# Act
pressure_isa_function = example_plain_env.pressure_ISA
source_array = pressure_isa_function.source
altitudes = source_array[:, 0]

# Expected min/max geometric heights
earth_radius = example_plain_env.earth_radius
expected_min_height = geopotential_height_to_geometric_height(-2000, earth_radius)
expected_max_height = geopotential_height_to_geometric_height(80000, earth_radius)

# Assert
assert np.isclose(altitudes[0], expected_min_height)
assert np.isclose(altitudes[-1], expected_max_height)
assert len(altitudes) == 100
Loading