Fixed docstrings and moving several unncessary methods into class

constructors instead.
This commit is contained in:
ssun30 2023-01-04 23:21:03 -05:00 committed by Ray Speth
parent d92474ec2b
commit 0fbf09bba5
69 changed files with 569 additions and 623 deletions

View File

@ -1,7 +1,7 @@
classdef AxisymmetricFlow < Domain1D
% Create an axisymmetric flow domain.
% Create an axisymmetric flow domain. ::
%
% m = AxisymmetricFlow(gas, id)
% >> m = AxisymmetricFlow(gas, id)
%
% :param gas:
% Instance of class :mat:class:`Solution`
@ -13,10 +13,10 @@ classdef AxisymmetricFlow < Domain1D
methods
% Constructor
function m = AxisymmetricFlow(gas, id)
% Constructor
m = m@Domain1D('StagnationFlow', gas);
m@Domain1D('StagnationFlow', gas);
if nargin == 1
m.setID('flow');

View File

@ -1,6 +1,7 @@
function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidizer)
% Create a counter flow diffusion flame stack.
% flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidizer)
classdef CounterFlowDiffusionFlame < Sim1D
% Create a counter flow diffusion flame stack. ::
%
% >> flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidizer)
%
% :param left:
% Object representing the left inlet, which must be
@ -20,207 +21,222 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
% :param oxidizer:
% String representing the oxidizer species. Most commonly O2.
% :return:
% Instance of :mat:class:`Sim1D` object representing the left
% inlet, flow, and right inlet.
% Instance of :mat:class:`CounterFlowDiffusionFlame` object
% representing the left inlet, flow, and right inlet.
%
%% Check input parameters
methods
if nargin ~= 6
error('CounterFlowDiffusionFlame expects six input arguments.');
end
function flame = CounterFlowDiffusionFlame(left, flow, right, ...
tp_f, tp_o, oxidizer)
if ~tp_f.isIdealGas
error('Fuel gas object must represent an ideal gas mixture.');
end
% Constructor
if ~tp_o.isIdealGas
error('Oxidizer gas object must represent an ideal gas mixture.');
end
if ~left.isInlet
error('Left inlet object of wrong type.');
end
if ~flow.isFlow
error('Flow object of wrong type.');
end
if ~right.isInlet
error('Right inlet object of wrong type.');
end
if ~ischar(oxidizer)
error('Oxidizer name must be of format character.');
end
%% Get the density of both fuel and oxidizer streams.
% To be used in determining velocity of each stream. Also get the
% temperature of both inlet streams.
rhof = tp_f.D;
rho0 = tp_o.D;
tf = left.T;
tox = right.T;
%% Find the species index of the oxidizer.
% To be used in determining initial strain rate.
ioxidizer = tp_o.speciesIndex(oxidizer);
%% Calculate the stoichiometric mixture fraction.
% Needed for determining location of flame edges and composition.
% elMoles function used to calculate the number of moles of C, H, and O
% atoms in the fuel and oxidizer streams:
%
% elMoles = elementalMassFraction/element atomic weight.
%
% From this, the stoichiometric Air/Fuel ratio can be determined.
% 1 Mole of O needs 2 Moles of C and 0.5 Moles of H for stoichiometric
% conditions. The stoichiometric mixture fraction, Zst, is then
% calculated.
sFuel = elMoles(tp_f, 'O') - 2 * elMoles(tp_f, 'C') - 0.5 * elMoles(tp_f, 'H');
sOx = elMoles(tp_o, 'O') - 2 * elMoles(tp_o, 'C') - 0.5 * elMoles(tp_o, 'H');
phi = sFuel / sOx;
zst = 1.0 / (1.0 - phi);
%% Compute the stoichiometric mass fractions of each species.
% Use this to set the fuel gas object and calculate adiabatic flame
% temperature and equilibrium composition.
spec = tp_f.speciesNames; % Get all of the species names in gas object.
nsp = tp_f.nSpecies; % Get total number of species in gas object.
% Get the current mass fractions of both fuel and inlet streams.
yox = tp_o.Y;
yf = tp_f.Y;
ystoich_double = zeros(1, nsp); % Create empty vector for stoich mass frac.
for n = 1:nsp
% Calculate stoichiometric mass fractions.
ystoich_double(n) = zst * yf(n) + (1.0 - zst) * yox(n);
% Convert mass fraction vector to string vector.
ystoich_str{n} = num2str(ystoich_double(n));
% Convert string vector to cell with SPECIES:MASS FRACTION format.
y_stoich{n} = [spec{n}, ':', ystoich_str{n}];
end
% Initialize stoichiometric mass fraction cell with first SP:Y value.
ystoich = [y_stoich{1}];
for i = 2:nsp
% Update cell to have format similar to N2:Yst,O2:Yst,...
ystoich = [ystoich ',', y_stoich{i}];
end
% Set the fuel gas object as stoichiometric values and use equilibrate
% function to determine stoichiometric equilibrium temperature and mass
% fractions.
tp_f.TPY = {tf, tp_f.P, ystoich};
tp_f.equilibrate('HP');
teq = tp_f.T;
yeq = tp_f.Y;
%% Estimate the strain rate.
% Based on the inlet stream velocities and determine initial 'guess'
% for mixture fraction based on mass flux ratio.
zz = flow.gridPoints;
dz = zz(end) - zz(1);
mdotl = left.massFlux;
mdotr = right.massFlux;
uleft = mdotl / rhof;
uright = mdotr / rho0;
a = (abs(uleft) + abs(uright)) / dz;
diff = tp_f.mixDiffCoeffs;
f = sqrt(a / (2.0 * diff(ioxidizer)));
x0num = sqrt(uleft * mdotl) * dz;
x0den = sqrt(uleft * mdotr) + sqrt(uright * mdotr);
x0 = x0num / x0den;
%% Calculate initial values of temperature and mass fractions.
% These values to be used for energy equation solution. Method is based
% on the Burke-Schumann model.
nz = flow.nPoints;
zm = zeros(1, nz);
u = zeros(1, nz);
v = zeros(1, nz);
y = zeros(nz, nsp);
t = zeros(1, nz);
for j = 1:nz
x = zz(j);
zeta = f * (x - x0);
zmix = 0.5 * (1.0 - erf(zeta)); % Mixture fraction in flame.
zm(j) = zmix;
u(j) = a * (x0 - zz(j)); % Axial velocity.
v(j) = a; % Radial velocity.
if zmix > zst
for n = 1:nsp
y(j, n) = yeq(n) + (zmix - zst) * (yf(n) - yeq(n)) / (1.0 - zst);
%% Check input parameters
if nargin ~= 6
error('CounterFlowDiffusionFlame expects six input arguments.');
end
t(j) = teq + (tf - teq) * (zmix - zst) / (1.0 - zst);
else
for n = 1:nsp
y(j, n) = yox(n) + zmix * (yeq(n) - yox(n)) / zst;
if ~tp_f.isIdealGas
error('Fuel gas object must represent an ideal gas mixture.');
end
if ~tp_o.isIdealGas
error('Oxidizer gas object must represent an ideal gas mixture.');
end
if ~left.isInlet
error('Left inlet object of wrong type.');
end
if ~flow.isFlow
error('Flow object of wrong type.');
end
if ~right.isInlet
error('Right inlet object of wrong type.');
end
if ~ischar(oxidizer)
error('Oxidizer name must be of format character.');
end
%% Define elMoles function
function moles = elMoles(tp, element)
% Determine the elemental moles in a gas object per unit mass.
% Check input parameters
if nargin ~= 2
error('elMoles expects two input arguments.');
end
if ~tp.isIdealGas
error('Gas object must represent an ideal gas mixture.');
end
if ~ischar(element)
error('Element name must be of format character.');
end
% Calculate the moles per mass of mixture of an element within a gas
% object. The equation used is:
%
% elMoles = elMassFrac/Mel
%
% where elMassFrac is the elemental mass fraction within the gas object
% using the elementalMassFraction function; Mel is the atomic mass of
% the element.
elMassFrac = tp.elementalMassFraction(element);
eli = tp.elementIndex(element);
M = tp.atomicMasses;
Mel = M(eli);
moles = elMassFrac / Mel;
end
%% Get the density of both fuel and oxidizer streams.
% To be used in determining velocity of each stream. Also get the
% temperature of both inlet streams.
rhof = tp_f.D;
rho0 = tp_o.D;
tf = left.T;
tox = right.T;
%% Find the species index of the oxidizer.
% To be used in determining initial strain rate.
ioxidizer = tp_o.speciesIndex(oxidizer);
%% Calculate the stoichiometric mixture fraction.
% Needed for determining location of flame edges and composition.
% elMoles function used to calculate the number of moles of C, H, and O
% atoms in the fuel and oxidizer streams:
%
% elMoles = elementalMassFraction/element atomic weight.
%
% From this, the stoichiometric Air/Fuel ratio can be determined.
% 1 Mole of O needs 2 Moles of C and 0.5 Moles of H for stoichiometric
% conditions. The stoichiometric mixture fraction, Zst, is then
% calculated.
sFuel = elMoles(tp_f, 'O') - 2 * elMoles(tp_f, 'C') - ...
0.5 * elMoles(tp_f, 'H');
sOx = elMoles(tp_o, 'O') - 2 * elMoles(tp_o, 'C') - ...
0.5 * elMoles(tp_o, 'H');
phi = sFuel / sOx;
zst = 1.0 / (1.0 - phi);
%% Compute the stoichiometric mass fractions of each species.
% Use this to set the fuel gas object and calculate adiabatic flame
% temperature and equilibrium composition.
spec = tp_f.speciesNames; % Get all of the species names in gas object.
nsp = tp_f.nSpecies; % Get total number of species in gas object.
% Get the current mass fractions of both fuel and inlet streams.
yox = tp_o.Y;
yf = tp_f.Y;
ystoich_double = zeros(1, nsp); % Create empty vector for stoich mass frac.
for n = 1:nsp
% Calculate stoichiometric mass fractions.
ystoich_double(n) = zst * yf(n) + (1.0 - zst) * yox(n);
% Convert mass fraction vector to string vector.
ystoich_str{n} = num2str(ystoich_double(n));
% Convert string vector to cell with SPECIES:MASS FRACTION format.
y_stoich{n} = [spec{n}, ':', ystoich_str{n}];
end
% Initialize stoichiometric mass fraction cell with first SP:Y value.
ystoich = [y_stoich{1}];
for i = 2:nsp
% Update cell to have format similar to N2:Yst,O2:Yst,...
ystoich = [ystoich ',', y_stoich{i}];
end
% Set the fuel gas object as stoichiometric values and use equilibrate
% function to determine stoichiometric equilibrium temperature and mass
% fractions.
tp_f.TPY = {tf, tp_f.P, ystoich};
tp_f.equilibrate('HP');
teq = tp_f.T;
yeq = tp_f.Y;
%% Estimate the strain rate.
% Based on the inlet stream velocities and determine initial 'guess'
% for mixture fraction based on mass flux ratio.
zz = flow.gridPoints;
dz = zz(end) - zz(1);
mdotl = left.massFlux;
mdotr = right.massFlux;
uleft = mdotl / rhof;
uright = mdotr / rho0;
a = (abs(uleft) + abs(uright)) / dz;
diff = tp_f.mixDiffCoeffs;
f = sqrt(a / (2.0 * diff(ioxidizer)));
x0num = sqrt(uleft * mdotl) * dz;
x0den = sqrt(uleft * mdotr) + sqrt(uright * mdotr);
x0 = x0num / x0den;
%% Calculate initial values of temperature and mass fractions.
% These values to be used for energy equation solution. Method is based
% on the Burke-Schumann model.
nz = flow.nPoints;
zm = zeros(1, nz);
u = zeros(1, nz);
v = zeros(1, nz);
y = zeros(nz, nsp);
t = zeros(1, nz);
for j = 1:nz
x = zz(j);
zeta = f * (x - x0);
zmix = 0.5 * (1.0 - erf(zeta)); % Mixture fraction in flame.
zm(j) = zmix;
u(j) = a * (x0 - zz(j)); % Axial velocity.
v(j) = a; % Radial velocity.
if zmix > zst
for n = 1:nsp
y(j, n) = yeq(n) + (zmix - zst) * (yf(n) - yeq(n)) /...
(1.0 - zst);
end
t(j) = teq + (tf - teq) * (zmix - zst) / (1.0 - zst);
else
for n = 1:nsp
y(j, n) = yox(n) + zmix * (yeq(n) - yox(n)) / zst;
end
t(j) = tox + zmix * (teq - tox) / zst;
end
end
zrel = zz / dz;
%% Create the flame stack.
% Set the profile of the flame with the estimated axial velocities,
% radial velocities, temperature, and mass fractions calculated above.
flame@Sim1D({left flow right});
flame.setProfile(2, {'velocity', 'spread_rate'}, [zrel; u; v]);
flame.setProfile(2, 'T', [zrel; t]);
for n = 1:nsp
nm = tp_f.speciesName(n);
flame.setProfile(2, nm, [zrel; transpose(y(:, n))]);
end
t(j) = tox + zmix * (teq - tox) / zst;
end
end
zrel = zz / dz;
%% Create the flame stack.
% Set the profile of the flame with the estimated axial velocities,
% radial velocities, temperature, and mass fractions calculated above.
flame = Sim1D([left flow right]);
flame.setProfile(2, {'velocity', 'spread_rate'}, [zrel; u; v]);
flame.setProfile(2, 'T', [zrel; t]);
for n = 1:nsp
nm = tp_f.speciesName(n);
flame.setProfile(2, nm, [zrel; transpose(y(:, n))])
end
end
%% Define elMoles function
function moles = elMoles(tp, element)
% Determine the elemental moles in a gas object per unit mass.
% Check input parameters
if nargin ~= 2
error('elMoles expects two input arguments.');
end
if ~tp.isIdealGas
error('Gas object must represent an ideal gas mixture.');
end
if ~ischar(element)
error('Element name must be of format character.');
end
% Calculate the moles per mass of mixture of an element within a gas
% object. The equation used is:
%
% elMoles = elMassFrac/Mel
%
% where elMassFrac is the elemental mass fraction within the gas object
% using the elementalMassFraction function; Mel is the atomic mass of
% the element.
elMassFrac = tp.elementalMassFraction(element);
eli = tp.elementIndex(element);
M = tp.atomicMasses;
Mel = M(eli);
moles = elMassFrac / Mel;
end

