Skip to content

Commit 9e39948

Browse files
authored
Correction of SolidMotor
Clean comments and cleared code
1 parent 1c41394 commit 9e39948

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

rocketpy/motors/solid_motor.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..plots.solid_motor_plots import _SolidMotorPlots
88
from ..prints.solid_motor_prints import _SolidMotorPrints
99
from .motor import Motor
10-
from os import path
10+
1111

1212
class SolidMotor(Motor):
1313
"""Class to specify characteristics and useful operations for solid motors.
@@ -195,7 +195,6 @@ class SolidMotor(Motor):
195195
It will allow to obtain the net thrust in the Flight class.
196196
"""
197197

198-
199198
def __init__(
200199
self,
201200
thrust_source,
@@ -321,20 +320,22 @@ class Function. Thrust units are Newtons.
321320
"""
322321
self.rse_motor_data = None
323322
self.description_eng_file = None
324-
323+
325324
if isinstance(thrust_source, str):
326325
if thrust_source.endswith(".eng"):
327-
328-
comments, description, thrust_source_data = Motor.import_eng(thrust_source)
326+
327+
comments, description, thrust_source_data = Motor.import_eng(
328+
thrust_source
329+
)
329330
self.description_eng_file = description
330331
self.comments_eng_file = comments
331-
thrust_source = thrust_source_data
332+
thrust_source = thrust_source_data
332333
elif thrust_source.endswith(".rse"):
333-
334+
334335
rse_data, thrust_source_data = Motor.import_rse(thrust_source)
335336
self.rse_motor_data = rse_data
336-
thrust_source = thrust_source_data
337-
337+
thrust_source = thrust_source_data
338+
338339
super().__init__(
339340
thrust_source=thrust_source,
340341
dry_inertia=dry_inertia,
@@ -348,12 +349,10 @@ class Function. Thrust units are Newtons.
348349
coordinate_system_orientation=coordinate_system_orientation,
349350
reference_pressure=reference_pressure,
350351
)
351-
352-
352+
353353
self.throat_radius = throat_radius
354354
self.throat_area = np.pi * throat_radius**2
355355

356-
357356
self.grains_center_of_mass_position = grains_center_of_mass_position
358357
self.grain_number = grain_number
359358
self.grain_separation = grain_separation
@@ -362,7 +361,6 @@ class Function. Thrust units are Newtons.
362361
self.grain_initial_inner_radius = grain_initial_inner_radius
363362
self.grain_initial_height = grain_initial_height
364363

365-
366364
self.grain_initial_volume = (
367365
self.grain_initial_height
368366
* np.pi
@@ -372,7 +370,6 @@ class Function. Thrust units are Newtons.
372370

373371
self.evaluate_geometry()
374372

375-
376373
self.prints = _SolidMotorPrints(self)
377374
self.plots = _SolidMotorPlots(self)
378375
self.propellant_I_11_from_propellant_CM = self.propellant_I_11
@@ -393,45 +390,44 @@ class Function. Thrust units are Newtons.
393390

394391
propellant_com_func = self.center_of_propellant_mass
395392

396-
397393
propellant_com_vector_func = Function(
398394
lambda t: Vector([0, 0, propellant_com_func(t)]),
399-
inputs="t", outputs="Vector (m)"
395+
inputs="t",
396+
outputs="Vector (m)",
400397
)
401398

402399
# Utiliser les nouvelles fonctions PAT
403400
self.propellant_I_11 = parallel_axis_theorem_I11(
404401
self.propellant_I_11_from_propellant_CM,
405402
self.propellant_mass,
406-
propellant_com_vector_func
403+
propellant_com_vector_func,
407404
)
408405
self.propellant_I_22 = parallel_axis_theorem_I22(
409406
self.propellant_I_22_from_propellant_CM,
410407
self.propellant_mass,
411-
propellant_com_vector_func
408+
propellant_com_vector_func,
412409
)
413410
self.propellant_I_33 = parallel_axis_theorem_I33(
414411
self.propellant_I_33_from_propellant_CM,
415412
self.propellant_mass,
416-
propellant_com_vector_func
413+
propellant_com_vector_func,
417414
)
418415
self.propellant_I_12 = parallel_axis_theorem_I12(
419-
self.propellant_I_12_from_propellant_CM,
416+
self.propellant_I_12_from_propellant_CM,
420417
self.propellant_mass,
421-
propellant_com_vector_func
418+
propellant_com_vector_func,
422419
)
423420
self.propellant_I_13 = parallel_axis_theorem_I13(
424-
self.propellant_I_13_from_propellant_CM,
421+
self.propellant_I_13_from_propellant_CM,
425422
self.propellant_mass,
426-
propellant_com_vector_func
423+
propellant_com_vector_func,
427424
)
428425
self.propellant_I_23 = parallel_axis_theorem_I23(
429426
self.propellant_I_23_from_propellant_CM,
430427
self.propellant_mass,
431-
propellant_com_vector_func
428+
propellant_com_vector_func,
432429
)
433430

434-
435431
self.I_11 = Function(lambda t: self.dry_I_11) + self.propellant_I_11
436432
self.I_22 = Function(lambda t: self.dry_I_22) + self.propellant_I_22
437433
self.I_33 = Function(lambda t: self.dry_I_33) + self.propellant_I_33

0 commit comments

Comments
 (0)