From 8483c2bee12cbea8995138583fdd11e066b0d839 Mon Sep 17 00:00:00 2001 From: Pedro Bressan Date: Thu, 7 Sep 2023 12:27:43 -0300 Subject: [PATCH] DOC: update motor docstrings regarding coordinate systems. --- rocketpy/Rocket.py | 6 +- rocketpy/motors/HybridMotor.py | 11 ++-- rocketpy/motors/LiquidMotor.py | 10 ++-- rocketpy/motors/Motor.py | 106 +++++++++++++++++++++++++++++++-- rocketpy/motors/SolidMotor.py | 20 ++----- 5 files changed, 120 insertions(+), 33 deletions(-) diff --git a/rocketpy/Rocket.py b/rocketpy/Rocket.py index 2599b92a6..e873f2c8b 100644 --- a/rocketpy/Rocket.py +++ b/rocketpy/Rocket.py @@ -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 -------- diff --git a/rocketpy/motors/HybridMotor.py b/rocketpy/motors/HybridMotor.py index 81112dd75..a3e84867c 100644 --- a/rocketpy/motors/HybridMotor.py +++ b/rocketpy/motors/HybridMotor.py @@ -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". @@ -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 @@ -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 @@ -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 -------- diff --git a/rocketpy/motors/LiquidMotor.py b/rocketpy/motors/LiquidMotor.py index 1792caf88..cfca55985 100644 --- a/rocketpy/motors/LiquidMotor.py +++ b/rocketpy/motors/LiquidMotor.py @@ -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". @@ -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 @@ -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 -------- diff --git a/rocketpy/motors/Motor.py b/rocketpy/motors/Motor.py index 81e419b0f..b40887223 100644 --- a/rocketpy/motors/Motor.py +++ b/rocketpy/motors/Motor.py @@ -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 @@ -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' @@ -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 @@ -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 @@ -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 ` + + 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 ` + 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 ` + 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 ` + 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, diff --git a/rocketpy/motors/SolidMotor.py b/rocketpy/motors/SolidMotor.py index df0fc5487..606104fe4 100644 --- a/rocketpy/motors/SolidMotor.py +++ b/rocketpy/motors/SolidMotor.py @@ -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". @@ -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 @@ -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 @@ -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] @@ -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):