44from abc import ABC , abstractmethod
55from functools import cached_property
66from os import path
7-
87import numpy as np
9- from ..mathutils .vector_matrix import Matrix , Vector
108from ..mathutils .function import Function , funcify_method
9+ from ..mathutils .vector_matrix import Vector
1110from ..plots .motor_plots import _MotorPlots
1211from ..prints .motor_prints import _MotorPrints
1312from ..tools import (
1716 parallel_axis_theorem_I12 ,
1817 parallel_axis_theorem_I13 ,
1918 parallel_axis_theorem_I23 ,
20- tuple_handler
19+ tuple_handler ,
2120)
2221
2322
@@ -169,7 +168,6 @@ class Motor(ABC):
169168 It will allow to obtain the net thrust in the Flight class.
170169 """
171170
172- # pylint: disable=too-many-statements
173171 # pylint: disable=too-many-statements
174172 def __init__ (
175173 self ,
@@ -183,7 +181,7 @@ def __init__(
183181 reshape_thrust_curve = False ,
184182 interpolation_method = "linear" ,
185183 coordinate_system_orientation = "nozzle_to_combustion_chamber" ,
186- reference_pressure = None , # <-- CORRECTION 1 : Ajout de l'argument
184+ reference_pressure = None ,
187185 ):
188186 """Initializes Motor class, process thrust curve and geometrical
189187 parameters and store results.
@@ -215,15 +213,8 @@ def __init__(
215213 + '"combustion_chamber_to_nozzle".'
216214 )
217215 self .coordinate_system_orientation = coordinate_system_orientation
218-
219- self .reference_pressure = reference_pressure # <-- CORRECTION 1 : Stockage de l'argument
220216
221- # --- DÉBUT CORRECTION 2 : Gestion des fichiers .eng ---
222- delimiter = ","
223- comments = "#"
224- if isinstance (thrust_source , str ) and thrust_source .endswith (".eng" ):
225- delimiter = " " # Les fichiers Eng utilisent des espaces
226- comments = ";" # Les fichiers Eng utilisent des points-virgules
217+ self .reference_pressure = reference_pressure
227218
228219 # Thrust curve definition and processing
229220 self .thrust = Function (
@@ -233,7 +224,7 @@ def __init__(
233224 interpolation_method ,
234225 extrapolation = "zero" ,
235226 )
236- # --- FIN CORRECTION 2 ---
227+
237228 self .interpolate = interpolation_method
238229 # Burn time definition
239230 self .burn_time = tuple_handler (burn_time )
@@ -251,7 +242,7 @@ def __init__(
251242 self .burn_start_time , self .burn_out_time
252243 )
253244 self .max_thrust = self .thrust .max
254-
245+
255246 self .average_thrust = self .total_impulse / self .burn_duration
256247
257248 # Abstract methods - must be implemented by subclasses
@@ -265,37 +256,36 @@ def __init__(
265256 self .center_of_propellant_mass = Function (0 )
266257 self .center_of_mass = Function (0 )
267258
268- # --- DÉBUT CORRECTION 3 : Utilisation des nouvelles fonctions PAT ---
269-
270259 # Inertia tensor for propellant referenced to the MOTOR's origin
271260 # Note: distance_vec_3d is the vector from the motor origin to the propellant CoM
272261 propellant_com_func = self .center_of_propellant_mass
273262
274263 # Create a Function that returns the distance vector [0, 0, center_of_propellant_mass(t)]
275264 propellant_com_vector_func = Function (
276265 lambda t : Vector ([0 , 0 , propellant_com_func (t )]),
277- inputs = "t" , outputs = "Vector (m)"
266+ inputs = "t" ,
267+ outputs = "Vector (m)" ,
278268 )
279269
280270 # Use the new specific PAT functions
281271 self .propellant_I_11 = parallel_axis_theorem_I11 (
282272 self .propellant_I_11_from_propellant_CM ,
283273 self .propellant_mass ,
284- propellant_com_vector_func
274+ propellant_com_vector_func ,
285275 )
286276 self .propellant_I_11 .set_outputs ("Propellant I_11 (kg*m^2)" )
287277
288278 self .propellant_I_22 = parallel_axis_theorem_I22 (
289279 self .propellant_I_22_from_propellant_CM ,
290280 self .propellant_mass ,
291- propellant_com_vector_func
281+ propellant_com_vector_func ,
292282 )
293283 self .propellant_I_22 .set_outputs ("Propellant I_22 (kg*m^2)" )
294284
295285 self .propellant_I_33 = parallel_axis_theorem_I33 (
296286 self .propellant_I_33_from_propellant_CM ,
297287 self .propellant_mass ,
298- propellant_com_vector_func
288+ propellant_com_vector_func ,
299289 )
300290 self .propellant_I_33 .set_outputs ("Propellant I_33 (kg*m^2)" )
301291
@@ -314,8 +304,6 @@ def __init__(
314304 )
315305 self .propellant_I_23 .set_outputs ("Propellant I_23 (kg*m^2)" )
316306
317- # --- FIN CORRECTION 3 ---
318-
319307 # Calculate total motor inertia relative to motor's origin
320308 self .I_11 = Function (lambda t : self .dry_I_11 ) + self .propellant_I_11
321309 self .I_11 .set_outputs ("Motor I_11 (kg*m^2)" )
@@ -575,11 +563,14 @@ def I_11(self):
575563 """
576564 # Inertias relative to the motor origin (calculated in __init__)
577565 prop_I_11_origin = self .propellant_I_11
578- dry_I_11_origin = Function (lambda t : self .dry_I_11 ) # Dry inertia is constant
566+ dry_I_11_origin = Function (lambda t : self .dry_I_11 ) # Dry inertia is constant
579567
580568 # Distance vectors FROM the instantaneous motor CoM TO the component CoMs
581569 prop_com_to_inst_com = self .center_of_propellant_mass - self .center_of_mass
582- dry_com_to_inst_com = Function (lambda t : Vector ([0 , 0 , self .center_of_dry_mass_position ])) - self .center_of_mass
570+ dry_com_to_inst_com = (
571+ Function (lambda t : Vector ([0 , 0 , self .center_of_dry_mass_position ]))
572+ - self .center_of_mass
573+ )
583574
584575 # Apply PAT relative to the instantaneous motor CoM
585576 # Note: We need the negative of the distance vector for PAT formula (origin to point)
@@ -592,24 +583,6 @@ def I_11(self):
592583
593584 return prop_I_11_cm + dry_I_11_cm
594585
595- def I_22 (self ):
596- """Builds a Function for the total I_22 inertia component relative
597- to the instantaneous center of mass of the motor.
598- """
599- prop_I_22_origin = self .propellant_I_22
600- dry_I_22_origin = Function (lambda t : self .dry_I_22 )
601-
602- prop_com_to_inst_com = self .center_of_propellant_mass - self .center_of_mass
603- dry_com_to_inst_com = Function (lambda t : Vector ([0 , 0 , self .center_of_dry_mass_position ])) - self .center_of_mass
604-
605- prop_I_22_cm = parallel_axis_theorem_I22 (
606- prop_I_22_origin , self .propellant_mass , - prop_com_to_inst_com
607- )
608- dry_I_22_cm = parallel_axis_theorem_I22 (
609- dry_I_22_origin , self .dry_mass , - dry_com_to_inst_com
610- )
611-
612- return prop_I_22_cm + dry_I_22_cm
613586 @funcify_method ("Time (s)" , "Inertia I_22 (kg m²)" )
614587 def I_22 (self ):
615588 """Inertia tensor 22 component, which corresponds to the inertia
@@ -1155,7 +1128,7 @@ def vacuum_thrust(self):
11551128 Returns
11561129 -------
11571130 vacuum_thrust : Function
1158- The rocket's thrust in a vaccum .
1131+ The rocket's thrust in a vacuum .
11591132 """
11601133 if self .reference_pressure is None :
11611134 warnings .warn (
@@ -1244,7 +1217,7 @@ def to_dict(self, include_outputs=False):
12441217 thrust_source = Function (thrust_source )
12451218
12461219 data = {
1247- "thrust_source" : self . thrust ,
1220+ "thrust_source" : thrust_source ,
12481221 "dry_I_11" : self .dry_I_11 ,
12491222 "dry_I_22" : self .dry_I_22 ,
12501223 "dry_I_33" : self .dry_I_33 ,
0 commit comments