Skip to content

Conversation

aZira371
Copy link
Collaborator

@aZira371 aZira371 commented Dec 3, 2024

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

for issue #655

New behavior

(DRAFT)
ENH: adds 3 DOF simulation capability to rocketpy.Flight.

*ENH: added "u_dot_3dof" for "solid_propulsion"
mode

*ENH: adding "u_dot_generalized_3dof" for "standard" mode (still incomplete)

*ENH: new parameter "simulation_mode" for swtiching between 3 dof and 6 dof

*ENH: updated conditions for "__init_equations_of_motion"

*ENH: 2 new example files have been created to test 3 dof model "test_bella_lui_flight_sim" and "test_camoes_flight_sim"

Breaking change

  • No

Additional information

This is a draft pull request!
Equations of motion have been modified in such a way that values related to various rotational dofs is set to zero.

ENH: adds 3 DOF simulation capability to rocketpy.Flight.

*ENH: added "u_dot_3dof" for "solid_propulsion"
mode

*ENH: adding "u_dot_generalized_3dof" for "standard"
mode (still incomplete)

*ENH: new parameter "simulation_mode" for swtiching
between 3 dof and 6 dof

*ENH: updated conditions for "__init_equations_of_motion"

*ENH: 2 new example files have been created to test 3 dof model
"test_bella_lui_flight_sim" and "test_camoes_flight_sim"
@Lucas-Prates Lucas-Prates added Enhancement New feature or request, including adjustments in current codes Flight Flight Class related features labels Dec 4, 2024
@Lucas-Prates Lucas-Prates linked an issue Dec 4, 2024 that may be closed by this pull request
@Lucas-Prates
Copy link
Contributor

Lucas-Prates commented Dec 4, 2024

Thank you for your interest in implementing 3-DOF in RocketPy, @aZira371 . I will try to take a better look into it, but I notice one thing already: use 6 DOF as the default input for simulation_mode for two reasons:

  1. most people will use 6 DOF;
  2. changing it to 3 DOF introduces breaking changes, and we really want to avoid that. You can see that a breaking change occurred because the tests failed.

