Skip to content

Commit

Permalink
DOC: update motor docstrings regarding coordinate systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
phmbressan committed Sep 7, 2023
1 parent 2ec8643 commit 8483c2b
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 33 deletions.
6 changes: 3 additions & 3 deletions rocketpy/Rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,11 @@ def add_motor(self, motor, position):
Parameters
----------
motor : Motor, SolidMotor, HybridMotor, LiquidMotor
motor : Motor, SolidMotor, HybridMotor, LiquidMotor, GenericMotor
Motor to be added to the rocket.
position : int, float
Position, in m, of the motor's nozzle exit area relative to the user
defined rocket coordinate system.
Position, in meters, of the motor's coordinate system origin
relative to the user defined rocket coordinate system.
See Also
--------
Expand Down
11 changes: 6 additions & 5 deletions rocketpy/motors/HybridMotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HybridMotor(Motor):
HybridMotor.coordinate_system_orientation : str
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle".
Expand Down Expand Up @@ -144,7 +144,7 @@ class HybridMotor(Motor):
HybridMotor.burn_duration : float
Total motor burn duration, in seconds. It is the difference between the
``burn_out_time`` and the ``burn_start_time``.
HybridMotor.exhaust_velocity : float
HybridMotor.exhaust_velocity : Function
Propulsion gases exhaust velocity, assumed constant, in m/s.
HybridMotor.burn_area : Function
Total burn area considering all grains, made out of inner
Expand Down Expand Up @@ -272,7 +272,7 @@ def __init__(
coordinate_system_orientation : string, optional
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle". Default is
Expand Down Expand Up @@ -497,8 +497,9 @@ def add_tank(self, tank, position):
tank : Tank
Tank object to be added to the motor.
position : float
Position of the tank relative to the nozzle exit. The
tank reference point is its tank_geometry zero point.
Position of the tank relative to the origin of the motor
coordinate system. The tank reference point is its
tank_geometry zero reference point.
See Also
--------
Expand Down
10 changes: 5 additions & 5 deletions rocketpy/motors/LiquidMotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LiquidMotor(Motor):
LiquidMotor.coordinate_system_orientation : str
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle".
Expand Down Expand Up @@ -226,7 +226,7 @@ def __init__(
coordinate_system_orientation : string, optional
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber"
and "combustion_chamber_to_nozzle". Default is
Expand Down Expand Up @@ -434,9 +434,9 @@ def add_tank(self, tank, position):
tank : Tank
Tank object to be added to the rocket motor.
position : float
Position of the tank relative to the motor nozzle, in meters.
The position is measured from the nozzle tip to the tank
geometry reference zero point.
Position of the tank relative to the origin of the motor
coordinate system. The tank reference point is its
tank_geometry zero reference point.
See Also
--------
Expand Down
106 changes: 100 additions & 6 deletions rocketpy/motors/Motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Motor(ABC):
Motor.coordinate_system_orientation : str
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
coordinate system may be placed anywhere along such axis, such as
at the nozzle exit area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle".
Motor.nozzle_radius : float
Expand Down Expand Up @@ -135,8 +135,8 @@ class Motor(ABC):
Motor.burn_duration : float
Total motor burn duration, in seconds. It is the difference between
the burn_out_time and the burn_start_time.
Motor.exhaust_velocity : float
Propulsion gases exhaust velocity, assumed constant, in m/s.
Motor.exhaust_velocity : rocketpy.Function
Propulsion gases exhaust velocity in m/s.
Motor.interpolate : string
Method of interpolation used in case thrust curve is given
by data set in .csv or .eng, or as an array. Options are 'spline'
Expand Down Expand Up @@ -226,7 +226,7 @@ def __init__(
coordinate_system_orientation : string, optional
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle". Default is
Expand Down Expand Up @@ -361,7 +361,7 @@ def exhaust_velocity(self):
Returns
-------
self.exhaust_velocity : float
self.exhaust_velocity : rocketpy.Function
Gas exhaust velocity of the motor.
Notes
Expand Down Expand Up @@ -1074,6 +1074,100 @@ def __init__(
interpolation_method="linear",
coordinate_system_orientation="nozzle_to_combustion_chamber",
):
"""Initialize GenericMotor class, process thrust curve and geometrical
parameters and store results.
Parameters
----------
thrust_source : int, float, callable, string, array, Function
Motor's thrust curve. Can be given as an int or float, in which
case the thrust will be considered constant in time. It can
also be given as a callable function, whose argument is time in
seconds and returns the thrust supplied by the motor in the
instant. If a string is given, it must point to a .csv or .eng file.
The .csv file shall contain no headers and the first column must
specify time in seconds, while the second column specifies thrust.
Arrays may also be specified, following rules set by the class
Function. Thrust units are Newtons.
.. seealso:: :doc:`Thrust Source Details </user/motors/thrust>`
chamber_radius : int, float
The radius of a overall cylindrical chamber of propellant in meters.
This is a rough estimate for the motor's propellant chamber or tanks.
chamber_height : int, float
The height of a overall cylindrical chamber of propellant in meters.
This is a rough estimate for the motor's propellant chamber or tanks.
chamber_position : int, float
The position, in meters, of the centroid (half height) of the motor's
overall cylindrical chamber of propellant with respect to the motor's
coordinate system.
See :doc:`Positions and Coordinate Systems </user/positions>`
dry_mass : int, float
The total mass of the motor structure, including chambers
and tanks, when it is empty and does not contain any propellant.
propellant_initial_mass : int, float
The initial mass of the propellant in the motor.
center_of_dry_mass_position : int, float, optional
The position, in meters, of the motor's center of mass with respect
to the motor's coordinate system when it is devoid of propellant.
If not specified, automatically sourced as the chamber position.
See :doc:`Positions and Coordinate Systems </user/positions>`
dry_inertia : tuple, list
Tuple or list containing the motor's dry mass inertia tensor
components, in kg*m^2. This inertia is defined with respect to the
the `center_of_dry_mass_position` position.
Assuming e_3 is the rocket's axis of symmetry, e_1 and e_2 are
orthogonal and form a plane perpendicular to e_3, the dry mass
inertia tensor components must be given in the following order:
(I_11, I_22, I_33, I_12, I_13, I_23), where I_ij is the
component of the inertia tensor in the direction of e_i x e_j.
Alternatively, the inertia tensor can be given as
(I_11, I_22, I_33), where I_12 = I_13 = I_23 = 0.
nozzle_radius : int, float, optional
Motor's nozzle outlet radius in meters.
burn_time: float, tuple of float, optional
Motor's burn time.
If a float is given, the burn time is assumed to be between 0 and
the given float, in seconds.
If a tuple of float is given, the burn time is assumed to be between
the first and second elements of the tuple, in seconds.
If not specified, automatically sourced as the range between the
first and last-time step of the motor's thrust curve. This can only
be used if the motor's thrust is defined by a list of points, such
as a .csv file, a .eng file or a Function instance whose source is a
list.
nozzle_position : int, float, optional
Motor's nozzle outlet position in meters, in the motor's coordinate
system. See :doc:`Positions and Coordinate Systems </user/positions>`
for details. Default is 0, in which case the origin of the
coordinate system is placed at the motor's nozzle outlet.
reshape_thrust_curve : boolean, tuple, optional
If False, the original thrust curve supplied is not altered. If a
tuple is given, whose first parameter is a new burn out time and
whose second parameter is a new total impulse in Ns, the thrust
curve is reshaped to match the new specifications. May be useful
for motors whose thrust curve shape is expected to remain similar
in case the impulse and burn time varies slightly. Default is
False. Note that the Motor burn_time parameter must include the new
reshaped burn time.
interpolation_method : string, optional
Method of interpolation to be used in case thrust curve is given
by data set in .csv or .eng, or as an array. Options are 'spline'
'akima' and 'linear'. Default is "linear".
coordinate_system_orientation : string, optional
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle". Default is
"nozzle_to_combustion_chamber".
Returns
-------
None
"""
super().__init__(
thrust_source,
dry_mass,
Expand Down
20 changes: 6 additions & 14 deletions rocketpy/motors/SolidMotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SolidMotor(Motor):
SolidMotor.coordinate_system_orientation : str
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle".
Expand Down Expand Up @@ -170,7 +170,7 @@ class SolidMotor(Motor):
SolidMotor.burn_duration : float
Total motor burn duration, in seconds. It is the difference between the
``burn_out_time`` and the ``burn_start_time``.
SolidMotor.exhaust_velocity : float
SolidMotor.exhaust_velocity : rocketpy.Function
Propulsion gases exhaust velocity, assumed constant, in m/s.
SolidMotor.burn_area : Function
Total burn area considering all grains, made out of inner
Expand Down Expand Up @@ -298,7 +298,7 @@ def __init__(
coordinate_system_orientation : string, optional
Orientation of the motor's coordinate system. The coordinate system
is defined by the motor's axis of symmetry. The origin of the
coordinate system may be placed anywhere along such axis, such as
coordinate system may be placed anywhere along such axis, such as
at the nozzle area, and must be kept the same for all other
positions specified. Options are "nozzle_to_combustion_chamber" and
"combustion_chamber_to_nozzle". Default is
Expand Down Expand Up @@ -456,19 +456,11 @@ def evaluate_geometry(self):
"""Calculates grain inner radius and grain height as a function of time
by assuming that every propellant mass burnt is exhausted. In order to
do that, a system of differential equations is solved using
scipy.integrate.odeint. Furthermore, the function calculates burn area,
burn rate and Kn as a function of time using the previous results. All
functions are stored as objects of the class Function in
``self.grain_inner_radius``, ``self.grain_height``, ``self.burn_area``,
``self.burn_rate`` and ``self.Kn``.
scipy.integrate.solve_ivp.
Returns
-------
geometry : list of rocketpy.Functions
First element is the Function representing the inner radius of a
grain as a function of time. Second argument is the Function
representing the height of a grain as a function of time.
None
"""
# Define initial conditions for integration
y0 = [self.grain_initial_inner_radius, self.grain_initial_height]
Expand Down Expand Up @@ -530,7 +522,7 @@ def terminate_burn(t, y):

reset_funcified_methods(self)

return [self.grain_inner_radius, self.grain_height]
return None

@funcify_method("Time (s)", "burn area (m²)")
def burn_area(self):
Expand Down

0 comments on commit 8483c2b

Please sign in to comment.