Fixed all docstring issues.

This commit is contained in:
ssun30 2022-09-16 10:54:24 -04:00 committed by Ray Speth
parent 83596b7611
commit 9c87e5d571
30 changed files with 995 additions and 2058 deletions

View File

@ -20,12 +20,22 @@ classdef Domain1D < handle
% all other valid values of ``a``.
%
properties
properties (SetAccess = immutable)
domainID % ID of the domain
type % Type of the domain
end
properties (SetAccess = public)
T % Boundary Temperature. Units: K.
P % Boundary Pressure. Units: Pa.
bounds
end
properties (SetAccess = protected)
% Get the (lower, upper) bounds for a solution component.
%
% b = d.bounds(componoent)
@ -35,8 +45,8 @@ classdef Domain1D < handle
% returned.
% :return:
% 1x2 Vector of the lower and upper bounds.
bounds
%
componentIndex
% Index of a component given its name.
%
% n = d.componentIndex(name)
@ -48,8 +58,8 @@ classdef Domain1D < handle
% is passed, it will be returned.
% :return:
% Index of the component, or input numeric value.
componentIndex
%
componentName
% Name of a component given its index.
%
% n = d.componentName(index)
@ -61,8 +71,8 @@ classdef Domain1D < handle
% to get.
% :return:
% Cell array of component names.
componentName
%
domainIndex
% Domain index.
%
% i = d.domainIndex
@ -72,8 +82,8 @@ classdef Domain1D < handle
% :return:
% Integer flag denoting the location of the domain,
% beginning with 1 at the left.
domainIndex
%
domainType
% Type of the domain.
%
% i = d.domainType
@ -82,8 +92,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% Integer flag denoting the domain type.
domainType
%
gridPoints
% Grid points from a domain.
%
% zz = d.gridPoints(n)
@ -94,8 +104,8 @@ classdef Domain1D < handle
% Optional, vector of grid points to be retrieved.
% :return:
% Vector of grid points.
gridPoints
%
isFlow
% Determines whether a domain is a flow.
%
% a = d.isFlow
@ -104,8 +114,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% 1 if the domain is a flow domain, and 0 otherwise.
isFlow
%
isInlet
% Determines whether a domain is an inlet.
%
% a = d.isInlet
@ -114,8 +124,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% 1 if the domain is an inlet, and 0 otherwise.
isInlet
%
isSurface
% Determines if a domain is a surface.
%
% a = d.isSurface
@ -124,8 +134,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% 1 if the domain is a surface, and 0 otherwise.
isSurface
%
massFlux
% Mass flux.
%
% mdot = d.massFlux
@ -134,8 +144,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% The mass flux in the domain.
massFlux
%
massFraction
% Get the mass fraction of a species given its integer index.
%
% y = d.massFraction(k)
@ -150,8 +160,8 @@ classdef Domain1D < handle
% Integer species index
% :return:
% Mass fraction of species
massFraction
%
nComponents
% Number of components.
%
% n = d.nComponents
@ -160,8 +170,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% Number of variables at each grid point
nComponents
%
nPoints
% Get the number of grid points.
%
% n = d.nPoints
@ -170,8 +180,8 @@ classdef Domain1D < handle
% Instance of class :mat:func:`Domain1D`
% :return:
% Integer number of grid points.
nPoints
%
tolerances
% Return the (relative, absolute) error tolerances for a
% solution component.
%
@ -182,7 +192,8 @@ classdef Domain1D < handle
% returned.
% :return:
% 1x2 Vector of the relative and absolute error tolerances.
%
tolerances
end
methods
@ -301,16 +312,6 @@ classdef Domain1D < handle
%% Domain Get Methods
function b = get.bounds(d, component)
% Return the (lower, upper) bounds for a solution component.
%
% b = d.bounds(componoent)
%
% :param component:
% String name of the component for which the bounds are
% returned.
% :return:
% 1x2 Vector of the lower and upper bounds.
%
n = d.componentIndex(component);
lower = callct('domain_lowerBound', d.domainID, n);
upper = callct('domain_upperBound', d.domainID, n);
@ -318,18 +319,6 @@ classdef Domain1D < handle
end
function n = get.componentIndex(d, name)
% Get the index of a component given its name.
%
% n = d.componentIndex(name)
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :param name:
% String name of the component to look up. If a numeric value
% is passed, it will be returned.
% :return:
% Index of the component, or input numeric value.
%
if isa(name, 'double')
n = name;
else
@ -345,18 +334,6 @@ classdef Domain1D < handle
end
function s = get.componentName(d, index)
% Get the name of a component given its index.
%
% n = d.componentName(index)
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :param index:
% Integer or vector of integers of component names
% to get.
% :return:
% Cell array of component names.
%
n = length(index);
s = cell(1, n);
for i = 1:n
@ -367,16 +344,6 @@ classdef Domain1D < handle
end
function i = get.domainIndex(d)
% Get the domain index.
%
% i = d.domainIndex
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% This function returns an integer flag denoting the location
% of the domain, beginning with 1 at the left.
%
i = callct('domain_index', d.domainID);
if i >= 0
i = i + 1;
@ -387,31 +354,10 @@ classdef Domain1D < handle
end
function i = get.domainType(d)
% Get the type of domain.
%
% i = d.domainType
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% This function returns an integer flag denoting the domain
% type.
%
i = callct('domain_type', d.domainID);
end
function zz = get.gridPoints(d, n)
% Get grid points from a domain.
%
% zz = d.gridPoints(n)
%
% :param d:
% Instance of class 'Domain1D'.
% :param n:
% Optional, vector of grid points to be retrieved.
% :return:
% Vector of grid points.
if nargin == 1
np = d.nPoints;
zz = zeros(1, np);
@ -428,15 +374,6 @@ classdef Domain1D < handle
end
function a = get.isFlow(d)
% Determine whether a domain is a flow.
%
% a = d.isFlow
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% 1 if the domain is a flow domain, and 0 otherwise.
%
t = d.domainType;
% See Domain1D.h for definitions of constants.
if t < 100
@ -446,15 +383,6 @@ classdef Domain1D < handle
end
function a = get.isInlet(d)
% Determine whether a domain is an inlet.
%
% a = d.isInlet
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% 1 if the domain is an inlet, and 0 otherwise.
%
t = d.domainType;
% See Domain1D.h for definitions of constants.
if t == 104
@ -464,15 +392,6 @@ classdef Domain1D < handle
end
function a = get.isSurface(d)
% Determine if a domain is a surface.
%
% a = d.isSurface
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% 1 if the domain is a surface, and 0 otherwise.
%
t = d.domainType;
% See Domain1D.h for definitions of constants.
if t == 102
@ -482,34 +401,10 @@ classdef Domain1D < handle
end
function mdot = get.massFlux(d)
% Get the mass flux.
%
% mdot = d.massFlux
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% The mass flux in the domain.
%
mdot = callct('bdry_mdot', d.domainID);
end
function y = get.massFraction(d, k)
% Get the mass fraction of a species given its integer index.
%
% y = d.massFraction(k)
%
% This method returns the mass fraction of species ``k``, where
% k is the integer index of the species in the flow domain
% to which the boundary domain is attached.
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :param k:
% Integer species index
% :return:
% Mass fraction of species
%
if d.domainIndex == 0
error('No flow domain attached!')
end
@ -521,43 +416,14 @@ classdef Domain1D < handle
end
function n = get.nComponents(d)
% Get the number of components.
%
% n = d.nComponents
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% Number of variables at each grid point
%
n = callct('domain_nComponents', d.domainID);
end
function n = get.nPoints(d)
% Get the number of grid points.
%
% n = d.nPoints
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% Integer number of grid points.
%
n = callct('domain_nPoints', d.domainID);
end
function tol = tolerances(d, component)
% Return the (relative, absolute) error tolerances for a
% solution component.
%
% tol = d.tolerances(component)
%
% :param component:
% String name of the component for which the bounds are
% returned.
% :return:
% 1x2 Vector of the relative and absolute error tolerances.
n = d.componentIndex(component);
rerr = callct('domain_rtol', d.domainID, n);
aerr = callct('domain_atol', d.domainID, n);
@ -565,28 +431,10 @@ classdef Domain1D < handle
end
function temperature = get.T(d)
% GET.T Get the boundary temperature.
%
% temperature = d.T
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% Temperature. Units: K
%
temperature = callct('bdry_temperature', d.domainID);
end
function pressure = get.P(d)
% GET.P Get the boundary pressure.
%
% pressure = d.P
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% Pressure. Units: Pa
%
pressure = calllibt(ct, 'stflow_pressure', d.domainID);
end
@ -834,15 +682,6 @@ classdef Domain1D < handle
end
function set.T(d, t)
% SET.T Set the temperature.
%
% d.T = t
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :param t:
% Temperature to be set. Units: K
%
if t <= 0
error('The temperature must be positive');
end
@ -850,15 +689,6 @@ classdef Domain1D < handle
end
function set.P(d, p)
% SET.P Set the pressure.
%
% d.P = p
%
% :param d:
% Instance of class :mat:func:`Domain1D`
% :param p:
% Pressure to be set. Units: Pa
%
if p <= 0
error('The pressure must be positive');
end

View File

