mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Matlab] Documentation updates
This commit is contained in:
parent
55ccdc63b9
commit
1df1da16d9
@ -1,4 +1,12 @@
|
||||
function m = AxiStagnFlow(gas)
|
||||
% Get an axisymmetric stagnation flow domain.
|
||||
% m = AxiStagnFlow(gas)
|
||||
%
|
||||
% :param gas:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
% :return:
|
||||
% Domain1D instance representing an axisymmetric
|
||||
% stagnation flow.
|
||||
%
|
||||
m = Domain1D('StagnationFlow', gas);
|
||||
end
|
||||
|
@ -1,7 +1,14 @@
|
||||
function m = AxisymmetricFlow(gas, id)
|
||||
% Create an axisymmetric flow domain.
|
||||
% m = AxisymmetricFlow(gas, id)
|
||||
%
|
||||
% :param gas:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
% :param id:
|
||||
% String ID of the flow.
|
||||
% String, ID of the flow
|
||||
% :return:
|
||||
% Domain1D instance representing an axisymmetric flow.
|
||||
%
|
||||
m = Domain1D('StagnationFlow', gas);
|
||||
if nargin == 1
|
||||
m.setID('flow');
|
||||
|
@ -1,25 +1,28 @@
|
||||
function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidizer)
|
||||
% Create a counter flow flame stack.
|
||||
% 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 created using
|
||||
% function 'Inlet'.
|
||||
% Object representing the left inlet, which must be
|
||||
% created using function :mat:func:`Inlet`.
|
||||
% :param flow:
|
||||
% Object representing the flow, created with function
|
||||
% 'AxisymmetricFlow'.
|
||||
% Object representing the flow, created with
|
||||
% function :mat:func:`AxisymmetricFlow`.
|
||||
% :param right:
|
||||
% Object representing the right inlet, which must be created using
|
||||
% function 'Inlet'.
|
||||
% Object representing the right inlet, which must be
|
||||
% created using function :mat:func:`Inlet`.
|
||||
% :param tp_f:
|
||||
% Object representing the fuel inlet gas, instance of class
|
||||
% 'Solution', and an ideal gas.
|
||||
% Object representing the fuel inlet gas, instance of class
|
||||
% :mat:func:`Solution`, and an ideal gas.
|
||||
% :param tp_o:
|
||||
% Object representing the oxidizer inlet gas, instance of class
|
||||
% 'Solution', and an ideal gas.
|
||||
% :param oxidier:
|
||||
% String representing the oxidizer species. Most commonly O2.
|
||||
% Object representing the oxidizer inlet gas, instance of class
|
||||
% :mat:func:`Solution`, and an ideal gas.
|
||||
% :param oxidizer:
|
||||
% String representing the oxidizer species. Most commonly O2.
|
||||
% :return:
|
||||
% Instance of 'Stack' representing the left inlet, flow, and right
|
||||
% inlet.
|
||||
% Instance of :mat:func:`Stack` object representing the left
|
||||
% inlet, flow, and right inlet.
|
||||
%
|
||||
|
||||
%% Check input parameters
|
||||
|
||||
|
@ -11,10 +11,11 @@ classdef Domain1D < handle
|
||||
%% Domain1D class constructor.
|
||||
|
||||
function d = Domain1D(a, b, c)
|
||||
% DOMAIN1D Domain1D class constructor.
|
||||
% Domain1D class constructor.
|
||||
%
|
||||
% d = Domain1D(a, b, c)
|
||||
%
|
||||
% :parameter a:
|
||||
% :param a:
|
||||
% String type of domain. Possible values are:
|
||||
% `StagnationFlow`
|
||||
% `Inlet1D`
|
||||
@ -96,8 +97,10 @@ classdef Domain1D < handle
|
||||
%% Utility Methods
|
||||
|
||||
function clear(d)
|
||||
% CLEAR Delete the C++ Domain1D object.
|
||||
% Delete the C++ Domain1D object.
|
||||
%
|
||||
% d.clear
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D` (or another
|
||||
% object that derives from Domain1D)
|
||||
@ -106,8 +109,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function d = disableEnergy(d)
|
||||
% DISABLEENERGY Disable the energy equation.
|
||||
% Disable the energy equation.
|
||||
%
|
||||
% d.disableEnergy
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
%
|
||||
@ -117,8 +122,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function d = enableEnergy(d)
|
||||
% ENABLEENERGY Enable the energy equation.
|
||||
% Enable the energy equation.
|
||||
%
|
||||
% d.enableEnergy
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
%
|
||||
@ -128,8 +135,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function d = disableSoret(d)
|
||||
% DISABLESORET Disable the diffusive mass fluxes due to the Soret effect.
|
||||
% Disable the diffusive mass fluxes due to the Soret effect.
|
||||
%
|
||||
% d.disableSoret
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
%
|
||||
@ -139,8 +148,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function d = enableSoret(d)
|
||||
% ENABLESORET Enable the diffusive mass fluxes due to the Soret effect.
|
||||
% Enable the diffusive mass fluxes due to the Soret effect.
|
||||
%
|
||||
% d.enableSoret
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
%
|
||||
@ -152,8 +163,10 @@ classdef Domain1D < handle
|
||||
%% Domain Get Methods
|
||||
|
||||
function b = bounds(d, component)
|
||||
% BOUNDS Return the (lower, upper) bounds for a solution component.
|
||||
% d.bounds(componoent)
|
||||
% 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.
|
||||
@ -167,8 +180,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function n = componentIndex(d, name)
|
||||
% COMPONENTINDEX Get the index of a component given its name.
|
||||
% Get the index of a component given its name.
|
||||
%
|
||||
% n = d.componentIndex(name)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param name:
|
||||
@ -192,12 +207,14 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function n = componentName(d, index)
|
||||
% COMPONENTNAME Get the name of a component given its 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 components' names
|
||||
% Integer or vector of integers of component names
|
||||
% to get.
|
||||
% :return:
|
||||
% Cell array of component names.
|
||||
@ -218,8 +235,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function i = domainIndex(d)
|
||||
% DOMAININDEX Get the domain index.
|
||||
% Get the domain index.
|
||||
%
|
||||
% i = d.domainIndex
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -236,8 +255,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function i = domainType(d)
|
||||
% DOMAINTYPE Get the type of domain.
|
||||
% Get the type of domain.
|
||||
%
|
||||
% i = d.domainType
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -249,9 +270,12 @@ classdef Domain1D < handle
|
||||
|
||||
function zz = gridPoints(d, n)
|
||||
% Get grid points from a domain.
|
||||
% :parameter d:
|
||||
%
|
||||
% zz = d.gridPoints(n)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class 'Domain1D'.
|
||||
% :parameter n:
|
||||
% :param n:
|
||||
% Optional, vector of grid points to be retrieved.
|
||||
% :return:
|
||||
% Vector of grid points.
|
||||
@ -272,8 +296,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function a = isFlow(d)
|
||||
% ISFLOW Determine whether a domain is a flow.
|
||||
% Determine whether a domain is a flow.
|
||||
%
|
||||
% a = d.isFlow
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -288,8 +314,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function a = isInlet(d)
|
||||
% ISINLET Determine whether a domain is an inlet.
|
||||
% Determine whether a domain is an inlet.
|
||||
%
|
||||
% a = d.isInlet
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -304,8 +332,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function a = isSurface(d)
|
||||
% ISSURFACE Determine if a domain is a surface.
|
||||
% Determine if a domain is a surface.
|
||||
%
|
||||
% a = d.isSurface
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -320,8 +350,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function mdot = massFlux(d)
|
||||
% MASSFLUX Get the mass flux.
|
||||
% Get the mass flux.
|
||||
%
|
||||
% mdot = d.massFlux
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -331,8 +363,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function y = massFraction(d, k)
|
||||
% MASSFRACTION Get the mass fraction of a species given its integer index.
|
||||
% 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.
|
||||
@ -355,8 +389,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function n = nComponents(d)
|
||||
% NCOMPONENTS Get the number of components.
|
||||
% Get the number of components.
|
||||
%
|
||||
% n = d.nComponents
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -366,8 +402,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function n = nPoints(d)
|
||||
% NPOINTS Get the number of grid points.
|
||||
% Get the number of grid points.
|
||||
%
|
||||
% n = d.nPoints
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -377,9 +415,11 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function tol = tolerances(d, component)
|
||||
% TOLERANCES Return the (relative, absolute) error tolerances for a
|
||||
% 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.
|
||||
@ -394,7 +434,9 @@ classdef Domain1D < handle
|
||||
|
||||
function temperature = get.T(d)
|
||||
% GET.T Get the boundary temperature.
|
||||
%
|
||||
% temperature = d.T
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -405,7 +447,9 @@ classdef Domain1D < handle
|
||||
|
||||
function pressure = get.P(d)
|
||||
% GET.P Get the boundary pressure.
|
||||
%
|
||||
% pressure = d.P
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :return:
|
||||
@ -418,7 +462,9 @@ classdef Domain1D < handle
|
||||
|
||||
function set.T(d, t)
|
||||
% SET.T Set the temperature.
|
||||
%
|
||||
% d.T = t
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param t:
|
||||
@ -432,7 +478,9 @@ classdef Domain1D < handle
|
||||
|
||||
function set.P(d, p)
|
||||
% SET.P Set the pressure.
|
||||
%
|
||||
% d.P = p
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param p:
|
||||
@ -446,22 +494,28 @@ classdef Domain1D < handle
|
||||
|
||||
function setBounds(d, component, lower, upper)
|
||||
% Set bounds on the solution components.
|
||||
% :parameter d:
|
||||
%
|
||||
% d.setBounds(component, lower, upper)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class 'Domain1D'.
|
||||
% :parameter component:
|
||||
% :param component:
|
||||
% String, component to set the bounds on.
|
||||
% :parameter lower:
|
||||
% :param lower:
|
||||
% Lower bound.
|
||||
% :parameter upper:
|
||||
% :param upper:
|
||||
% Upper bound.
|
||||
%
|
||||
|
||||
n = d.componentIndex(component);
|
||||
calllib(ct, 'domain_setBounds', d.domainID, n-1, lower, upper);
|
||||
end
|
||||
|
||||
function setCoverageEqs(d, onoff)
|
||||
% SETBOUNDS Set bounds on the solution components.
|
||||
% Set bounds on the solution components.
|
||||
%
|
||||
% d.setBounds(component, lower, upper)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param component:
|
||||
@ -491,8 +545,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setFixedTempProfile(d, profile)
|
||||
% SETFIXEDTEMPPROFILE Set a fixed temperature profile.
|
||||
% Set a fixed temperature profile.
|
||||
%
|
||||
% d.setFixedTempProfile(profile)
|
||||
%
|
||||
% Set the temperature profile to use when the
|
||||
% energy equation is not being solved. The profile must be entered
|
||||
% as an array of positions / temperatures, which may be in rows or
|
||||
@ -518,8 +574,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setID(d, id)
|
||||
% SETID Set the ID tag for a domain.
|
||||
% Set the ID tag for a domain.
|
||||
%
|
||||
% d.setID(id)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param id:
|
||||
@ -529,19 +587,23 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setMdot(d, mdot)
|
||||
% SETMDOT Set the mass flow rate.
|
||||
% d.setMdot(mdot)
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param mdot:
|
||||
% Mass flow rate
|
||||
%
|
||||
% Set the mass flow rate.
|
||||
%
|
||||
% d.setMdot(mdot)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param mdot:
|
||||
% Mass flow rate
|
||||
%
|
||||
calllib(ct, 'bdry_setMdot', d.domainID, mdot);
|
||||
end
|
||||
|
||||
function setMoleFractions(d, x)
|
||||
% SETMOLEFRACTIONS Set the mole fractions.
|
||||
% Set the mole fractions.
|
||||
%
|
||||
% d.setMoleFractions(x)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param x:
|
||||
@ -552,8 +614,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setProfileD(d, n, p)
|
||||
% SETPROFILED Set the profile of a component.
|
||||
% Set the profile of a component.
|
||||
%
|
||||
% d.setProfileD(n, p)
|
||||
%
|
||||
% Convenience function to allow an instance of :mat:func:`Domain1D` to
|
||||
% have a profile of its components set when it is part of a :mat:func:`Stack`.
|
||||
%
|
||||
@ -574,8 +638,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setSteadyTolerances(d, component, rtol, atol)
|
||||
% SETSTEADYTOLERANCES Set the steady-state tolerances.
|
||||
% Set the steady-state tolerances.
|
||||
%
|
||||
% d.setSteadyTolerances(component, rtol, atol)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param component:
|
||||
@ -608,8 +674,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setTransientTolerances(d, component, rtol, atol)
|
||||
% SETTRANSIENTTOLERANCES Set the transient tolerances.
|
||||
% Set the transient tolerances.
|
||||
%
|
||||
% d.setTransientTolerances(component, rtol, atol)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param component:
|
||||
@ -642,8 +710,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setTransport(d, itr)
|
||||
% SETTRANSPORT Set the solution object used for calculating transport properties.
|
||||
% Set the solution object used for calculating transport properties.
|
||||
%
|
||||
% d.setTransport(itr)
|
||||
%
|
||||
% :param itr:
|
||||
% ID of the solution object for which transport properties
|
||||
% are calculated.
|
||||
@ -652,8 +722,10 @@ classdef Domain1D < handle
|
||||
end
|
||||
|
||||
function setupGrid(d, grid)
|
||||
% SETUPGRID Set up the solution grid.
|
||||
% Set up the solution grid.
|
||||
%
|
||||
% d.setupGrid(grid)
|
||||
%
|
||||
% :param d:
|
||||
% Instance of class :mat:func:`Domain1D`
|
||||
% :param grid:
|
||||
|
@ -1,5 +1,15 @@
|
||||
function m = FreeFlame(gas, id)
|
||||
% Create a freely-propagating flat flame.
|
||||
% m = FreeFlame(gas, id)
|
||||
%
|
||||
% :param gas:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
% :param id:
|
||||
% String, ID of the flow
|
||||
% :return:
|
||||
% Domain1D instance representing a freely propagating,
|
||||
% adiabatic flame
|
||||
%
|
||||
m = Domain1D('StagnationFlow', gas, 2);
|
||||
if nargin == 1
|
||||
m.setID('flame');
|
||||
|
@ -1,5 +1,14 @@
|
||||
function m = Inlet(id)
|
||||
% Create an inlet domain.
|
||||
% 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.
|
||||
%
|
||||
% :param id:
|
||||
% String name of the inlet.
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Domain1D` representing an inlet.
|
||||
%
|
||||
m = Domain1D('Inlet1D');
|
||||
if nargin == 0
|
||||
m.setID('inlet');
|
||||
|
@ -1,5 +1,12 @@
|
||||
function m = Outlet(id)
|
||||
% Create an outlet domain.
|
||||
% m = Outlet(id)
|
||||
%
|
||||
% :param id:
|
||||
% String ID of the outlet.
|
||||
% :return:
|
||||
% Instance of :mat:func:`Domain1D` representing an outlet.
|
||||
%
|
||||
m = Domain1D('Outlet1D');
|
||||
if nargin == 0
|
||||
m.setID('outlet');
|
||||
|
@ -1,5 +1,11 @@
|
||||
function m = OutletRes(id)
|
||||
% Create an outlet reservoir domain.
|
||||
% m = OutletRes(id)
|
||||
%
|
||||
% :return:
|
||||
% Instance of :mat:func:`Domain1D` representing an outlet
|
||||
% reservoir.
|
||||
%
|
||||
m = Domain1D('OutletRes');
|
||||
if nargin == 0
|
||||
m.setID('outletres');
|
||||
|
@ -9,15 +9,21 @@ classdef Stack < handle
|
||||
%% Stack class constructor
|
||||
|
||||
function s = Stack(domains)
|
||||
% Stack class constructor.
|
||||
%
|
||||
% s = Stack(domains)
|
||||
%
|
||||
% A stack object is a container for one-dimensional domains,
|
||||
% which are instances of class Domain1D. The domains are of two
|
||||
% types - extended domains, and connector domains.
|
||||
%
|
||||
% :parameter domains:
|
||||
% Vector of domain instances.
|
||||
% See also: :mat:func:`Domain1D`
|
||||
%
|
||||
% :param domains:
|
||||
% Vector of domain instances
|
||||
% :return:
|
||||
% Instance of class 'Stack'.
|
||||
|
||||
% Instance of class :mat:func:`Stack`
|
||||
%
|
||||
checklib;
|
||||
|
||||
s.stID = -1;
|
||||
@ -41,20 +47,26 @@ classdef Stack < handle
|
||||
%% Utility Methods
|
||||
|
||||
function clear(s)
|
||||
% Delete the Sim1D object
|
||||
|
||||
% Delete the C++ Sim1D object.
|
||||
%
|
||||
% s.clear
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
%
|
||||
calllib(ct, 'sim1D_del', s.stID);
|
||||
end
|
||||
|
||||
function display(s, fname)
|
||||
% Show all domains.
|
||||
%
|
||||
% :parameter s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter fname:
|
||||
% File to write summary to. If omitted, output is to the
|
||||
% command window.
|
||||
|
||||
% 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
|
||||
@ -66,9 +78,11 @@ classdef Stack < handle
|
||||
function n = stackIndex(s, name)
|
||||
% Get the index of a domain in a stack given its name.
|
||||
%
|
||||
% :parameter s:
|
||||
% n = s.stackIndex(name)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter name:
|
||||
% :param name:
|
||||
% If double, the value is :returned. Otherwise, the name is
|
||||
% looked up and its index is :returned.
|
||||
% :return:
|
||||
@ -95,13 +109,16 @@ classdef Stack < handle
|
||||
function z = grid(s, name)
|
||||
% Get the grid in one domain.
|
||||
%
|
||||
% :parameter s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter name:
|
||||
% Name of the domain for which the grid should be retrieved.
|
||||
% 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.
|
||||
|
||||
% The grid in domain name
|
||||
%
|
||||
n = s.stackIndex(name);
|
||||
d = s.domains(n);
|
||||
z = d.gridPoints;
|
||||
@ -110,13 +127,16 @@ classdef Stack < handle
|
||||
function plotSolution(s, domain, component)
|
||||
% Plot a specified solution component.
|
||||
%
|
||||
% :parameter s:
|
||||
% s.plotSolution(domain, component)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter domain:
|
||||
% :param domain:
|
||||
% Name of domain from which the component should be
|
||||
% retrieved.
|
||||
% :parameter component:
|
||||
% :param component:
|
||||
% Name of the component to be plotted.
|
||||
%
|
||||
|
||||
n = s.stackIndex(domain);
|
||||
d = s.domains(n);
|
||||
@ -130,13 +150,16 @@ classdef Stack < handle
|
||||
function r = resid(s, domain, rdt, count)
|
||||
% Get the residuals.
|
||||
%
|
||||
% :parameter s:
|
||||
% r = s.resid(domain, rdt, count)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter domain:
|
||||
% :param domain:
|
||||
% Name of the domain.
|
||||
% :parameter rdt:
|
||||
% :parameter count:
|
||||
% :param rdt:
|
||||
% :param count:
|
||||
% :return:
|
||||
%
|
||||
|
||||
if nargin == 2
|
||||
rdt = 0.0;
|
||||
@ -161,32 +184,41 @@ classdef Stack < handle
|
||||
|
||||
function restore(s, fname, id)
|
||||
% Restore a previously-saved solution.
|
||||
% This method can be used ot provide an initial guess for the
|
||||
% solution.
|
||||
%
|
||||
% :parameter s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter fname:
|
||||
% File name of an XML file containing solution info.
|
||||
% :parameter id:
|
||||
% ID of the element that should be restored.
|
||||
|
||||
% s.restore(fname, id)
|
||||
%
|
||||
% This method can be used to provide an initial guess for the solution.
|
||||
%
|
||||
% See also: :mat:func:`save`
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% :param fname:
|
||||
% File name of an XML file containing solution information
|
||||
% :param id:
|
||||
% ID of the element that should be restored
|
||||
%
|
||||
calllib(ct, 'sim1D_restore', s.stID, fname, id)
|
||||
end
|
||||
|
||||
function saveSoln(s, fname, id, desc)
|
||||
% Save a solution to a file.
|
||||
% The output file is in a format that can be used by 'restore'.
|
||||
%
|
||||
% :parameter s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter fname:
|
||||
% File name where XML file should be written.
|
||||
% :parameter id:
|
||||
% ID to be assigned to the XMl element when it is written.
|
||||
% :parameter desc:
|
||||
% Description to be written to the output file.
|
||||
|
||||
% s.saveSoln(fname, id, desc)
|
||||
%
|
||||
% The output file is in a format that
|
||||
% can be used by :mat:func:`restore`
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
% :param fname:
|
||||
% File name where XML file should be written
|
||||
% :param id:
|
||||
% ID to be assigned to the XML element when it is
|
||||
% written
|
||||
% :param desc:
|
||||
% Description to be written to the output file
|
||||
%
|
||||
if nargin == 1
|
||||
fname = 'soln.xml';
|
||||
id = 'solution';
|
||||
@ -204,8 +236,11 @@ classdef Stack < handle
|
||||
% Set the temperature used to fix the spatial location of a
|
||||
% freely propagating flame.
|
||||
%
|
||||
% :parameter T:
|
||||
% s.setFixedTemperature(T)
|
||||
%
|
||||
% :param T:
|
||||
% Double Temperature to be set. Unit: K.
|
||||
%
|
||||
|
||||
if T <= 0
|
||||
error('temperature must be positive');
|
||||
@ -216,14 +251,17 @@ classdef Stack < handle
|
||||
function setFlatProfile(s, domain, comp, v)
|
||||
% Set a component to a value across the entire domain.
|
||||
%
|
||||
% :parameter s:
|
||||
% s.setFlatProfile(domain, comp, v)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter domain:
|
||||
% :param domain:
|
||||
% Integer ID of the domain.
|
||||
% :parameter comp:
|
||||
% :param comp:
|
||||
% Component to be set.
|
||||
% :parameter v:
|
||||
% :param v:
|
||||
% Double value to be set.
|
||||
%
|
||||
|
||||
calllib(ct, 'sim1D_setFlatProfile', s.stID, ...
|
||||
domain - 1, comp - 1, v);
|
||||
@ -232,10 +270,13 @@ classdef Stack < handle
|
||||
function setGridMin(s, domain, gridmin)
|
||||
% Set the minimum grid spacing on domain.
|
||||
%
|
||||
% :parameter domain:
|
||||
% s.setGridMin(domain, gridmin)
|
||||
%
|
||||
% :param domain:
|
||||
% Integer ID of the domain.
|
||||
% :parameter gridmin:
|
||||
% :param gridmin:
|
||||
% Double minimum grid spacing.
|
||||
%
|
||||
|
||||
calllib(ct, 'sim1D_setGridMin', s.stID, domain-1, gridmin);
|
||||
end
|
||||
@ -244,13 +285,16 @@ classdef Stack < handle
|
||||
% Set the number of times the Jacobian will be used before it
|
||||
% is recomputed.
|
||||
%
|
||||
% :parameter s:
|
||||
% s.setMaxJacAge(ss_age, ts_age)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter ss_age:
|
||||
% :param ss_age:
|
||||
% Maximum age of the Jacobian for steady state analysis.
|
||||
% :parameter ts_age:
|
||||
% :param ts_age:
|
||||
% Maximum age of the Jacobian for transient analysis. If not
|
||||
% specified, deftauls to 'ss_age'.
|
||||
% specified, defaults to 'ss_age'.
|
||||
%
|
||||
|
||||
if nargin == 2
|
||||
ts_age = ss_age;
|
||||
@ -261,6 +305,8 @@ classdef Stack < handle
|
||||
function setProfile(s, name, comp, p)
|
||||
% Specify a profile for one component,
|
||||
%
|
||||
% s.setProfile(name, comp, p)
|
||||
%
|
||||
% The solution vector values for this component will be
|
||||
% linearly interpolated from the discrete function defined by
|
||||
% p(:, 1) vs p(:, 2).
|
||||
@ -275,16 +321,17 @@ classdef Stack < handle
|
||||
% >> v = [500, 650, 700, 730, 800, 900];
|
||||
% >> s.setProfile(1, 2, [zr, v]);
|
||||
%
|
||||
% :parameter s:
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter name:
|
||||
% :param name:
|
||||
% Domain name.
|
||||
% :parameter comp:
|
||||
% :param comp:
|
||||
% Component number.
|
||||
% :parameter p:
|
||||
% :param p:
|
||||
% n x 2 array, whose columns are the relative (normalized)
|
||||
% positions and the component values at those points. The
|
||||
% number of positions 'n' is arbitrary.
|
||||
%
|
||||
|
||||
if isa(name, 'double')
|
||||
n = name;
|
||||
@ -322,21 +369,24 @@ classdef Stack < handle
|
||||
function setRefineCriteria(s, n, ratio, slope, curve, prune)
|
||||
% Set the criteria used to refine the grid.
|
||||
%
|
||||
% :parameter s:
|
||||
% s.setRefineCriteria(n, ratio, slope, curve, prune)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter ratio:
|
||||
% :param ratio:
|
||||
% Maximum size ratio between adjacent cells.
|
||||
% :parameter slope:
|
||||
% :param slope:
|
||||
% Maximum relative difference in value between adjacent
|
||||
% points.
|
||||
% :parameter curve:
|
||||
% :param curve:
|
||||
% Maximum relative difference in slope between adjacent
|
||||
% cells.
|
||||
% :parameter prune:
|
||||
% :param prune:
|
||||
% Minimum value for slope or curve for which points will be
|
||||
% retained or curve value is below prune for all components,
|
||||
% it will be deleted, unless either neighboring point is
|
||||
% already marked for deletion.
|
||||
%
|
||||
|
||||
if nargin < 3
|
||||
ratio = 10.0;
|
||||
@ -357,14 +407,17 @@ classdef Stack < handle
|
||||
function setTimeStep(s, stepsize, steps)
|
||||
% Specify a sequence of time steps.
|
||||
%
|
||||
% :parameter stepsize:
|
||||
% s.setTimeStep(stepsize, steps)
|
||||
%
|
||||
% :param stepsize:
|
||||
% Initial step size.
|
||||
% :parameter steps:
|
||||
% :param steps:
|
||||
% Vector of number of steps to take before re-attempting
|
||||
% solution of steady-state problem.
|
||||
% For example, steps = [1, 2, 5, 10] would cause one time
|
||||
% step to be taken first time the steady-state solution
|
||||
% attempted. If this failed, two time steps would be taken.
|
||||
%
|
||||
|
||||
calllib(ct, 'sim1D_TimeStep', s.stID, ...
|
||||
stepsize, length(steps), steps);
|
||||
@ -373,6 +426,8 @@ classdef Stack < handle
|
||||
function setValue(s, n, comp, localPoints, v)
|
||||
% Set the value of a single entry in the solution vector.
|
||||
%
|
||||
% s.setValue(n, comp, localPoints, v)
|
||||
%
|
||||
% Example (assuming 's' is an instance of class 'Stack'):
|
||||
%
|
||||
% setValue(s, 3, 5, 1, 5.6);
|
||||
@ -383,16 +438,17 @@ classdef Stack < handle
|
||||
% the global index of the point, wchih depends on the location
|
||||
% of this domain in the stack.
|
||||
%
|
||||
% :parameter s:
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter n:
|
||||
% :param n:
|
||||
% Domain number.
|
||||
% :parameter comp:
|
||||
% :param comp:
|
||||
% Component number.
|
||||
% :parameter localPoints:
|
||||
% :param localPoints:
|
||||
% Local index of the grid point in the domain.
|
||||
% :parameter v:
|
||||
% :param v:
|
||||
% Value to be set.
|
||||
%
|
||||
|
||||
calllib(ct, 'sim1D_setValue', s.stID, ...
|
||||
n - 1, comp - 1, localPoints - 1, v);
|
||||
@ -401,18 +457,21 @@ classdef Stack < handle
|
||||
function x = solution(s, domain, component)
|
||||
% Get a solution component in one domain.
|
||||
%
|
||||
% :parameter s:
|
||||
% s.solution(domain, component)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter domain:
|
||||
% :param domain:
|
||||
% String name of the domain from which the solution is
|
||||
% desired.
|
||||
% :parameter component:
|
||||
% :param component:
|
||||
% String component for which the solution is desired. If
|
||||
% omitted, solution for all of the components will be
|
||||
% :returned in an 'nPoints' x 'nComponnts' array.
|
||||
% :return:
|
||||
% Either an 'nPoints' x 1 vector, or 'nPoints' x
|
||||
% 'nCOmponents' array.
|
||||
%
|
||||
|
||||
idom = s.stackIndex(domain);
|
||||
d = s.domains(idom);
|
||||
@ -439,23 +498,33 @@ classdef Stack < handle
|
||||
function solve(s, loglevel, refineGrid)
|
||||
% Solve the problem.
|
||||
%
|
||||
% :parameter s:
|
||||
% s.solve(loglevel, refineGrid)
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class 'Stack'.
|
||||
% :parameter loglevel:
|
||||
% :param loglevel:
|
||||
% Integer flag controlling the amount of diagnostic output.
|
||||
% Zero supresses all output, and 5 produces very verbose
|
||||
% output.
|
||||
% :parameter refine_grid:
|
||||
% :param refineGrid:
|
||||
% Integer, 1 to allow grid refinement, 0 to disallow.
|
||||
%
|
||||
|
||||
calllib(ct, 'sim1D_solve', s.stID, loglevel, refineGrid);
|
||||
end
|
||||
|
||||
function writeStats(s)
|
||||
% Print statistics for the current solution.
|
||||
% Prints a summary of the number of function and Jacobian
|
||||
% evaluations for each grid, and the CPU time spent on each
|
||||
% one.
|
||||
%
|
||||
% writeStats(s)
|
||||
%
|
||||
% Prints a summary of the number of function and
|
||||
% Jacobian evaluations for each grid, and the CPU time spent on
|
||||
% each one.
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Stack`
|
||||
%
|
||||
|
||||
calllib(ct, 'sim1D_writeStats', s.stID, 1);
|
||||
end
|
||||
|
@ -1,8 +1,16 @@
|
||||
function m = Surface(id, surface_mech)
|
||||
% Create an surface domain.
|
||||
% :param surface_mech
|
||||
% Instance of class 'Interface' defining the surface reaction
|
||||
% mechanism to be used. Optional.
|
||||
% Create a surface domain.
|
||||
% m = Surface(id, surface_mech)
|
||||
%
|
||||
% :param id:
|
||||
% String ID of surface
|
||||
% :param surface_mech:
|
||||
% Instance of class :mat:func:`Interface` defining
|
||||
% the surface reaction mechanism to be used. Optional.
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Domain1D` representing a
|
||||
% non-reacting or reacting surface.
|
||||
%
|
||||
if nargin < 2
|
||||
m = Domain1D('Surf1D');
|
||||
if nargin == 0
|
||||
|
@ -1,5 +1,13 @@
|
||||
function m = SymmPlane(id)
|
||||
% Create an symmetry plane domain.
|
||||
% Create a symmetry plane domain.
|
||||
% m = SymmPlane(id)
|
||||
%
|
||||
% :param id:
|
||||
% String ID of the symmetry plane.
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Domain1D` representing a symmetry
|
||||
% plane.
|
||||
%
|
||||
m = Domain1D(Symm1D);
|
||||
if nargin == 0
|
||||
m.setID('symmetry_plane');
|
||||
|
@ -1,4 +1,12 @@
|
||||
function gas = Air()
|
||||
% Create an object representing air.
|
||||
% gas = Air()
|
||||
% Air is modeled as an ideal gas mixture. The specification is taken
|
||||
% from file ``air.yaml``. Several reactions among oxygen and nitrogen are
|
||||
% defined. Mixture-averaged transport is specified by default.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
gas = Solution('air.yaml', 'air');
|
||||
end
|
||||
|
@ -1,4 +1,20 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances.* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% For more details, see classes Cantera::PureFluid and tpx::CarbonDioxide in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'carbon-dioxide');
|
||||
end
|
||||
|
@ -1,4 +1,21 @@
|
||||
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.
|
||||
% Chem. Ref. Data, Vol. 23, No. 5, 1994. pp. 657--729.
|
||||
% http://dx.doi.org/10.1063/1.555958
|
||||
%
|
||||
% For more details, see classes Cantera::PureFluid and tpx::HFC134a in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'HFC-134a');
|
||||
end
|
||||
|
@ -1,4 +1,20 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances.* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% For more details, see classes Cantera::PureFluid and tpx::Heptane in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'heptane');
|
||||
end
|
||||
|
@ -1,4 +1,20 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% For more details, see classes Cantera::PureFluid and tpx::hydrogen in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'hydrogen');
|
||||
end
|
||||
|
@ -1,4 +1,17 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'methane');
|
||||
end
|
||||
|
@ -1,4 +1,17 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'nitrogen');
|
||||
end
|
||||
|
@ -1,4 +1,17 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
h = Solution('liquidvapor.yaml', 'oxygen');
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
|
||||
properties
|
||||
properties (Access = private)
|
||||
tp
|
||||
end
|
||||
|
||||
@ -8,8 +8,10 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
|
||||
%% Solution class constructor
|
||||
function s = Solution(src, id, trans)
|
||||
% SOLUTION Solution class constructor.
|
||||
% Solution class constructor.
|
||||
%
|
||||
% s = Solution(src, id, trans)
|
||||
%
|
||||
% Class :mat:func:`Solution` represents solutions of multiple species. A
|
||||
% solution is defined as a mixture of two or more constituents
|
||||
% (species) that are completely mixed on molecular length
|
||||
@ -73,8 +75,10 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
|
||||
% Delete the kernel objects associated with a solution
|
||||
function clear(s)
|
||||
% CLEAR Delete the kernel objects associated with a Solution.
|
||||
% Delete the kernel objects associated with a Solution.
|
||||
%
|
||||
% s.clear
|
||||
%
|
||||
% :param s:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
|
@ -10,7 +10,7 @@ classdef ThermoPhase < handle
|
||||
H % enthalpy
|
||||
S % entropy
|
||||
U % internal energy
|
||||
G % Gibbs free energy
|
||||
G % Gibbs free energye
|
||||
basis
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,20 @@
|
||||
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
|
||||
% equation of state is taken from
|
||||
%
|
||||
% Reynolds, W. C. *Thermodynamic Properties in SI: graphs, tables, and
|
||||
% computational equations for forty substances.* Stanford: Stanford
|
||||
% University, 1979. Print.
|
||||
%
|
||||
% For more details, see classes Cantera::PureFluid and tpx::water in the
|
||||
% Cantera C++ source code documentation.
|
||||
%
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Solution`
|
||||
%
|
||||
w = Solution('liquidvapor.yaml', 'water');
|
||||
end
|
||||
|
@ -1,4 +1,9 @@
|
||||
function r = faradayconstant
|
||||
% Get the Faraday constant in C/kmol of electron.
|
||||
% r = faradayconstant
|
||||
%
|
||||
% :return:
|
||||
% The Faraday constant in C/kmol-e.
|
||||
%
|
||||
r = 96485336.4595687;
|
||||
end
|
||||
|
@ -12,8 +12,10 @@ classdef Func < handle
|
||||
%% Functor class constructor
|
||||
|
||||
function x = Func(typ, n, p)
|
||||
% FUNC Func class constructor.
|
||||
% Func class constructor.
|
||||
%
|
||||
% 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
|
||||
@ -74,7 +76,7 @@ classdef Func < handle
|
||||
itype = -1;
|
||||
|
||||
function nn = newFunc(itype, n, p)
|
||||
% helper function to pass the correct :parameters to the C
|
||||
% helper function to pass the correct parameters to the C
|
||||
% library
|
||||
if itype < 20
|
||||
[m, n] = size(p);
|
||||
@ -129,8 +131,10 @@ classdef Func < handle
|
||||
%% Utility methods
|
||||
|
||||
function clear(f)
|
||||
% CLEAR Delete the C++ Func1 object.
|
||||
% Delete the C++ Func1 object.
|
||||
%
|
||||
% f.clear
|
||||
%
|
||||
% :param f:
|
||||
% Instance of class :mat:func:`Func`
|
||||
%
|
||||
@ -138,8 +142,10 @@ classdef Func < handle
|
||||
end
|
||||
|
||||
function display(f)
|
||||
% DISPLAY Display the equation of the input function on the terminal.
|
||||
% Display the equation of the input function on the terminal.
|
||||
%
|
||||
% f.display
|
||||
%
|
||||
% :param f:
|
||||
% Instance of class :mat:func:`Func`
|
||||
%
|
||||
@ -151,8 +157,10 @@ classdef Func < handle
|
||||
end
|
||||
|
||||
function b = subsref(a, s)
|
||||
% SUBSREF Redefine subscripted references for functors.
|
||||
% Redefine subscripted references for functors.
|
||||
%
|
||||
% b = a.subsref(s)
|
||||
%
|
||||
% :param a:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :param s:
|
||||
@ -171,8 +179,10 @@ classdef Func < handle
|
||||
end
|
||||
|
||||
function s = char(f)
|
||||
% CHAR Get the formatted string to display the function.
|
||||
% Get the formatted string to display the function.
|
||||
%
|
||||
% s = f.char
|
||||
%
|
||||
% :param f:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :return:
|
||||
|
@ -1,5 +1,13 @@
|
||||
function r = fplus(a, b)
|
||||
% Get a functor representing the sum two input functors 'a' and
|
||||
% 'b'.
|
||||
% Get a functor representing the sum of two input functors.
|
||||
% r = fplus(a, b)
|
||||
%
|
||||
% :param a:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :param b:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Func`
|
||||
%
|
||||
r = Func('sum', a, b);
|
||||
end
|
||||
|
@ -1,5 +1,13 @@
|
||||
function r = frdivide(a, b)
|
||||
% Get a functor that is the ratio of the input functors 'a' and
|
||||
% 'b'.
|
||||
% Get a functor that is the ratio of the input functors.
|
||||
% r = frdivide(a,b)
|
||||
%
|
||||
% :param a:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :param b:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Func`
|
||||
%
|
||||
r = Func('ratio', a, b);
|
||||
end
|
||||
|
@ -1,4 +1,13 @@
|
||||
function r = ftimes(a, b)
|
||||
% Get a functor that multiplies two functors 'a' and 'b'
|
||||
% Create a functor that multiplies two other functors.
|
||||
% r = ftimes(a, b)
|
||||
%
|
||||
% :param a:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :param b:
|
||||
% Instance of class :mat:func:`Func`
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Func`
|
||||
%
|
||||
r = Func('prod', a, b);
|
||||
end
|
||||
|
@ -1,12 +1,16 @@
|
||||
function g = gaussian(peak, center, width)
|
||||
% Create a Gaussian functor instance.
|
||||
% Create a Gaussian :mat:func:`Func` instance.
|
||||
% g = gaussian(peak, center, width)
|
||||
%
|
||||
% :param peak:
|
||||
% The peak value.
|
||||
% The peak value
|
||||
% :param center:
|
||||
% Value of x at which the peak is located.
|
||||
% Value of x at which the peak is located
|
||||
% :param width:
|
||||
% Full width at half-maximum. The value of the function at center
|
||||
% +/- (width)/2 is one-half the peak value.
|
||||
% Full width at half-maximum. The value of the
|
||||
% function at center +/- (width)/2 is one-half
|
||||
% the peak value.
|
||||
%
|
||||
|
||||
g = Func('gaussian', 0, [peak, center, width]);
|
||||
end
|
||||
|
@ -1,10 +1,19 @@
|
||||
function poly = polynom(coeffs)
|
||||
% Create a polynomial functor instance.
|
||||
% The polynomial coefficients are specified by a vector [a0, a1, ...
|
||||
% an]. Examples:
|
||||
% Create a polynomial :mat:func:`Func` instance.
|
||||
% poly = polynom(coeffs)
|
||||
% The polynomial coefficients are specified by a vector
|
||||
% ``[a0 a1 .... aN]``. Examples:
|
||||
%
|
||||
% .. code-block:: matlab
|
||||
%
|
||||
% polynom([-2 6 3]) %3x^2 + 6.0x - 2
|
||||
% polynom([1.0 -2.5 0 0 2]) %2x^4 - 2.5x + 1
|
||||
%
|
||||
% :param coeffs:
|
||||
% Vector of polynomial coefficients
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Func`
|
||||
%
|
||||
% polynom([-2, 6, 3]) % 3x^2+6x-2
|
||||
% polynom([1.0, -2.5, 0, 0, 2]) % 2x^4-2.5x+1
|
||||
|
||||
[n m] = size(coeffs);
|
||||
if n == 1
|
||||
|
457
interfaces/matlab_experimental/Phases/Mixture.m
Normal file
457
interfaces/matlab_experimental/Phases/Mixture.m
Normal file
@ -0,0 +1,457 @@
|
||||
classdef Mixture < handle
|
||||
|
||||
properties
|
||||
mixID
|
||||
phases % Phases in the mixture
|
||||
T % Temperature
|
||||
P % Pressure
|
||||
end
|
||||
|
||||
methods
|
||||
%% 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
|
||||
error('Mixture: wrong number of arguments');
|
||||
end
|
||||
|
||||
% Create an empty mixture.
|
||||
m.mixID = calllib(ct, 'mix_new');
|
||||
m.phases = phases;
|
||||
|
||||
% If phases are supplied, add them
|
||||
if nargin == 1
|
||||
if ~isa(phases, 'cell')
|
||||
error('Enter phases as a cell array.');
|
||||
end
|
||||
|
||||
% First column contains the phase objects, and the second
|
||||
% column contains the mole numbers of each phase.
|
||||
[np, nc] = size(phases);
|
||||
if nc ~= 2
|
||||
error('Cell array of phases should have each phase on a new row');
|
||||
end
|
||||
for n = 1:np
|
||||
m.addPhase(phases{n, 1}, phases{n, 2});
|
||||
end
|
||||
m.T = phases{n, 1}.T;
|
||||
m.P = phases{n, 1}.P;
|
||||
end
|
||||
end
|
||||
|
||||
%% 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`
|
||||
%
|
||||
calllib(ct, 'mix_updatePhases', m.mixID);
|
||||
[np, nc] = size(m.phases);
|
||||
for n = 1:np
|
||||
s = [sprintf('\n******************* Phase %d', n) ...
|
||||
sprintf(' ******************************\n\n Moles: %12.6g', ...
|
||||
phaseMoles(m, n))];
|
||||
disp(s);
|
||||
display(m.phases{n, 1});
|
||||
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.
|
||||
% addPhase(self, phase, moles)
|
||||
% :param self:
|
||||
% Instance of class :mat:func:`Mixture` to which phases should be
|
||||
% added
|
||||
% :param phase:
|
||||
% Instance of class :mat:func:`ThermoPhase` which should be added
|
||||
% :param moles:
|
||||
% Number of moles of the ``phase`` to be added to this mixture.
|
||||
% Units: kmol
|
||||
%
|
||||
if ~isa(phase, 'ThermoPhase')
|
||||
error('Phase object of wrong type.');
|
||||
end
|
||||
if ~isa(moles, 'numeric')
|
||||
error('Number of moles must be numeric');
|
||||
end
|
||||
if moles < 0.0
|
||||
error('Negative moles');
|
||||
end
|
||||
|
||||
iok = calllib(ct, 'mix_addPhase', m.mixID, phase.tp_id, ...
|
||||
moles);
|
||||
if iok < 0
|
||||
error('Error adding phase');
|
||||
end
|
||||
end
|
||||
|
||||
%% 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.
|
||||
%
|
||||
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
|
||||
%
|
||||
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
|
||||
%
|
||||
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
|
||||
%
|
||||
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.
|
||||
%
|
||||
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.
|
||||
%
|
||||
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.
|
||||
%
|
||||
if nargin == 2
|
||||
moles = calllib(ct, 'mix_elementMoles', m.mixID, e)
|
||||
elseif nargin == 1
|
||||
nel = m.nElements;
|
||||
moles = zeros(1, nel);
|
||||
for i = 1:nel
|
||||
moles(i) = calllib(ct, 'mix_elementMoles', m.mixID, i);
|
||||
end
|
||||
else error('wrong number of arguments');
|
||||
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.
|
||||
%
|
||||
if nargin == 2
|
||||
moles = calllib(ct, 'mix_phaseMoles', m.mixID, n);
|
||||
elseif nargin == 1
|
||||
np = m.nPhases;
|
||||
moles = zeros(1, np);
|
||||
for i = 1:np
|
||||
moles(i) = calllib(ct, 'mix_phaseMoles', ...
|
||||
m.mixID, i);
|
||||
end
|
||||
else error('wrong number of arguments');
|
||||
end
|
||||
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
|
||||
nsp = m.nSpecies;
|
||||
moles = zeros(1, nsp);
|
||||
for i = 1:nsp
|
||||
moles(i) = calllib(ct, 'mix_speciesMoles', ...
|
||||
m.mixID, i);
|
||||
end
|
||||
else error('wrong number of arguments');
|
||||
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
|
||||
%
|
||||
nsp = m.nSpecies;
|
||||
xx = zeros(1, nsp);
|
||||
ptr = libpointer('doublePtr', xx);
|
||||
calllib(ct, 'mix_getChemPotential', m.mixID, nsp, ptr);
|
||||
mu = ptr.Value;
|
||||
end
|
||||
|
||||
%% 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.
|
||||
% m.setPhaseMoles(n, moles)
|
||||
% :param m:
|
||||
% Instance of class :mat:func:`Mixture`
|
||||
% :param n:
|
||||
% Phase number in the input
|
||||
% :param moles:
|
||||
% Number of moles to add. Units: kmol
|
||||
%
|
||||
calllib(ct, 'mix_setPhaseMoles', m.mixID, n-1, moles);
|
||||
end
|
||||
|
||||
function setSpeciesMoles(m, moles)
|
||||
% SETSPECIESMOLES 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
|
||||
% of species in the mixture. Note that the species may belong to any
|
||||
% phase, and unspecified species are set to zero. ::
|
||||
%
|
||||
% >> mix.setSpeciesMoles('C(s):1.0, CH4:2.0, O2:0.2');
|
||||
%
|
||||
% :param m:
|
||||
% Instance of class :mat:func:`Mixture`
|
||||
% :param moles:
|
||||
% Vector or string specifying the moles of species
|
||||
%
|
||||
if isa(moles, 'double')
|
||||
l = length(moles);
|
||||
calllib(ct, 'mix_setMoles', m.mixID, l, moles);
|
||||
elseif isa(moles, 'string')
|
||||
calllib(ct, 'mix_setMolesByName', m.mixID, moles);
|
||||
else
|
||||
error('The input must be a vector or string!');
|
||||
end
|
||||
end
|
||||
|
||||
function r = equilibrate(m, XY, err, maxsteps, maxiter, loglevel)
|
||||
% EQUILIBRATE 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
|
||||
% description of the theory, see Smith and Missen, "Chemical
|
||||
% Reaction Equilibrium." The VCS algorithm is implemented in
|
||||
% Cantera kernel class MultiPhaseEquil.
|
||||
%
|
||||
% The VCS algorithm solves for the equilibrium composition for
|
||||
% specified temperature and pressure. If any other property pair
|
||||
% other than "TP" is specified, then an outer iteration loop is
|
||||
% used to adjust T and/or P so that the specified property
|
||||
% values are obtained. ::
|
||||
%
|
||||
% >> mix.equilibrate('TP')
|
||||
% >> mix.equilibrate('TP', 1.0e-6, 500)
|
||||
%
|
||||
% :param m:
|
||||
% Instance of class :mat:func:`Mixture`
|
||||
% :param XY:
|
||||
% Two-letter string specifying the two properties to hold
|
||||
% fixed. Currently, ``'TP'``, ``'HP'``, ``'TV'``, and ``'SP'`` are
|
||||
% implemented. Default: ``'TP'``.
|
||||
% :param err:
|
||||
% Error tolerance. Iteration will continue until :math:`\Delta\mu)/RT`
|
||||
% is less than this value for each reaction. Default:
|
||||
% 1.0e-9. Note that this default is very conservative, and good
|
||||
% equilibrium solutions may be obtained with larger error
|
||||
% tolerances.
|
||||
% :param maxsteps:
|
||||
% Maximum number of steps to take while solving the
|
||||
% equilibrium problem for specified T and P. Default: 1000.
|
||||
% :param maxiter:
|
||||
% Maximum number of temperature and/or pressure
|
||||
% iterations. This is only relevant if a property pair other
|
||||
% than (T,P) is specified. Default: 200.
|
||||
% :param loglevel:
|
||||
% Set to a value > 0 to write diagnostic output.
|
||||
% Larger values generate more detailed information.
|
||||
% :return:
|
||||
% The error in the solution
|
||||
%
|
||||
if nargin < 6
|
||||
loglevel = 0;
|
||||
end
|
||||
if nargin < 5
|
||||
maxiter = 200;
|
||||
end
|
||||
if nargin < 4
|
||||
maxsteps = 1000;
|
||||
end
|
||||
if nargin < 3
|
||||
err = 1.0e-9;
|
||||
end
|
||||
if nargin < 2
|
||||
XY = 'TP'
|
||||
end
|
||||
r = calllib(ct, 'mix_equilibrate', m.mixID, XY, err, ...
|
||||
maxsteps, maxiter, loglevel);
|
||||
end
|
||||
|
||||
end
|
||||
end
|
34
interfaces/matlab_experimental/Phases/importEdge.m
Normal file
34
interfaces/matlab_experimental/Phases/importEdge.m
Normal file
@ -0,0 +1,34 @@
|
||||
function s = importEdge(file, name, phase1, phase2, phase3, phase4)
|
||||
% Import edges between phases.
|
||||
% s = importEdge(file, name, phase1, phase2, phase3, phase4)
|
||||
% Supports up to four neighbor phases. See
|
||||
% `Interfaces <https://cantera.org/tutorials/cti/phases.html#interfaces>`__
|
||||
%
|
||||
% :param file:
|
||||
% File containing phases
|
||||
% :param name:
|
||||
% Name of phase
|
||||
% :param phase1:
|
||||
% First neighbor phase
|
||||
% :param phase2:
|
||||
% Second neighbor phase
|
||||
% :param phase3:
|
||||
% Third neighbor phase
|
||||
% :param phase4:
|
||||
% Fourth neighbor phase
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Interface`
|
||||
%
|
||||
|
||||
if nargin == 3
|
||||
s = Interface(file, name, phase1);
|
||||
elseif nargin == 4
|
||||
s = Interface(file, name, phase1, phase2);
|
||||
elseif nargin == 5
|
||||
s = Interface(file, name, phase1, phase2, phase3);
|
||||
elseif nargin == 6
|
||||
s = Interface(file, name, phase1, phase2, phase3, phase4);
|
||||
else
|
||||
error('importEdge only supports 4 neighbor phases.');
|
||||
end
|
||||
end
|
25
interfaces/matlab_experimental/Phases/importInterface.m
Normal file
25
interfaces/matlab_experimental/Phases/importInterface.m
Normal file
@ -0,0 +1,25 @@
|
||||
function s = importInterface(file, name, phase1, phase2)
|
||||
% Import an interface between phases.
|
||||
% s = importInterface(file, name, phase1, phase2)
|
||||
% See `Interfaces <https://cantera.org/tutorials/cti/phases.html#interfaces>`__.
|
||||
%
|
||||
% :param file:
|
||||
% CTI or CTML file containing the interface
|
||||
% :param name:
|
||||
% Name of the interface to import
|
||||
% :param phase1:
|
||||
% First phase in the interface
|
||||
% :param phase2:
|
||||
% Second phase in the interface
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Interface`
|
||||
%
|
||||
|
||||
if nargin == 3
|
||||
s = Interface(file, name, phase1);
|
||||
elseif nargin == 4
|
||||
s = Interface(file, name, phase1, phase2);
|
||||
else
|
||||
error('importInterface only supports 2 bulk phases');
|
||||
end
|
||||
end
|
@ -1,11 +1,24 @@
|
||||
function r = ConstPressureReactor(contents)
|
||||
% Create a constant pressure reactor object.
|
||||
% Pressure is held constant. The volume is not a state variable, but
|
||||
% instead takes on whatever value is consistent with holding the
|
||||
% pressure constant.
|
||||
% r = ConstPressureReactor(contents)
|
||||
% A :mat:func:`ConstPressureReactor` is an instance of class
|
||||
% :mat:func:`Reactor` where the pressure is held constant. The volume
|
||||
% is not a state variable, but instead takes on whatever value is
|
||||
% consistent with holding the pressure constant. Examples:
|
||||
%
|
||||
% .. code-block:: matlab
|
||||
%
|
||||
% r1 = ConstPressureReactor % an empty reactor
|
||||
% r2 = ConstPressureReactor(contents) % a reactor containing contents
|
||||
%
|
||||
% See also: :mat:func:`Reactor`
|
||||
%
|
||||
% :param contents:
|
||||
% Cantera :mat:func:`Solution` to be set as the contents of the
|
||||
% reactor
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
%
|
||||
%: param contents:
|
||||
% Contents of the reactor of class 'Solution'.
|
||||
|
||||
if nargin == 0
|
||||
contents = 0;
|
||||
|
@ -1,9 +1,22 @@
|
||||
function r = FlowReactor(contents)
|
||||
% Create a flow reactor object.
|
||||
% A reactor representing adiabatic plug flow in a constant-area duct.
|
||||
% r = FlowReactor(contents)
|
||||
% A reactor representing adiabatic plug flow in a constant-area
|
||||
% duct. Examples:
|
||||
%
|
||||
% .. code-block:: matlab
|
||||
%
|
||||
% r1 = FlowReactor % an empty reactor
|
||||
% r2 = FlowReactor(gas) % a reactor containing a gas
|
||||
%
|
||||
% See also: :mat:func:`Reactor`
|
||||
%
|
||||
% :param contents:
|
||||
% Cantera :mat:func:`Solution` to be set as the contents of the
|
||||
% reactor
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
%
|
||||
%: param contents:
|
||||
% Contents of the reactor of class 'Solution'.
|
||||
|
||||
if nargin == 0
|
||||
contents = 0;
|
||||
|
@ -1,11 +1,26 @@
|
||||
function r = IdealGasConstPressureReactor(contents)
|
||||
% Create a constant pressure reactor object with an ideal gas.
|
||||
% Pressure is held constant. The volume is not a state variable, but
|
||||
% instead takes on whatever value is consistent with holding the
|
||||
% pressure constant.
|
||||
% Create a constant pressure reactor with an ideal gas.
|
||||
% 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
|
||||
% instead takes on whatever value is consistent with holding the pressure
|
||||
% constant. Additionally, its governing equations are specialized for the
|
||||
% ideal gas equation of state (and do not work correctly with other
|
||||
% thermodynamic models). Examples:
|
||||
%
|
||||
% .. code-block:: matlab
|
||||
%
|
||||
% r1 = IdealGasConstPressureReactor % an empty reactor
|
||||
% r2 = IdealGasConstPressureReactor(gas) % a reactor containing a gas
|
||||
%
|
||||
% See also: :mat:func:`Reactor`
|
||||
%
|
||||
% :param contents:
|
||||
% Cantera :mat:func:`Solution` to be set as the contents of the
|
||||
% reactor
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
%
|
||||
%: param contents:
|
||||
% Contents of the reactor of class 'Solution'.
|
||||
|
||||
if nargin == 0
|
||||
contents = 0;
|
||||
|
@ -1,10 +1,23 @@
|
||||
function r = IdealGasReactor(contents)
|
||||
% Create a ideal gas reactor object.
|
||||
% The governing equations are specialized for the ideal gas equation of
|
||||
% state (and do not work correctly with other thermodynamic models).
|
||||
% Create a reactor with an ideal gas.
|
||||
% 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
|
||||
% work correctly with other thermodynamic models). Examples:
|
||||
%
|
||||
% .. code-block:: matlab
|
||||
%
|
||||
% r1 = IdealGasReactor % an empty reactor
|
||||
% r2 = IdealGasReactor(gas) % a reactor containing a gas
|
||||
%
|
||||
% See also: :mat:func:`Reactor`
|
||||
%
|
||||
% :param contents:
|
||||
% Cantera :mat:func:`Solution` to be set as the contents of the
|
||||
% reactor
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
%
|
||||
%: param contents:
|
||||
% Contents of the reactor of class 'Solution'.
|
||||
|
||||
if nargin == 0
|
||||
contents = 0;
|
||||
|
@ -1,15 +1,28 @@
|
||||
function r = Reservoir(contents)
|
||||
% Create a reservoir object.
|
||||
% An instance of class 'Reactor' configured so that its intensive state
|
||||
% is constant in time. A reservoir may be thought of as inifinite in
|
||||
% extent, perfectly mixed, and non-reacting, so that fluid may be
|
||||
% extracted or added without changing the composition or thermodynamic
|
||||
% state. Note that even if the reaction mechanism associated with the
|
||||
% fluid in the reactor defines reactions, they are disabled within
|
||||
% reservoirs.
|
||||
% Create a Reservoir object.
|
||||
% r = Reservoir(contents)
|
||||
% A :mat:func:`Reservoir` is an instance of class :mat:func:`Reactor`
|
||||
% configured so that its intensive state is constant in time. A
|
||||
% reservoir may be thought of as infinite in extent, perfectly mixed,
|
||||
% and non-reacting, so that fluid may be extracted or added without
|
||||
% changing the composition or thermodynamic state. Note that even
|
||||
% if the reaction mechanism associated with the fluid in the
|
||||
% reactor defines reactions, they are disabled within
|
||||
% reservoirs. Examples:
|
||||
%
|
||||
% .. code-block:: matlab
|
||||
%
|
||||
% r1 = Reservoir % an empty reservoir
|
||||
% r2 = Reservoir(gas) % a reservoir containing a gas
|
||||
%
|
||||
% See also: :mat:func:`Reactor`
|
||||
%
|
||||
% :param contents:
|
||||
% Cantera :mat:func:`Solution` to be set as the contents of the
|
||||
% reactor
|
||||
% :return:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
%
|
||||
%: param contents:
|
||||
% Contents of the reactor of class 'Solution'.
|
||||
|
||||
if nargin == 0
|
||||
contents = 0;
|
||||
|
@ -1,5 +1,10 @@
|
||||
function v = canteraGitCommit()
|
||||
% Get Cantera Git commit hash
|
||||
% canteraGitCommit()
|
||||
%
|
||||
% :return:
|
||||
% A string containing the Git commit hash for the current version of Cantera
|
||||
%
|
||||
checklib;
|
||||
buflen = calllib(ct, 'ct_getGitCommit', 0, '');
|
||||
aa = char(zeros(1, buflen));
|
||||
|
@ -1,5 +1,10 @@
|
||||
function v = canteraVersion()
|
||||
% Get Cantera version information
|
||||
% canteraVersion()
|
||||
%
|
||||
% :return:
|
||||
% A string containing the Cantera version
|
||||
%
|
||||
checklib;
|
||||
buflen = calllib(ct, 'ct_getCanteraVersion', 0, '');
|
||||
aa = char(zeros(1, buflen));
|
||||
|
@ -1,5 +1,6 @@
|
||||
function cleanup()
|
||||
% Delete all stored Cantera objects and reclaim memory
|
||||
% Delete all stored Cantera objects and reclaim memory.
|
||||
%
|
||||
checklib;
|
||||
calllib(ct, 'ct_clearOneDim');
|
||||
calllib(ct, 'ct_clearMix');
|
||||
|
@ -1,5 +1,11 @@
|
||||
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:
|
||||
% Cell array with strings representing the data file search directories
|
||||
%
|
||||
checklib;
|
||||
buflen = calllib(ct, 'ct_getDataDirectories', 0, '', ';');
|
||||
aa = char(zeros(1, buflen));
|
||||
|
@ -1,5 +1,6 @@
|
||||
function e = geterr()
|
||||
% Get the error message from Cantera error.
|
||||
% Get the error message from a Cantera error.
|
||||
%
|
||||
checklib;
|
||||
try
|
||||
buflen = calllib(ct, 'ct_getCanteraError', 0, '');
|
||||
|
@ -1,15 +0,0 @@
|
||||
function s = importEdge(file, name, phase1, phase2, phase3, phase4)
|
||||
% Import edges between phases.
|
||||
|
||||
if nargin == 3
|
||||
s = Interface(file, name, phase1);
|
||||
elseif nargin == 4
|
||||
s = Interface(file, name, phase1, phase2);
|
||||
elseif nargin == 5
|
||||
s = Interface(file, name, phase1, phase2, phase3);
|
||||
elseif nargin == 6
|
||||
s = Interface(file, name, phase1, phase2, phase3, phase4);
|
||||
else
|
||||
error('importEdge only supports 4 neighbor phases.');
|
||||
end
|
||||
end
|
@ -1,11 +0,0 @@
|
||||
function s = importInterface(file, name, phase1, phase2)
|
||||
% Import an interface between phases.
|
||||
|
||||
if nargin == 3
|
||||
s = Interface(file, name, phase1);
|
||||
elseif nargin == 4
|
||||
s = Interface(file, name, phase1, phase2);
|
||||
else
|
||||
error('importInterface only supports 2 bulk phases');
|
||||
end
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
This Matlab Toolbox for Cantera serves as a proof of concept for direct C-library integration into Matlab.
|
||||
|
||||
Move the toolbox_C folder into <installation directory to Cantera>\matlab.
|
||||
|
||||
For first time users, launch matlab, navigate to the toolbox folder, then run the 'SetCanteraPath(<installation directory to Cantera>)' command.
|
||||
|
||||
To start using the toolbox, use the LoadCantera command to load cantera_shared.dll into the memory.
|
||||
|
||||
To stop using Cantera and purge all objects from memory, first run cleanup command, then run UnloadCantera command.
|
Loading…
Reference in New Issue
Block a user