Skip to content

Commit f048c56

Browse files
committed
Functions associated to the regression updated RocketPy-Team#801
only_radial_burn optional parameter added and used in the functions related to the grain regression as a conditon to change the applied equations. Still need to update the comment section, the CHANGELOG and maybe the dict related functions, but not sure about the last one yet.
1 parent 4df0b38 commit f048c56

File tree

1 file changed

+96
-41
lines changed

1 file changed

+96
-41
lines changed

rocketpy/motors/solid_motor.py

Lines changed: 96 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def __init__(
204204
reshape_thrust_curve=False,
205205
interpolation_method="linear",
206206
coordinate_system_orientation="nozzle_to_combustion_chamber",
207+
only_radial_burn=False,
207208
):
208209
"""Initialize Motor class, process thrust curve and geometrical
209210
parameters and store results.
@@ -315,6 +316,7 @@ class Function. Thrust units are Newtons.
315316
reshape_thrust_curve=reshape_thrust_curve,
316317
interpolation_method=interpolation_method,
317318
coordinate_system_orientation=coordinate_system_orientation,
319+
only_radial_burn = only_radial_burn,
318320
)
319321
# Nozzle parameters
320322
self.throat_radius = throat_radius
@@ -339,6 +341,8 @@ class Function. Thrust units are Newtons.
339341

340342
self.evaluate_geometry()
341343

344+
# Burn surface definition
345+
self.only_radial_burn = only_radial_burn
342346
# Initialize plots and prints object
343347
self.prints = _SolidMotorPrints(self)
344348
self.plots = _SolidMotorPlots(self)
@@ -479,15 +483,25 @@ def geometry_dot(t, y):
479483

480484
# Compute state vector derivative
481485
grain_inner_radius, grain_height = y
482-
burn_area = (
483-
2
484-
* np.pi
485-
* (
486-
grain_outer_radius**2
487-
- grain_inner_radius**2
488-
+ grain_inner_radius * grain_height
486+
if self.only_radial_burn:
487+
burn_area = (
488+
2
489+
* np.pi
490+
* (
491+
grain_inner_radius * grain_height
492+
)
489493
)
490-
)
494+
else:
495+
burn_area = (
496+
2
497+
* np.pi
498+
* (
499+
grain_outer_radius**2
500+
- grain_inner_radius**2
501+
+ grain_inner_radius * grain_height
502+
)
503+
)
504+
491505
grain_inner_radius_derivative = -volume_diff / burn_area
492506
grain_height_derivative = -2 * grain_inner_radius_derivative
493507

@@ -500,33 +514,64 @@ def geometry_jacobian(t, y):
500514

501515
# Compute jacobian
502516
grain_inner_radius, grain_height = y
503-
factor = volume_diff / (
504-
2
505-
* np.pi
506-
* (
507-
grain_outer_radius**2
508-
- grain_inner_radius**2
509-
+ grain_inner_radius * grain_height
517+
if self.only_radial_burn:
518+
factor = volume_diff / (
519+
2
520+
* np.pi
521+
* (
522+
grain_inner_radius * grain_height
523+
)
524+
** 2
510525
)
511-
** 2
512-
)
513-
inner_radius_derivative_wrt_inner_radius = factor * (
514-
grain_height - 2 * grain_inner_radius
515-
)
516-
inner_radius_derivative_wrt_height = factor * grain_inner_radius
517-
height_derivative_wrt_inner_radius = (
518-
-2 * inner_radius_derivative_wrt_inner_radius
519-
)
520-
height_derivative_wrt_height = -2 * inner_radius_derivative_wrt_height
521526

522-
return [
523-
[
524-
inner_radius_derivative_wrt_inner_radius,
525-
inner_radius_derivative_wrt_height,
526-
],
527-
[height_derivative_wrt_inner_radius, height_derivative_wrt_height],
528-
]
527+
inner_radius_derivative_wrt_inner_radius = factor * (
528+
grain_height - 2 * grain_inner_radius
529+
)
530+
inner_radius_derivative_wrt_height = factor * grain_inner_radius
531+
height_derivative_wrt_inner_radius = 0
532+
height_derivative_wrt_height = 0
533+
534+
return [
535+
[
536+
inner_radius_derivative_wrt_inner_radius,
537+
inner_radius_derivative_wrt_height,
538+
],
539+
[height_derivative_wrt_inner_radius, height_derivative_wrt_height],
540+
541+
542+
]
543+
544+
else:
545+
factor = volume_diff / (
546+
2
547+
* np.pi
548+
* (
549+
grain_outer_radius**2
550+
- grain_inner_radius**2
551+
+ grain_inner_radius * grain_height
552+
)
553+
** 2
554+
)
529555

556+
inner_radius_derivative_wrt_inner_radius = factor * (
557+
grain_height - 2 * grain_inner_radius
558+
)
559+
inner_radius_derivative_wrt_height = factor * grain_inner_radius
560+
height_derivative_wrt_inner_radius = (
561+
-2 * inner_radius_derivative_wrt_inner_radius
562+
)
563+
height_derivative_wrt_height = -2 * inner_radius_derivative_wrt_height
564+
565+
return [
566+
[
567+
inner_radius_derivative_wrt_inner_radius,
568+
inner_radius_derivative_wrt_height,
569+
],
570+
[height_derivative_wrt_inner_radius, height_derivative_wrt_height],
571+
572+
573+
]
574+
530575
def terminate_burn(t, y): # pylint: disable=unused-argument
531576
end_function = (self.grain_outer_radius - y[0]) * y[1]
532577
return end_function
@@ -576,16 +621,26 @@ def burn_area(self):
576621
burn_area : Function
577622
Function representing the burn area progression with the time.
578623
"""
579-
burn_area = (
580-
2
581-
* np.pi
582-
* (
583-
self.grain_outer_radius**2
584-
- self.grain_inner_radius**2
585-
+ self.grain_inner_radius * self.grain_height
624+
if self.only_radial_burn:
625+
burn_area = (
626+
2
627+
* np.pi
628+
* (
629+
self.grain_inner_radius * self.grain_height
630+
)
631+
* self.grain_number
632+
)
633+
else:
634+
burn_area = (
635+
2
636+
* np.pi
637+
* (
638+
self.grain_outer_radius**2
639+
- self.grain_inner_radius**2
640+
+ self.grain_inner_radius * self.grain_height
641+
)
642+
* self.grain_number
586643
)
587-
* self.grain_number
588-
)
589644
return burn_area
590645

591646
@funcify_method("Time (s)", "burn rate (m/s)")

0 commit comments

Comments
 (0)