Skip to content

Commit 4f32f88

Browse files
committed
super() corrected and dict functions updated RocketPy-Team#801
The new parameter of the SolidMotor class was removed from super, since it's not on the Motor class. The dict functions were updated to take this new parameter into acount. Also the comments about the SolidMotor class parameters were updated. Still need to do some tests running the code to be sure everything is ok, then I can open the PR.
1 parent f048c56 commit 4f32f88

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

rocketpy/motors/solid_motor.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ class Function. Thrust units are Newtons.
300300
positions specified. Options are "nozzle_to_combustion_chamber" and
301301
"combustion_chamber_to_nozzle". Default is
302302
"nozzle_to_combustion_chamber".
303+
only_radial_burn : boolean, optional
304+
If True, inhibits the grain from burning axially, only computing
305+
radial burn. Otherwise, if False, allows the grain to also burn
306+
axially. May be useful for axially inhibited grains or hybrid motors.
307+
Default is False.
303308
304309
Returns
305310
-------
@@ -316,7 +321,6 @@ class Function. Thrust units are Newtons.
316321
reshape_thrust_curve=reshape_thrust_curve,
317322
interpolation_method=interpolation_method,
318323
coordinate_system_orientation=coordinate_system_orientation,
319-
only_radial_burn = only_radial_burn,
320324
)
321325
# Nozzle parameters
322326
self.throat_radius = throat_radius
@@ -484,13 +488,7 @@ def geometry_dot(t, y):
484488
# Compute state vector derivative
485489
grain_inner_radius, grain_height = y
486490
if self.only_radial_burn:
487-
burn_area = (
488-
2
489-
* np.pi
490-
* (
491-
grain_inner_radius * grain_height
492-
)
493-
)
491+
burn_area = 2 * np.pi * (grain_inner_radius * grain_height)
494492
else:
495493
burn_area = (
496494
2
@@ -516,12 +514,7 @@ def geometry_jacobian(t, y):
516514
grain_inner_radius, grain_height = y
517515
if self.only_radial_burn:
518516
factor = volume_diff / (
519-
2
520-
* np.pi
521-
* (
522-
grain_inner_radius * grain_height
523-
)
524-
** 2
517+
2 * np.pi * (grain_inner_radius * grain_height) ** 2
525518
)
526519

527520
inner_radius_derivative_wrt_inner_radius = factor * (
@@ -537,8 +530,6 @@ def geometry_jacobian(t, y):
537530
inner_radius_derivative_wrt_height,
538531
],
539532
[height_derivative_wrt_inner_radius, height_derivative_wrt_height],
540-
541-
542533
]
543534

544535
else:
@@ -568,10 +559,8 @@ def geometry_jacobian(t, y):
568559
inner_radius_derivative_wrt_height,
569560
],
570561
[height_derivative_wrt_inner_radius, height_derivative_wrt_height],
571-
572-
573562
]
574-
563+
575564
def terminate_burn(t, y): # pylint: disable=unused-argument
576565
end_function = (self.grain_outer_radius - y[0]) * y[1]
577566
return end_function
@@ -625,9 +614,7 @@ def burn_area(self):
625614
burn_area = (
626615
2
627616
* np.pi
628-
* (
629-
self.grain_inner_radius * self.grain_height
630-
)
617+
* (self.grain_inner_radius * self.grain_height)
631618
* self.grain_number
632619
)
633620
else:
@@ -812,6 +799,7 @@ def to_dict(self, include_outputs=False):
812799
"grain_initial_height": self.grain_initial_height,
813800
"grain_separation": self.grain_separation,
814801
"grains_center_of_mass_position": self.grains_center_of_mass_position,
802+
"only_radial_burn": self.only_radial_burn,
815803
}
816804
)
817805

@@ -855,4 +843,5 @@ def from_dict(cls, data):
855843
throat_radius=data["throat_radius"],
856844
interpolation_method=data["interpolate"],
857845
coordinate_system_orientation=data["coordinate_system_orientation"],
846+
only_radial_burn=data.get("only_radial_burn", False),
858847
)

0 commit comments

Comments
 (0)