@ -15,10 +15,15 @@ classdef Stack < handle
% Instance of class :mat:func:`Stack`
%
properties
properties (SetAccess = immutable)
stID % ID of the stack.
domains % Domain instances contained within the Stack object.
stackIndex
end
properties (SetAccess = protected)
% The index of a domain in a stack given its name.
%
% n = s.stackIndex(name)
@ -30,8 +35,8 @@ classdef Stack < handle
% looked up and its index is :returned.
% :return:
% Index of domain.
stackIndex
%
grid
% Get the grid in one domain.
%
% z = s.grid(name)
@ -43,8 +48,8 @@ classdef Stack < handle
% should be retrieved.
% :return:
% The grid in domain name
grid
%
resid
% Get the residuals.
%
% r = s.resid(domain, rdt, count)
@ -56,11 +61,12 @@ classdef Stack < handle
% :param rdt:
% :param count:
% :return:
%
resid
end
methods
%% Stack class constructor
%% Stack Class Constructor
function s = Stack(domains)
checklib;
@ -76,7 +82,7 @@ classdef Stack < handle
s.stID = callct('sim1D_new', nd, ids);
else
help(Stack);
error('Wrong number of :parameters.');
error('Wrong number of parameters.');
end
end
@ -92,14 +98,7 @@ classdef Stack < handle
function display(s, fname)
% Show all domains.
%
% s.display(fname)
%
% :param s:
% Instance of class :mat:func:`Stack`
% :param fname:
% File to write summary to. If omitted, output is to the screen.
%
if nargin == 1
fname = '-';
end
@ -241,7 +240,7 @@ classdef Stack < handle
function writeStats(s)
% Print statistics for the current solution.
%
% writeStats(s)
% s.writeStats
%
% Prints a summary of the number of function and
% Jacobian evaluations for each grid, and the CPU time spent on
@ -263,18 +262,6 @@ classdef Stack < handle
end
function n = get.stackIndex(s, name)
% Get the index of a domain in a stack given its name.
%
% n = s.stackIndex(name)
%
% :param s:
% Instance of class 'Stack'.
% :param name:
% If double, the value is :returned. Otherwise, the name is
% looked up and its index is :returned.
% :return:
% Index of domain.
if isa(name, 'double')
n = name;
else
@ -288,37 +275,12 @@ classdef Stack < handle
end
function z = get.grid(s, name)
% Get the grid in one domain.
%
% z = s.grid(name)
%
% :param s:
% Instance of class :mat:func:`Stack`
% :param name:
% Name of the domain for which the grid
% should be retrieved.
% :return:
% The grid in domain name
%
n = s.stackIndex(name);
d = s.domains(n);
z = d.gridPoints;
end
function r = get.resid(s, domain, rdt, count)
% Get the residuals.
%
% r = s.resid(domain, rdt, count)
%
% :param s:
% Instance of class 'Stack'.
% :param domain:
% Name of the domain.
% :param rdt:
% :param count:
% :return:
%
if nargin == 2
rdt = 0.0;
count = 0;

View File

@ -1,6 +1,8 @@
function c = CarbonDioxide()
% Return an object representing carbon dioxide.
%
% 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
% liquid/vapor, and supercritical regions of the phase diagram. The

View File

@ -1,10 +1,13 @@
function h = HFC134a()
% Return an object representing refrigerant 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,
% vapor, saturated liquid/vapor, and supercritical regions of the phase
% diagram. Implements the equation of state given in:
%
% R. Tillner-Roth and H. D. Baehr. "An International Standard Formulation for
% The Thermodynamic Properties of 1,1,1,2-Tetrafluoroethane (HFC-134a) for
% Temperatures From 170 K to 455 K and Pressures up to 70 MPa". J. Phys.

View File

@ -1,6 +1,8 @@
function h = Heptane
% Return an object representing n-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
% liquid/vapor, and supercritical regions of the phase diagram. The

View File

@ -1,6 +1,8 @@
function h = Hydrogen()
% Return an object representing 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
% liquid/vapor, and supercritical regions of the phase diagram. The

View File

@ -21,12 +21,17 @@ classdef Interface < handle & ThermoPhase & Kinetics
% :return:
% Instance of class :mat:func:`Interface`
%
properties
properties (SetAccess = public)
coverages % Surface coverages of the species on an interface.
% Surface coverages of the species on an interface.
% Unit: kmol/m^2 for surface phases, kmol/m for edge phases.
siteDensity
% Surface coverages of the species on an interface.
% Unit: kmol/m^2 for surface phases, kmol/m for edge phases.
%
end
properties (SetAccess = protected)
concentrations % Concentrations of the species on an interface.
end
@ -34,6 +39,7 @@ classdef Interface < handle & ThermoPhase & Kinetics
%% Interface Class Constructor
function s = Interface(src, id, p1, p2, p3, p4)
% Interface class constructor
checklib;
t = ThermoPhase(src, id);
@ -56,15 +62,6 @@ classdef Interface < handle & ThermoPhase & Kinetics
%% Interface Get Methods
function c = get.coverages(s)
% GET.COVERAGES Get the surface coverages of the species on an interface.
% c = s.coverages
% :param s:
% Instance of class :mat:func:`Interface` with surface species
% :return:
% If no output value is assigned, a bar graph will be plotted.
% Otherwise, a vector of length ``n_surf_species`` will be
% returned.
%
surfID = s.tpID;
nsp = s.nSpecies;
xx = zeros(1, nsp);
@ -74,24 +71,11 @@ classdef Interface < handle & ThermoPhase & Kinetics
end
function d = get.siteDensity(s)
% GET.SITEDENSITY Get the surface coverages of the species on an interface.
% c = s.siteDensity
% :param s:
% Instance of class :mat:func:`Interface` with surface species
% :return:
% Double site density. Unit: kmol/m^2 for surface phases,
% kmol/m for edge phases.
%
surfID = s.tpID;
d = calllibt(ct, 'surf_siteDensity', surfID);
end
function c = get.concentrations(s)
% Get the concentrations of the species on an interface.
%
% :return:
% Vector of length "n_surf_species" for concentration.
surfID = s.tr_id;
nsp = s.nSpecies;
xx = zeros(1, nsp);
@ -101,8 +85,10 @@ classdef Interface < handle & ThermoPhase & Kinetics
end
function set.coverages(s, cov, norm)
% SET.COVERAGES Set surface coverages of the species on an interface.
% Set surface coverages of the species on an interface.
%
% s.coverages = (cov, norm)
%
% :param s:
% Instance of class :mat:func:`Interface`
% :param cov:
@ -143,13 +129,16 @@ classdef Interface < handle & ThermoPhase & Kinetics
end
function set.siteDensity(s, d)
% SET.SITEDENSITY Set the site density of a phase on an interface.
% Set the site density of a phase on an interface.
%
% s.siteDensity = d
%
% :param s:
% Instance of class :mat:func:`Interface`
% :parameter d
% :param d
% Double site density. Unit: kmol/m^2 for surface phases,
% kmol/m for edge phases.
%
surfID = s.tpID;
callct('surf_setSiteDensity', surfID, d);

View File