View File

@ -1,7 +1,7 @@
classdef Domain1D < handle
% Domain1D Class
% Domain1D Class ::
%
% d = Domain1D(a, b)
% >> d = Domain1D(a, b)
%
% :param a:
% String type of domain. Possible values are:
@ -122,10 +122,13 @@ classdef Domain1D < handle
methods
%% Domain1D Class Constructor.
function d = Domain1D(a, b)
function d = Domain1D(varargin)
% Create a :mat:class:`Domain1D` object.
checklib;
if nargin == 1
a = varargin{1};
if strcmp(a, 'Inlet1D')
d.domainID = callct('inlet_new');
@ -142,7 +145,9 @@ classdef Domain1D < handle
end
elseif nargin == 2
% a stagnation flow
a = varargin{1};
b = varargin{2};
if strcmp(a, 'StagnationFlow')
if isa(b, 'Solution')
@ -183,7 +188,7 @@ classdef Domain1D < handle
%% Domain1D Class Destructor
function delete(d)
% Delete the C++ Domain1D object.
% Delete the :mat:class:`Domain1D` object.
callct('domain_del', d.domainID);
end

View File

@ -1,7 +1,7 @@
classdef FreeFlame < Domain1D
% Create a freely-propagating flat flame.
% Create a freely-propagating flat flame. ::
%
% m = FreeFlame(gas, id)
% >> m = FreeFlame(gas, id)
%
% :param gas:
% Instance of class :mat:class:`Solution`
@ -13,10 +13,10 @@ classdef FreeFlame < Domain1D
%
methods
% Constructor
function m = FreeFlame(gas, id)
% Constructor
m = m@Domain1D('StagnationFlow', gas, 2);
m@Domain1D('StagnationFlow', gas, 2);
if nargin == 1
m.setID('flame');

