Skip to content

Commit 325598a

Browse files
committed
ENH: implement grain regression ODE jacobian.
1 parent 30a1505 commit 325598a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

rocketpy/motors/solid_motor.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,21 @@ def geometry_dot(t, y):
484484

485485
return [rIDot, hDot]
486486

487+
# Define jacobian of the system of differential equations
488+
def geometry_jacobian(t, y):
489+
# Store physical parameters
490+
volume_diff = self.mass_flow_rate(t) / (n_grain * density)
491+
492+
# Compute jacobian
493+
rI, h = y
494+
factor = volume_diff / (2 * np.pi * (rO**2 - rI**2 + rI * h) ** 2)
495+
drI_dot_drI = factor * (h - 2 * rI)
496+
drI_dot_dh = factor * rI
497+
dh_dot_drI = -2 * factor * (h - 2 * rI)
498+
dh_dot_dh = -2 * factor * rI
499+
500+
return [[drI_dot_drI, drI_dot_dh], [dh_dot_drI, dh_dot_dh]]
501+
487502
def terminate_burn(t, y):
488503
end_function = (self.grain_outer_radius - y[0]) * y[1]
489504
return end_function
@@ -496,6 +511,7 @@ def terminate_burn(t, y):
496511
geometry_dot,
497512
t_span,
498513
y0,
514+
jac=geometry_jacobian,
499515
events=terminate_burn,
500516
atol=1e-12,
501517
rtol=1e-11,

0 commit comments

Comments
 (0)