@ -1,179 +1,198 @@
classdef Kinetics < handle
% Kinetics Class.
%
% 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.
%
% Instances of class :mat:func:`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:func:`ThermoPhase` representing the phase
% in which reactions occur
% :param src:
% Input string of YAML file name.
% :param id:
% ID of the phase to import as specified in the input file. (optional)
% :param neighbor1:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :param neighbor2:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :param neighbor3:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :param neighbor4:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :return:
% Instance of class :mat:func:`Kinetics`
%
properties
%% Scalar Attributes
properties (SetAccess = immutable)
kinID % ID of the Kinetics object.
kineticsSpeciesIndex
% Get the species index of a species of a phase in the Kinetics class.
%
% :param name:
% String name of the species.
% :param phase:
% String name of the phase.
% :return:
% Index of the species.
%
multiplier
% Get the multiplier for reaction rate of progress.
%
% :parameter irxn:
% Integer reaction number for which the multiplier is
% desired.
% :return:
% Multiplier of the rate of progress of reaction irxn.
%
nPhases % Number of phases.
nReactions % Number of reactions.
nTotalSpecies % The total number of species.
phaseIndex
% The index of a specific phase.
%
% :param phase:
% String name of the phase.
% :return:
% Index of the phase.
%
stoichReactant
% Reactant stoichiometric coefficients.
%
% :parameter species:
% Species indices for which reactant stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "rxns" must be specified as well.
% :parameter rxns:
% Reaction indicies for which reactant stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% Returns a sparse matrix of all reactant stoichiometric
% coefficients. The matrix elements "nu(k, i)" is the
% stoichiometric coefficient of species k as a reactant in
% reaction i. If "species" and "rxns" are specified, the
% matrix will contain only entries for the specified species
% and reactions. For example, "stoich_p(a, 3, [1, 3, 5,
% 7])" :returns a sparse matrix containing only the
% coefficients for specis 3 in reactions 1, 3, 5, and 7.
%
stoichProduct
% Product stoichiometric coefficients.
%
% :parameter species:
% Species indices for which product stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "rxns" must be specified as well.
% :parameter rxns:
% Reaction indicies for which product stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% Returns a sparse matrix of all product stoichiometric
% coefficients.
%
stoichNet
% Net stoichiometric coefficients.
%
% :parameter species:
% Species indices for which net stoichiometric coefficients
% should be retrieved. Optional argument; if specified,
% "rxns" must be specified as well.
% :parameter rxns:
% Reaction indicies for which net stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% A sparse matrix of all net stoichiometric coefficients.
%
end
properties (SetAccess = protected)
% Get the species index of a species of a phase in the Kinetics class.
%
% :param name:
% String name of the species.
% :param phase:
% String name of the phase.
% :return:
% Index of the species.
kineticsSpeciesIndex
%
% Get the multiplier for reaction rate of progress.
%
% :param irxn:
% Integer reaction number for which the multiplier is
% desired.
% :return:
% Multiplier of the rate of progress of reaction irxn.
multiplier
nPhases % Number of phases.
nReactions % Number of reactions.
nTotalSpecies % The total number of species.
% The index of a specific phase.
%
% :param phase:
% String name of the phase.
% :return:
% Index of the phase.
phaseIndex
%
% Reactant stoichiometric coefficients.
%
% :param species:
% Species indices for which reactant stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, ``rxns`` must be specified as well.
% :param rxns:
% Reaction indicies for which reactant stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, ``species`` must be specified as well.
% :return:
% Returns a sparse matrix of all reactant stoichiometric
% coefficients. The matrix elements ``nu(k, i)`` is the
% stoichiometric coefficient of species k as a reactant in
% reaction i. If ``species`` and ``rxns`` are specified, the
% matrix will contain only entries for the specified species
% and reactions. For example, ``stoich_p(a, 3, [1, 3, 5,
% 7])`` returns a sparse matrix containing only the
% coefficients for specis 3 in reactions 1, 3, 5, and 7.
stoichReactant
%
% Product stoichiometric coefficients.
%
% :param species:
% Species indices for which product stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, ``rxns`` must be specified as well.
% :param rxns:
% Reaction indicies for which product stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, ``species`` must be specified as well.
% :return:
% Returns a sparse matrix of all product stoichiometric
% coefficients.
stoichProduct
%
% Net stoichiometric coefficients.
%
% :param species:
% Species indices for which net stoichiometric coefficients
% should be retrieved. Optional argument; if specified,
% "rxns" must be specified as well.
% :param rxns:
% Reaction indicies for which net stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% A sparse matrix of all net stoichiometric coefficients.
stoichNet
%% Array Attributes
creationRates % Chemical reaction rates. Unit: kmol/m^3-s.
destructionRates % Chemical destruction rates. Unit: kmol/m^3-s.
dH % enthalpy of reaction. Unit: J/kmol.
dH_standard % standard state enthalpy of reaction. Unit: J/kmol.
dS % entropy of reaction. Unit: J/kmol-K
dS % entropy of reaction. Unit: J/kmol-K.
dS_standard % standard state entropy of reaction. Unit: J/kmol-K.
dG % gibbs free energy of reaction. Unit: J/kmol-K.
dG_standard % standard state gibbs free energy of reaction. Unit: J/kmol-K.
% Equilibrium constants for all reactions.
%
% k = kin.equilibriumConstants
%
% :return:
% A column vector of the equilibrium constants for all
% reactions. The vector has an entry for every reaction,
% whether reversible or not, but non-zero values occur only
% for the reversible reactions.
equilibriumConstants
% Equilibrium constants for all reactions.
%
% k = kin.equilibriumConstants
%
% :return:
% A column vector of the equilibrium constants for all
% reactions. The vector has an entry for every reaction,
% whether reversible or not, but non-zero values occur only
% for the reversible reactions.
%
forwardRateConstants % Forward reaction rate constants for all reactions.
reverseRateConstants % Rever reaction rate constants for all reactions.
% An array of flags indicating reversibility of a reaction.
%
% n = kin.isReversible(i)
%
% :param i:
% Integer reaction number.
% :return:
% 1 if reaction number i is reversible. 0 if irreversible.
isReversible
% An array of flags indicating reversibility of a reaction.
%
% n = kin.isReversible(i)
%
% :parameter i:
% Integer reaction number.
% :return:
% 1 if reaction number i is reversible. 0 if irreversible.
%
massProdRate % Mass production rate of all species. Unit: kg/s.
netProdRates % Net chemical production rates for all species. Unit: kmol/m^3-s.
ropForward % Forward rates of progress for all reactions. Unit: kmol/m^3-s.
ropReverse % Reverse rates of progress for all reactions. Unit: kmol/m^3-s.
ropNet % Net rates of progress for all reactions. Unit: kmol/m^3-s.
% Reaction equation of a reaction
%
% rxn = kin.reactionEqn(irxn)
%
% :param irxn:
% Integer index of the reaction.
% :return:
% String reaction equation.
reactionEqn
% Reaction equation of a reaction
%
% rxn = kin.reactionEqn(irxn)
%
% :parameter irxn:
% Integer index of the reaction.
% :return:
% String reaction equation.
%
reactionEqns % All reaction equations within the Kinetics object.
end
methods
%% Kinetics Class Constructor
function kin = Kinetics(ph, src, id, n1, n2, n3, n4)
% Kinetics Class
%
% 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.
%
% Instances of class :mat:func:`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:func:`ThermoPhase` representing the phase
% in which reactions occur
% :param src:
% Input string of YAML file name.
% :param id:
% ID of the phase to import as specified in the input file. (optional)
% :param neighbor1:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :param neighbor2:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :param neighbor3:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :param neighbor4:
% Instance of class :mat:func:`ThermoPhase` or :mat:func:`Solution` representing a
% neighboring phase.
% :return:
% Instance of class :mat:func:`Kinetics`
%
checklib;
% indices for bulk phases in a heterogeneous mechanism
inb1 = -1;
inb2 = -1;
@ -199,7 +218,7 @@ classdef Kinetics < handle
end
end
kin.kinID = callct('kin_newFromFile', src, id, ...
iph, inb1, inb2, inb3, inb4);
iph, inb1, inb2, inb3, inb4);
end
%% Kinetics Class Destructor
@ -213,94 +232,30 @@ classdef Kinetics < handle
%% Get scalar attributes
function n = get.kineticsSpeciesIndex(kin, name, phase)
% KINETICSSPECIESINDEX
%
% Get the species index in the Kinetics class.
%
% :param name:
% String name of the species.
% :param phase:
% String name of the phase.
% :return:
% Index of the species.
%
n = callct('kin_speciesIndex', kin.kinID, name, phase);
end
function n = get.multiplier(kin, irxn)
% Get the multiplier for reaction rate of progress.
%
% :parameter irxn:
% Integer reaction number for which the multiplier is
% desired.
% :return:
% Multiplier of the rate of progress of reaction irxn.
n = callct('kin_multiplier', kin.kinID, irxn-1);
end
function n = get.nPhases(kin)
% Get the number of phases.
%
% :return:
% Integer number of phases.
n = callct('kin_nPhases', kin.kinID);
end
function n = get.nReactions(kin)
% Get the number of reactions.
%
% :return:
% Integer number of reactions.
n = callct('kin_nReactions', kin.kinID);
end
function n = get.nTotalSpecies(kin)
% Get the total number of species.
%
% :return:
% Integer total number of species.
n = callct('kin_nSpecies', kin.kinID);
end
function n = get.phaseIndex(kin, phase)
% PHASEINDEX
%
% Get the index of a phase.
%
% :param phase:
% String name of the phase.
% :return:
% Index of the phase.
n = callct('kin_phaseIndex', kin.kinID, phase);
end
function n = get.stoichReactant(kin, species, rxns)
% Get the reactant stoichiometric coefficients.
%
% :parameter species:
% Species indices for which reactant stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "rxns" must be specified as well.
% :parameter rxns:
% Reaction indicies for which reactant stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% Returns a sparse matrix of all reactant stoichiometric
% coefficients. The matrix elements "nu(k, i)" is the
% stoichiometric coefficient of species k as a reactant in
% reaction i. If "species" and "rxns" are specified, the
% matrix will contain only entries for the specified species
% and reactions. For example, "stoich_p(a, 3, [1, 3, 5,
% 7])" :returns a sparse matrix containing only the
% coefficients for specis 3 in reactions 1, 3, 5, and 7.
nsp = kin.nTotalSpecies;
nr = kin.nReactions;
temp = sparse(nsp, nr);
@ -327,26 +282,6 @@ classdef Kinetics < handle
end
function n = get.stoichProduct(kin, species, rxns)
% Get the product stoichiometric coefficients.
%
% :parameter species:
% Species indices for which product stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "rxns" must be specified as well.
% :parameter rxns:
% Reaction indicies for which product stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% Returns a sparse matrix of all product stoichiometric
% coefficients. The matrix elements "nu(k, i)" is the
% stoichiometric coefficient of species k as a product in
% reaction i. If "species" and "rxns" are specified, the
% matrix will contain only entries for the specified species
% and reactions. For example, "stoich_p(a, 3, [1, 3, 5,
% 7])" :returns a sparse matrix containing only the
% coefficients for specis 3 in reactions 1, 3, 5, and 7.
nsp = kin.nTotalSpecies;
nr = kin.nReactions;
temp = sparse(nsp, nr);
@ -373,26 +308,6 @@ classdef Kinetics < handle
end
function n = get.stoichNet(kin, species, rxns)
% Get the net stoichiometric coefficients.
%
% :parameter species:
% Species indices for which net stoichiometric coefficients
% should be retrieved. Optional argument; if specified,
% "rxns" must be specified as well.
% :parameter rxns:
% Reaction indicies for which net stoichiometric
% coefficients should be retrieved. Optional argument; if
% specified, "species" must be specified as well.
% :return:
% A sparse matrix of all net stoichiometric coefficients.
% The matrix elements "nu(k, i)" is the stoichiometric
% coefficient of species k as a net in reaction.
% If "species" and "rxns" are specified, the matrix will
% contain only entries for the specified species and reactions.
% For example, "stoich_net(a, 3, [1, 3, 5, 7])" returns a
% sparse matrix containing only the coefficients for
% specis 3 in reactions 1, 3, 5, and 7.
if nargin == 1
n = kin.stoichProduct - kin.stoichReactant;
elseif nargin == 3
@ -404,11 +319,6 @@ classdef Kinetics < handle
%% Get reaction array attributes
function cdot = get.creationRates(kin)
% Get the chemical reaction rates.
%
% :return:
% A vector of the creation rates of all species. Unit: kmol/m^3-s.
nsp = kin.nTotalSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
@ -417,11 +327,6 @@ classdef Kinetics < handle
end
function ddot = get.destructionRates(kin)
% Get the chemical destruction rates.
%
% :return:
% A vector of the destruction rates of all species. Unit: kmol/m^3-s.
nsp = kin.nTotalSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
@ -430,23 +335,10 @@ classdef Kinetics < handle
end
function n = get.isReversible(kin, i)
% Get an array of flags indicating reversibility of a reaction.
%
% :parameter i:
% Integer reaction number.
% :return:
% 1 if reaction number i is reversible. 0 if irreversible.
n = callct('kin_isReversible', kin.kinID, i);
end
function wdot = get.netProdRates(kin)
% Get the net chemical production rates for all species.
%
% :return:
% A vector of the net production (creation-destruction)
% rates of all species. Unit: kmol/m^3-s.
nsp = kin.nTotalSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
@ -455,12 +347,6 @@ classdef Kinetics < handle
end
function q = get.ropForward(kin)
% Get the forward rates of progress for all reactions.
%
% :return:
% A column vector of the forward rates of progress for all
% reactions.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -469,12 +355,6 @@ classdef Kinetics < handle
end
function q = get.ropReverse(kin)
% Get the reverse rates of progress for all reactions.
%
% :return:
% A column vector of the reverse rates of progress for all
% reactions.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -483,12 +363,6 @@ classdef Kinetics < handle
end
function q = get.ropNet(kin)
% Get the net rates of progress for all reactions.
%
% :return:
% A column vector of the net rates of progress for all
% reactions.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -497,22 +371,10 @@ classdef Kinetics < handle
end
function rxn = get.reactionEqn(kin, irxn)
% Get the reaction equation of a reaction
%
% :parameter irxn:
% Integer index of the reaction.
% :return:
% String reaction equation.
output = callct2('kin_getReactionString', kin.kinID, irxn-1);
end
function rxn = get.reactionEqns(kin)
% Get all reaction equations within the Kinetics class
%
% :return:
% Cell arrray of strings of the reaction equations.
m = kin.nReactions;
irxn = (1:m);
rxns = cell(1, m);
@ -522,12 +384,6 @@ classdef Kinetics < handle
end
function enthalpy = get.dH(kin)
% Get the enthalpy of reaction for each reaction.
%
% :return:
% A vector of the enthalpy of reaction for each reaction.
% Unit: J/kmol.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -536,12 +392,6 @@ classdef Kinetics < handle
end
function enthalpy = get.dH_standard(kin)
% Get the standard state enthalpy of reaction for each reaction.
%
% :return:
% A vector of the standard state enthalpy of reaction for each reaction.
% Unit: J/kmol.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -550,12 +400,6 @@ classdef Kinetics < handle
end
function entropy = get.dS(kin)
% Get the entropy of reaction for each reaction.
%
% :return:
% A vector of the entropy of reaction for each reaction.
% Unit: J/kmol-K.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -564,12 +408,6 @@ classdef Kinetics < handle
end
function entropy = get.dS_standard(kin)
% Get the standard state entropy of reaction for each reaction.
%
% :return:
% A vector of the standard state entropy of reaction for each reaction.
% Unit: J/kmol-K.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -578,12 +416,6 @@ classdef Kinetics < handle
end
function gibbs = get.dG(kin)
% Get the Gibbs free energy of reaction for each reaction.
%
% :return:
% A vector of the Gibbs free energy of reaction for each
% reaction. Unit: J/kmol.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -592,12 +424,6 @@ classdef Kinetics < handle
end
function gibbs = get.dG_standard(kin)
% Get the standard state Gibbs free energy of reaction for each reaction.
%
% :return:
% A vector of the standard state Gibbs free energy of reaction for each
% reaction. Unit: J/kmol.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -606,14 +432,6 @@ classdef Kinetics < handle
end
function k = get.equilibriumConstants(kin)
% Get the equilibrium constants for all reactions.
%
% :return:
% A column vector of the equilibrium constants for all
% reactions. The vector has an entry for every reaction,
% whether reversible or not, but non-zero values occur only
% for the reversible reactions.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -622,12 +440,6 @@ classdef Kinetics < handle
end
function k = get.forwardRateConstants(kin)
% Get the forward reaction rate constants for all reactions.
%
% :return:
% A column vector of the forward rates constants of all
% reactions.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -636,12 +448,6 @@ classdef Kinetics < handle
end
function k = get.reverseRateConstants(kin)
% Get the reverse reaction rate constants for all reactions.
%
% :return:
% A column vector of the reverse rates constants of all
% reactions.
nr = kin.nReactions;
xx = zeros(1, nr);
pt = libpointer('doublePtr', xx);
@ -650,11 +456,6 @@ classdef Kinetics < handle
end
function ydot = get.massProdRate(kin)
% Get the mass production rates of the species.
%
% :return:
% A vector of the mass production rates.
nsp = kin.nTotalSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
@ -669,10 +470,10 @@ classdef Kinetics < handle
%
% kin.setMultiplier(irxn, v)
%
% :parameter irxn:
% :param irxn:
% Integer vector reaction numbers for which the multiplier
% should be set. Optional.
% :parameter v:
% :param v:
% Value by which the reaction rate of progress should be
% multiplied.
%
@ -697,7 +498,7 @@ classdef Kinetics < handle
%
% kin.advanceCoverages(dt)
%
% :parameter dt:
% :param dt:
% Time interval by which the coverages should be advanced.
%

