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

ENH: Flight simulation speed up #581

Merged
merged 78 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
21331ee
MNT: use Function.get_value_opt() instead of Function.get_value()
Gui-FernandesBR Mar 25, 2024
11feb2a
MNT: refactor and improve Function initialization
Gui-FernandesBR Mar 25, 2024
5a356cd
MNT: better interpolation and extrapolation for get_value_opt
Gui-FernandesBR Mar 25, 2024
cbaa145
MNT: refactors Function.__mul__()
Gui-FernandesBR Mar 25, 2024
9a637a8
TST: fix tests not passing
Gui-FernandesBR Mar 25, 2024
bb293aa
DOC: remove forgotten type hints and update docstrings
Gui-FernandesBR Mar 25, 2024
a22d38c
MNT: Refactor variable assignment in Function.__mul__
Gui-FernandesBR Mar 26, 2024
b23e312
MNT: minor adjustments to Function setters:
Gui-FernandesBR Mar 26, 2024
c93480f
MNT: invokes get_value_opt inside get_value
Gui-FernandesBR Mar 26, 2024
99d8948
BUG: Fix wind direction calculation in Environment class
Gui-FernandesBR Mar 26, 2024
9b47dfe
MNT: use local variable instead of class variable in TimeNodes.merge()
Gui-FernandesBR Mar 26, 2024
6deb233
MNT: speedup Flight._calculate_pressure_signal method
Gui-FernandesBR Mar 26, 2024
939d294
TST: fix test not passing
Gui-FernandesBR Mar 26, 2024
26cc6a1
ENH: rework setters and validation
MateusStano Mar 28, 2024
387e532
TST: fix function test for correct behaviour
MateusStano Mar 28, 2024
c175e76
BUG: revert comit https://github.com/RocketPy-Team/RocketPy/pull/581/…
MateusStano Mar 28, 2024
81a79e3
ENH: change np.searchsorted to bisect_left
MateusStano Mar 28, 2024
c1d1324
DOC: adds docs to new methods
MateusStano Mar 28, 2024
d5d9c31
MNT: run isort
MateusStano Mar 30, 2024
7cd270b
MNT: remove unecessary varibale intialization
MateusStano Mar 30, 2024
0bd6f63
ENH: x, y and z array for all ndarray functions
MateusStano Mar 30, 2024
ca1ce44
Update rocketpy/mathutils/function.py
MateusStano Mar 30, 2024
8cfaedc
Update rocketpy/mathutils/function.py
MateusStano Mar 31, 2024
07f9ed5
MNT: remove unecessary list casting
MateusStano Mar 31, 2024
fa8a892
MNT: return interp and extrap results directly
MateusStano Mar 31, 2024
29bb5fa
ENH: completely private methods
MateusStano Mar 31, 2024
3bee49b
TST: improve tests coverage
MateusStano Apr 4, 2024
00a3c1f
DEV: changelog
MateusStano Apr 4, 2024
f03adeb
Merge pull request #582 from RocketPy-Team/enh/function-validation-re…
Gui-FernandesBR Apr 4, 2024
001d430
Merge branch 'develop' into mnt/flight-simulation-speed-up
Gui-FernandesBR Apr 4, 2024
8498512
TST: Add unit tests for TimeNodes class and its methods
Gui-FernandesBR Apr 16, 2024
88eefa2
ENH: add Function.calculate_cubic_hermite_coefficients method
Gui-FernandesBR Apr 16, 2024
cacd95f
ENH: Adds Function.cardanos_root_finding
Gui-FernandesBR Apr 16, 2024
c7bbd45
TST: Refactor acceptance message to include error threshold
Gui-FernandesBR Apr 16, 2024
80d271e
ENH: Allows the comparison of two TimeNode objects based on their ini…
Gui-FernandesBR Apr 16, 2024
ac294c6
ENH: calculates atmospheric attributes from environment
Gui-FernandesBR Apr 16, 2024
cadcf10
ENH: Add property to calculate differences in function evaluations pe…
Gui-FernandesBR Apr 16, 2024
77be755
ENH: small fixes to the TimeNode() class
Gui-FernandesBR Apr 16, 2024
dc6ff4a
ENH: Improve Flight.__init_xxxx methods
Gui-FernandesBR Apr 16, 2024
826331f
Fix code style issues with Black
lint-action Apr 16, 2024
9568256
Merge branch 'develop' into mnt/flight-simulation-speed-up
Gui-FernandesBR Apr 18, 2024
25093f6
BUG: restore tests, roll back errors
Gui-FernandesBR Apr 18, 2024
13b3d57
MNT: renames FlightPhases to flight_phases
Gui-FernandesBR Apr 18, 2024
9c6c7db
MNT: renames TimeNodes to time_nodes
Gui-FernandesBR Apr 18, 2024
41cbcc3
MNT: don't re-assign the time_iterator function
Gui-FernandesBR Apr 18, 2024
cabdcd2
MNT: Refactor Flight class root finding algorithm for rail exit and i…
Gui-FernandesBR Apr 18, 2024
ce32cb1
MNT: Refactor simulation loop to use Function.calculate_cubic_hermite…
Gui-FernandesBR Apr 18, 2024
48ac2f1
TST: adds tests for new Function calculations
Gui-FernandesBR Apr 18, 2024
af31b94
ENH: cast float type in the Hermite interpolation function in Functio…
Gui-FernandesBR Apr 18, 2024
2602e4d
ENH: improve Flight.TimeNodes.merge method
Gui-FernandesBR Apr 18, 2024
b55236e
MNT: rename cardanos_root_finding to find_roots_cubic_function in Fun…
Gui-FernandesBR Apr 18, 2024
28d0c62
DOC: representation methods, TODOs and docstring
Gui-FernandesBR Apr 19, 2024
1b37951
ENH: providing lambda to sort() is no longer needed
Gui-FernandesBR Apr 19, 2024
ce68150
ENH: new Flight.__calculate_and_save_pressure_signals method
Gui-FernandesBR Apr 19, 2024
8f6efdf
ENH: use Function.find_root_linear_interpolation in the simulation loop
Gui-FernandesBR Apr 19, 2024
39003cd
MNT: rename __transform_pressure_signals_lists_to_functions method
Gui-FernandesBR Apr 19, 2024
b8660db
ENH: optimize post_process mode
Gui-FernandesBR Apr 19, 2024
f84a03f
MNT: small fixes to the Flight class
Gui-FernandesBR Apr 19, 2024
ac01264
DEV: Adds PR 581 to CHANGELOG
Gui-FernandesBR Apr 19, 2024
5f2a4dc
BUG: fix linear interpolation root finding method name in Function class
Gui-FernandesBR Apr 19, 2024
7775a16
Merge branch 'develop' into mnt/flight-simulation-speed-up
Gui-FernandesBR Apr 25, 2024
8d09864
MNT: move auxiliary functions from Function to tools.py
Gui-FernandesBR Apr 26, 2024
505275a
MNT: Fix apogee position calculation in Flight class
Gui-FernandesBR Apr 26, 2024
2690fb2
MNT: delete unused comments in the Flight class
Gui-FernandesBR Apr 26, 2024
cb100c8
Merge branch 'develop' into mnt/flight-simulation-speed-up
Gui-FernandesBR Apr 26, 2024
0df1a46
BUG: fix Flight.__repr__ method
Gui-FernandesBR Apr 29, 2024
2013f16
MNT: simplify post process evaluation with __evaluate_post_process me…
Gui-FernandesBR Apr 29, 2024
79be714
TST: update test values for accelerations calculations
Gui-FernandesBR Apr 29, 2024
4b3d884
MNT: Refactor find_roots_cubic_function method in tools.py
Gui-FernandesBR Apr 29, 2024
a1737c8
ENH: defaults to u_dot in case the rocket has a solid propulsion
Gui-FernandesBR Apr 29, 2024
c268add
Merge branch 'develop' into mnt/flight-simulation-speed-up
MateusStano May 1, 2024
327d9b3
REV: reverts commit a1737c8
Gui-FernandesBR May 2, 2024
0eb4ae8
TST: test_max_values now receives relative tolerance
Gui-FernandesBR May 2, 2024
14eca09
TST: fix the documentation tests of tools.py
Gui-FernandesBR May 2, 2024
dd9bc15
BUG: fix append function in rocketpy/simulation/flight.py
Gui-FernandesBR May 2, 2024
90306f1
Merge branch 'develop' into mnt/flight-simulation-speed-up
Gui-FernandesBR May 3, 2024
92e93a7
ENH: modify the post_processing version of udot_rail1
Gui-FernandesBR May 3, 2024
80d85bb
Fix code style issues with Black
lint-action May 3, 2024
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- ENH: Exponential backoff decorator (fix #449) [#588](https://github.com/RocketPy-Team/RocketPy/pull/588)
- ENH: Function Validation Rework & Swap `np.searchsorted` to `bisect_left` [#582](https://github.com/RocketPy-Team/RocketPy/pull/582)
- ENH: Add new stability margin properties to Flight class [#572](https://github.com/RocketPy-Team/RocketPy/pull/572)
- ENH: adds `Function.remove_outliers` method [#554](https://github.com/RocketPy-Team/RocketPy/pull/554)

### Changed

- DEP: delete deprecated rocketpy.tools.cached_property [#587](https://github.com/RocketPy-Team/RocketPy/pull/587)
- DEP: delete deprecated rocketpy.tools.cached_property [#587](https://github.com/RocketPy-Team/RocketPy/pull/587)
- ENH: Flight simulation speed up [#581] (https://github.com/RocketPy-Team/RocketPy/pull/581)
- MNT: Modularize Rocket Draw [#580](https://github.com/RocketPy-Team/RocketPy/pull/580)
- DOC: Improvements of Environment docstring phrasing [#565](https://github.com/RocketPy-Team/RocketPy/pull/565)
- MNT: Refactor flight prints module [#579](https://github.com/RocketPy-Team/RocketPy/pull/579)
Expand Down
39 changes: 24 additions & 15 deletions rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,24 +1551,26 @@ def process_custom_atmosphere(
# Check maximum height of custom wind input
if not callable(self.wind_velocity_x.source):
max_expected_height = max(self.wind_velocity_x[-1, 0], max_expected_height)
if not callable(self.wind_velocity_y.source):
max_expected_height = max(self.wind_velocity_y[-1, 0], max_expected_height)

# Compute wind profile direction and heading
wind_heading = (
lambda h: np.arctan2(self.wind_velocity_x(h), self.wind_velocity_y(h))
* (180 / np.pi)
% 360
)
def wind_heading_func(h):
return (
np.arctan2(
self.wind_velocity_x.get_value_opt(h),
self.wind_velocity_y.get_value_opt(h),
)
* (180 / np.pi)
% 360
)

self.wind_heading = Function(
wind_heading,
wind_heading_func,
inputs="Height Above Sea Level (m)",
outputs="Wind Heading (Deg True)",
interpolation="linear",
)

def wind_direction(h):
return (wind_heading(h) - 180) % 360
return (wind_heading_func(h) - 180) % 360
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved

self.wind_direction = Function(
wind_direction,
Expand All @@ -1578,7 +1580,10 @@ def wind_direction(h):
)

def wind_speed(h):
return np.sqrt(self.wind_velocity_x(h) ** 2 + self.wind_velocity_y(h) ** 2)
return np.sqrt(
self.wind_velocity_x.get_value_opt(h) ** 2
+ self.wind_velocity_y.get_value_opt(h) ** 2
)

self.wind_speed = Function(
wind_speed,
Expand Down Expand Up @@ -3179,22 +3184,26 @@ def add_wind_gust(self, wind_gust_x, wind_gust_y):
# Reset wind heading and velocity magnitude
self.wind_heading = Function(
lambda h: (180 / np.pi)
* np.arctan2(self.wind_velocity_x(h), self.wind_velocity_y(h))
* np.arctan2(
self.wind_velocity_x.get_value_opt(h),
self.wind_velocity_y.get_value_opt(h),
)
% 360,
"Height (m)",
"Wind Heading (degrees)",
extrapolation="constant",
)
self.wind_speed = Function(
lambda h: (self.wind_velocity_x(h) ** 2 + self.wind_velocity_y(h) ** 2)
lambda h: (
self.wind_velocity_x.get_value_opt(h) ** 2
+ self.wind_velocity_y.get_value_opt(h) ** 2
)
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
** 0.5,
"Height (m)",
"Wind Speed (m/s)",
extrapolation="constant",
)

return None

def info(self):
"""Prints most important data and graphs available about the
Environment.
Expand Down
Loading
Loading