aquakin.PlugFlowReactor#
- class aquakin.PlugFlowReactor(model, conditions, n_points, length, velocity, *, rtol=1e-06, atol=None, integrator=IntegratorConfig(order=3, factormax=3.0, colored_jacobian='auto', dtmax=None, max_steps=100000, solver=None), diff=DifferentiationConfig(mode='reverse', method='stable', check_finite=True, adjoint_max_steps=100000, adjoint_low_memory=False))[source]#
Bases:
GradientCheckMixinSteady-state plug-flow reactor.
The chemistry RHS is integrated along the reactor axis:
\[\frac{dC}{dx} = \frac{1}{v}\, \mathbf{S}^T\, r(C, p, \theta(x))\]Condition fields supplied at
n_locationsgrid points are linearly interpolated to the integrator’s currentx.- Parameters:
model (CompiledModel)
conditions (SpatialConditions) – Either a uniform single-location conditions object, or a spatially resolved one with
n_locations >= 2. Grid points are assumed evenly spaced over[0, length].n_points (int) – Number of axial output points at which to record the solution.
length (float) – Reactor length.
velocity (float) – Bulk velocity through the reactor.
rtol (float, optional) – Relative tolerance for the ODE solver.
atol (float or jnp.ndarray, optional) – Absolute tolerance, scalar or shape
(n_species,). Defaults toNone-> a per-component noise floor scaled off the model reference concentrations (seeBatchReactorfor the per-species rationale).integrator (IntegratorConfig, optional) – Integrator / step-size configuration (ESDIRK
order,factormax,dtmax,max_steps, an explicitsolver). SeeBatchReactor. Setdtmaxfor reverse-mode differentiation of a stiff model.diff (DifferentiationConfig, optional) – Autodiff configuration (
mode,method). SeeBatchReactor.
- __init__(model, conditions, n_points, length, velocity, *, rtol=1e-06, atol=None, integrator=IntegratorConfig(order=3, factormax=3.0, colored_jacobian='auto', dtmax=None, max_steps=100000, solver=None), diff=DifferentiationConfig(mode='reverse', method='stable', check_finite=True, adjoint_max_steps=100000, adjoint_low_memory=False))[source]#
- Parameters:
model (CompiledModel)
conditions (SpatialConditions)
n_points (int)
length (float)
velocity (float)
rtol (float)
integrator (IntegratorConfig)
diff (DifferentiationConfig)
- Return type:
None
Methods
__init__(model, conditions, n_points, ...[, ...])check_gradient_finite(grad_value, *[, what])Raise a friendly error if a reverse-mode gradient is non-finite.
solve(C0, *[, params, conditions])Integrate the steady-state PFR.
solve_sensitivity(C0, *, params, sens_params)Solve and return the forward sensitivity
dC/dthetaalong the axis.- solve(C0, *, params=None, conditions=None)[source]#
Integrate the steady-state PFR.
- Parameters:
C0 (jnp.ndarray) – Inlet concentration vector, shape
(n_species,).params (jnp.ndarray, optional) – Rate constant vector, shape
(n_params,). Defaults tomodel.default_parameters().conditions (SpatialConditions, optional) – Override the conditions stored on the reactor for this call. Must match the constructor-time
n_locationsso the precomputedx_gridremains valid.
- Return type:
- solve_sensitivity(C0, *, params, sens_params, conditions=None, sens_rtol=None, sens_atol=None, param_scale=None, shared_factor=None)[source]#
Solve and return the forward sensitivity
dC/dthetaalong the axis.Integrates the augmented
[C; S]system over the reactor length with adaptive control over both, so the sensitivity profile is exact and finite without adtmaxcap (seeaquakin.integrate.forward_sensitivity).- Parameters:
C0 (Array) – As for
solve().conditions (SpatialConditions | None) – As for
solve().params (jnp.ndarray) – Full parameter vector; keyword-only, matching
solve().sens_params (list of str or int) – Namespaced parameter names (or integer indices into
params).sens_rtol (float | None) – Sensitivity error-control tolerances (CVODES defaults).
sens_atol – Sensitivity error-control tolerances (CVODES defaults).
param_scale – Sensitivity error-control tolerances (CVODES defaults).
shared_factor (bool, optional) – CVODES simultaneous-corrector linear solve.
None(default) auto-selectsTruefor more than one sensitivity parameter, elseFalse.
- Returns:
sol (PFRSolution) – The usual axial concentration profile.
S (jnp.ndarray) – Sensitivity
dC/dthetaat the axial output points, shape(n_points, n_species, n_sens_params).
- Return type:
tuple[PFRSolution, Array]