View File

@ -1,6 +1,8 @@
function m = Methane()
% Return an object representing 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
% liquid/vapor, and supercritical regions of the phase diagram. The

View File

@ -1,6 +1,8 @@
function n = Nitrogen()
% Return an object representing 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
% liquid/vapor, and supercritical regions of the phase diagram. The

View File

@ -1,6 +1,8 @@
function o = Oxygen()
% Return an object representing 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
% liquid/vapor, and supercritical regions of the phase diagram. The

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,57 @@
classdef Transport < handle
% Transport Class
%
% tr = Transport(r, th, model, loglevel)
%
% Create a new instance of class :mat:func:`Transport`. One to three arguments
% may be supplied. The first must be an instance of class
% :mat:func:`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
% phase definition. The third argument is the logging level desired.
%
% :param th:
% Instance of class :mat:func:`ThermoPhase`
% :param model:
% String indicating the transport model to use. Possible values
% are ``'default'``, ``'None'``, ``'Mix'``, and ``'Multi'``.
% Optional.
% :param loglevel:
% Level of diagnostic logging. Default if not specified is 4.
% :return:
% Instance of class :mat:func:`Transport`
%
properties
properties (Access = private)
th
trID
end
properties (SetAccess = immutable)
trID % ID of Transport object
end
properties (SetAccess = protected)
viscosity % Dynamic viscosity. Unit: Pa*s.
thermoConductivity % Thermal conductivity. Unit: W/m-K.
electricalConductivity % Electrical conductivity. Unit: S/m.
mixDiffCoeffs % Mixture-averaged diffusion coefficients. Unit: m^2/s.
thermalDiffCoeffs % Thermal diffusion coefficients.
binDiffCoeffs % Binary diffusion coefficients. Unit: m^2/s.
multiDiffCoeffs % Multicomponent diffusion coefficients. Unit: m^2/s.
end
methods
%% Transport Class Constructor
function tr = Transport(tp, model, loglevel)
% Transport Class
%
% tr = Transport(r, th, model, loglevel)
%
% Create a new instance of class :mat:func:`Transport`. One to three arguments
% may be supplied. The first must be an instance of class
% :mat:func:`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
% phase definition. The third argument is the logging level desired.
%
% :param th:
% Instance of class :mat:func:`ThermoPhase`
% :param model:
% String indicating the transport model to use. Possible values
% are ``'default'``, ``'None'``, ``'Mix'``, and ``'Multi'``.
% Optional.
% :param loglevel:
% Level of diagnostic logging. Default if not specified is 4.
% :return:
% Instance of class :mat:func:`Transport`
%
checklib;
tr.trID = 0;
if nargin == 2
@ -75,39 +89,18 @@ classdef Transport < handle
%% Transport Get Methods
function v = get.viscosity(tr)
% Get the dynamic viscosity.
%
% :return:
% Double dynamic viscosity. Unit: Pa*s.
v = callct('trans_viscosity', tr.trID);
end
function v = get.thermalConductivity(tr)
% Get the thermal conductivity.
%
% :return:
% Double thermal conductivity. Unit: W/m-K.
v = callct('trans_thermalConductivity', tr.trID);
end
function v = get.electricalConductivity(tr)
% Get the electrical conductivity.
%
% :return:
% Double electrical conductivity. Unit: S/m.
v = callct('trans_electricalConductivity', tr.trID);
end
function v = get.mixDiffCoeffs(tr)
% Get the mixture-averaged diffusion coefficients.
%
% :return:
% Vector of length nSpecies with the mixture-averaged
% diffusion coefficients. Unit: m^2/s.
nsp = tr.th.nSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
@ -116,12 +109,6 @@ classdef Transport < handle
end
function v = get.thermalDiffCoeffs(tr)
% Get the thermal diffusion coefficients.
%
% :return:
% Vector of length nSpecies with the thermal diffusion
% coefficients.
nsp = tr.th.nSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
@ -130,12 +117,6 @@ classdef Transport < handle
end
function v = get.binDiffCoeffs(tr)
% Get the binary diffusion coefficients.
%
% :return:
% A matrix of binary diffusion coefficients. The matrix is
% symmetric: d(i, j) = d(j, i). Unit: m^2/s.
nsp = tr.th.nSpecies;
xx = zeros(nsp, nsp);
pt = libpointer('doublePtr', xx);
@ -144,12 +125,6 @@ classdef Transport < handle
end
function v = get.multiDiffCoeffs(tr)
% Get the multicomponent diffusion coefficients.
%
% :return:
% Vector of length nSpecies with the multicomponent
% diffusion coefficients. Unit: m^2/s.
nsp = tr.th.nSpecies;
xx = zeros(nsp, nsp);
pt = libpointer('doublePtr', xx);
@ -164,9 +139,9 @@ classdef Transport < handle
%
% tr.setParameters(type, k, p)
%
% :parameter type:
% :parameter k:
% :parameter p:
% :param type:
% :param k:
% :param p:
callct('trans_setParameters', tr.trID, type, k, p);
end
@ -176,7 +151,7 @@ classdef Transport < handle
%
% tr.setThermalConductivity(lam)
%
% :parameter lam:
% :param lam:
% Thermal conductivity in W/(m-K).
%

