Changed a bunch of docstrings for examples, added error handling for Reactor classes

This commit is contained in:
ssun30 2022-08-31 19:12:05 -04:00 committed by Ray Speth
parent 132dd6a81f
commit 9a7615e2d6
22 changed files with 94 additions and 85 deletions

View File

@ -54,9 +54,9 @@ classdef Reactor < handle
r.type = char(typ);
r.id = callct('reactor_new', typ);
% if r.id < 0
% error(geterr);
% end
if r.id < 0
error(geterr);
end
if isa(content, 'Solution')
r.insert(content);

View File

@ -38,9 +38,9 @@ classdef ReactorSurface < handle
s.surfID = callct('reactorsurface_new', 0);
s.reactor = -1;
% if r.id < 0
% error(geterr);
% end
if r.id < 0
error(geterr);
end
if nargin >= 1
s.setKinetics(kleft);

View File

@ -75,9 +75,9 @@ classdef Wall < handle
x.type = char(typ);
x.id = callct('wall_new', x.type);
% if x.index < 0
% error(geterr);
% end
if x.index < 0
error(geterr);
end
x.left = -1;
x.right = -1;

View File

@ -1,4 +1,4 @@
% Catalytic combustion of a stagnation flow on a platinum surface
%% CATCOMB - Catalytic combustion of a stagnation flow on a platinum surface
%
% This script solves a catalytic combustion problem. A stagnation flow
% is set up, with a gas inlet 10 cm from a platinum surface at 900
@ -9,6 +9,7 @@
%
% The catalytic combustion mechanism is from Deutschman et al., 26th
% Symp. (Intl.) on Combustion,1996 pp. 1747-1754
%
%% Initialization
@ -57,13 +58,13 @@ refine_grid = 1; % 1 to enable refinement, 0 to
% and transport properties
%
% The gas phase will be taken from the definition of phase 'gas' in
% input file 'ptcombust.yaml,' which is a stripped-down version of
% input file 'ptcombust.yaml', which is a stripped-down version of
% GRI-Mech 3.0.
gas = Solution('ptcombust.yaml', 'gas', transport);
gas.TPX = {tinlet, p, comp1};
%% create the interface object
%% Create the interface object
%
% This object will be used to evaluate all surface chemical production
% rates. It will be created from the interface definition 'Pt_surf'
@ -86,7 +87,7 @@ surf_phase.advanceCoverages(1.0);
% for 1-D simulations. These will be 'stacked' together to create
% the complete simulation.
%% create the flow object
%% Create the flow object
%
% The flow object is responsible for evaluating the 1D governing
% equations for the flow. We will initialize it with the gas

View File

@ -1,10 +1,9 @@
function dydt = conhp(t, y, gas, mw) %#ok<INUSL>
% CONHP - ODE system for a constant-pressure, adiabatic reactor.
%
% Function CONHP evaluates the system of ordinary differential
% equations for an adiabatic, constant-pressure,
% zero-dimensional reactor. It assumes that the 'gas' object
% represents a reacting ideal gas mixture.
% Function CONHP evaluates the system of ordinary differential equations
% for an adiabatic, constant-pressure, zero-dimensional reactor.
% It assumes that the 'gas' object represents a reacting ideal gas mixture.
% Set the state of the gas, based on the current solution vector.
gas.Y = y(2: end);

View File

@ -1,10 +1,9 @@
function dydt = conuv(t, y, gas, mw) %#ok<INUSL>
% CONUV ODE system for a constant-volume, adiabatic reactor.
%
% Function CONUV evaluates the system of ordinary differential
% equations for an adiabatic, constant-volume,
% zero-dimensional reactor. It assumes that the 'gas' object
% represents a reacting ideal gas mixture.
% Function CONUV evaluates the system of ordinary differential
% equations for an adiabatic, constant-volume, zero-dimensional reactor.
% It assumes that the 'gas' object represents a reacting ideal gas mixture.
% Set the state of the gas, based on the current solution vector.

View File

@ -1,7 +1,9 @@
% DIFF_FLAME - An opposed-flow diffusion flame.
%% DIFF_FLAME - An opposed-flow diffusion flame.
%
% This example uses the CounterFlowDiffusionFlame function to solve an
% opposed-flow diffusion flame for Ethane in Air. This example is the same
% as the diffusion_flame.py example without radiation.
%
%% Initialization

View File

@ -1,8 +1,9 @@
function equil(g)
% EQUIL A chemical equilibrium example.
%% EQUIL - A chemical equilibrium example.
%
% This example computes the adiabatic flame temperature and equilibrium
% composition for a methane/air mixture as a function of equivalence ratio.
%
clear all
close all

View File

