-
-
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?
Changes from 11 commits
e557e17
a768648
9b00c57
87e9180
4524219
57b4732
81ce869
0673076
47c9f2f
f6ad658
33cb63a
1d2d4dc
fe21271
b18b241
8aa1016
87e7dce
0e4d8a4
41e94f1
e299a30
d4dc989
c8096c5
724f9dd
f1e0fb0
4b9b952
45380fd
5cd1535
1e590c2
981dda5
5c75298
70f24ee
0cb0994
58f8b0d
191744f
265dd93
5aa2027
464212d
a1b1d1f
d9cbde5
0aa32b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ | |
Parachute, | ||
RailButtons, | ||
Rocket, | ||
BaseRocket, | ||
PointMassRocket, | ||
Tail, | ||
TrapezoidalFins, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
from functools import cached_property | ||
import numpy as np | ||
from ..mathutils.function import Function, funcify_method | ||
from .motor import Motor | ||
|
||
class PointMassMotor(Motor): | ||
"""Class representing a motor modeled as a point mass. | ||
Inherits from the Motor class and simplifies the model to a thrust-producing | ||
object without detailed structural components.""" | ||
|
||
def __init__( | ||
self, | ||
thrust_source, | ||
dry_mass, | ||
thrust_curve=None, | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
propellant_initial_mass=None, | ||
propellant_final_mass=None, | ||
burn_time=None, | ||
center_of_dry_mass_position=0, | ||
reshape_thrust_curve=False, | ||
interpolation_method="linear", | ||
coordinate_system_orientation="nozzle_to_combustion_chamber", | ||
): | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Initialize the PointMassMotor class. | ||
|
||
Parameters | ||
---------- | ||
thrust_source : int, float, callable, string, array, Function | ||
Thrust source similar to the Motor class. | ||
dry_mass : float | ||
Total dry mass of the motor in kg. | ||
thrust_curve : Function, np.array, or str (csv file), optional | ||
Required if thrust_source is a csv file, Function, or np.array. | ||
propellant_initial_mass : float, optional | ||
Required if thrust_source is a csv file, Function, or np.array. | ||
propellant_final_mass : float, optional | ||
Required if thrust_source is callable. | ||
burn_time : float or tuple of float, optional | ||
Required if thrust_source is callable or if a thrust value is given. | ||
center_of_dry_mass_position : float, optional | ||
Initial position of the motor, default is 0. | ||
interpolation_method : string, optional | ||
Interpolation method for thrust curve, default is 'linear'. | ||
""" | ||
if isinstance(thrust_source, (Function, np.ndarray, str)): | ||
if thrust_curve is None or propellant_initial_mass is None: | ||
raise ValueError("thrust_curve and propellant_initial_mass are required for csv, Function, or np.array inputs.") | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
elif callable(thrust_source): | ||
if any(param is None for param in [thrust_curve, propellant_initial_mass, burn_time, propellant_final_mass]): | ||
raise ValueError("thrust_curve, propellant_initial_mass, burn_time, and propellant_final_mass are required for callable inputs.") | ||
elif isinstance(thrust_source, (int, float)): | ||
if any(param is None for param in [thrust_curve, propellant_initial_mass, burn_time]): | ||
raise ValueError("thrust_curve, propellant_initial_mass, and burn_time are required when a thrust value is given.") | ||
|
||
self._propellant_initial_mass = propellant_initial_mass | ||
super().__init__( | ||
thrust_source=thrust_source, | ||
dry_inertia=(0, 0, 0), | ||
nozzle_radius=0, | ||
center_of_dry_mass_position=center_of_dry_mass_position, | ||
dry_mass=dry_mass, | ||
nozzle_position=0, | ||
burn_time=burn_time, | ||
reshape_thrust_curve=reshape_thrust_curve, | ||
interpolation_method=interpolation_method, | ||
coordinate_system_orientation=coordinate_system_orientation, | ||
) | ||
@funcify_method("Time (s)", "Thrust (N)") | ||
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. You are not using the propellant_final_mass at all. Unless you think this is valuable to simulate when considering motors that end burning with propellant still in them (I guess some hybrids and liquids could have that) then I think you can delete it. Currently the |
||
def thrust(self): | ||
"""Returns the thrust of the motor as a function of time.""" | ||
return self.thrust_source | ||
|
||
@funcify_method("Time (s)", "Acceleration (m/s^2)") | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def total_mass(self): | ||
"""Returns the constant total mass of the point mass motor.""" | ||
return self.dry_mass | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@funcify_method("Time (s)", "Acceleration (m/s^2)") | ||
def acceleration(self): | ||
"""Computes the acceleration of the motor as thrust divided by mass.""" | ||
return self.thrust() / self.total_mass | ||
|
||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@funcify_method("Time (s)", "Propellant Mass (kg)") | ||
def center_of_propellant_mass(self): | ||
return 0 | ||
|
||
@funcify_method("Time (s)", "Exhaust Velocity (m/s)") | ||
def exhaust_velocity(self): | ||
return 2000 # m/s, estimated value | ||
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. I believe this should be calculate in the same way that SolidMotor does. @phmbressan can you confirm 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. Similar confusion as mass flow rate here. |
||
|
||
@funcify_method("Time (s)", "Propellant Mass (kg)") | ||
def propellant_initial_mass(self): | ||
return self._propellant_initial_mass | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@property | ||
def is_point_mass(self): | ||
aZira371 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return True | ||
|
||
@funcify_method("Time (s)", "Inertia (kg·m²)") | ||
def propellant_I_11(self): | ||
return 0 | ||
|
||
@funcify_method("Time (s)", "Inertia (kg·m²)") | ||
def propellant_I_12(self): | ||
return 0 | ||
|
||
@funcify_method("Time (s)", "Inertia (kg·m²)") | ||
def propellant_I_13(self): | ||
return 0 | ||
|
||
@funcify_method("Time (s)", "Inertia (kg·m²)") | ||
def propellant_I_22(self): | ||
return 0 | ||
|
||
@funcify_method("Time (s)", "Inertia (kg·m²)") | ||
def propellant_I_23(self): | ||
return 0 | ||
|
||
@funcify_method("Time (s)", "Inertia (kg·m²)") | ||
def propellant_I_33(self): | ||
return 0 |
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? |
Uh oh!
There was an error while loading. Please reload this page.