View File

@ -1,6 +1,8 @@
function w = Water()
% Return an object representing 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
% liquid/vapor, and supercritical regions of the phase diagram. The

View File

@ -53,7 +53,7 @@ classdef Func < handle
% Instance of class :mat:func:`Func`
%
properties
properties (SetAccess = immutable)
f1
f2
coeffs
@ -133,12 +133,7 @@ classdef Func < handle
function delete(f)
% Delete the C++ Func1 object.
%
% f.clear
%
% :param f:
% Instance of class :mat:func:`Func`
%
callct('func_del', f.id);
end
@ -146,12 +141,7 @@ classdef Func < handle
function display(f)
% Display the equation of the input function on the terminal.
%
% f.display
%
% :param f:
% Instance of class :mat:func:`Func`
%
disp(' ');
disp([inputname(1),' = '])
disp(' ');

View File

@ -1,51 +1,155 @@
classdef Mixture < handle
% Mixture Class.
%
% m = Mixture(phases)
%
% Class :mat:func:`Mixture` represents mixtures of one or more phases of matter.
% To construct a mixture, supply a cell array of phases and
% mole numbers::
%
% >> gas = Solution('gas.yaml');
% >> graphite = Solution('graphite.yaml');
% >> mix = Mixture({gas, 1.0; graphite, 0.1});
%
% Phases may also be added later using the addPhase method::
%
% >> water = Solution('water.yaml');
% >> mix.addPhase(water, 3.0);
%
% Note that the objects representing each phase compute only the
% intensive state of the phase - they do not store any information
% on the amount of this phase. Mixture objects, on the other hand,
% represent the full extensive state.
%
% Mixture objects are 'lightweight' in the sense that they do not
% store parameters needed to compute thermodynamic or kinetic
% properties of the phases. These are contained in the
% ('heavyweight') phase objects. Multiple mixture objects may be
% constructed using the same set of phase objects. Each one stores
% its own state information locally, and synchronizes the phase
% objects whenever it requires phase properties.
%
% :param phases:
% Cell array of phases and mole numbers
% :return:
% Instance of class :mat:func:`Mixture`
%
properties
properties (SetAccess = immutable)
mixID
end
properties (SetAccess = public)
T % Temperature. Units: K.
P % Pressure. Units: Pa.
end
properties (SetAccess = protected)
phases % Phases in the mixture
T % Temperature
P % Pressure
% Number of atoms of an element in a mixture.
%
% n = m.nAtoms(e)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param e:
% Index of element
% :return:
% Number of atoms for element e
%
% Note: In keeping with the conventions used by Matlab, the
% indices start from 1 instead of 0 as in Cantera C++ and
% Python interfaces.
nAtoms
nElements % Number of elements in a mixture.
nPhases % Number of phases in a mixture.
nSpecies % Number of species in a mixture.
% Index of an element.
%
% n = m.elementIndex(name)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param name:
% Name of the element whose index is desired
% :return:
% Index of element with name ``name``
%
% Note: In keeping with the conventions used by Matlab, the
% indices start from 1 instead of 0 as in Cantera C++ and
% Python interfaces.
elementIndex
%
% Number of moles of an element in a mixture.
%
% moles = m.elementMoles(e)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param e:
% Integer element number.
% :return:
% Moles of element number 'e'. If input 'e' is empty, return
% moles of every element in the mixture. Unit: kmol.
elementMoles
%
% Index of a species in a mixture.
%
% n = m.speciesIndex(k, p)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param name:
% Name of the speces whose index is desired
% :return:
% Index of species with name ``name``
%
% Note: In keeping with the conventions used by Matlab, the
% indices start from 1 instead of 0 as in Cantera C++ and
% Python interfaces.
speciesIndex
%
% Number of moles of a species in a mixture.
%
% moles = m.speciesMoles(k)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param k:
% Integer species number.
% :return:
% Moles of species number 'k'. If input 'k' is empty, return
% moles of every species in the mixture. Unit: kmol.
%
speciesMoles
%
% Number of moles of a phase in a mixture.
%
% moles = m.phaseMoles(n)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param n:
% Integer phase number.
% :return:
% Moles of element number 'n'. If input 'n' is empty, return
% moles of every element in the mixture. Unit: kmol.
%
phaseMoles
chemPotentials % Chemical potentials of species in the mixture. Units: J/kmol.
end
methods
%% Mixture class constructor
%% Mixture Class Constructor
function m = Mixture(phases)
% MIXTURE Multiphase mixture class constructor.
% m = Mixture(phases)
%
% Class :mat:func:`Mixture` represents mixtures of one or more phases of matter.
% To construct a mixture, supply a cell array of phases and
% mole numbers::
%
% >> gas = Solution('gas.yaml');
% >> graphite = Solution('graphite.yaml');
% >> mix = Mixture({gas, 1.0; graphite, 0.1});
%
% Phases may also be added later using the addPhase method::
%
% >> water = Solution('water.yaml');
% >> mix.addPhase(water, 3.0);
%
% Note that the objects representing each phase compute only the
% intensive state of the phase - they do not store any information
% on the amount of this phase. Mixture objects, on the other hand,
% represent the full extensive state.
%
% Mixture objects are 'lightweight' in the sense that they do not
% store parameters needed to compute thermodynamic or kinetic
% properties of the phases. These are contained in the
% ('heavyweight') phase objects. Multiple mixture objects may be
% constructed using the same set of phase objects. Each one stores
% its own state information locally, and synchronizes the phase
% objects whenever it requires phase properties.
%
% :param phases:
% Cell array of phases and mole numbers
% :return:
% Instance of class :mat:func:`Mixture`
%
checklib;
if nargin > 1
@ -76,15 +180,19 @@ classdef Mixture < handle
end
end
%% Utility methods
%% Mixture Class Destructor
function delete(m)
% Delete the MultiPhase object.
calllib(ct, 'mix_del', m.mixID);
end
%% Mixture Utility methods
function display(m)
% DISPLAY Display the state of the mixture on the terminal.
% m.display
%
% :param self:
% Instance of class :mat:func:`Mixture`
%
% Display the state of the mixture on the terminal.
calllib(ct, 'mix_updatePhases', m.mixID);
[np, nc] = size(m.phases);
for n = 1:np
@ -96,18 +204,9 @@ classdef Mixture < handle
end
end
function clear(m)
% CLEAR Delete the C++ MultiPhase object.
% m.clear
%
% :param m:
% Instance of class :mat:func:`Mixture`
%
calllib(ct, 'mix_del', m.mixID);
end
function addPhase(m, phase, moles)
% ADDPHASE Add a phase to a mixture.
% Add a phase to a mixture.
%
% addPhase(self, phase, moles)
%
% :param self:
@ -139,132 +238,38 @@ classdef Mixture < handle
%% Mixture Get methods
function temperature = get.T(m)
% GET.T Get the temperature of a mixture.
% temperature = m.T
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :return:
% Temperature (K)
%
temperature = calllib(ct, 'mix_temperature', m.mixID);
end
function pressure = get.P(m)
% GET.P Get the pressure of the mixture.
% pressure = m.P
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :return:
% Pressure. Units: Pa
%
pressure = calllib(ct, 'mix_pressure', m.mixID);
end
function n = nAtoms(m, e)
% NATOMS Get the number of atoms of an element in a mixture.
% n = m.nAtoms(e)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param e:
% Index of element
% :return:
% Number of atoms for element e
%
% Note: In keeping with the conventions used by Matlab, the
% indices start from 1 instead of 0 as in Cantera C++ and
% Python interfaces.
%
function n = get.nAtoms(m, e)
n = calllib(ct, 'mix_nPhases', m.mixID, k-1, e-1);
% Check back on this one!
end
function n = nElements(m)
% NELEMENTS Get the number of elements in a mixture.
% n = m.nElements
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :return:
% Number of elements in the input
%
function n = get.nElements(m)
n = calllib(ct, 'mix_nElements', m.mixID);
end
function n = nPhases(m)
% NPHASES Get the number of phases in a mixture.
% n = m.nPhases
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :return:
% Number of phases in the input
%
function n = get.nPhases(m)
n = calllib(ct, 'mix_nPhases', m.mixID);
end
function n = nSpecies(m)
% NSPECIES Get the number of species in a mixture.
% n = m.nSpecies
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :return:
% Number of species in the input
%
function n = get.nSpecies(m)
n = calllib(ct, 'mix_nSpecies', m.mixID);
end
function n = elementIndex(m, name)
% ELEMENTINDEX Get the index of an element.
% n = m.elementIndex(name)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param name:
% Name of the element whose index is desired
% :return:
% Index of element with name ``name``
%
% Note: In keeping with the conventions used by Matlab, the
% indices start from 1 instead of 0 as in Cantera C++ and
% Python interfaces.
%
function n = get.elementIndex(m, name)
n = calllib(ct, 'mix_elementIndex', m.mixID, name) + 1;
end
function n = speciesIndex(m, k, p)
% SPECIESINDEX Get the index of a species in a mixture.
% n = m.speciesIndex(k, p)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param name:
% Name of the speces whose index is desired
% :return:
% Index of species with name ``name``
%
% Note: In keeping with the conventions used by Matlab, the
% indices start from 1 instead of 0 as in Cantera C++ and
% Python interfaces.
%
function n = get.speciesIndex(m, k, p)
n = calllib(ct, 'mix_speciesIndex', m.mixID, k-1, p-1) + 1;
end
function moles = elementMoles(m, e)
% ELEMENTMOLES Get the number of moles of an element in a mixture.
% moles = m.elementMoles(e)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param e:
% Integer element number.
% :return:
% Moles of element number 'e'. If input 'e' is empty, return
% moles of every element in the mixture. Unit: kmol.
%
function moles = get.elementMoles(m, e)
if nargin == 2
moles = calllib(ct, 'mix_elementMoles', m.mixID, e)
elseif nargin == 1
@ -277,18 +282,7 @@ classdef Mixture < handle
end
end
function moles = phaseMoles(m, n)
% PHASEMOLES Get the number of moles of a phase in a mixture.
% moles = m.phaseMoles(n)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param n:
% Integer phase number.
% :return:
% Moles of phase number 'n'. If input 'n' is empty, return
% moles of every phase in the mixture. Unit: kmol.
%
function moles = get.phaseMoles(m, n)
if nargin == 2
moles = calllib(ct, 'mix_phaseMoles', m.mixID, n);
elseif nargin == 1
@ -303,17 +297,6 @@ classdef Mixture < handle
end
function moles = speciesMoles(m, k)
% SPECIESMOLES Get the number of moles of a species in a mixture.
% moles = m.speciesMoles(n)
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :param k:
% Integer species number.
% :return:
% Moles of species number 'k'. If input 'k' is empty, return
% moles of every species in the mixture. Unit: kmol.
if nargin == 2
moles = calllib(ct, 'mix_speciesMoles', m.mixID, k);
elseif nargin == 1
@ -327,15 +310,7 @@ classdef Mixture < handle
end
end
function mu = chemPotentials(m)
% CHEMPOTENTIALS Get the chemical potentials of species in a mixture.
% mu = m.chemPotentials
%
% :param m:
% Instance of class :mat:func:`Mixture`
% :return:
% Vector of chemical potentials. Units: J/kmol
%
function mu = get.chemPotentials(m)
nsp = m.nSpecies;
xx = zeros(1, nsp);
ptr = libpointer('doublePtr', xx);
@ -346,29 +321,16 @@ classdef Mixture < handle
%% Mixture Set methods
function m = set.T(m, temp)
% SET.T Set the mixture temperature.
% m.T = temp
% :param m:
% Instance of class :mat:func:`Mixture`
% :param temp:
% Temperature. Units: K
%
calllib(ct, 'mix_setTemperature', m.mixID, temp);
end
function m = set.P(m, pressure)
% SET.P Set the pressure of the mixture.
% m.P = pressure
% :param m:
% Instance of class :mat:func:`Mixture`
% :param pressure:
% Pressure. Units: Pa
%
calllib(ct, 'mix_setPressure', m.mixID, pressure);
end
function setPhaseMoles(m, n, moles)
% SETPHASEMOLES Set the number of moles of a phase in a mixture.
% Set the number of moles of a phase in a mixture.
%
% m.setPhaseMoles(n, moles)
%
% :param m:
@ -382,8 +344,10 @@ classdef Mixture < handle
end
function setSpeciesMoles(m, moles)
% SETSPECIESMOLES Set the moles of the species.
% Set the moles of the species.
%
% m.setSpeciesMoles(moles)
%
% Set the moles of the species in kmol. The moles may
% be specified either as a string, or as an vector. If a vector is
% used, it must be dimensioned at least as large as the total number
@ -408,8 +372,10 @@ classdef Mixture < handle
end
function r = equilibrate(m, XY, err, maxsteps, maxiter, loglevel)
% EQUILIBRATE Set the mixture to a state of chemical equilibrium.
% Set the mixture to a state of chemical equilibrium.
%
% m.equilibrate(XY, err, maxsteps, maxiter, loglevel)
%
% This method uses a version of the VCS algorithm to find the
% composition that minimizes the total Gibbs free energy of the
% mixture, subject to element conservation constraints. For a

