Canonical RHS excerpt from the registered callable used for this benchmark cell. Expand it to verify the state equations; it is not a standalone runnable fixture.
Show canonical RHS excerpt
def _kamal_sourour_rate_vec(T: np.ndarray, alpha: np.ndarray) -> np.ndarray:
T_safe = np.clip(T, _T_FLOOR, _T_CEIL)
alpha_safe = np.clip(alpha, 0.0, 1.0)
inv_RT = 1.0 / (_R_GAS * T_safe)
arg1 = np.clip(_E1 * inv_RT, 0.0, _EXP_ARG_MAX)
arg2 = np.clip(_E2 * inv_RT, 0.0, _EXP_ARG_MAX)
k1 = _A1 * np.exp(-arg1)
k2 = _A2 * np.exp(-arg2)
return (k1 + k2 * np.power(alpha_safe, _M)) * np.power(1.0 - alpha_safe, _N_ORD)
def _fp_crossply_12layer_rhs(t, y):
T = np.clip(y[:_CP12_N_SPATIAL], _T_FLOOR, _T_CEIL)
alpha = np.clip(y[_CP12_N_SPATIAL:2 * _CP12_N_SPATIAL], 0.0, 1.0)
P = y[2 * _CP12_N_SPATIAL:]
dadt = _kamal_sourour_rate_vec(T, alpha)
dT = np.empty(_CP12_N_SPATIAL)
dP = np.empty(_CP12_N_SPATIAL)
for layer in range(_CP12_LAYERS):
start = layer * _CP12_NODES
end = start + _CP12_NODES
diff_layer = _CP12_DIFF[layer]
for i in range(start, end):
local = i - start
if i == 0:
T_left = _CP12_T_BOTTOM
elif local == 0:
prev_layer = layer - 1
k_left = _CP12_K_THRU[prev_layer]
k_right = _CP12_K_THRU[layer]
R_left = _CP12_DX / (2.0 * k_left) + _R_CONTACT
R_right = _CP12_DX / (2.0 * k_right)
T_left = (T[i - 1] / R_left + T[i] / R_right) / (1.0 / R_left + 1.0 / R_right)
else:
T_left = T[i - 1]
if i == _CP12_N_SPATIAL - 1:
k_top = _CP12_K_THRU[layer]
T_right = T[i] + (_H_CONV * _CP12_DX / k_top) * (_T_AMBIENT - T[i])
elif local == _CP12_NODES - 1 and layer < _CP12_LAYERS - 1:
k_left_b = _CP12_K_THRU[layer]
k_right_b = _CP12_K_THRU[layer + 1]
R_left_b = _CP12_DX / (2.0 * k_left_b)
R_right_b = _CP12_DX / (2.0 * k_right_b) + _R_CONTACT
T_right = (T[i] / R_left_b + T[i + 1] / R_right_b) / (1.0 / R_left_b + 1.0 / R_right_b)
else:
T_right = T[i + 1]
lap = (T_left - 2.0 * T[i] + T_right) * _CP12_INV_DX2
dT[i] = diff_layer * lap + _SRC_COEFF * dadt[i]
dT[0] = 0.0
dP[:] = (
(_RHO_RESIN * _V_GAS_SPECIFIC * dadt * _R_GAS_IDEAL * T) / _V_PORE
- P * _PERM_LOSS
)
dy = np.empty(_CP12_DIM)
dy[:_CP12_N_SPATIAL] = dT
dy[_CP12_N_SPATIAL:2 * _CP12_N_SPATIAL] = dadt
dy[2 * _CP12_N_SPATIAL:] = dP
return dy- Parameters
- _A1 = 20000
- _A2 = 1.5e+06
- _CP12_DIFF = [3.10559e-07, 3.10559e-06, 3.10559e-07, 3.10559e-06, 3.10559e-07, 3.10559e-06, 3.10559e-07, 3.10559e-06, 3.10559e-07, 3.10559e-06, 3.10559e-07, 3.10559e-06]
- _CP12_DIM = 540
- _CP12_DX = 0.00025
- _CP12_INV_DX2 = 1.6e+07
- _CP12_K_THRU = [0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5]
- _CP12_LAYERS = 12
- _CP12_NODES = 15
- _CP12_N_SPATIAL = 180
- _CP12_T_BOTTOM = 453.15
- _E1 = 60000
- _E2 = 75000
- _EXP_ARG_MAX = 500
- _H_CONV = 10
- _M = 0.8
- _N_ORD = 1.8
- _PERM_LOSS = 0.001
- _RHO_RESIN = 1150
- _R_CONTACT = 0.0005
- _R_GAS = 8.314
- _R_GAS_IDEAL = 8.314
- _SRC_COEFF = 250
- _T_AMBIENT = 298
- _T_CEIL = 5000
- _T_FLOOR = 200
- _V_GAS_SPECIFIC = 0.02
- _V_PORE = 0.01
- Initial condition
- y(0) = [453.15, 298, 298, 298, 298, 298, …] [shape=(540,), min=0.001, max=101325]
- Horizon
- t ∈ [0, 180]
Canonical RHS excerpt captured from the same registered callable used for the published benchmark. Frozen closure values are summarized below; helper imports and solver settings are intentionally omitted.