网页
综合
更新时间 2026-11-14 10:01:53
Using Reactor Networks for Time Integration — Cantera 3.2.0 documentation
自动蜘蛛
cantera.org
正文约 6000 字
This guide explains the basics of setting up and integrating the governing equations of a transient reactor network problem.
First, let’s take a look at a basic example to see how we might utilize Cantera’s time integration functionality. We’ll simulate an isolated reactor in Python that is filled with a homogeneous gas mixture. The gas state used in this example is arbitrary, but interesting because it’s explosive.
Now, let’s advance the simulation in time to an absolute time of 1 second, and examine how the state of the gas has changed. There isn’t anything special about choosing 1 second as the end time for the integration; any end time can be chosen. We are choosing 1 second here because after that amount of time, the mixture will have almost certainly ignited for a wide range of initial conditions.
The state of a ReactorNet can be advanced in time by one of the following three methods:
step(): The step() method computes the state of the system after one time step. The size of the step is determined by SUNDIALS when the method is called. SUNDIALS determines the step size by estimating the local error, which must satisfy tolerance conditions. The step is redone with reduced step size whenever that error test fails. SUNDIALS also periodically checks if the maximum step size is being used. The time step must not be larger than a predefined maximum time step \(\Delta t_\t{max}\). The new time \(t_\t{new}\) at the end of the single step is returned by this function. This method produces the highest time resolution in the output data of the methods implemented in Cantera.
advance(t_new): This method computes the state of the system at the user-provided time \(t_\t{new}\). \(t_\t{new}\) is the absolute time from the initial time of the system. Although the user specifies the time when integration should stop, SUNDIALS chooses the time step size as the network is integrated. Many internal SUNDIALS time steps are usually required to reach \(t_\t{new}\). As such, advance(t_new) preserves the accuracy of using step() but allows consistent spacing in the output data.
advance_to_steady_state(max_steps, residual_threshold, atol, write_residuals) Python interface only: If the steady state solution of a reactor network is of interest, this method can be used. Internally, the steady state is approached by time stepping. The network is considered to be at steady state if the feature-scaled residual of the state vector is below a given threshold value (which by default is 10 times the time step rtol).
The advance(t_new) approach is typically used when consistent, regular, time steps are required in the output data. This usually simplifies comparisons among many simulation results at a single time point. However, some detail, for example, a fast ignition process, might not be resolved in the output data if the user-provided time step is not small enough.
To avoid losing this detail, the Reactor::setAdvanceLimit() method (C++) or the Reactor.set_advance_limit() method (Python) can be used to set the maximum amount that a specified solution component can change between output times. For an example of this feature’s use, see the example reactor1.py. However, as a tradeoff, the time step sizes in the output data are no longer guaranteed to be uniform.
Even though Cantera comes pre-defined with reasonable default values for tolerances and the maximum internal time step, the solver may not be correctly configured for the specific system. In this case SUNDIALS may stop with an error. To solve this problem, three parameters can be tuned:
the absolute tolerances
the relative tolerances
the maximum time step size
Reducing the third value is particularly useful when dealing with abrupt changes in the boundary conditions. One example of this is opening or closing valves; see also the IC engine example.
The following examples demonstrate the use of flow devices such as valves and mass flow controllers to model the inlets and outlets of reactors:
Soot precursor formation with time-varying mass flow rate
Diesel-type internal combustion engine simulation with gaseous fuel
Adiabatic combustor (C++)
The following examples demonstrate the use of walls to model volume changes and heat transfer between reactors:
Reactors separated by a moving piston
Reactors with walls and heat transfer
Diesel-type internal combustion engine simulation with gaseous fuel
Additional examples can be found in the Python Reactor Network Examples section.
The Ideal Gas Control Volume Mole Reactor and the Ideal Gas Constant Pressure Mole Reactor are able to be solved using preconditioned sparse iterative methods, instead of the normal direct linear methods. Using these solvers can greatly speed up integration for systems with hundreds or thousands of species [Walker et al., 2023].
To enable the use of this solver, a preconditioner object needs to be created and specified for use by the reactor network. The previous example can be modified as follows:
The results of the time integration are the same as before:
The approximate Jacobian matrices used to construct the preconditioners do not currently account for terms that link multiple reactors in the same network. For networks of this type, the iterative solver may exhibit convergence errors for systems where the default direct solver does not. If the solver converges, the solution will satisfy the error tolerances, even though the Jacobian matrix is not exact.
If you are interested in how a homogeneous chemical mixture changes state in time when isolated from the surroundings, a simple batch reactor can be used. Two versions are commonly considered: a rigid vessel with fixed volume but variable pressure, or a system idealized at constant pressure but varying volume.
The initial state of the solution can be specified by composition and a set of intensive thermodynamic parameters, like temperature and pressure, as a standard Cantera Solution object. From this base, a Reactor or a ConstPressureReactor
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。