View File

@ -1,37 +1,54 @@
classdef FlowDevice < handle
% FlowDevice Class.
%
% x = FlowDevice(typ)
%
% Base class for devices that allow flow between reactors.
% :mat:func:`FlowDevice` objects are assumed to be adiabatic,
% non-reactive, and have negligible internal volume, so that they are
% internally always in steady-state even if the upstream and downstream
% reactors are not. The fluid enthalpy, chemical composition, and mass
% flow rate are constant across a :mat:func:`FlowDevice`, and the
% pressure difference equals the difference in pressure between the
% upstream and downstream reactors.
%
% See also: :mat:func:`MassFlowController`, :mat:func:`Valve`
%
% :param typ:
% Type of :mat:func:`FlowDevice` to be created. ``typ='MassFlowController'``
% for :mat:func:`MassFlowController`, ``typ='PressureController'`` for
% :mat:func:`PressureController` and ``typ='Valve'`` for
% :mat:func:`Valve`
% :return:
% Instance of class :mat:func:`FlowDevice`
%
properties (SetAccess = immutable)
type % Type of flow device.
id % ID of Flowdevice object.
end
properties (SetAccess = protected)
upstream % Upstream object of type :mat:func:`Reactor` or :mat:func:`Reservoir`.
downstream % Downstream object of type :mat:func:`Reactor` or :mat:func:`Reservoir`.
% Get the mass flow rate.
%
% mdot = f.massFlowRate
%
% :param f:
% Instance of class :mat:func:`MassFlowController`
% :return:
% The mass flow rate through the :mat:func:`FlowDevice` at the current time
massFlowRate
properties
type
id
upstream
downstream
end
methods
%% FlowDevice class constructor
%% FlowDevice Class Constructor
function x = FlowDevice(typ)
% FLOWDEVICE FlowDevice class constructor.
% x = FlowDevice(typ)
% Base class for devices that allow flow between reactors.
% :mat:func:`FlowDevice` objects are assumed to be adiabatic,
% non-reactive, and have negligible internal volume, so that they are
% internally always in steady-state even if the upstream and downstream
% reactors are not. The fluid enthalpy, chemical composition, and mass
% flow rate are constant across a :mat:func:`FlowDevice`, and the
% pressure difference equals the difference in pressure between the
% upstream and downstream reactors.
%
% See also: :mat:func:`MassFlowController`, :mat:func:`Valve`
%
% :param typ:
% Type of :mat:func:`FlowDevice` to be created. ``typ='MassFlowController'``
% for :mat:func:`MassFlowController`, ``typ='PressureController'`` for
% :mat:func:`PressureController` and ``typ='Valve'`` for
% :mat:func:`Valve`
% :return:
% Instance of class :mat:func:`FlowDevice`
%
checklib;
if nargin == 0
@ -44,22 +61,19 @@ classdef FlowDevice < handle
x.downstream = -1;
end
%% Utility methods
%% FlowDevice Class Destructor
function delete(f)
% Delete the specified flow device from memory.
function clear(f)
% CLEAR Clear the specified flow device from memory.
% f.clear
%
% :param f:
% Instance of :mat:func:`FlowDevice` to be cleared.
%
callct('flowdev_del', f.id);
end
%% FlowDevice methods
%% Utility Methods
function install(f, upstream, downstream)
% INSTALL Install a flow device between reactors or reservoirs.
% Install a flow device between reactors or reservoirs.
%
% f.install(upstream, downstream)
%
% :param f:
@ -83,8 +97,11 @@ classdef FlowDevice < handle
end
end
function mdot = massFlowRate(f)
% MASSFLOWRATE Get the mass flow rate.
%% Flowdevice Get Methods
function mdot = get.massFlowRate(f)
% Get the mass flow rate.
%
% mdot = f.massFlowRate
%
% :param f:
@ -95,8 +112,11 @@ classdef FlowDevice < handle
mdot = callct('flowdev_massFlowRate2', f.id);
end
%% Flowdevice Set Methods
function setFunction(f, mf)
% SETFUNCTION Set the mass flow rate with class :mat:func:`Func`.
% Set the mass flow rate with class :mat:func:`Func`.
%
% f.setFunction(mf)
%
% See also: :mat:func:`MassFlowController`, :mat:func:`Func`
@ -115,7 +135,8 @@ classdef FlowDevice < handle
end
function setMassFlowRate(f, mdot)
% SETMASSFLOWRATE Set the mass flow rate to a constant value.
% Set the mass flow rate to a constant value.
%
% f.setMassFlowRate(mdot)
%
% See also: :mat:func:`MassFlowController`
@ -133,8 +154,9 @@ classdef FlowDevice < handle
end
function setMaster(f, d)
% SETMASTER Set the Master flow device used to compute this device's mass
% Set the Master flow device used to compute this device's mass
% flow rate.
%
% f.setMaster(d)
%
% :param f:
@ -150,8 +172,10 @@ classdef FlowDevice < handle
end
function setValveCoeff(f, k)
% SETVALVECOEFF Set the valve coefficient :math:`K`.
% Set the valve coefficient :math:`K`.
%
% f.setValveCoeff(k)
%
% The mass flow rate [kg/s] is computed from the expression
%
% .. math:: \dot{m} = K(P_{upstream} - P_{downstream})

