-
-
Notifications
You must be signed in to change notification settings - Fork 200
ENH: Implementing 3-dof-simulation #745
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
base: develop
Are you sure you want to change the base?
Conversation
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"
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
|
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.
|
2931c30
to
7864590
Compare
…into enh/3-dof-simulation
…otor ENH: added "BaseRocket" and "PointMassRocket" to rocket class ENH: added "PointMassMotor" to motor class with various input cases of thrust values
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
…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.
…cketPy into enh/3-dof-simulation
-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
There was a problem hiding this 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 toFlight
and wired upu_dot_generalized_3dof
- Created
PointMassRocket
class andPointMassMotor
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 theFlight
class, leading to an AttributeError. Either implementu_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
- 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
simulation_mode="6 DOF", | ||
ode_solver="LSODA", |
There was a problem hiding this comment.
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
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?
@aZira371 great work, code seems cleaner now!! There's still some work to do, here are suggestions on how to proceed:
Let me know if you need any help on this process. |
- 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 <[email protected]> * ENH: more intuitive uniform distribution display in StochasticModel Co-authored-by: MateusStano <[email protected]> * DOC: improve drag curve factor definition in StochasticAirBrakes * ENH: Change assert statement to if Co-authored-by: Gui-FernandesBR <[email protected]> * DOC: better explanation of __mul__ function Co-authored-by: MateusStano <[email protected]> * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: MateusStano <[email protected]> Co-authored-by: MateusStano <[email protected]> Co-authored-by: MateusStano <[email protected]>
* 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.
…cketPy into enh/3-dof-simulation
@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 |
There was a problem hiding this comment.
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).
Pull request type
Checklist
black rocketpy/ tests/
) has passed locallypytest tests -m slow --runslow
) have passed locallyCHANGELOG.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
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.