-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
mach = free_stream_speed / speed_of_sound | ||
|
||
# Drag computation | ||
if t < self.rocket.motor.burn_out_time: |
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.
Shouldn't the time be in the interval of burn start and burn out? Do you know @MateusStano ?
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.
It should do whatever the normal udot does. I think we changed this recently and this branch is not updated though
@aZira371 I would say you should merge develop into this branch and check if this u_dot is updated with the newer standard one
rocketpy/rocket/rocket.py
Outdated
motor_mass_func = ( | ||
self.motor.total_mass if hasattr(self.motor.total_mass, "get_value_opt") | ||
else Function(lambda t: self.motor.total_mass) | ||
) |
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.
This check seems to be in place in order to convert to a Function
the self.motor.total_mass
if it is not one. However, the attribute from the motor class is annotated with funcify
, so it will always be a Function
.
rocketpy/motors/PointMassMotor.py
Outdated
@funcify_method("Time (s)", "Acceleration (m/s^2)") | ||
def total_mass(self): | ||
"""Returns the constant total mass of the point mass motor.""" | ||
return self.dry_mass |
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.
To me it makes sense to evaluate the mass_flow_rate
of a point mass motor if the user inputs a thrust curve. The schema would be quite similar to what is already done in the Motor
parent class (e.g. Motor.total_mass_flow_rate
). Let me know what you think about it.
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.
Yes I was confused about what to implement for mass flow rate. Like different types of motors have different ways to calculate this. When it comes to point mass motor the problem I faced was that the input can be any kind of data irrespective of propellant nature. Thus could not understand which equations to implement for mass flow rate.
rocketpy/rocket/rocket.py
Outdated
class BaseRocket: | ||
"""Base class for a rocket model with minimal attributes and methods.""" | ||
def __init__(self, mass): | ||
self.mass = mass | ||
self.motor = None | ||
def add_motor(self, motor): | ||
self.motor = motor | ||
self.evaluate_total_mass() | ||
def evaluate_total_mass(self): | ||
if self.motor: | ||
return self.mass + self.motor.total_mass | ||
return self.mass | ||
|
||
|
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.
This class seems useless right now. You can just remove it
rocketpy/rocket/rocket.py
Outdated
class PointMassRocket(BaseRocket): | ||
"""Rocket modeled as a point mass for 3-DOF simulations.""" |
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.
Maybe having this inherit from the Rocket class will make the implementation easier. Then all_info and plots and prints will already be defined
elif self.equations_of_motion == "solid_propulsion" and self.simulation_mode == '3 DOF': | ||
# NOTE: The u_dot is faster, but only works for solid propulsion | ||
self.u_dot_generalized = self.u_dot_3dof | ||
elif self.simulation_mode == '3 DOF': | ||
# NOTE: The u_dot is faster, but only works for solid propulsion | ||
self.u_dot_generalized = self.u_dot_generalized_3dof |
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.
Can the PointMassRocket run with 6dof? If not then I think we should just check if the rocket is a PointMassRocket and set the equations of motion to 3dof
mach = free_stream_speed / speed_of_sound | ||
|
||
# Drag computation | ||
if t < self.rocket.motor.burn_out_time: |
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.
It should do whatever the normal udot does. I think we changed this recently and this branch is not updated though
@aZira371 I would say you should merge develop into this branch and check if this u_dot is updated with the newer standard one
-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: 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
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):
@@ -1191,9 +1193,15 @@ def __init_solver_monitors(self): | |||
|
|||
def __init_equations_of_motion(self): | |||
"""Initialize equations of motion.""" | |||
if self.equations_of_motion == "solid_propulsion": | |||
if self.equations_of_motion == "solid_propulsion" and self.simulation_mode == '6 DOF': |
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.
When equations_of_motion
is "standard" and simulation_mode
is '6 DOF', u_dot_generalized
is never set. Add a catch-all or explicit branch to assign self.u_dot_generalized = self.u_dot
for standard 6-DOF.
Copilot uses AI. Check for mistakes.
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.