-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
Open
aZira371
wants to merge
39
commits into
RocketPy-Team:develop
Choose a base branch
from
aZira371:enh/3-dof-simulation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
e557e17
DRAFT: for ENH/3-dof-simulation (See #655)
aZira371 a768648
ENH/3-dof-simulation (See RocketPy-Team#655)
aZira371 9b00c57
MNT: cleaned up new functions and
aZira371 87e9180
Rebase: Merge branch 'develop' of https://github.com/aZira371/RocketP…
aZira371 4524219
ENH: Addition of point mass classes to rocketpy.rocket and rocketpy.m…
aZira371 57b4732
ENH: PointMassMotor and PointMassRocket working as intended after som…
aZira371 81ce869
MNT: Removing unnecessary files added by mistake.
aZira371 0673076
Merge branch 'RocketPy-Team:master' into enh/3-dof-simulation
aZira371 47c9f2f
MNT: Cleaned up PointMassMotor and PointMassRocket class
aZira371 f6ad658
Merge branch 'enh/3-dof-simulation' of https://github.com/aZira371/Ro…
aZira371 33cb63a
MNT: Cleaning up flight class and PointMassMotor class
aZira371 1d2d4dc
Merge branch 'enh/3-dof-simulation' into develop
aZira371 fe21271
Merge pull request #1 from aZira371/develop
aZira371 b18b241
MNT: point mass motor cleanup
aZira371 8aa1016
ENH: restructuring rocket class
aZira371 87e7dce
MNT: fixing certain calculations on point mass motor
aZira371 0e4d8a4
Rename PointMassMotor.py to pointmassmotor.py
aZira371 41e94f1
Merge branch 'develop' into enh/3-dof-simulation
aZira371 e299a30
MNT: updates to 3dof example
aZira371 d4dc989
MNT: lint cleanup and adding 3dof to init
aZira371 c8096c5
MNT: Point mass motor and rocket fixes
aZira371 724f9dd
MNT: flight class fix on simulation mode detection
aZira371 f1e0fb0
MNT: make format changes
aZira371 4b9b952
MNT: point mass motor cleanup
aZira371 45380fd
ENH: restructuring rocket class
aZira371 5cd1535
MNT: fixing certain calculations on point mass motor
aZira371 1e590c2
Rename PointMassMotor.py to pointmassmotor.py
aZira371 981dda5
ENH: _MotorPrints inheritance - issue #460 (#828)
Gui-FernandesBR 5c75298
MNT: fix deprecations and warnings (#829)
Gui-FernandesBR 70f24ee
DEV: streamline caching of Python dependencies in GitHub Actions
Gui-FernandesBR 0cb0994
ENH: Add the Coriolis Force to the Flight class (#799)
kevin-alcaniz 58f8b0d
MNT: deprecated decorator (#830)
Gui-FernandesBR 191744f
MNT: updates to 3dof example
aZira371 265dd93
MNT: lint cleanup and adding 3dof to init
aZira371 5aa2027
MNT: Point mass motor and rocket fixes
aZira371 464212d
MNT: flight class fix on simulation mode detection
aZira371 a1b1d1f
MNT: make format changes
aZira371 d9cbde5
Merge branch 'enh/3-dof-simulation' of https://github.com/aZira371/Ro…
aZira371 0aa32b5
Merge branch 'develop' into enh/3-dof-simulation
aZira371 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
from functools import cached_property | ||
from typing import Callable | ||
|
||
import numpy as np | ||
|
||
from rocketpy.mathutils.function import Function, funcify_method | ||
|
||
from .motor import Motor | ||
|
||
|
||
class PointMassMotor(Motor): | ||
"""Motor modeled as a point mass for 3-DOF simulations.""" | ||
|
||
def __init__( | ||
self, | ||
thrust_source, | ||
dry_mass, | ||
propellant_initial_mass, | ||
burn_time=None, | ||
propellant_final_mass=None, | ||
reshape_thrust_curve=False, | ||
interpolation_method="linear", | ||
): | ||
if isinstance(thrust_source, (int, float, Callable)): | ||
if propellant_initial_mass is None: | ||
raise ValueError( | ||
"For constant or callable thrust, 'propellant_initial_mass' is required." | ||
) | ||
if burn_time is None and propellant_final_mass is None: | ||
raise ValueError( | ||
"For constant or callable thrust, either 'burn_time' or " | ||
"'propellant_final_mass' must be provided." | ||
) | ||
elif isinstance(thrust_source, (Function, np.ndarray, str)): | ||
if propellant_initial_mass is None: | ||
raise ValueError( | ||
"For thrust from a Function, NumPy array, or CSV, 'propellant_initial_mass' is required." | ||
) | ||
else: | ||
raise TypeError( | ||
"Invalid 'thrust_source' type. Must be int, float, callable, str, numpy.ndarray, or Function." | ||
) | ||
|
||
self._propellant_initial_mass = propellant_initial_mass | ||
self.propellant_final_mass = propellant_final_mass | ||
|
||
super().__init__( | ||
thrust_source=thrust_source, | ||
dry_inertia=(0, 0, 0), | ||
nozzle_radius=0, | ||
center_of_dry_mass_position=0, | ||
dry_mass=dry_mass, | ||
nozzle_position=0, | ||
burn_time=burn_time, | ||
reshape_thrust_curve=reshape_thrust_curve, | ||
interpolation_method=interpolation_method, | ||
coordinate_system_orientation="nozzle_to_combustion_chamber", | ||
) | ||
|
||
@property | ||
def propellant_initial_mass(self): | ||
return self._propellant_initial_mass | ||
|
||
@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 | ||
|
||
@cached_property | ||
def center_of_propellant_mass(self): | ||
"""Center of propellant mass is always zero""" | ||
return Function(0.0) | ||
|
||
# Propellant inertias: always zero, but return as Function objects | ||
def _zero_inertia_func(self): | ||
return Function(0.0) | ||
|
||
@cached_property | ||
def propellant_I_11(self): | ||
return self._zero_inertia_func() | ||
|
||
@cached_property | ||
def propellant_I_12(self): | ||
return self._zero_inertia_func() | ||
|
||
@cached_property | ||
def propellant_I_13(self): | ||
return self._zero_inertia_func() | ||
|
||
@cached_property | ||
def propellant_I_22(self): | ||
return self._zero_inertia_func() | ||
|
||
@cached_property | ||
def propellant_I_23(self): | ||
return self._zero_inertia_func() | ||
|
||
@cached_property | ||
def propellant_I_33(self): | ||
return self._zero_inertia_func() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we also accept drag curves, instead of only float values? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andMotor.total_mass_flow_rate
. If I understood correctly, they could be deleted without any problems (the parent class one would be used).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 initially we were thinking of implementing something new for point_mass_motor but ended up adopting the default from motor class. I think i would like to leave it as is for now - just to see if some other way of modelling point_mass_motor fits in here. Let me know what you think about the same!