View File

@ -23,46 +23,52 @@ classdef Reactor < handle
% Instance of class 'Reactor'.
%
properties
type
id
properties (SetAccess = immutable)
type % Type of Reactor.
id % ID of Reactor.
end
properties (SetAccess = protected)
contents
D
%
% Density of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: kg/m^3.
D
%
P
% Pressure of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: K.
P
%
M
% Mass of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: kg.
M
%
H
% Mass specific enthalpy of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: J/kg.
H
%
U
% Mass specific internal energy of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: J/kg.
U
%
T
% Temperature of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: K.
T
%
V
% VOlume of the reactor contents at the end of the last call to
% Volume of the reactor contents at the end of the last call to
% 'advance' or 'step'. Unit: m^3.
V
%
Y
% Mass fractions of the reactor contents at the end of the last call to
% 'advance' or 'step'.
%
Y
end
methods
%% Reactor class constructor
%% Reactor Class Constructor
function r = Reactor(content, typ)
checklib;
@ -102,8 +108,11 @@ classdef Reactor < handle
% respect to reaction m should be computed. The reactor must be
% part of a network first.
%
% :parameter m:
% r.addSensitivityReaction(m)
%
% :param m:
% Index number of reaction.
%
callct('reactor_addSensitivityReaction', r.id, m);
end
@ -111,10 +120,13 @@ classdef Reactor < handle
function insert(r, gas)
% Insert a solution or mixture into a reactor.
%
% :parameter r:
% r.insert(gas)
%
% :param r:
% Instance of class 'Reactor'.
% :parameter gas:
% :param gas:
% Instance of class 'Solution'.
%
r.contents = gas;
setThermoMgr(r, gas);
@ -126,82 +138,37 @@ classdef Reactor < handle
%% Reactor Get Methods
function temperature = get.T(r)
% Get the temperature of the reactor.
%
% :return:
% The temperature of the reactor contents at the end of the
% last call to 'advance' or 'step'. Unit: K.
temperature = callct('reactor_temperature', r.id);
end
function pressure = get.P(r)
% Get the pressure of the reactor.
%
% :return:
% The pressure of the reactor contents at the end of the
% last call to 'advance' or 'step'. Unit: Pa.
pressure = callct('reactor_pressure', r.id);
end
function rho = get.D(r)
% Get the density of the reactor.
%
% :return:
% Density of the phase in the input. Unit: kg/m^3.
rho = callct('reactor_density', r.id);
end
function mass = get.M(r)
% Get the mass of the reactor.
%
% :return:
% The mass of the reactor contents at the end of the
% last call to 'advance' or 'step'. The mass is retrieved
% from the solution vector. Unit: kg.
mass = callct('reactor_mass', r.id);
end
function volume = get.V(r)
% Get the volume of the reactor.
%
% :return:
% The volume of the reactor contents at the end of the
% last call to 'advance' or 'step'. Unit: m^3.
volume = callct('reactor_volume', r.id);
end
function enthalpy_mass = get.H(r)
% Get the mass specific enthalpy of the reactor.
%
% :return:
% The mass specific enthalpy of the reactor contents at the
% end of the last call to 'advance' or 'step'. The enthalpy
% is retrieved from the solution vector. Unit: J/kg.
enthalpy_mass = callct('reactor_enthalpy_mass', r.id);
end
function intEnergy_mass = get.U(r)
% Get the mass specific internal energy of the reactor.
%
% :return:
% The mass specific internal energy of the reactor contents
% at the end of the last call to 'advance' or 'step'. The
% internal energy is retrieved from the solution vector.
% Unit: J/kg.
intEnergy_mass = callct('reactor_intEnergy_mass', r.id);
end
function yi = massFraction(r, species)
% Get the mass fraction of a species.
%
% :parameter species:
% :param species:
% String or one-based integer id of the species.
if ischar(species)
@ -213,12 +180,6 @@ classdef Reactor < handle
end
function massFractions = get.Y(r)
% Get the mass fractions of the reactor.
%
% :return:
% The mass fractions of the reactor contents at the end of
% the last call to 'advance' or 'step'.
nsp = r.contents.nSpecies;
massFractions = zeros(1, nsp);
for i = 1:nsp
@ -233,7 +194,7 @@ classdef Reactor < handle
%
% r.setInitialVolume(v0)
%
% :parameter v0:
% :param v0:
% Initial volume in m^3.
callct('reactor_setInitialVolume', r.id, v0);
@ -244,7 +205,7 @@ classdef Reactor < handle
%
% r.setMdot(MFR)
%
% :parameter MFR:
% :param MFR:
% Mass flow rate in kg/s.
%
@ -258,16 +219,16 @@ classdef Reactor < handle
% r.setChemistryFlag(flag)
%
% If the chemistry is disabled, then the reactor composition is
% constant. The :parameter should be the string "on" to enable
% constant. The parameter should be the string "on" to enable
% the species equaionts, or "off" to disable it.
%
% By default, Reactor objects are created with the species
% equations enabled if there are reactions present in the
% mechanism file, and disabled otherwise.
%
% :parameter r:
% :param r:
% Instance of class 'Reactor'.
% :parameter flag:
% :param flag:
% String, either "on" or "off" to enable or disable chemical
% reactions, respectively.
%
@ -288,15 +249,15 @@ classdef Reactor < handle
% r.setEnergyFlag(flag)
%
% If the energy equation is disabled, then the reactor
% temperature is constant. The :parameter should be the string
% temperature is constant. The parameter should be the string
% "on" to enable the energy equation, or "off" to disable it.
%
% By default, Reactor objects are created with the energy
% equation enabled, so usually this method
%
% :parameter r:
% :param r:
% Instance of class 'Reactor'.
% :parameter flag:
% :param flag:
% String, either "on" or "off" to enable or disable chemical
% reactions, respectively.
%
@ -322,9 +283,9 @@ classdef Reactor < handle
% This method is used internally during Reactor initialization,
% but is usually not called by users.
%
% :parameter r:
% :param r:
% Instance of class 'Reactor'.
% :parameter t:
% :param t:
% Instance of class 'ThermoPhase' or another object
% containing an instance of that class.
@ -343,9 +304,9 @@ classdef Reactor < handle
% This method is used internally during Reactor initialization,
% but is usually not called by users.
%
% :parameter r:
% :param r:
% Instance of class 'Reactor'.
% :parameter t:
% :param t:
% Instance of class 'Kinetics' or another object
% containing an instance of that class.

View File

@ -8,42 +8,49 @@ classdef ReactorNet < handle
% to simultaneously advance the state of one or more coupled
% reactors.
%
% :parameter reactors:
% :param reactors:
% Instance of class 'Reactor' or a cell array of instance of
% 'Reactor'.
% :return:
% Instance of class 'ReactorNet'.
%
properties
properties (SetAccess = immutable)
id
end
properties (SetAccess = protected)
% Internal time step in s.
%
% t = r.dt
%
% The integrator used to integrate the ODEs (CVODE) takes
% variable-size steps, chosen so that a specified error
% tolerance is maintained. At times when the solution is
% rapidly changing, the time step becomes smaller to resolve
% the solution.
dt
% Internal time step in s.
%
% t = r.dt
%
% The integrator used to integrate the ODEs (CVODE) takes
% variable-size steps, chosen so that a specified error
% tolerance is maintained. At times when the solution is
% rapidly changing, the time step becomes smaller to resolve
% the solution.
%
time % Current time in s.
atol % Absolute error tolerance.
rtol % Relative error tolerance.
% Sensitivity of the solution variable c in reactor
% rxtr with respect to the parameter p.
%
% s = r.sensitivity(component, p, rxtr)
%
% :param component:
% String name of variable.
% :param p:
% Integer sensitivity parameter.
% :param rxtr:
% Instance of class 'reactor'.
sensitivity
% Sensitivity of the solution variable c in reactor
% rxtr with respect to the parameter p.
%
% s = r.sensitivity(component, p, rxtr)
%
% :param component:
% String name of variable.
% :param p:
% Integer sensitivity parameter.
% :param rxtr:
% Instance of class 'reactor'.
%
end
methods
@ -86,9 +93,9 @@ classdef ReactorNet < handle
%
% net.addReactor(reactor)
%
% :parameter net:
% :param net:
% Instance of class 'ReactorNet'.
% :parameter reactor:
% :param reactor:
% Instance of class 'Solution'.
%
@ -107,7 +114,7 @@ classdef ReactorNet < handle
% an absolute time, not a time interval.) The integrator may
% take many internal timesteps before reaching tout.
%
% :parameter tout:
% :param tout:
% End time of the integration. Unit: s.
%
@ -167,9 +174,9 @@ classdef ReactorNet < handle
%
% r.setTolerances(rerr, aerr)
%
% :parameter rerr:
% :param rerr:
% Scalar relative error tolerance.
% :parameter aerr:
% :param aerr:
% Scalar absolute error tolerance.
%
@ -179,15 +186,6 @@ classdef ReactorNet < handle
%% ReactorNet get methods
function t = get.dt(r)
% Get the internal time step in s.
%
% The integrator used to integrate the ODEs (CVODE) takes
% variable-size steps, chosen so that a specified error
% tolerance is maintained. At times when the solution is
% rapidly changing, the time step becomes smaller to resolve
% the solution.
%
t = callct('reactor_step', r.id);
end
@ -210,16 +208,6 @@ classdef ReactorNet < handle
end
function s = get.sensitivity(r, component, p, rxtr)
% Get the sensitivity of the solution variable c in reactor
% rxtr with respect to the parameter p.
%
% :param component:
% String name of variable.
% :param p:
% Integer sensitivity parameter.
% :param rxtr:
% Instance of class 'reactor'.
if isa(component, 'string')
callct('reactornet_sensitivity', r.id, component, ...
p, rxtr.id);