@ -1,7 +1,8 @@
% FLAME1 - A burner-stabilized flat flame
%% FLAME1 - A burner-stabilized flat flame
%
% This script simulates a burner-stablized lean hydrogen-oxygen flame
% at low pressure.
%
% This script simulates a burner-stablized lean hydrogen-oxygen flame
% at low pressure.
%% Initialization

View File

@ -1,6 +1,7 @@
% FLAME2 - An axisymmetric stagnation-point non-premixed flame
%% FLAME2 - An axisymmetric stagnation-point non-premixed flame
%
% This script simulates a stagnation-point ethane-air flame.
%
% This script simulates a stagnation-point ethane-air flame.
%% Initialization

View File

@ -1,5 +1,5 @@
function plotdata = ignite(g)
% IGNITE Zero-dimensional kinetics: adiabatic, constant pressure.
%% IGNITE Zero-dimensional kinetics: adiabatic, constant pressure.
%
% This example solves the same problem as 'reactor1,' but does
% it using one of MATLAB's ODE integrators, rather than using the

View File

@ -1,8 +1,8 @@
function isentropic(g)
% ISENTROPIC isentropic, adiabatic flow example
%% ISENTROPIC - isentropic, adiabatic flow example
%
% In this example, the area ratio vs. Mach number curve is
% computed for a hydrogen/nitrogen gas mixture.
% In this example, the area ratio vs. Mach number curve is computed for a
% hydrogen/nitrogen gas mixture.
%
clear all
close all

View File

