Skip to content

Conversation

@hogatata
Copy link

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)

Checklist

  • Tests for the changes have been added (if needed)
  • All tests (pytest tests -m slow --runslow) have passed locally

Current behavior

Currently, the Flight class calculates various kinematic properties, but it does not explicitly expose the axial acceleration (acceleration along the rocket's longitudinal axis) as a direct property or method. Users have to calculate it manually from other components.

New behavior

This PR adds the calculation of the axial acceleration to the Flight class:

  • Implemented axial_acceleration calculation.
  • Added a corresponding unit test to verify the correctness of the values against expected physical behavior.

Breaking change

  • Yes
  • No

@hogatata hogatata requested a review from a team as a code owner November 26, 2025 11:06
@aZira371 aZira371 requested a review from Copilot November 26, 2025 11:50
Copilot finished reviewing on behalf of aZira371 November 26, 2025 11:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to add axial acceleration calculation to the Flight class, which represents the acceleration along the rocket's longitudinal axis. However, the PR includes several unrelated changes that significantly expand its scope beyond the stated purpose.

Key Changes:

  • Added axial_acceleration property to calculate acceleration along rocket's axis
  • Added corresponding unit test using dot product verification
  • Unexpectedly restored previously deprecated export methods (export_pressures, export_data, export_sensor_data, export_kml) with full implementations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
rocketpy/simulation/flight.py Added axial_acceleration cached property; restored export methods that were previously moved to FlightDataExporter; removed self.apogee initialization; added json and simplekml imports; removed deprecated import
tests/unit/simulation/test_flight.py Added parameterized test to verify axial_acceleration calculation against manual dot product computation at key flight times

self.out_of_rail_state = np.array([0])
self.apogee_state = np.array([0])
self.apogee = 0
self.apogee_time = 0
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of self.apogee = 0 initialization appears to be unintentional. This attribute is still used in the codebase (e.g., line 899 where self.apogee = self.apogee_state[2] is assigned). Without this initialization, accessing self.apogee before apogee is reached during flight simulation could raise an AttributeError.

This line should be restored to maintain proper initialization of instance attributes.

Suggested change
self.apogee_time = 0
self.apogee_time = 0
self.apogee = 0

Copilot uses AI. Check for mistakes.
Comment on lines +2 to 11
import json
import math
import warnings
from copy import deepcopy
from functools import cached_property

import numpy as np
import simplekml
from scipy.integrate import BDF, DOP853, LSODA, RK23, RK45, OdeSolver, Radau

Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of import json and import simplekml at the module level, along with the removal of the FlightDataExporter import and the deprecated import from tools, appears to be unrelated to the stated purpose of this PR (adding axial acceleration calculation).

These changes seem to be reverting the refactoring that moved export methods to FlightDataExporter, as the methods export_pressures, export_data, export_sensor_data, and export_kml have been restored to the Flight class with their full implementations (lines 3276-3539).

This significantly expands the scope of the PR beyond what is described and should be addressed in a separate PR or the PR description should be updated to reflect these additional changes.

Copilot uses AI. Check for mistakes.
Comment on lines 16 to 20
from ..tools import (
calculate_cubic_hermite_coefficients,
deprecated,
euler313_to_quaternions,
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the deprecated import and restoration of export methods (export_pressures, export_data, export_sensor_data, export_kml) appears to be reverting a previous deprecation without explanation. These methods were previously marked as deprecated in favor of FlightDataExporter class, but are now being restored with full implementations.

This change is unrelated to the PR's stated purpose of adding axial acceleration and represents a significant architectural change that should be discussed separately or properly documented in the PR description.

Copilot uses AI. Check for mistakes.
Comment on lines +2472 to +2628
@cached_property
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
)
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The axial_acceleration property is missing the @funcify_method decorator that other similar properties use. This decorator is used throughout the codebase to define the output labels and interpolation methods for Function objects. It should include appropriate labels with units.

Suggested fix:

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

Copilot generated this review using guidance from repository custom instructions.
"""Maximum acceleration reached by the rocket."""
max_acceleration_time_index = np.argmax(self.acceleration[:, 1])
return self.acceleration[max_acceleration_time_index, 1]

Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected. This line should end immediately after the closing brace without extra spaces.

Suggested change

Copilot uses AI. Check for mistakes.
@Gui-FernandesBR Gui-FernandesBR changed the base branch from master to develop November 27, 2025 12:39
@Gui-FernandesBR Gui-FernandesBR force-pushed the env/flight-axial_aceleration branch from c5a1258 to 47e5b61 Compare November 27, 2025 12:39
@Gui-FernandesBR
Copy link
Member

@hogatata are you still willing to work on this one? Tests are not passing, we need that fixed before starting our review

@Gui-FernandesBR Gui-FernandesBR marked this pull request as draft November 27, 2025 12:55
@Gui-FernandesBR Gui-FernandesBR linked an issue Nov 27, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

ENH: adds axial_acceleration attribute to the Flight class

2 participants