bloc.reactors.solvers#
Procedural reactor and PFR solvers.
Functions#
|
Solve the kinetics in an isothermal isobaric reactor at T_reactor_C (°C) and P_bar (bar) for a residence time t_res (s). |
|
Solve the kinetics in an adiabatic isobaric reactor at P_bar (bar) for a residence time t_res (s). |
|
Solve kinetics in a PFR with a prescribed temperature profile T(x). |
|
Solve kinetics in a PFR with a prescribed temperature profile T(t). |
|
Solve kinetics in a PFR with a prescribed specific-enthalpy profile h(t). |
|
Solve kinetics in a PFR heated by a temperature-difference-driven flux. |
Module Contents#
- bloc.reactors.solvers.solve_isothermal_reactor(qm_kgs, T_reactor_C, t_res, X0, T0_C, P_bar, mechanism=None, dt_short=1e-09, rtolT_prevention=0.0001, rtolT_fatal=0.01, heat_recycling=True, conversion_target=None, H2_yield_target=None, name=None, verbose=2, termination='residence_time', L_r=None, S_r=None)#
Solve the kinetics in an isothermal isobaric reactor at T_reactor_C (°C) and P_bar (bar) for a residence time t_res (s).
- Parameters:
qm_kgs (-) – Mass flow rate of the input gas in kg/s
T_reactor_C (-) – Temperature of the reactor in °C
t_res (-) – Residence time in the reactor in s
X0 (-) – Composition of the input gas in mole fraction
T0_C (-) – Temperature of the input gas in °C
P_bar (-) – Pressure in the reactor in bar
mechanism (-) – Path to the mechanism file
dt_short (-) – Short time step for the simulation. A short time step is used to prevent temperature variations.
rtolT_prevention (-) – Relative tolerance for temperature variations. If the relative variation of the temperature exceed rtolT_prevention, the time step is reduced.
rtolT_fatal (-) – Relative tolerance for temperature variations. If the relative variation of the temperature exceed rtolT_fatal, the simulation is stopped.
heat_recycling (-) – If True, the energy released in exothermic reactions is used in later endothermic reactions. Default is True.
conversion_target (-) – Target for the conversion of the input gas. Default is None.
H2_yield_target (-) – Target for the H2 yield. Default is None.
name (-) – Name of the reactor. Default is None.
verbose (
int) – if >0, print infos. If >=2, add calculation progress bar.
Notes
Energy calculation: Two terms are computed: - Ecost_init: the energy required to heat the input gas from T0_C to T_reactor_C. Multiplying it by the mass flow
yields the heating power
- delta_h: the energy required to compensate for the endothermic reactions and maintain the temperature constant in the reactor.
If heat_recycling is True, the energy released in exothermic reactions is used in later endothermic reactions. Multiplying it by the mass flow yields the chemical power.
To compute delta_h, we use ‘energy = on’ in the reactor object definition, and evaluate the enthalpy variation at each time step. The time step is choosed so that the relative variation of the temperature is less than rtolT_prevention.
- bloc.reactors.solvers.solve_adiabatic_reactor(qm_kgs, P_in_kW, t_res, X0, T0_C, P_bar, mechanism, dt_short=1e-09, conversion_target=None, H2_yield_target=None, termination='residence_time', L_reactor=0.0, S_reactor=1.0, P_in_kW_avg=0.0, name=None, verbose=2)#
Solve the kinetics in an adiabatic isobaric reactor at P_bar (bar) for a residence time t_res (s).
- Parameters:
qm_kgs (-) – Mass flow rate of the input gas in kg/s
P_in_kW (-) – Instantaneous power input in kW. Applied once at t = 0 as an inlet specific-enthalpy pulse
P_in_kW * 1e3 / qm_kgs(J/kg), before time integration starts.t_res (-) – Residence time in the reactor in s
X0 (-) – Composition of the input gas in mole fraction
T0_C (-) – Temperature of the input gas in °C
P_bar (-) – Pressure in the reactor in bar
mechanism (-) – Name of the mechanism file
dt_short (-) – Short time step for the simulation
conversion_target (-) – Target for the conversion of the input gas. Default is None.
H2_yield_target (-) – Target for the H2 yield. Default is None.
termination (-) – Termination condition for the simulation. Default is ‘residence_time’. Can be ‘residence_time’ or ‘reactor_length’.
L_reactor (-) – Length of the reactor in m. Default is 0. If termination is ‘reactor_length’, L_reactor must be defined.
S_reactor (-) – Section of the reactor in m2. Default is 1. If termination is ‘reactor_length’, S_reactor must be defined.
P_in_kW_avg (-) – Average power input/removal in kW distributed uniformly over
t_res. At each integration stepdt, the specific enthalpy is adjusted bydh = P_in_kW_avg * 1e3 / qm_kgs * dt / t_res(J/kg). Positive values add heat; negative values remove heat.name (-) – Name of the reactor. Default is None.
verbose (
int) – if >0, print infos. If >=2, add calculation progress bar.
- Returns:
- “gas”: ct.Solution
Gas object with the final state of the reactor
- ”states”: ct.SolutionArray
Solution array with the states of the reactor at each time step
- Return type:
a dictionary
- bloc.reactors.solvers.solve_fixed_position_temperature_profile_pfr(qm_kgs, inlet_composition, P_bar, mechanism, temperature_profile_position, dx=0.01, L_reactor=0.0, d_reactor=1.0, name=None, verbose=2)#
Solve kinetics in a PFR with a prescribed temperature profile T(x).
Integrates along the reactor axis with fixed spatial step dx. At each step, the reactor advances by dt = dx / velocity (from mass flow and cross-section), then temperature is set from the profile. No energy equation; T is imposed.
- Parameters:
qm_kgs (
float) – Mass flow rate (kg/s).inlet_composition (
str) – Inlet composition (Cantera format, mole fractions).P_bar (
float) – Pressure (bar).mechanism (
str, optional) – Mechanism name or path; must not be None.temperature_profile_position (
np.ndarray) – Shape (2, n): row 0 = axial positions (m), row 1 = temperature (K).dx (
float, optional) – Spatial integration step (m). Default 0.01.L_reactor (
float, optional) – Reactor length (m); used for reporting. Default 0.0.d_reactor (
float, optional) – Reactor diameter (m); used for velocity and cross-section. Default 1.0.name (
str, optional) – Reactor name for logging.verbose (
int, optional) – Logging level. Default 2.
- Returns:
“gas”: Cantera Solution; “states”: SolutionArray with extra “t”, “x”. If mechanism is CRECK_Nobili2024.yaml, also “reaction_rates_by_class” and “mass_carbon_rates_by_class”.
- Return type:
dict
- bloc.reactors.solvers.solve_fixed_time_temperature_profile_pfr(inlet_composition, P_bar, mechanism, temperature_profile_time, dt=1e-06, name=None, verbose=2)#
Solve kinetics in a PFR with a prescribed temperature profile T(t).
Integrates in time with fixed step dt. At each step the reactor advances by dt, then temperature is set from the profile. No energy equation; T is imposed. No reactor geometry or velocity; purely time-residence integration.
- Parameters:
inlet_composition (
str) – Inlet composition (Cantera format, mole fractions).P_bar (
float) – Pressure (bar).mechanism (
str, optional) – Mechanism name or path; must not be None.temperature_profile_time (
np.ndarray) – Shape (2, n): row 0 = residence times (s), row 1 = temperature (K).dt (
float, optional) – Time integration step (s). Default 1e-6.name (
str, optional) – Reactor name for logging.verbose (
int, optional) – Logging level. Default 2.
- Returns:
“gas”: Cantera Solution; “states”: SolutionArray with extra “t”. If mechanism is CRECK_Nobili2024.yaml, also “reaction_rates_by_class” and “mass_carbon_rates_by_class”.
- Return type:
dict
- bloc.reactors.solvers.solve_fixed_time_enthalpy_profile_pfr(inlet_composition, P_bar, mechanism, times, h_profile, dt=1e-06, initial_temperature=300.0, name=None, verbose=2)#
Solve kinetics in a PFR with a prescribed specific-enthalpy profile h(t).
Counterpart of
solve_fixed_time_temperature_profile_pfr: instead of imposing temperature, the specific enthalpy is imposed at each step. The reactor energy equation is off, so during eachdtadvance the temperature is held at the value implied by the imposed enthalpy and the current composition; the temperature then follows from re-imposing the next enthalpy on the reacted mixture.- Parameters:
inlet_composition (
str) – Inlet composition (Cantera format, mole fractions).P_bar (
float) – Pressure (bar).mechanism (
str, optional) – Mechanism name or path; must not be None.times (
np.ndarray) – Shape (n,): residence times (s), monotonically increasing.h_profile (
np.ndarray) – Shape (n,): specific enthalpy (J/kg) imposed at each time intimes.dt (
float, optional) – Time integration step (s). Default 1e-6.initial_temperature (
float, optional) – Temperature (K) used to define the initial composition state before the first enthalpy is imposed. Default 300.0.name (
str, optional) – Reactor name for logging.verbose (
int, optional) – Logging level. Default 2.
- Returns:
“gas”: Cantera Solution; “states”: SolutionArray with extra “t”. If mechanism is CRECK_Nobili2024.yaml, also “reaction_rates_by_class” and “mass_carbon_rates_by_class”.
- Return type:
dict
- bloc.reactors.solvers.solve_fixed_time_heat_flux_pfr(inlet_composition, P_bar, mechanism, times, T_env_profile, thermal_time_constant, dt=1e-06, initial_temperature=300.0, name=None, verbose=2)#
Solve kinetics in a PFR heated by a temperature-difference-driven flux.
The reactor energy equation is on. An external environment at the prescribed temperature T_env(t) heats the gas through a wall with a first-order thermal lag: in the absence of chemistry the temperature gap closes as
dT/dt = (T_env - T) / thermal_time_constant. The coupling is self-limiting (the flux vanishes as T -> T_env) and never drives the gas above the environment, so directionality and the equilibrium-temperature cap are enforced automatically. Chemistry and wall heating are integrated together, so the gas temperature follows from its own energy balance.The wall heat term is added to the ODE right-hand side via a Cantera
Wall(the same technique assolve_adiabatic_reactor), avoiding the per-stepsyncStatereset used by the prescribed-temperature/enthalpy solvers.- Parameters:
inlet_composition (
str) – Inlet composition (Cantera format, mole fractions).P_bar (
float) – Pressure (bar).mechanism (
str, optional) – Mechanism name or path; must not be None.times (
np.ndarray) – Shape (n,): times (s), monotonically increasing, starting at 0.T_env_profile (
np.ndarray) – Shape (n,): environment (hot-zone) temperature (K) at each time.thermal_time_constant (
float) – Thermal response time tau (s) of the gas-to-environment coupling.dt (
float, optional) – Time integration step (s). Default 1e-6.initial_temperature (
float, optional) – Initial gas temperature (K). Default 300.0.name (
str, optional) – Reactor name for logging.verbose (
int, optional) – Logging level. Default 2.
- Returns:
“gas”: Cantera Solution; “states”: SolutionArray with extra “t”; “delivered_specific_enthalpy_J_per_kg”: net specific enthalpy added by the wall (h_final - h_initial), an output to compare against the hot-zone budget. If mechanism is CRECK_Nobili2024.yaml, also “reaction_rates_by_class” and “mass_carbon_rates_by_class”.
- Return type:
dict