@ -1,13 +1,13 @@
% LITHIUM_ION_BATTERY
%% LITHIUM_ION_BATTERY
%
% This example file calculates the cell voltage of a lithium-ion battery
% at given temperature, pressure, current, and range of state of charge (SOC).
%
% The thermodynamics are based on a graphite anode and a LiCoO2 cathode,
% modeled using the 'BinarySolutionTabulatedThermo' class.
% Further required cell parameters are the electrolyte ionic resistance, the
% stoichiometry ranges of the active materials (electrode balancing), and the
% surface area of the active materials.
% Further required cell parameters are the electrolyte ionic resistance,
% the stoichiometry ranges of the active materials (electrode balancing),
% and the surface area of the active materials.
%
% The functionality of this example is presented in greater detail in the
% reference (which also describes the derivation of the
@ -18,6 +18,7 @@
% of the thermodynamics of lithium-ion battery intercalation materials in the
% open-source software Cantera, Electrochim. Acta 323, 134797 (2019),
% https://doi.org/10.1016/j.electacta.2019.134797
%
%% Initialization

View File

@ -1,22 +1,21 @@
function periodic_cstr
%% PERIODIC_CSTR - A CSTR with steady inputs but periodic interior state.
%
% PERIODIC_CSTR - A CSTR with steady inputs but periodic interior state.
%
% A stoichiometric hydrogen/oxygen mixture is introduced and reacts to produce
% water. But since water has a large efficiency as a third body in the chain
% termination reaction
% A stoichiometric hydrogen/oxygen mixture is introduced and reacts to
% produce water. But since water has a large efficiency as a third body
% in the chain termination reaction
%
% H + O2 + M = HO2 + M
%
% as soon as a significant amount of water is produced the reaction
% stops. After enough time has passed that the water is exhausted from
% the reactor, the mixture explodes again and the process
% repeats. This explanation can be verified by decreasing the rate for
% reaction 7 in file 'h2o2.yaml' and re-running the example.
% as soon as a significant amount of water is produced the reaction stops.
% After enough time has passed that the water is exhausted from the reactor,
% the mixture explodes again and the process repeats. This explanation can be
% verified by decreasing the rate for reaction 7 in file 'h2o2.yaml' and
% re-running the example.
%
% Acknowledgments: The idea for this example and an estimate of the
% conditions needed to see the oscillations came from Bob Kee,
% Colorado School of Mines
% Acknowledgments: The idea for this example and an estimate of the
% conditions needed to see the oscillations came from Bob Kee,
% Colorado School of Mines
%
clear all

View File

@ -1,24 +1,25 @@
% General_Plug_Flow_Reactor (PFR) - to solve PFR equations for reactors
%% Plug_Flow_Reactor (PFR) - to solve PFR equations for reactors
%
% This code snippet is to model a constant area and varying area
% (converging and diverging) nozzle as Plug Flow Reactor with given
% dimensions and an incoming gas. The pressure is not assumed to be
% constant here, as opposed to the Python Version of the
% Plug Flow Reactor model.
% This code snippet is to model a constant area and varying area
% (converging and diverging) nozzle as Plug Flow Reactor with given
% dimensions and an incoming gas. The pressure is not assumed to be
% constant here, as opposed to the Python Version of the
% Plug Flow Reactor model.
%
% The reactor assumes that the flow follows the Ideal Gas Law.
% The reactor assumes that the flow follows the Ideal Gas Law.
%
% The governing equations used in this code can be referenced at:
% *S.R Turns, An Introduction to Combustion - Concepts and Applications,
% McGraw Hill Education, India, 2012, 206-210.*
% The governing equations used in this code can be referenced at:
% *S.R Turns, An Introduction to Combustion - Concepts and Applications,
% McGraw Hill Education, India, 2012, 206-210.*
%
% The current example is written for methane combustion, but can be readily
% adapted for other chemistries.
% The current example is written for methane combustion, but can be readily
% adapted for other chemistries.
%
% Developed by Ashwin Kumar/Dr.Joseph Meadows (mgak@vt.edu/jwm84@vt.edu) on 3-June-2020
% Research Assistant/Assistant Professor
% Advanced Propulsion and Power Laboratory
% Virginia Tech
%
% Developed by Ashwin Kumar/Dr.Joseph Meadows (mgak@vt.edu/jwm84@vt.edu) on 3-June-2020
% Research Assistant/Assistant Professor
% Advanced Propulsion and Power Laboratory
% Virginia Tech
%% Clear all variables, close all figures, clear the command line:

View File

@ -1,9 +1,10 @@
function prandtl1(g)
% PRANDTL1 Prandtl number for an equilibrium H/O gas mixture.
%% PRANDTL1 - Prandtl number for an equilibrium H/O gas mixture.
%
% This example computes and plots the Prandtl number for a hydrogen / oxygen
% mixture in chemical equilibrium for P = 1 atm and a range of temperatures
% and elemental O/(O+H) ratios.
%
% This example computes and plots the Prandtl number for a
% hydrogen / oxygen mixture in chemical equilibrium for P = 1
% atm and a range of temperatures and elemental O/(O+H) ratios.
clear all
close all

View File

@ -1,8 +1,8 @@
function prandtl2(g)
% PRANDTL2 Prandtl number for an equilibrium H/O gas mixture.
%% PRANDTL2 - Prandtl number for an equilibrium H/O gas mixture.
%
% This example does the same thing as prandtl1, but using
% the multicomponent expression for the thermal conductivity.
% This example does the same thing as prandtl1, but using the
% multicomponent expression for the thermal conductivity.
%
clear all

View File

@ -1,9 +1,10 @@
function reactor1(g)
% REACTOR1 Zero-dimensional kinetics: adiabatc, constant pressure.
%% REACTOR1 Zero-dimensional kinetics: adiabatc, constant pressure.
%
% This example illustrates how to use class 'Reactor' for zero-dimensional
% kinetics simulations. Here the parameters are set so that the reactor is
% adiabatic and very close to constant pressure.
%
clear all
close all

View File

@ -1,9 +1,10 @@
function reactor2(g)
% REACTOR2 Zero-dimensional kinetics: adiabatic, constant volume.
%% REACTOR2 - Zero-dimensional kinetics: adiabatic, constant volume.
%
% This example illustrates how to use class 'Reactor' for zero-dimensional
% kinetics simulations. Here the parameters are set so that the reactor is
% adiabatic and constant volume.
%
% This example illustrates how to use class 'Reactor' for
% zero-dimensional kinetics simulations. Here the parameters are
% set so that the reactor is adiabatic and constant volume.
clear all
close all

View File

@ -1,9 +1,9 @@
function dydt = reactor_ode(t, y, gas, vdot, area, heatflux)
% REACTOR ODE system for a generic zero-dimensional reactor.
%% REACTOR ODE - system for a generic zero-dimensional reactor.
%
% Function REACTOR evaluates the system of ordinary differential
% equations for a zero-dimensional reactor with arbitrary heat
% transfer and volume change.
% Function REACTOR evaluates the system of ordinary differential equations
% for a zero-dimensional reactor with arbitrary heat transfer and
% volume change.
%
% Solution vector components:
% y(1) Total internal energy U

View File

@ -1,8 +1,8 @@
% SURFREACTOR Zero-dimensional reactor with surface chemistry
%% SURFREACTOR - Zero-dimensional reactor with surface chemistry
%
% This example illustrates how to use class 'Reactor' for zero-dimensional
% simulations including both homogeneous and heterogeneous chemistry.
%
% This example illustrates how to use class 'Reactor' for
% zero-dimensional simulations including both homogeneous and
% heterogeneous chemistry.
%% Initialization

View File

@ -1,4 +1,5 @@
% runs selected examples without pausing
LoadCantera
clear all
close all