@Lucas-Prates Lucas-Prates changed the title DRAFT: for ENH/3-dof-simulation (See #655) ENH: Implementing 3-dof-simulation Dec 4, 2024
ENH: adds 3 DOF simulation capability to rocketpy.Flight.

*ENH: added "u_dot_3dof" for "solid_propulsion"
mode

*ENH: added "u_dot_generalized_3dof" for "standard"
mode

*ENH: new parameter "simulation_mode" for swtiching
between 3 dof and 6 dof

*ENH: updated conditions for "__init_equations_of_motion"
ENH: fixed standard 3 dof

*MNT: Cleaned up the "u_dot_3dof" and "u_dot_generalized_3_dof"

*MNT: Corrected Typos in "simulation_mode"
description

*ENH: "u_dot_generalized_3_dof" fixed and tested
on examples.
@Gui-FernandesBR
Copy link
Member

Gui-FernandesBR commented Feb 8, 2025

  • Git rebase develop
  • Revert changes in the jupyter notebook
  • Create PointMassMotor
  • Create BaseRocket
  • Create PointMassRocket
  • Modify Rocket class where it's needed (here other people can help you, including Gui)
  • Modify the Flight class again, if needed (delete u_dot_3dof)
  • Include integration tests (here you can ask for help)
  • Format and lint the code (see the Makefile)

…otor

ENH: added "BaseRocket" and "PointMassRocket" to rocket class

ENH: added "PointMassMotor" to motor class with various input cases of thrust values
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 159 lines in your changes missing coverage. Please review.

Project coverage is 78.73%. Comparing base (4a41f7a) to head (0673076).
Report is 12 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/simulation/flight.py 10.00% 108 Missing ⚠️
rocketpy/rocket/rocket.py 24.32% 28 Missing ⚠️
rocketpy/motors/PointMassMotor.py 56.60% 23 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #745      +/-   ##
===========================================
- Coverage    79.09%   78.73%   -0.37%     
===========================================
  Files           96       98       +2     
  Lines        11583    12118     +535     
===========================================
+ Hits          9162     9541     +379     
- Misses        2421     2577     +156     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

aZira371 and others added 6 commits April 11, 2025 20:31
…e tests

ENH: Added a new jupyter notebook for a simplified 3 DOF example

MNT: PointMassMotor intialization error fixed

MNT: PointMassRocket properties enhanced based on the example runs
MNT: Cleaned up the flight class u_dot_generalized_3dof

TODO: Add info for 3 dof cases and fix some new issues when parachute is added.
@aZira371 aZira371 marked this pull request as ready for review May 10, 2025 17:51
@aZira371 aZira371 requested a review from a team as a code owner May 10, 2025 17:51
aZira371 and others added 6 commits June 11, 2025 01:18
-MNT: removing the parameters not needed for point mass kind of motors

-MNT: removing extra parameter thrust_curve

-MNT: fixing problems with motor class inheritance
-ENH: removed 'BaseRocket' class now 'PointMassRocket' inherits directly from 'Rocket' class
-MNT: fixed calculations of mass flow rate and exhaust velocity
-MNT: adjusted propellant initial mass setter error by allocating the input initial mass to the property
MNT: renaming pointmassmotor.py

-MNT:snake case renaming
-MNT: cleaned up PointMassRocket rocket.py for linters.
-ENH: including PointMassMotor in motors and rocketpy __init__.py
-MNT: adopting to structural changes in 3dof on the 3_DOF_TRIAL.ipynb
-MNT: including pointmassmotor in settings.json as a spell word
@Gui-FernandesBR Gui-FernandesBR requested a review from Copilot July 16, 2025 13:58
Copy link

@Copilot 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

Adds 3-DOF simulation support alongside the existing 6-DOF model, introduces a simulation_mode switch in Flight, and defines a new PointMassRocket plus corresponding PointMassMotor for simplified dynamics.

  • Added simulation_mode parameter to Flight and wired up u_dot_generalized_3dof
  • Created PointMassRocket class and PointMassMotor implementation
  • Updated imports to expose new point-mass classes

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rocketpy/simulation/flight.py Introduce simulation_mode, route to new 3-DOF methods
rocketpy/rocket/rocket.py Add PointMassRocket with zero-inertia modeling
rocketpy/rocket/init.py Export PointMassRocket
rocketpy/motors/pointmassmotor.py Implement PointMassMotor
rocketpy/motors/init.py Export PointMassMotor
rocketpy/init.py Expose new point-mass classes
.vscode/settings.json Add pointmassmotor to tool settings
Comments suppressed due to low confidence (4)

rocketpy/simulation/flight.py:492

  • The new simulation_mode argument is not documented in the __init__ docstring. Add descriptions of valid modes ('6 DOF', '3 DOF') and behavior changes.
        simulation_mode="6 DOF",

rocketpy/simulation/flight.py:1627

  • The new u_dot_generalized_3dof method lacks unit tests to verify its correctness. Consider adding tests for basic trajectories and mass variation in 3-DOF mode.
    def u_dot_generalized_3dof(self, t, u, post_processing=False):

rocketpy/simulation/flight.py:1201

  • u_dot_3dof is not defined in the Flight class, leading to an AttributeError. Either implement u_dot_3dof or update this reference to the correct 3-DOF method.
            self.u_dot_generalized = self.u_dot_3dof

rocketpy/rocket/rocket.py:2010

  • The __init__ body contains parameter declarations (self, radius: float = 0, ...) inside the method instead of in the signature, causing a syntax error. Move all parameters into the signature and remove these misplaced lines.
    def __init__(self, mass, radius=0.05):

- MNT: pointmassmotor fixing the various properties.
- MNT: fixing super init and init inheritance by changing order in pointmassrocket
- MNT: pointmassrocket property setter and default value fixes
@aZira371 aZira371 requested a review from MateusStano August 30, 2025 19:29
- MNT: implemented identification of simulation mode based on check if point mass objects are used
# ------------------------------------------------------------------
@property
def dry_I_11(self): return 0.0
@dry_I_11.setter
Copy link
Member

Choose a reason for hiding this comment

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

question: do you really need a @dry_I_11.setter? Apparently you have already set the properties to always be 0

Copy link
Member

Choose a reason for hiding this comment

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

could we also accept drag curves, instead of only float values?

Comment on lines +493 to 494
simulation_mode="6 DOF",
ode_solver="LSODA",
Copy link
Member

Choose a reason for hiding this comment

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

you cannot add keyword arguments before the current ones that already exist. Otherwise it would be a breaking change

Suggested change
simulation_mode="6 DOF",
ode_solver="LSODA",
ode_solver="LSODA",
simulation_mode="6 DOF",

Plus, could you kindly add the new parameter to the class docstring please?

@Gui-FernandesBR
Copy link
Member

@aZira371 great work, code seems cleaner now!!

There's still some work to do, here are suggestions on how to proceed:

  1. Rebase this PR onto develop. This will bring the most recent commits to your branch.
  2. Remind to run the make format and make lint commands before pushing, this makes review much easier.
  3. Resolve each comment in this PR, asking questions if you have any.

Let me know if you need any help on this process.

aZira371 and others added 17 commits September 10, 2025 00:25
- MNT: used make format to correct formatting mistakes on all the new classes.
-MNT: removing the parameters not needed for point mass kind of motors

-MNT: removing extra parameter thrust_curve

-MNT: fixing problems with motor class inheritance
-ENH: removed 'BaseRocket' class now 'PointMassRocket' inherits directly from 'Rocket' class
-MNT: fixed calculations of mass flow rate and exhaust velocity
-MNT: adjusted propellant initial mass setter error by allocating the input initial mass to the property
MNT: renaming pointmassmotor.py

-MNT:snake case renaming
…m#828)

* ENH: refactor motor prints classes to inherit from _MotorPrints

* STY: make format

* ENH: add entry for _MotorPrints inheritance in changelog
* MNT: update code and remove deprecated functions

* MNT: simplify geodesic_to_utm import and usage in Environment class

* MNT: update CHANGELOG to fix deprecations and warnings

* make lint

* MNT: remove unused post_processed attribute from Flight class

* MNT: update matplotlib version to 3.8.3 in requirements.txt

* MNT: update matplotlib version to 3.10.0 in requirements.txt

* MNT: downgrade matplotlib version to 3.9.0 in requirements.txt

* MNT: change boxplot orientation to horizontal for compatibility with future Python versions

* MNT: change boxplot orientation from horizontal to vertical for consistency
* wind factor bug corrected

the wind factor wasn't applied to the env.wind_velocity properties

* BUG: StochasticModel visualize attributes of a uniform distribution

It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in

* variable names corrections

* Corrections requested by the pylint test

* ENH: add multiplication for 2D functions in rocketpy.function

Added the ability to multiply functions with 2D domains in the __mul__ function

* ENH: StochasticAirBrakes class created

The StochasticAirBrakes class has been created. The __init__.py files in the stochastic and rocketpy folders have also been modified accordingly to incorporate this new class

* ENH: set_air_brakes function created

This functions appends an airbrake and controller objects previuosly created to the rocket

* ENH: add StochasticAirBrake to rocketpy.stochastic_rocket

Some functions has been modified and other has been created in order to include the new StochasticAirBrakes feature into the StochasticRocket class. A new function named 'add_air_brakes' has been created to append a StochasticAirBrakes and Controller objects to the StochasticRocket object. A new function '_create_air_brake' has been introduced to create a sample of an AirBrake object through a StochasticAirBrake object. Enventually, the 'create_object' function has been modified to add the sampled AirBrakes to the sampled Rocket

* BUG: StochasticAirBrake object input in _Controller

When defining the _Controller object a StochasticAirBrake was input. This is already corrected and a AirBrake object is now introduced

* ENH: add time_overshoot option to rocketpy.stochastic_flight

Since the new StochasticAirBrake class is defined, we need the 'time_overshoot' option in the Flight class to ensure that the time step defined in the simulation is the controller sampling rate. The MonteCarlo class has had to be modified as well to include this option.

* DOC: StochasticAirBrakes related documentation added

Documentation related to the StochasticAirBrakes implementation has been added in StochasticAirBrakes, StochasticRocket and Rocket classes.

* ENH: pylint recommendations done

* ENH: Reformatted files to pass Ruff linting checks

* ENH: Update rocketpy/stochastic/stochastic_rocket.py

Unnecessary comment

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>

* ENH: more intuitive uniform distribution display in StochasticModel

Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com>

* DOC: improve drag curve factor definition in StochasticAirBrakes

* ENH: Change assert statement to if

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>

* DOC: better explanation of __mul__ function

Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com>

* ENH: delete set_air_brakes function for simplicity

* ENH: inertial foreces added to u_dot_generalized

* ENH: define Earth's angular velocity vector in Environment

* ENH: some corrections to the Flight class

* ENH: modifications in the Flight class

* DOC: improving Environment documentation

* DOC: more improvements in the Environment class

* ENH: format changes done

* DOC: env.earth_rotation_vector improved

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>

* ENH: Coriolis acceleration added to u_dot

* BUG: print left

* ENH: ruff changes

* ENH: CHANGELOG updated

* ENH: remove unecessary frame rotation

* ENH: remove rotation from solid prop udot

* ENH: add coriolis to parachute

* TST: fix tests values

* MNT: remove debug functions

* DEV: changelog

---------

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com>
Co-authored-by: MateusStano <go34lap@mytum.de>
Co-authored-by: MateusStano <mateusstano@usp.br>
* ENH: refactor motor prints classes to inherit from _MotorPrints

* STY: make format

* MNT: update code and remove deprecated functions

* ENH: add deprecation decorator and update deprecated methods

* make format

* fix warnings
-MNT: incorporating latest structural changes made to PointMassMotor and PointMassRocket
-MNT: cleaned up PointMassRocket rocket.py for linters.
-ENH: including PointMassMotor in motors and rocketpy __init__.py
-MNT: adopting to structural changes in 3dof on the 3_DOF_TRIAL.ipynb
-MNT: including pointmassmotor in settings.json as a spell word
- MNT: pointmassmotor fixing the various properties.
- MNT: fixing super init and init inheritance by changing order in pointmassrocket
- MNT: pointmassrocket property setter and default value fixes
- MNT: implemented identification of simulation mode based on check if point mass objects are used
- MNT: used make format to correct formatting mistakes on all the new classes.
Comment on lines +64 to +73
@funcify_method("Time (s)", "Exhaust velocity (m/s)")
def exhaust_velocity(self):
"""Assume constant exhaust velocity: total impulse / propellant mass"""
v_e = self.total_impulse / self.propellant_initial_mass
return Function(v_e).set_discrete_based_on_model(self.thrust)

@cached_property
def total_mass_flow_rate(self) -> Function:
"""Mass flow rate: -thrust / exhaust_velocity"""
return -self.thrust / self.exhaust_velocity
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two methods seem to be equal to the parent class Motor.exhaust_velocity and Motor.total_mass_flow_rate. If I understood correctly, they could be deleted without any problems (the parent class one would be used).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request, including adjustments in current codes Flight Flight Class related features
Projects
Status: Mid-Term
Development

Successfully merging this pull request may close these issues.

ENH: 3-DOF simulation
6 participants