Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Attention: The newest changes should be on top -->

### Added

- ENH: Add axial_acceleration attribute to the Flight class [#876](https://github.com/RocketPy-Team/RocketPy/pull/876)
- ENH: Rail button bending moments calculation in Flight class [#893](https://github.com/RocketPy-Team/RocketPy/pull/893)
- ENH: Built-in flight comparison tool (`FlightComparator`) to validate simulations against external data [#888](https://github.com/RocketPy-Team/RocketPy/pull/888)
- ENH: Add persistent caching for ThrustCurve API [#881](https://github.com/RocketPy-Team/RocketPy/pull/881)
Expand Down
9 changes: 9 additions & 0 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,15 @@ def acceleration(self):
"""Rocket acceleration magnitude as a Function of time."""
return (self.ax**2 + self.ay**2 + self.az**2) ** 0.5

@funcify_method("Time (s)", "Axial Acceleration (m/s²)", "spline", "zero")
def axial_acceleration(self):
"""Axial acceleration magnitude as a Function of time."""
return (
self.ax * self.attitude_vector_x
+ self.ay * self.attitude_vector_y
+ self.az * self.attitude_vector_z
)

@cached_property
def max_acceleration_power_on_time(self):
"""Time at which the rocket reaches its maximum acceleration during
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/simulation/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,37 @@ def test_max_values(flight_calisto_robust):
assert pytest.approx(285.94948, rel=rtol) == test.max_speed


@pytest.mark.parametrize(
"flight_time_attr",
["t_initial", "out_of_rail_time", "apogee_time", "t_final"],
)
def test_axial_acceleration(flight_calisto_custom_wind, flight_time_attr):
"""Tests the axial_acceleration property by manually calculating the
dot product of the acceleration vector and the attitude vector at
specific time steps.

Parameters
----------
flight_calisto_custom_wind : rocketpy.Flight
Flight object to be tested.
flight_time_attr : str
The name of the attribute of the flight object that contains the time
of the point to be tested.
"""
flight = flight_calisto_custom_wind
t = getattr(flight, flight_time_attr)

calculated_axial_acc = flight.axial_acceleration(t)

expected_axial_acc = (
flight.ax(t) * flight.attitude_vector_x(t)
+ flight.ay(t) * flight.attitude_vector_y(t)
+ flight.az(t) * flight.attitude_vector_z(t)
)

assert pytest.approx(expected_axial_acc, abs=1e-9) == calculated_axial_acc


def test_effective_rail_length(flight_calisto_robust, flight_calisto_nose_to_tail):
"""Tests the effective rail length of the flight simulation. The expected
values are calculated by hand, and should be valid as long as the rail
Expand Down