Zero-Dimensional Reactor Networks#
- Reactor
Wrapper around a Cantera reactor CLib handle. Construct one of the concrete helpers (
IdealGasReactor,Reactor,ConstPressureReactor,IdealGasConstPressureReactor) rather than this type directly.Reactor(gas; name="")
General constant-volume reactor.
- IdealGasReactor(gas; name="")
Zero-dimensional constant-volume reactor with an ideal-gas energy equation.
- ConstPressureReactor(gas; name="")
Constant-pressure reactor.
- IdealGasConstPressureReactor(gas; name="")
Constant-pressure reactor with an ideal-gas energy equation.
- mass(r::Reactor)
Mass of the reactor contents [kg].
- reactor_phase(r::Reactor) -> Solution
The
Solutionactually integrated by the reactor. This is the reactor’s own clone of the phase it was constructed from (seeIdealGasReactorand friends), and reflects its current state, unlike the originalSolutionpassed to the constructor.
- set_energy_enabled!(r::Reactor, flag::Bool)
Enable/disable the energy equation in the reactor.
- set_chemistry_enabled!(r::Reactor, flag::Bool)
Enable/disable chemistry in the reactor.
- set_initial_volume!(r::Reactor, vol)
Set the initial reactor volume [m^3].
- Reservoir(gas; name="")
A reactor with a fixed thermodynamic state, used as a boundary (source or sink) for
FlowDevices andWalls. Its state never changes during integration.
- area(r::Reactor) -> Float64
Wall/surface area associated with the reactor [m^2].
area(w::Wall)
Wall area [m^2].
- set_area!(r::Reactor, a)
Set the wall/surface area of the reactor [m^2].
set_area!(w::Wall, a)
Set the wall area [m^2].
- ReactorSurface(surf, reactor; name="")
A surface on which heterogeneous reactions take place, coupling the surface phase
surf(aSolutionfor an interface phase) to a bulkreactor.
- mass_flow_rate(r::Reactor)
Mass flow rate through the reactor [kg/s].
mass_flow_rate(d::FlowDevice)
Mass flow rate through the flow device [kg/s].
- set_mass_flow_rate!(r::Reactor, mdot)
Set the mass flow rate through the reactor [kg/s].
set_mass_flow_rate!(mfc, mdot)
Set the (constant) mass flow rate of a
MassFlowController[kg/s].
- add_sensitivity_reaction!(r, i)
Mark reaction
i(1-based) as a sensitivity parameter for reactorr. The reactor must already be part of aReactorNet.
- n_sens_params(r::Reactor)
Number of sensitivity parameters associated with the reactor.
- ReactorNet(reactors::Vector{Reactor})
ReactorNet(reactor::Reactor)
Create a reactor network for time integration. The network keeps references to its reactors so they are not finalized while integration is in progress.
- advance!(net, t)
Advance the network state to absolute time
t[s].
- step!(net) -> Float64
Take one internal timestep and return the new time [s].
- set_initial_time!(net::ReactorNet, t)
Set the initial integration time [s].
- set_max_time_step!(net::ReactorNet, dt)
Set the maximum internal timestep [s].
- set_tolerances!(net; rtol=1e-9, atol=1e-15)
Set the relative and absolute integrator tolerances.
- rtol(net::ReactorNet)
Relative error tolerance of the network integrator.
- atol(net::ReactorNet)
Absolute error tolerance of the network integrator.
- set_sensitivity_tolerances!(net; rtol=1e-6, atol=1e-6)
Set the relative and absolute tolerances used for sensitivity analysis.
- sensitivity(net, component, p, reactor) -> Float64
Normalized sensitivity of
component(e.g."temperature"or a species name) inreactorwith respect to sensitivity parameterp(1-based).reactormay be aReactorbelonging to the network or its 1-based position.
- n_components(net) -> Int
Number of state variables (equations) integrated by the network.
n_components(d::Domain1D)
Number of solution components in the domain.
- state(net) -> Vector{Float64}
Current network state vector, of length
n_components.
- component_name(net::ReactorNet, i::Integer)
Name of state-vector component
i(1-based).component_name(d::Domain1D, n::Integer)
Name of component
n(1-based).
- component_names(net) -> Vector{String}
Names of all state-vector components, aligned with
state.component_names(d::Domain1D)
Vector of all component names in the domain.
- Connector
Abstract supertype of objects that link two reactors in a network (
Wall,MassFlowController,Valve,PressureController).
- FlowDevice <: Connector
Abstract supertype of flow devices that move mass between reactors.
- connector_type(c::Connector)
Connector type string.
- set_name!(c::Connector, nm::AbstractString)
Set the connector name.
- Wall(left, right; A=1.0, U=0.0, K=0.0, Q=nothing, velocity=nothing,
expansion_rate_coeff=nothing, emissivity=nothing, name="")
A wall separating reactors
leftandright.Ais the wall area [m^2],Uthe heat-transfer coefficient [W/m^2/K],Kthe expansion-rate coefficient [m/s/Pa].Q(heat flux) andvelocitymay beFunc1objects;emissivityenables radiative transfer.
- expansion_rate(w::Wall)
Rate of volumetric expansion of the left reactor [m^3/s].
- heat_rate(w::Wall)
Rate of heat transfer through the wall (left to right) [W].
- set_heat_transfer_coeff!(w::Wall, U)
Set the wall heat-transfer coefficient [W/m^2/K].
- set_thermal_resistance!(w::Wall, Rth)
Set the wall thermal resistance [m^2*K/W].
- set_expansion_rate_coeff!(w::Wall, k)
Set the wall expansion-rate coefficient [m/s/Pa].
- set_emissivity!(w::Wall, epsilon)
Set the wall emissivity for radiative heat transfer (0..1).
- set_heat_flux!(w::Wall, q)
Set the wall heat flux as a time-dependent
Func1(or handle) [W/m^2].
- set_velocity!(w::Wall, f)
Set the wall velocity as a time-dependent
Func1(or handle) [m/s].
- device_coefficient(d::FlowDevice)
Device coefficient of the flow device (meaning depends on the device type).
- set_device_coefficient!(d::FlowDevice, c)
Set the device coefficient of the flow device.
- set_pressure_function!(d::FlowDevice, f)
Set the pressure function of the flow device as a
Func1(or handle).
- set_time_function!(d::FlowDevice, g)
Set the time function of the flow device as a
Func1(or handle).
- set_primary!(d::FlowDevice, primary::FlowDevice)
Set the primary flow device (used by
PressureController).
- MassFlowController(upstream, downstream; mdot=0.0, name="")
A flow device that maintains a specified mass flow rate
mdot[kg/s] fromupstreamtodownstream, independent of the pressure difference.
- Valve(upstream, downstream; K=0.0, name="")
A flow device whose mass flow rate is proportional to the pressure difference,
mdot = K * (P_upstream - P_downstream), with valve coefficientK.
- PressureController(upstream, downstream; primary=nothing, K=0.0, name="")
A flow device that regulates the pressure difference across it relative to a
primaryflow device:mdot = primary.mdot + K * (P_upstream - P_downstream).
- Func1
A wrapper around a Cantera
Func1function object. AFunc1is callable:f(t)evaluates it att. Instances combine with+,-,*and/to build compound functions and support symbolicderivative.
- constant_function(c) -> Func1
Convenience constructor for the constant functor
t -> c.
- evaluate(f::Func1, t) -> Float64
Evaluate the functor at
t.
- derivative(f::Func1) -> Func1
Return a new
Func1representing the symbolic derivative off.
- func_type(f::Func1) -> String
The functor’s type string (e.g.
"sin","sum").
Examples#
f = Func1("sin", 2.0) # t -> sin(2t)
f(pi/4) # == sin(pi/2)
g = Func1("polynomial3", [1.0, 2.0, 3.0, 4.0]) # t^3 + 2t^2 + 3t + 4
h = Func1("constant", 2.0) + Func1("constant", 3.0)
Func1(type::String, coeff::Real=1.0)
Construct a basic functor of the given type (e.g. "sin", "cos", "exp",
"log", "pow", "constant"). For "sin" with coefficient w, evaluating
at t returns sin(w*t).
Func1(type::String, coeffs::AbstractVector)
Construct an advanced functor parametrized by an array of coefficients, e.g.
"polynomial3" (coefficients from highest to lowest degree) or "Fourier".