View File

@ -1,7 +1,7 @@
classdef Inlet < Domain1D
% Create an inlet domain.
% Create an inlet domain. ::
%
% m = Inlet(id)
% >> m = Inlet(id)
%
% Note that an inlet can only be a terminal domain - it must be
% either the leftmost or rightmost domain in a stack.
@ -14,10 +14,10 @@ classdef Inlet < Domain1D
methods
% Constructor
function m = Inlet(id)
% Constructor
m = m@Domain1D('Inlet1D');
m@Domain1D('Inlet1D');
if nargin == 0
m.setID('inlet');

View File

@ -1,7 +1,7 @@
classdef Outlet < Domain1D
% Create an outlet domain.
% Create an outlet domain. ::
%
% m = Outlet(id)
% >> m = Outlet(id)
%
% :param id:
% String ID of the outlet.
@ -11,10 +11,10 @@ classdef Outlet < Domain1D
methods
% Constructor
function m = Outlet(id)
% Constructor
m = m@Domain1D('Outlet1D');
m@Domain1D('Outlet1D');
if nargin == 0
m.setID('outlet');

View File

@ -1,7 +1,7 @@
classdef OutletRes < Domain1D
% Create an outlet reservoir domain.
% Create an outlet reservoir domain. ::
%
% m = OutletRes(id)
% >> m = OutletRes(id)
%
% :param id:
% String ID of the outlet reservoir.
@ -11,10 +11,10 @@ classdef OutletRes < Domain1D
methods
% Constructor
function m = OutletRes(id)
% Constructor
m = m@Domain1D('OutletRes');
m@Domain1D('OutletRes');
if nargin == 0
m.setID('outletres');

View File

@ -1,7 +1,7 @@
classdef Sim1D < handle
% Sim1D Class
% Sim1D Class. ::
%
% s = Sim1D(domains)
% >> s = Sim1D(domains)
%
% A Sim1D object is a container for one-dimensional domains,
% which are instances of class Domain1D. The domains are of two
@ -10,9 +10,9 @@ classdef Sim1D < handle
% See also: :mat:class:`Domain1D`
%
% :param domains:
% Vector of domain instances
% Cell array of instances of :mat:class:`Domain1D` and its subclasses.
% :return:
% Instance of class :mat:class:`Sim1D`
% Instance of class :mat:class:`Sim1D`.
%
properties (SetAccess = immutable)
@ -24,9 +24,12 @@ classdef Sim1D < handle
end
methods
%% Sim1D Class Constructor
function s = Sim1D(domains)
% Create a :mat:class:`Sim1D` object.
checklib;
s.stID = -1;
@ -41,7 +44,7 @@ classdef Sim1D < handle
ids = zeros(1, nd);
for n = 1:nd
ids(n) = domains(n).domainID;
ids(n) = domains{n}.domainID;
end
s.stID = callct('sim1D_new', nd, ids);
@ -51,7 +54,7 @@ classdef Sim1D < handle
%% Sim1D Class Destructor
function delete(s)
% Delete the C++ Sim1D object.
% Delete the :mat:class:`Sim1D` object.
callct('sim1D_del', s.stID);
end
@ -83,7 +86,7 @@ classdef Sim1D < handle
%
n = s.stackIndex(domain);
d = s.domains(n);
d = s.domains{n};
z = d.gridPoints;
x = s.solution(domain, component);
plot(z, x);
@ -162,7 +165,7 @@ classdef Sim1D < handle
%
idom = s.stackIndex(domain);
d = s.domains(idom);
d = s.domains{idom};
np = d.nPoints;
if nargin == 3
@ -275,7 +278,7 @@ classdef Sim1D < handle
% The grid in domain name
n = s.stackIndex(name);
d = s.domains(n);
d = s.domains{n};
z = d.gridPoints;
end
@ -298,7 +301,7 @@ classdef Sim1D < handle
end
idom = s.stackIndex(domain);
d = s.domains(idom);
d = s.domains{idom};
nc = d.nComponents;
np = d.nPoints;
@ -428,7 +431,7 @@ classdef Sim1D < handle
n = s.domainIndex(name);
end
d = s.domains(n);
d = s.domains{n};
if isa(comp, 'double') || isa(comp, 'cell')
c = comp;

View File

@ -1,7 +1,7 @@
classdef Surface < Domain1D
% Create a surface domain.
% Create a surface domain. ::
%
% m = Surface(id, surface_mech)
% >> m = Surface(id, surface_mech)
%
% :param id:
% String ID of surface
@ -15,17 +15,16 @@ classdef Surface < Domain1D
methods
% Constructor
function m = Surface(id, surface_mech)
% Constructor
if nargin > 1
m = m@Domain1D('ReactingSurface', surface_mech);
m.setID(id);
return
if nargin < 2
param = {'Surf1D'};
else
param = {'ReactingSurface', surface_mech};
end
m = m@Domain1D('Surf1D');
m@Domain1D(param{:});
if nargin == 0
m.setID('surface');
elseif nargin == 1

View File

@ -1,7 +1,7 @@
classdef SymmPlane < Domain1D
% Create a symmetry plane domain.
% Create a symmetry plane domain. ::
%
% m = SymmPlane(id)
% >> m = SymmPlane(id)
%
% :param id:
% String ID of the symmetry plane.
@ -11,10 +11,10 @@ classdef SymmPlane < Domain1D
methods
% Constructor
function m = SymmPlane(id)
% Constructor
m = Domain1D(Symm1D);
m@Domain1D('Symm1D');
if nargin == 0
m.setID('symmetry_plane');

View File

@ -1,7 +1,7 @@
function c = CarbonDioxide()
% Return an object representing carbon dioxide.
% Return an object representing carbon dioxide. ::
%
% c = CarbonDioxide
% >> c = CarbonDioxide
%
% The object returned by this method implements an accurate equation of
% state for carbon dioxide that can be used in the liquid, vapor, saturated

View File

@ -1,7 +1,7 @@
function h = HFC134a()
% Return an object representing refrigerant HFC134a.
% Return an object representing refrigerant HFC134a. ::
%
% h = HFC134a()
% >> h = HFC134a()
%
% The object returned by this method implements an accurate equation of
% state for refrigerant HFC134a (R134a) that can be used in the liquid,

View File

@ -1,7 +1,7 @@
function h = Heptane
% Return an object representing n-heptane.
% Return an object representing n-heptane. ::
%
% h = Heptane()
% >> h = Heptane()
%
% The object returned by this method implements an accurate equation of
% state for n-heptane that can be used in the liquid, vapor, saturated

View File

@ -1,7 +1,7 @@
function h = Hydrogen()
% Return an object representing hydrogen.
% Return an object representing hydrogen. ::
%
% h = Hydrogen()
% >> h = Hydrogen()
%
% The object returned by this method implements an accurate equation of
% state for hydrogen that can be used in the liquid, vapor, saturated

View File

@ -1,7 +1,7 @@
classdef Interface < handle & ThermoPhase & Kinetics
% Interface Class
% Interface Class ::
%
% s = Interface(src, id, p1, p2, p3, p4)
% >> s = Interface(src, id, p1, p2, p3, p4)
%
% See `ideal-surface <https://cantera.org/documentation/docs-2.6/sphinx/html/yaml/phases.html#sec-yaml-ideal-surface>`__
% and `Declaring adjacent phases <https://cantera.org/tutorials/yaml/phases.html#declaring-adjacent-phases>`__.
@ -38,7 +38,8 @@ classdef Interface < handle & ThermoPhase & Kinetics
%% Interface Class Constructor
function s = Interface(src, id, p1, p2, p3, p4)
% Interface class constructor
% Create an :mat:class:`Interface` object.
checklib;
t = ThermoPhase(src, id);