View File

@ -14,23 +14,29 @@ classdef ReactorSurface < handle
% after initial construction by using the various methods of
% the 'ReactorSurface' class.
%
% :parameter kleft:
% :param kleft:
% 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'.
% :parameter reactor:
% :param reactor:
% Instance of class 'Reactor' to be used as the adjacent
% bulk phase.
% :parameter area:
% :param area:
% The area of the surface in m^2. Defaults to 1.0 m^2 if not
% specified.
% :return:
% Instance of class 'ReactorSurface'.
%
properties
properties (SetAccess = immutable)
surfID
end
properties (SetAccess = protected)
reactor
end
properties (SetAccess = public)
area % Area of the reactor surface in m^2.
end
@ -95,7 +101,7 @@ classdef ReactorSurface < handle
%
% s.addSensitivityReaction(m)
%
% :parameter m:
% :param m:
% Index number of reaction.
callct('reactorsurface_addSensitivityReaction', s.surfID, m);
@ -104,16 +110,12 @@ classdef ReactorSurface < handle
%% ReactorSurface Get Methods
function a = get.area(s)
% Get the areaof the reactor surface in m^2.
a = callct('reactorsurface_area', s.surfID);
end
%% ReactorSurface Set Methods
function set.area(s, a)
% Set the area of a reactor surface
callct('reactorsurface_setArea', s.surfID, a);
end
@ -122,7 +124,7 @@ classdef ReactorSurface < handle
%
% s.setKinetics(kin)
%
% :parameter 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'.

View File

@ -1,7 +1,7 @@
classdef Wall < handle
% Wall Class
%
% x = Wall(left, right, area, k, u, q, v)
% x = Wall()
%
% A Wall separates two reactors, or a reactor and a reservoir.
% A Wall has a finite area, may conduct heat between the two
@ -29,51 +29,35 @@ classdef Wall < handle
% time. The heat flux is positive when heat flows from the
% reactor on the left to the reactor on the right.
%
% Note: all of the arguments are optional and can be activated
% Note: the Wall class constructor only assign default values
% to various properties. The user could specify those properties
% after initial construction by using the various methods of
% the 'Wall' class. Any improperly specified arguments will
% generate warnings; these can be ignored if the intention was
% to not use a particular argument. Thus, the velocity of the
% wall can be set by using empty strings or 0.0 for each of the
% arguments before the velocity with no harm.
%
% :parameter left:
% Instance of class 'Reactor' to be used as the bulk phase
% on the left side of the wall.
% :parameter right:
% Instance of class 'Reactor' to be used as the bulk phase
% on the right side of the wall.
% :parameter area:
% The area of the wall in m^2. Defaults to 1.0 m^2 if not
% specified.
% :parameter k:
% Expansion rate coefficient in m/(s-Pa). Defaults to 0.0 if
% not specified.
% :parameter u:
% Heat transfer coefficient in W/(m^2-K). Defaults to 0.0 if
% not specified.
% :parameter q:
% Heat flux in W/m^2. Defaults to 0.0 if not specified. Must
% be an instance of 'Func'.
% :parameter v:
% Velocity of the wall in m/s. Defaults to 0.0 if not
% specified. Must be an instance of 'Func'.
% the 'Wall' class.
%
properties
properties (SetAccess = immutable)
id
type
end
properties (SetAccess = protected)
left
right
area % Area of the wall in m^2.
qdot % Total heat transfer through a wall at given time.
vdot % Rate of volumetric change at given time.
end
properties (SetAccess = public)
area % Area of the wall in m^2.
end
methods
%% Wall Class Constructor
function x = Wall(left, right, area, k, u, q, v)
function x = Wall()
checklib;
% At the moment, only one wall type is implemented
@ -81,59 +65,14 @@ classdef Wall < handle
x.type = char(typ);
x.id = callct('wall_new', x.type);
% Set default values.
x.left = -1;
x.right = -1;
x.area = 1.0;
x.setExpansionRateCoeff(0.0);
x.setHeatTransferCoeff(0.0);
if nargin >= 2
if isa(left, 'Reactor') && isa(right, 'Reactor')
x.install(left, right);
else
warning(['left and/or right were not instances of Reactor, ' ...
'and were not installed.'])
end
end
if nargin >= 3
if isnumeric(area)
x.setArea(area);
else
warning('area was not a number and the area was not set')
end
end
if nargin >= 4
if isnumeric(k)
x.setExpansionRateCoeff(k);
else
warning(['k was not a number and the expansion rate ',...
'coefficient was not set'])
end
end
if nargin >= 5
if isnumeric(u)
x.setHeatTransferCoeff(u);
else
warning(['u was not a number and the expansion rate ',...
'coefficient was not set'])
end
end
if nargin >= 6
if isa(q, 'Func')
x.setHeatFlux(q);
else
warning('q was not an instance of Func and was not set')
end
end
if nargin >= 7
if isa(v, 'Func')
x.setVelocity(v)
else
warning('v was not an instance of Func and was not set')
end
end
end
%% Wall Class Destructor
@ -151,6 +90,12 @@ classdef Wall < handle
%
% 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;
@ -169,28 +114,20 @@ classdef Wall < handle
%% ReactorNet get methods
function a = get.area(w)
% Get the area of the wall in m^2.
a = callct('wall_area', w.id);
end
function q = get.qdot(w, t)
% Get the total heat transfer through a wall at given time.
q = callct('wall_Q', w.id, t);
q = callct('wall_Q', w.id, t);
end
function v = get.vdot(w, t)
% Get the rate of volumetric change at a given time.
v = callct('wall_vdot', w.id, t);
end
%% ReactorNet set methods
function set.area(w, a)
% Set the area of a wall.
callct('wall_setArea', w.id, a);
end
@ -199,7 +136,7 @@ classdef Wall < handle
%
% w.setTHermalResistance(w)
%
% :parameter r:
% :param r:
% Thermal resistance. Unit: K*m^2/W.
%
@ -211,7 +148,7 @@ classdef Wall < handle
%
% w.setHeatTransferCoeff(u)
%
% :parameter u:
% :param u:
% Heat transfer coefficient. Unit: W/(m^2-K).
%
@ -235,7 +172,7 @@ classdef Wall < handle
%
% w.setExpansionRateCoeff(k)
%
% :parameter k:
% :param k:
% Expanstion rate coefficient. Unit: m/(s-Pa).
%
@ -252,7 +189,7 @@ classdef Wall < handle
% to specify a constant heat flux by using the polynomial
% functor with only the first term specified.
%
% :parameter f:
% :param f:
% Instance of class 'Func'. Unit: W/m^2.
%
@ -269,7 +206,7 @@ classdef Wall < handle
% to specify a constant velocity by using the polynomial
% functor with only the first term specified.
%
% :parameter f:
% :param f:
% Instance of class 'Func'. Unit: m/s.
%

View File

@ -1,4 +1,3 @@
% LoadCantera
% Load the Cantera C Library into the Memory
%
if ispc

View File

@ -1,4 +1,3 @@
% UnloadCantera
% Unload the Cantear C Library from the Memory
%
if libisloaded(ct)

View File

@ -1,5 +1,4 @@
function output = callct(varargin)
% CALLCT
% Calls Cantera library functions with single outputs and returns
% errors if necessary.

View File

@ -1,5 +1,4 @@
function output = callct2(varargin)
% CALLCT2
% Calls Cantera library functions with string outputs and returns
% errors if necessary.

View File

@ -1,9 +1,10 @@
function v = canteraGitCommit()
% Get Cantera Git commit hash
% Get Cantera Git commit hash.
%
% canteraGitCommit()
%
% :return:
% A string containing the Git commit hash for the current version of Cantera
% A string containing the Git commit hash for the current version of Cantera.
%
checklib;
v = callct2('ct_getGitCommit');

View File

@ -1,9 +1,10 @@
function v = canteraVersion()
% Get Cantera version information
% Get Cantera version information.
%
% canteraVersion()
%
% :return:
% A string containing the Cantera version
% A string containing the Cantera version.
%
checklib;
v = callct2('ct_getCanteraVersion');

View File

@ -1,5 +1,4 @@
function cleanup()
% CLEANUP
% Delete all stored Cantera objects and reclaim memory.
%
checklib;

View File

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

View File

@ -1,5 +1,4 @@
function e = geterr()
% GETERR
% Get the error message from a Cantera error.
%
checklib;