View File

@ -73,16 +73,17 @@ classdef Kinetics < handle
%% Kinetics Class Constructor
function kin = Kinetics(ph, src, id, n1, n2, n3, n4)
% Kinetics Class
% Kinetics Class ::
%
% k = Kinetics(ph, neighbor1, neighbor2, neighbor3, neighbor4)
% >> k = Kinetics(ph, neighbor1, neighbor2, neighbor3, neighbor4)
%
% Class Kinetics represents kinetics managers, which are classes that manage
% reaction mechanisms. The reaction mechanism attributes are specified in a YAML file.
% reaction mechanisms. The reaction mechanism attributes are specified in a
% YAML file.
%
% Instances of class :mat:class:`Kinetics` are responsible for evaluating reaction rates
% of progress, species production rates, and other quantities pertaining to
% a reaction mechanism.
% Instances of class :mat:class:`Kinetics` are responsible for evaluating
% reaction rates of progress, species production rates, and other
% quantities pertaining to a reaction mechanism.
%
% :param ph:
% An instance of class :mat:class:`ThermoPhase` representing the phase
@ -92,20 +93,21 @@ classdef Kinetics < handle
% :param id:
% ID of the phase to import as specified in the input file. (optional)
% :param neighbor1:
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution` representing a
% neighboring phase.
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution`
% representing a neighboring phase.
% :param neighbor2:
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution` representing a
% neighboring phase.
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution`
% representing a neighboring phase.
% :param neighbor3:
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution` representing a
% neighboring phase.
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution`
% representing a neighboring phase.
% :param neighbor4:
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution` representing a
% neighboring phase.
% Instance of class :mat:class:`ThermoPhase` or :mat:class:`Solution`
% representing a neighboring phase.
% :return:
% Instance of class :mat:class:`Kinetics`
%
checklib;
% indices for bulk phases in a heterogeneous mechanism
@ -145,7 +147,7 @@ classdef Kinetics < handle
%% Kinetics Class Destructor
function delete(kin)
% Delete the kernel object
% Delete the :mat:class:`Kinetics` object.
callct('kin_del', kin.kinID);
end

View File

@ -1,7 +1,7 @@
function m = Methane()
% Return an object representing methane.
% Return an object representing methane. ::
%
% m = Methane()
% >> m = Methane()
%
% The object returned by this method implements an accurate equation of
% state for methane that can be used in the liquid, vapor, saturated

View File

@ -1,7 +1,7 @@
function n = Nitrogen()
% Return an object representing nitrogen.
% Return an object representing nitrogen. ::
%
% n = Nitrogen()
% >> n = Nitrogen()
%
% The object returned by this method implements an accurate equation of
% state for nitrogen that can be used in the liquid, vapor, saturated

View File

@ -1,7 +1,7 @@
function o = Oxygen()
% Return an object representing oxygen.
% Return an object representing oxygen. ::
%
% o = Oxygen()
% >> o = Oxygen()
%
% The object returned by this method implements an accurate equation of
% state for oxygen that can be used in the liquid, vapor, saturated

View File

@ -1,7 +1,7 @@
classdef Solution < handle & ThermoPhase & Kinetics & Transport
% Solution Class
% Solution Class ::
%
% s = Solution(src, id, trans)
% >> s = Solution(src, id, trans)
%
% Class :mat:class:`Solution` represents solutions of multiple species. A
% solution is defined as a mixture of two or more constituents
@ -54,6 +54,8 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
%% Solution Class Constructor
function s = Solution(src, id, trans)
% Create a :mat:class:`Solution` object.
checklib;
if nargin < 2 || nargin > 3
@ -77,7 +79,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
%% Solution Class Destructor
function delete(s)
% Delete the kernel objects associated with a Solution.
% Delete :mat:class:`Solution` object.
disp('Solution class object has been deleted');
end

View File

@ -1,14 +1,14 @@
classdef ThermoPhase < handle
% ThermoPhase Class
% ThermoPhase Class ::
%
% t = ThermoPhase(src, id)
% >> t = ThermoPhase(src, id)
%
% :param src:
% Input string of YAML file name.
% :param id:
% ID of the phase to import as specified in the input file.
% :return:
% Instance of class :mat:class:`ThermoPhase`
% Instance of class :mat:class:`ThermoPhase`.
%
properties (SetAccess = public)
@ -251,6 +251,7 @@ classdef ThermoPhase < handle
%% ThermoPhase Class Constructor
function tp = ThermoPhase(src, id)
% Create a :mat:class:`ThermoPhase` object.
checklib;
if nargin ~= 2
@ -264,7 +265,7 @@ classdef ThermoPhase < handle
%% ThermoPhase Class Destructor
function tpClear(tp)
% Delete the ThermoPhase object.
% Delete the :mat:class:`ThermoPhase` object.
callct('thermo_del', tp.tpID);
end

View File

@ -30,12 +30,12 @@ classdef Transport < handle
%% Transport Class Constructor
function tr = Transport(tp, model, loglevel)
% Transport Class
% Transport Class ::
%
% tr = Transport(r, th, model, loglevel)
% >> tr = Transport(r, th, model, loglevel)
%
% Create a new instance of class :mat:class:`Transport`. One to three arguments
% may be supplied. The first must be an instance of class
% Create a new instance of class :mat:class:`Transport`. One to three
% arguments may be supplied. The first must be an instance of class
% :mat:class:`ThermoPhase`. The second (optional) argument is the type of
% model desired, specified by the string ``'default'``, ``'Mix'`` or
% ``'Multi'``. ``'default'`` uses the default transport specified in the
@ -50,8 +50,9 @@ classdef Transport < handle
% :param loglevel:
% Level of diagnostic logging. Default if not specified is 4.
% :return:
% Instance of class :mat:class:`Transport`
% Instance of class :mat:class:`Transport`.
%
checklib;
tr.trID = 0;
@ -82,7 +83,7 @@ classdef Transport < handle
%% Transport Class Destructor
function delete(tr)
% Delete the kernel object.
% Delete the :mat:class:`Transport` object.
callct('trans_del', tr.trID);
end

View File

@ -1,7 +1,7 @@
function w = Water()
% Return an object representing water.
% Return an object representing water. ::
%
% w = Water()
% >> w = Water()
%
% The object returned by this method implements an accurate equation of
% state for water that can be used in the liquid, vapor, saturated

View File

@ -1,6 +1,7 @@
function r = faradayconstant
% Get the Faraday constant in C/kmol of electron.
% r = faradayconstant
% Get the Faraday constant in C/kmol of electron. ::
%
% >> r = faradayconstant
%
% :return:
% The Faraday constant in C/kmol-e.

View File

@ -1,4 +1,10 @@
function r = gasconstant
% Universal gas constant in J/kmol-K.
% Get the universal gas constant in J/kmol-K. ::
%
% >> r = gasconstant
%
% :return:
% The universal gas constant in J/kmol-K.
%
r = 8314.4621;
end

View File

@ -1,4 +1,10 @@
function p = oneatm
% Get 1 atm in Pa.
% Get one atmosphere in Pa. ::
%
% >> p = oneatm
%
% :return:
% One atmosphere in Pascals.
%
p = 101325.0;
end

View File

@ -1,57 +1,4 @@
classdef Func < handle
% Func Class
%
% x = Func(typ, n, p)
%
% A class for functors.
% A functor is an object that behaves like a function. Cantera
% defines a set of functors to use to create arbitrary functions to
% specify things like heat fluxes, piston speeds, etc., in reactor
% network simulations. Of course, they can be used for other things
% too.
%
% The main feature of a functor class is that it overloads the ``()``
% operator to evaluate the function. For example, suppose object
% ``f`` is a functor that evaluates the polynomial :math:`2x^2 - 3x + 1`.
% Then writing ``f(2)`` would cause the method that evaluates the
% function to be invoked, and would pass it the argument ``2``. The
% return value would of course be 3.
%
% The types of functors you can create in Cantera are these:
%
% 1. A polynomial
% 2. A Fourier series
% 3. A sum of Arrhenius terms
% 4. A Gaussian.
%
% You can also create composite functors by adding, multiplying, or
% dividing these basic functors, or other composite functors.
%
% Note: this MATLAB class shadows the underlying C++ Cantera class
% "Func1". See the Cantera C++ documentation for more details.
%
% See also: :mat:class:`polynom`, :mat:class:`gaussian`, :mat:class:`fplus`,
% :mat:class:`frdivide`, :mat:class:`ftimes`
%
% :param typ:
% String indicating type of functor to create. Possible values are:
%
% * ``'polynomial'``
% * ``'fourier'``
% * ``'gaussian'``
% * ``'arrhenius'``
% * ``'sum'``
% * ``'diff'``
% * ``'ratio'``
% * ``'composite'``
% * ``'periodic'``
% :param n:
% Number of parameters required for the functor
% :param p:
% Vector of parameters
% :return:
% Instance of class :mat:class:`Func`
%
properties (SetAccess = immutable)
f1
@ -65,6 +12,59 @@ classdef Func < handle
%% Func Class Constructor
function x = Func(typ, n, p)
% Func Class ::
%
% >> x = Func(typ, n, p)
%
% A functor is an object that behaves like a function. Cantera
% defines a set of functors to use to create arbitrary functions to
% specify things like heat fluxes, piston speeds, etc., in reactor
% network simulations. Of course, they can be used for other things
% too.
%
% The main feature of a functor class is that it overloads the ``()``
% operator to evaluate the function. For example, suppose object
% ``f`` is a functor that evaluates the polynomial :math:`2x^2 - 3x + 1`.
% Then writing ``f(2)`` would cause the method that evaluates the
% function to be invoked, and would pass it the argument ``2``. The
% return value would of course be 3.
%
% The types of functors you can create in Cantera are these:
%
% 1. A polynomial
% 2. A Fourier series
% 3. A sum of Arrhenius terms
% 4. A Gaussian.
%
% You can also create composite functors by adding, multiplying, or
% dividing these basic functors, or other composite functors.
%
% Note: this MATLAB class shadows the underlying C++ Cantera class
% "Func1". See the Cantera C++ documentation for more details.
%
% See also: :mat:class:`polynom`, :mat:class:`gaussian`, :mat:class:`fplus`,
% :mat:class:`frdivide`, :mat:class:`ftimes`
%
% :param typ:
% String indicating type of functor to create. Possible values are:
%
% * ``'polynomial'``
% * ``'fourier'``
% * ``'gaussian'``
% * ``'arrhenius'``
% * ``'sum'``
% * ``'diff'``
% * ``'ratio'``
% * ``'composite'``
% * ``'periodic'``
% :param n:
% Number of parameters required for the functor
% :param p:
% Vector of parameters
% :return:
% Instance of class :mat:class:`Func`
%
checklib;
if ~isa(typ, 'char')
@ -77,8 +77,7 @@ classdef Func < handle
itype = -1;
function nn = newFunc(itype, n, p)
% helper function to pass the correct parameters to the C
% library
% helper function to pass the correct parameters to the C library.
if itype < 20
[msize, nsize] = size(p);
lenp = msize * nsize;
@ -135,7 +134,7 @@ classdef Func < handle
%% Func Class Destructor
function delete(f)
% Delete the C++ Func1 object.
% Delete the :mat:class:`Func` object.
callct('func_del', f.id);
end

View File

@ -1,7 +1,7 @@
function r = fplus(a, b)
% Get a functor representing the sum of two input functors.
classdef fplus < Func
% Fplus - Get a functor representing the sum of two input functors. ::
%
% r = fplus(a, b)
% >> f = fplus(a, b)
%
% :param a:
% Instance of class :mat:class:`Func`
@ -12,9 +12,10 @@ function r = fplus(a, b)
%
methods
% Constructor
function f = fplus(a, b)
f = f@Func('sum', a, b);
% Constructor
f@Func('sum', a, b);
end
end

View File

@ -1,7 +1,7 @@
function r = frdivide(a, b)
% Get a functor that is the ratio of the input functors.
classdef frdivide < Func
% Frdivide - Get a functor representing the ratio of two input functors. ::
%
% r = frdivide(a,b)
% >> f = frdivide(a, b)
%
% :param a:
% Instance of class :mat:class:`Func`
@ -12,9 +12,10 @@ function r = frdivide(a, b)
%
methods
% Constructor
function f = frdivide(a, b)
f = f@Func('ratio', a, b);
% Constructor
f@Func('ratio', a, b);
end
end

View File

@ -1,7 +1,7 @@
classdef ftimes < Func
% Ftimes - Get a functor representing the product of two input functors.
% Ftimes - Get a functor representing the product of two input functors. ::
%
% f = ftimes(a, b)
% >> f = ftimes(a, b)
%
% :param a:
% Instance of class :mat:class:`Func`
@ -12,9 +12,10 @@ classdef ftimes < Func
%
methods
% Constructor
function f = ftimes(a, b)
f = f@Func('prod', a, b);
% Constructor
f@Func('prod', a, b);
end
end

View File

@ -1,7 +1,7 @@
classdef gaussian < Func
% Gaussian - Create a Gaussian :mat:class:`Func` instance.
% Gaussian - Create a Gaussian :mat:class:`Func` instance. ::
%
% f = gaussian(peak, center, width)
% >> f = gaussian(peak, center, width)
%
% :param peak:
% The peak value
@ -16,9 +16,10 @@ classdef gaussian < Func
%
methods
% Constructor
function f = gaussian(peak, center, width)
f = f@Func('gaussian', 0, [peak, center, width]);
% Constructor
f@Func('gaussian', 0, [peak, center, width]);
end
end

View File

@ -1,7 +1,7 @@
classdef polynom < Func
% Polynom - Create a polynomial :mat:class:`Func` instance.
% Polynom - Create a polynomial :mat:class:`Func` instance. ::
%
% poly = polynom(coeffs)
% >> f = polynom(coeffs)
%
% The polynomial coefficients are specified by a vector
% ``[a0 a1 .... aN]``. Examples:
@ -18,18 +18,22 @@ classdef polynom < Func
%
methods
% Constructor
function f = polynom(coeffs)
% Constructor
[n m] = size(coeffs);
[n m] = size(coeffs);
if n == 1
p = m - 1;
elseif m == 1
p = n - 1;
else
error('wrong shape for coefficient array');
end
f@Func('polynomial', p, coeffs);
end
if n == 1
poly = Func('polynomial', m - 1, coeffs);
elseif m == 1
poly = Func('polynomial', n - 1, coeffs);
else
error('wrong shape for coefficient array');
end
end

View File

@ -1,7 +1,7 @@
classdef Mixture < handle
% Mixture Class.
% Mixture Class ::
%
% m = Mixture(phases)
% >> m = Mixture(phases)
%
% Class :mat:class:`Mixture` represents mixtures of one or more phases of matter.
% To construct a mixture, supply a cell array of phases and
@ -150,6 +150,8 @@ classdef Mixture < handle
%% Mixture Class Constructor
function m = Mixture(phases)
% Create a :mat:class:`Mixture` object.
checklib;
if nargin > 1
@ -189,7 +191,7 @@ classdef Mixture < handle
%% Mixture Class Destructor
function delete(m)
% Delete the MultiPhase object.
% Delete the :mat:class:`Mixture` object.
calllib(ct, 'mix_del', m.mixID);
end

View File

@ -1,7 +1,7 @@
classdef ConstPressureReactor < Reactor
% Create a constant pressure reactor object.
% Create a constant pressure reactor object. ::
%
% r = ConstPressureReactor(contents)
% >> r = ConstPressureReactor(contents)
%
% A :mat:class:`ConstPressureReactor` is an instance of class
% :mat:class:`Reactor` where the pressure is held constant. The volume
@ -23,13 +23,14 @@ classdef ConstPressureReactor < Reactor
methods
% Constructor
function r = ConstPressureReactor(contents)
% Constructor
if nargin == 0
contents = 0;
end
r = r@Reactor(contents, 'ConstPressureReactor');
r@Reactor(contents, 'ConstPressureReactor');
end
end

View File

@ -1,7 +1,7 @@
classdef FlowDevice < handle
% FlowDevice Class.
% FlowDevice Class ::
%
% x = FlowDevice(typ)
% >> x = FlowDevice(typ)
%
% Base class for devices that allow flow between reactors.
% :mat:class:`FlowDevice` objects are assumed to be adiabatic,
@ -30,7 +30,7 @@ classdef FlowDevice < handle
end
properties (SetAccess = protected)
properties (SetAccess = public)
%
% Upstream object of type :mat:class:`Reactor` or :mat:class:`Reservoir`.
upstream
@ -59,6 +59,8 @@ classdef FlowDevice < handle
%% FlowDevice Class Constructor
function x = FlowDevice(typ)
% Create a :mat:class:`FlowDevice` object.
checklib;
if nargin == 0
@ -74,7 +76,7 @@ classdef FlowDevice < handle
%% FlowDevice Class Destructor
function delete(f)
% Delete the specified flow device from memory.
% Delete the :mat:class:`FlowDevice` object.
callct('flowdev_del', f.id);
end

View File

@ -1,7 +1,7 @@
classdef FlowReactor < Reactor
% Create a flow reactor object.
% Create a flow reactor object. ::
%
% r = FlowReactor(contents)
% >> r = FlowReactor(contents)
%
% A reactor representing adiabatic plug flow in a constant-area
% duct. Examples:
@ -21,13 +21,14 @@ classdef FlowReactor < Reactor
methods
% Constructor
function r = FlowReactor(contents)
% Constructor
if nargin == 0
contents = 0;
end
r = r@Reactor(contents, 'FlowReactor');
r@Reactor(contents, 'FlowReactor');
end
end

View File

@ -1,7 +1,7 @@
classdef IdealGasConstPressureReactor < Reactor
% Create a constant pressure reactor with an ideal gas.
% Create a constant pressure reactor with an ideal gas. ::
%
% r = IdealGasConstPressureReactor(contents)
% >> r = IdealGasConstPressureReactor(contents)
%
% An IdealGasConstPressureReactor is an instance of class Reactor where the
% pressure is held constant. The volume is not a state variable, but
@ -25,13 +25,14 @@ classdef IdealGasConstPressureReactor < Reactor
methods
% Constructor
function r = IdealGasConstPressureReactor(contents)
% Constructor
if nargin == 0
contents = 0;
end
r = r@Reactor(contents, 'IdealGasConstPressureReactor');
r@Reactor(contents, 'IdealGasConstPressureReactor');
end
end

View File

@ -1,7 +1,7 @@
classdef IdealGasReactor < Reactor
% Create a reactor with an ideal gas.
% Create a reactor with an ideal gas. ::
%
% r = IdealGasReactor(contents)
% >> r = IdealGasReactor(contents)
%
% An IdealGasReactor is an instance of class Reactor where the governing
% equations are specialized for the ideal gas equation of state (and do not
@ -22,13 +22,14 @@ classdef IdealGasReactor < Reactor
methods
% Constructor
function r = IdealGasReactor(contents)
% Constructor
if nargin == 0
contents = 0;
end
r = r@Reactor(contents, 'IdealGasReactor');
r@Reactor(contents, 'IdealGasReactor');
end
end

View File

@ -1,7 +1,7 @@
classdef MassFlowController < FlowDevice
% Create a mass flow controller.
% Create a mass flow controller. ::
%
% m = MassFlowController(upstream, downstream)
% >> m = MassFlowController(upstream, downstream)
%
% Creates an instance of class :mat:class:`FlowDevice` configured to
% simulate a mass flow controller that maintains a constant mass flow
@ -23,10 +23,10 @@ classdef MassFlowController < FlowDevice
methods
% Constructor
function m = MassFlowController(upstream, downstream)
% Constructor
m = m@FlowDevice('MassFlowController');
m@FlowDevice('MassFlowController');
if nargin == 2
m.install(upstream, downstream)

View File

@ -1,7 +1,7 @@
classdef Reactor < handle
% Reactor Class
% Reactor Class ::
%
% r = Reactor(content, typ)
% >> r = Reactor(content, typ)
%
% A 'Reactor' object simulates a perfectly-stirred reactor. It
% has a time-dependent tstate, and may be coupled to other
@ -30,7 +30,7 @@ classdef Reactor < handle
end
properties (SetAccess = protected)
properties (SetAccess = public)
contents
%
@ -111,6 +111,8 @@ classdef Reactor < handle
%% Reactor Class Constructor
function r = Reactor(content, typ)
% Create a :mat:class:`Reactor` object.
checklib;
if nargin == 0
@ -126,8 +128,18 @@ classdef Reactor < handle
r.id = callct('reactor_new', typ);
if isa(content, 'Solution')
r.insert(content);
elseif ~(isa(contents, 'double') && contents == 0)
r.contents = content;
if ~isa(content, 'ThermoPhase')
error('Wrong object type');
end
callct('reactor_setThermoMgr', r.id, content.tpID);
if ~strcmp(r.type, 'Reservoir')
callct('reactor_setKineticsMgr', r.id, content.kinID);
end
elseif ~(isa(content, 'double') && content == 0)
error('Reactor contents must be an object of type "Solution"');
end
@ -136,7 +148,7 @@ classdef Reactor < handle
%% Reactor Class Destructor
function delete(r)
% Delete the Reactor object from memory.
% Delete the :mat:class:`Reactor` object.
callct('reactor_del', r.id);
end
@ -157,26 +169,6 @@ classdef Reactor < handle
callct('reactor_addSensitivityReaction', r.id, m);
end
function insert(r, gas)
% Insert a solution or mixture into a reactor.
%
% r.insert(gas)
%
% :param r:
% Instance of class 'Reactor'.
% :param gas:
% Instance of class 'Solution'.
%
r.contents = gas;
setThermoMgr(r, gas);
if ~strcmp(r.type, 'Reservoir')
setKineticsMgr(r, gas);
end
end
%% Reactor Get Methods
function temperature = get.T(r)
@ -272,48 +264,6 @@ classdef Reactor < handle
end
function setThermoMgr(r, t)
% Set the thermodynamics manager.
%
% r.setThermoMgr(t)
%
% This method is used internally during Reactor initialization,
% but is usually not called by users.
%
% :param r:
% Instance of class 'Reactor'.
% :param t:
% Instance of class 'ThermoPhase' or another object
% containing an instance of that class.
if ~isa(t, 'ThermoPhase')
error('Wrong object type');
end
callct('reactor_setThermoMgr', r.id, t.tpID);
end
function setKineticsMgr(r, k)
% Set the kinetics manager.
%
% r.setKineticsMgr(k)
%
% This method is used internally during Reactor initialization,
% but is usually not called by users.
%
% :param r:
% Instance of class 'Reactor'.
% :param t:
% Instance of class 'Kinetics' or another object
% containing an instance of that class.
if ~isa(k, 'Kinetics')
error('Wrong object type');
end
callct('reactor_setKineticsMgr', r.id, k.kinID);
end
end
end

View File

@ -1,7 +1,7 @@
classdef ReactorNet < handle
% ReactorNet class
% ReactorNet class ::
%
% r = ReactorNet(reacgtors)
% >> r = ReactorNet(reactors)
%
% A 'ReactorNet' object is a container that holds one or more
% 'Reactor' objects in a network. 'ReactorNet' objects are used
@ -59,6 +59,8 @@ classdef ReactorNet < handle
%% ReactorNet Class Constructor
function r = ReactorNet(reactors)
% Create a :mat:class:`ReactorNet` object.
checklib;
if nargin ~= 1
@ -77,7 +79,7 @@ classdef ReactorNet < handle
nr = length(reactors);
for i = 1:nr
r.addReactor(reactors{i});
callct('reactornet_addreactor', r.id, reactors{i}.id);
end
end
@ -85,27 +87,13 @@ classdef ReactorNet < handle
%% ReactorNet Class Destructor
function delete(r)
% Delete the ReactorNet object from the memory.
% Delete the :mat:class:`ReactorNet` object object.
callct('reactornet_del', r.id);
end
%% ReactorNet Utility Methods
function addReactor(net, reactor)
% Add a reactor to a network.
%
% net.addReactor(reactor)
%
% :param net:
% Instance of class 'ReactorNet'.
% :param reactor:
% Instance of class 'Solution'.
%
callct('reactornet_addreactor', net.id, reactor.id);
end
function advance(r, tout)
% Advance the state of the reactor network in time.
%

View File

@ -1,7 +1,7 @@
classdef ReactorSurface < handle
% ReactorSurface Class
% ReactorSurface Class ::
%
% s = ReactorSurface(kleft, reactor, area)
% >> s = ReactorSurface(surf, reactor, area)
%
% A surface on which heterogeneous reactions take place. The
% mechanism object (typically an instance of class 'Interface')
@ -14,7 +14,7 @@ classdef ReactorSurface < handle
% after initial construction by using the various methods of
% the 'ReactorSurface' class.
%
% :param kleft:
% :param surf:
% Surface reaction mechanisms for the left-facing surface.
% This must bean instance of class 'Kinetics', or of a class
% derived from 'Kinetics', such as 'Interface'.
@ -43,20 +43,29 @@ classdef ReactorSurface < handle
methods
%% ReactorSurface Class Constructor
function s = ReactorSurface(kleft, reactor, area)
function s = ReactorSurface(surf, reactor, area)
% Create a :mat:class:`ReactorSurface` object.
checklib;
s.surfID = callct('reactorsurface_new', 0);
s.reactor = -1;
if nargin >= 1
s.setKinetics(kleft);
ikin = 0;
if isa(surf, 'Kinetics')
ikin = surf.kinID;
end
callct('reactorsurface_setkinetics', s.surfID, ikin);
end
if nargin >= 2
if isa(reactor, 'Reactor')
s.install(reactor);
s.reactor = reactor;
callct('reactorsurface_install', s.surfID, reactor.id);
else
warning('Reactor was not installed due to incorrect type');
end
@ -78,26 +87,13 @@ classdef ReactorSurface < handle
%% ReactorSurface Class Destructor
function delete(s)
% Delete the ReactorSurface object from the memory.
% Delete the :mat:class:`ReactorSurface` object.
callct('reactorsurface_del', s.surfID);
end
%% ReactorSurface Utility Methods
function install(s, r)
% Install a ReactorSurface in a Reactor.
%
% s.install(r)
%
% :param r:
% Instance of class 'Reactor'.
%
s.reactor = r;
callct('reactorsurface_install', s.surfID, r.id);
end
function addSensitivityReaction(s, m)
% Specifies that the sensitivity of the state variables with
% respect to reaction m should be computed. The surface must be
@ -123,26 +119,6 @@ classdef ReactorSurface < handle
callct('reactorsurface_setArea', s.surfID, a);
end
function setKinetics(s, kin)
% Setthe surface reaction mechanism on a reactor surface.
%
% s.setKinetics(kin)
%
% :param kin:
% Instance of class 'Kinetics' (or another object derived
% from kin) to be used as the kinetic mechanism for this
% surface. Typically an instance of class 'Interface'.
%
ikin = 0;
if isa(kin, 'Kinetics')
ikin = kin.kinID;
end
callct('reactorsurface_setkinetics', s.surfID, ikin);
end
end
end

View File

@ -1,7 +1,7 @@
classdef Reservoir < Reactor
% Create a Reservoir object.
% Create a Reservoir object. ::
%
% r = Reservoir(contents)
% >> r = Reservoir(contents)
%
% A :mat:class:`Reservoir` is an instance of class :mat:class:`Reactor`
% configured so that its intensive state is constant in time. A
@ -28,13 +28,14 @@ classdef Reservoir < Reactor
methods
% Constructor
function r = Reservoir(contents)
% Constructor
if nargin == 0
contents = 0;
end
r = r@Reactor(contents, 'Reservoir');
r@Reactor(contents, 'Reservoir');
end
end

View File

@ -1,6 +1,8 @@
classdef Valve < FlowDevice
% Create a valve.
% v = Valve(upstream, downstream)
% Create a valve. ::
%
% >> v = Valve(upstream, downstream)
%
% Create an instance of class :mat:class:`FlowDevice` configured to
% simulate a valve that produces a flow rate proportional to the
% pressure difference between the upstream and downstream reactors.
@ -30,10 +32,10 @@ classdef Valve < FlowDevice
methods
% Constructor
function v = Valve(upstream, downstream)
% Constructor
v = v@FlowDevice('Valve');
v@FlowDevice('Valve');
if nargin == 2
v.install(upstream, downstream)

View File

@ -1,7 +1,7 @@
classdef Wall < handle
% Wall Class
% Wall Class ::
%
% x = Wall()
% >> x = Wall(l, r)
%
% A Wall separates two reactors, or a reactor and a reservoir.
% A Wall has a finite area, may conduct heat between the two
@ -34,6 +34,15 @@ classdef Wall < handle
% after initial construction by using the various methods of
% the 'Wall' class.
%
% :param l:
% Instance of class 'Reactor' to be used as the bulk phase
% on the left side of the wall.
% :param r:
% Instance of class 'Reactor' to be used as the bulk phase
% on the right side of the wall.
% :return:
% Instance of class 'Wall'.
%
properties (SetAccess = immutable)
@ -77,60 +86,44 @@ classdef Wall < handle
methods
%% Wall Class Constructor
function x = Wall()
function w = Wall(l, r)
% Create a :mat:class:`Wall` object.
checklib;
% At the moment, only one wall type is implemented
typ = 'Wall';
x.type = char(typ);
x.id = callct('wall_new', x.type);
w.type = char(typ);
w.id = callct('wall_new', w.type);
% Install the wall between left and right reactors
w.left = l;
w.right = r;
callct('wall_install', w.id, l.id, r.id);
% Set default values.
x.left = -1;
x.right = -1;
x.area = 1.0;
x.setExpansionRateCoeff(0.0);
x.setHeatTransferCoeff(0.0);
w.area = 1.0;
w.expansionRateCoeff = 0.0;
w.heatTransferCoeff = 0.0;
% Check whether the wall is ready.
ok = callct('wall_ready', w.id);
if ok
disp('The wall object is ready.');
else
error('The wall object is not ready.');
end
end
%% Wall Class Destructor
function delete(w)
% Clear the Wall object from the memory.
% Clear the :mat:class:`Wall` object.
callct('wall_del', w.id);
end
%% Wall Class Utility Methods
function install(w, l, r)
% Install a wall between two reactors.
%
% w.install(l, r)
%
% :param l:
% Instance of class 'Reactor' to be used as the bulk phase
% on the left side of the wall.
% :param r:
% Instance of class 'Reactor' to be used as the bulk phase
% on the right side of the wall.
w.left = l;
w.right = r;
callct('wall_install', w.id, l.id, r.id);
end
function ok = ready(w)
% Check whether a wall is ready.
%
% ok = w.ready
%
ok = callct('wall_ready', w.id);
end
%% ReactorNet get methods
function a = get.area(w)
@ -138,7 +131,7 @@ classdef Wall < handle
end
function q = qdot(w, t)
% Total heat transfer through a wall at a given time t.
% Total heat transfer rate through a wall at a given time t.
q = callct('wall_Q', w.id, t);
end

View File

@ -1,7 +1,7 @@
function v = canteraGitCommit()
% Get Cantera Git commit hash.
% Get Cantera Git commit hash. ::
%
% canteraGitCommit()
% >> canteraGitCommit()
%
% :return:
% A string containing the Git commit hash for the current version of Cantera.

View File

@ -1,7 +1,7 @@
function v = canteraVersion()
% Get Cantera version information.
% Get Cantera version information. ::
%
% canteraVersion()
% >> canteraVersion()
%
% :return:
% A string containing the Cantera version.

View File

@ -1,7 +1,7 @@
function d = getDataDirectories()
% Get a cell array of the directories searched for data files.
% Get a cell array of the directories searched for data files. ::
%
% getdatadirectories()
% >> getdatadirectories()
%
% Get a cell array of the directories Cantera searches for data files
%

View File

@ -18,7 +18,6 @@ help catcomb;
clear all
close all
clc
t0 = cputime; % record the starting time
@ -130,7 +129,7 @@ surf.T = tsurf;
% Once the component parts have been created, they can be assembled
% to create the 1D simulation.
stack = Sim1D([inlt, flow, surf]);
stack = Sim1D({inlt, flow, surf});
% set the initial profiles.
stack.setProfile(2, {'velocity', 'spread_rate', 'T'}, ...

View File

@ -14,12 +14,10 @@
%% Initialization
help diamond_cvd
clear all
close all
clc
help diamond_cvd
t0 = cputime; % record the starting time
%% Operation Parameters

View File

@ -10,7 +10,6 @@
clear all
close all
clc
tic % total running time of the script
help diff_flame

View File

@ -8,7 +8,6 @@ function equil(g)
clear all
close all
clc
tic
help equil

View File

@ -27,7 +27,7 @@ function f = flame(gas, left, flow, right)
end
% create the container object
f = Sim1D([left flow right]);
f = Sim1D({left flow right});
% set default initial profiles.
rho0 = gas.D;

View File

@ -9,7 +9,6 @@
clear all
close all
clc
tic
help flame1

View File

@ -8,7 +8,6 @@
clear all
close all
clc
tic
help flame2

View File

@ -9,7 +9,6 @@ function plotdata = ignite(g)
clear all
close all
clc
tic
help ignite

View File

@ -6,7 +6,6 @@ function ignite_hp(gas)
clear all
close all
clc
tic
help ignite_hp

View File

@ -6,7 +6,6 @@ function ignite_uv(gas)
clear all
close all
clc
tic
help ignite_uv

View File

@ -8,7 +8,6 @@ function isentropic(g)
clear all
close all
clc
tic
help isentropic

View File

@ -25,7 +25,6 @@
clear all
close all
clc
tic
help lithium_ion_battery

View File

@ -21,7 +21,6 @@ function periodic_cstr
clear all
close all
clc
tic
help periodic_cstr
@ -48,7 +47,7 @@ function periodic_cstr
% Set its volume to 10 cm^3. In this problem, the reactor volume is
% fixed, so the initial volume is the volume at all later times.
cstr.setInitialVolume(10.0 * 1.0e-6);
cstr.V = 10.0 * 1.0e-6;
% We need to have heat loss to see the oscillations. Create a
% reservoir to represent the environment, and initialize its
@ -60,10 +59,9 @@ function periodic_cstr
% coefficient. Larger U causes the reactor to be closer to isothermal.
% If U is too small, the gas ignites, and the temperature spikes and
% stays high.
w = Wall;
w.install(cstr, env);
w = Wall(cstr, env);
w.area = 1.0;
w.setHeatTransferCoeff(0.02);
w.heatTransferCoeff = 0.02;
% Connect the upstream reservoir to the reactor with a mass flow
% controller (constant mdot). Set the mass flow rate to 1.25 sccm.
@ -72,7 +70,7 @@ function periodic_cstr
mdot = gas.D * vdot; % kg/s
mfc = MassFlowController;
mfc.install(upstream, cstr);
mfc.setMassFlowRate(mdot);
mfc.massFlowRate = mdot;
% now create a downstream reservoir to exhaust into.
downstream = Reservoir(gas);
@ -82,7 +80,7 @@ function periodic_cstr
% close to the downstream pressure of 60 Torr.
v = Valve;
v.install(cstr, downstream);
v.setValveCoeff(1.0e-9);
v.valveCoeff = 1.0e-9;
% create the network
network = ReactorNet({cstr});

View File

@ -26,7 +26,6 @@
clear all
close all
clc
tic
help plug_flow_reactor

View File

@ -9,7 +9,6 @@ function prandtl1(g)
clear all
close all
clc
tic
help prandtl1

View File

@ -8,7 +8,6 @@ function prandtl2(g)
clear all
close all
clc
tic
help prandtl2

View File

@ -21,23 +21,19 @@ basis = 'mass';
w.setState_Tsat(t1, 1.0);
h1 = w.H;
p1 = w.P;
w
% pump it to p2
pump_work = pump(w, p_max, eta_pump);
h2 = w.H;
w
% heat to saturated vapor
w.setState_Psat(p_max, 1.0);
h3 = w.H;
w
heat_added = h3 - h2;
% expand adiabatically back to the initial pressure
turbine_work = expand(w, p1, eta_turbine);
w
% compute the efficiency
efficiency = (turbine_work - pump_work) / heat_added;

View File

@ -9,7 +9,6 @@ function reactor1(g)
clear all
close all
clc
tic
help reactor1
@ -42,11 +41,10 @@ function reactor1(g)
% Define a wall between the reactor and the environment and
% make it flexible, so that the pressure in the reactor is held
% at the environment pressure.
w = Wall;
w.install(r, env);
w = Wall(r, env);
% set expansion parameter. dV/dt = KA(P_1 - P_2)
w.setExpansionRateCoeff(1.0e6);
w.expansionRateCoeff = 1.0e6;
% set wall area
w.area = 1.0;

View File

@ -9,7 +9,6 @@ function reactor2(g)
clear all
close all
clc
tic
help reactor2

View File

@ -9,7 +9,6 @@
clear all
close all
clc
tic
help surfreactor
@ -32,7 +31,7 @@ nSurfSp = surf.nSpecies;
% create a reactor, and insert the gas
r = IdealGasReactor(gas);
r.setInitialVolume(1.0e-6)
r.V = 1.0e-6;
% create a reservoir to represent the environment
a = Solution('air.yaml', 'air', 'None');
@ -42,8 +41,7 @@ env = Reservoir(a);
% Define a wall between the reactor and the environment and
% make it flexible, so that the pressure in the reactor is held
% at the environment pressure.
w = Wall;
w.install(r, env);
w = Wall(r, env);
A = 1e-4; % Wall area
@ -52,10 +50,10 @@ rsurf = ReactorSurface(surf, r, A);
% set the wall area and heat transfer coefficient.
w.area = A;
w.setHeatTransferCoeff(1.0e1); % W/m2/K
w.heatTransferCoeff = 1.0e1; % W/m2/K
% set expansion rate parameter. dV/dt = KA(P_1 - P_2)
w.setExpansionRateCoeff(1.0);
w.expansionRateCoeff = 1.0;
network = ReactorNet({r});
% setTolerances(network, 1.0e-8, 1.0e-12);

View File

@ -19,9 +19,13 @@ flame1;
flame2;
catcomb;
diff_flame;
ignite;
ignite_hp;
ignite_uv;
diamond_cvd;
clear all
close all
UnloadCantera
disp('Test example run successful.')