Fixed all issues caused by modifying class methods into properties.

This commit is contained in:
ssun30 2022-10-13 19:37:40 -04:00 committed by Ray Speth
parent 0c6920a98b
commit b227b274e2
44 changed files with 445 additions and 489 deletions

View File

@ -44,7 +44,7 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
if ~right.isInlet
error('Right inlet object of wrong type.');
end
if ~oxidizer.ischar
if ~ischar(oxidizer)
error('Oxidizer name must be of format character.');
end
@ -74,10 +74,10 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
% conditions. The stoichiometric mixture fraction, Zst, is then
% calculated.
sFuel = tp_f.elMoles('O')- 2*tp_f.elMoles('C')- 0.5*tp_f.elMoles('H');
sOx = tp_o.elMoles('O')- 2*tp_o.elMoles('C')- 0.5*tp_o.elMoles('H');
phi = sFuel/sOx;
zst = 1.0/(1.0 - phi);
sFuel = elMoles(tp_f, 'O')- 2 * elMoles(tp_f, 'C') - 0.5 * elMoles(tp_f, 'H');
sOx = elMoles(tp_o, 'O') - 2 * elMoles(tp_o, 'C') - 0.5 * elMoles(tp_o, 'H');
phi = sFuel / sOx;
zst = 1.0 / (1.0 - phi);
%% Compute the stoichiometric mass fractions of each species.
% Use this to set the fuel gas object and calculate adiabatic flame
@ -92,7 +92,7 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
for n = 1:nsp
% Calculate stoichiometric mass fractions.
ystoich_double(n) = zst*yf(n) + (1.0 - zst)*yox(n);
ystoich_double(n) = zst * yf(n) + (1.0 - zst) * yox(n);
% Convert mass fraction vector to string vector.
ystoich_str{n} = num2str(ystoich_double(n));
% Convert string vector to cell with SPECIES:MASS FRACTION format.
@ -122,13 +122,13 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
dz = zz(end) - zz(1);
mdotl = left.massFlux;
mdotr = right.massFlux;
uleft = mdotl/rhof;
uright = mdotr/rho0;
a = (abs(uleft) + abs(uright))/dz;
uleft = mdotl / rhof;
uright = mdotr / rho0;
a = (abs(uleft) + abs(uright)) / dz;
diff = tp_f.mixDiffCoeffs;
f = sqrt(a/(2.0*diff(ioxidizer)));
x0num = sqrt(uleft*mdotl)*dz;
x0den = sqrt(uleft*mdotr) + sqrt(uright*mdotr);
f = sqrt(a / (2.0 * diff(ioxidizer)));
x0num = sqrt(uleft * mdotl) * dz;
x0den = sqrt(uleft * mdotr) + sqrt(uright * mdotr);
x0 = x0num/x0den;
%% Calculate initial values of temperature and mass fractions.
@ -144,24 +144,24 @@ function flame = CounterFlowDiffusionFlame(left, flow, right, tp_f, tp_o, oxidiz
for j = 1:nz
x = zz(j);
zeta = f*(x - x0);
zmix = 0.5*(1.0 - erf(zeta)); % Mixture fraction in flame.
zeta = f * (x - x0);
zmix = 0.5 * (1.0 - erf(zeta)); % Mixture fraction in flame.
zm(j) = zmix;
u(j) = a*(x0 - zz(j)); % Axial velocity.
u(j) = a * (x0 - zz(j)); % Axial velocity.
v(j) = a; % Radial velocity.
if zmix > zst
for n = 1:nsp
y(j,n) = yeq(n) + (zmix - zst)*(yf(n) - yeq(n))/(1.0 - zst);
y(j,n) = yeq(n) + (zmix - zst) * (yf(n) - yeq(n)) / (1.0 - zst);
end
t(j) = teq + (tf - teq)*(zmix - zst)/(1.0 - zst);
t(j) = teq + (tf - teq) * (zmix - zst) / (1.0 - zst);
else
for n = 1:nsp
y(j,n) = yox(n) + zmix*(yeq(n) - yox(n))/zst;
y(j,n) = yox(n) + zmix * (yeq(n) - yox(n)) / zst;
end
t(j) = tox + zmix*(teq - tox)/zst;
t(j) = tox + zmix * (teq - tox) / zst;
end
end
zrel = zz/dz;
zrel = zz / dz;
%% Create the flame stack.
% Set the profile of the flame with the estimated axial velocities,
@ -184,7 +184,7 @@ function moles = elMoles(tp, element)
if nargin ~= 2
error('elMoles expects two input arguments.');
end
if ~isIdealGas(tp)
if ~tp.isIdealGas
error('Gas object must represent an ideal gas mixture.');
end
if ~ischar(element)
@ -204,5 +204,5 @@ function moles = elMoles(tp, element)
eli = tp.elementIndex(element);
M = tp.atomicMasses;
Mel = M(eli);
moles = elMassFrac/Mel;
moles = elMassFrac / Mel;
end

View File

@ -36,43 +36,6 @@ classdef Domain1D < handle
properties (SetAccess = protected)
% Get 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.
bounds
%
% 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.
componentIndex
%
% 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.
componentName
%
% Domain index.
%
% i = d.domainIndex
@ -94,18 +57,6 @@ classdef Domain1D < handle
% Integer flag denoting the domain type.
domainType
%
% 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.
gridPoints
%
% Determines whether a domain is a flow.
%
% a = d.isFlow
@ -146,22 +97,6 @@ classdef Domain1D < handle
% The mass flux in the domain.
massFlux
%
% 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
massFraction
%
% Number of components.
%
% n = d.nComponents
@ -181,18 +116,6 @@ classdef Domain1D < handle
% :return:
% Integer number of grid points.
nPoints
%
% 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.
tolerances
end
@ -311,14 +234,37 @@ classdef Domain1D < handle
%% Domain Get Methods
function b = get.bounds(d, component)
function b = bounds(d, component)
% Get 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);
b = [lower, upper];
end
function n = get.componentIndex(d, name)
function n = componentIndex(d, name)
%
% 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
@ -333,7 +279,20 @@ classdef Domain1D < handle
end
end
function s = get.componentName(d, index)
function s = componentName(d, index)
%
% 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
@ -357,7 +316,19 @@ classdef Domain1D < handle
i = callct('domain_type', d.domainID);
end
function zz = get.gridPoints(d, n)
function zz = gridPoints(d, n)
%
% 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);
@ -404,7 +375,23 @@ classdef Domain1D < handle
mdot = callct('bdry_mdot', d.domainID);
end
function y = get.massFraction(d, k)
function y = 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
@ -424,6 +411,18 @@ classdef Domain1D < handle
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);
@ -537,7 +536,7 @@ classdef Domain1D < handle
function setMassFlowRate(d, mdot)
% Set the mass flow rate.
%
% d.setMdot(mdot)
% d.setMassFlowRate(mdot)
%
% :param d:
% Instance of class :mat:func:`Domain1D`

View File

@ -22,49 +22,6 @@ classdef Sim1D < handle
domains % Domain instances contained within the Sim1D object.
end
properties (SetAccess = protected)
% The index of a domain in a Sim1D given its name.
%
% n = s.stackIndex(name)
%
% :param s:
% Instance of class 'Sim1D'.
% :param name:
% If double, the value is :returned. Otherwise, the name is
% looked up and its index is :returned.
% :return:
% Index of domain.
stackIndex
%
% Get the grid in one domain.
%
% z = s.grid(name)
%
% :param s:
% Instance of class :mat:func:`Sim1D`
% :param name:
% Name of the domain for which the grid
% should be retrieved.
% :return:
% The grid in domain name
grid
%
% Get the residuals.
%
% r = s.resid(domain, rdt, count)
%
% :param s:
% Instance of class 'Sim1D'.
% :param domain:
% Name of the domain.
% :param rdt:
% :param count:
% :return:
resid
end
methods
%% Sim1D Class Constructor
@ -261,7 +218,19 @@ classdef Sim1D < handle
callct('sim1D_getInitialSoln', s.stID);
end
function n = get.stackIndex(s, name)
function n = stackIndex(s, name)
% The index of a domain in a Sim1D given its name.
%
% n = s.stackIndex(name)
%
% :param s:
% Instance of class 'Sim1D'.
% :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
@ -274,13 +243,37 @@ classdef Sim1D < handle
end
end
function z = get.grid(s, name)
function z = grid(s, name)
% Get the grid in one domain.
%
% z = s.grid(name)
%
% :param s:
% Instance of class :mat:func:`Sim1D`
% :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)
function r = resid(s, domain, rdt, count)
% Get the residuals.
%
% r = s.resid(domain, rdt, count)
%
% :param s:
% Instance of class 'Sim1D'.
% :param domain:
% Name of the domain.
% :param rdt:
% :param count:
% :return:
if nargin == 2
rdt = 0.0;
count = 0;

View File

@ -23,7 +23,6 @@ classdef Interface < handle & ThermoPhase & Kinetics
%
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.
@ -61,7 +60,9 @@ classdef Interface < handle & ThermoPhase & Kinetics
%% Interface Get Methods
function c = get.coverages(s)
function c = coverages(s)
% Surface coverages of the species on an interface.
surfID = s.tpID;
nsp = s.nSpecies;
xx = zeros(1, nsp);
@ -84,10 +85,10 @@ classdef Interface < handle & ThermoPhase & Kinetics
c = pt.Value;
end
function set.coverages(s, cov, norm)
function setCoverages(s, cov, norm)
% Set surface coverages of the species on an interface.
%
% s.coverages = (cov, norm)
% s.setCoverages(cov, norm)
%
% :param s:
% Instance of class :mat:func:`Interface`
@ -102,7 +103,7 @@ classdef Interface < handle & ThermoPhase & Kinetics
% ``s`` is a vector, not a string. Since unnormalized coverages can lead to
% unphysical results, ``'nonorm'`` should be used only in rare cases, such
% as computing partial derivatives with respect to a species coverage.
%
if nargin == 3 && strcmp(norm, 'nonorm')
norm_flag = 0;
else
@ -138,7 +139,6 @@ classdef Interface < handle & ThermoPhase & Kinetics
% :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

@ -6,89 +6,12 @@ classdef Kinetics < handle
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
creationRates % Chemical reaction rates. Unit: kmol/m^3-s.
destructionRates % Chemical destruction rates. Unit: kmol/m^3-s.
@ -120,16 +43,18 @@ classdef Kinetics < handle
reverseRateConstants % Rever reaction rate constants for all reactions.
% An array of flags indicating reversibility of a reaction.
% Get the mass production rates of the species.
%
% n = kin.isReversible(i)
% ydot = kin.massProdRate
%
% :param i:
% Integer reaction number.
% Evaluates the source term :math:`\dot{\omega}_k M_k /\rho`
%
% :param a:
% Instance of class :mat:func:`Kinetics` (or another
% object deriving from Kinetics)
% for which the ydots are desired.
% :return:
% 1 if reaction number i is reversible. 0 if irreversible.
isReversible
% Returns a vector of length nSpecies. Units: kg/s
massProdRate % Mass production rate of all species. Unit: kg/s.
netProdRates % Net chemical production rates for all species. Unit: kmol/m^3-s.
@ -140,16 +65,6 @@ classdef Kinetics < handle
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
reactionEqns % All reaction equations within the Kinetics object.
end
@ -231,11 +146,28 @@ classdef Kinetics < handle
%% Get scalar attributes
function n = get.kineticsSpeciesIndex(kin, name, phase)
function n = kineticsSpeciesIndex(kin, name, phase)
% 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.
n = callct('kin_speciesIndex', kin.kinID, name, phase);
end
function n = get.multiplier(kin, irxn)
function n = multiplier(kin, irxn)
% 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.
n = callct('kin_multiplier', kin.kinID, irxn-1);
end
@ -251,11 +183,38 @@ classdef Kinetics < handle
n = callct('kin_nSpecies', kin.kinID);
end
function n = get.phaseIndex(kin, phase)
function n = phaseIndex(kin, phase)
% The index of a specific 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)
function n = stoichReactant(kin, species, rxns)
% 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.
nsp = kin.nTotalSpecies;
nr = kin.nReactions;
temp = sparse(nsp, nr);
@ -281,7 +240,21 @@ classdef Kinetics < handle
n = temp;
end
function n = get.stoichProduct(kin, species, rxns)
function n = stoichProduct(kin, species, rxns)
% 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.
nsp = kin.nTotalSpecies;
nr = kin.nReactions;
temp = sparse(nsp, nr);
@ -307,7 +280,20 @@ classdef Kinetics < handle
n = temp;
end
function n = get.stoichNet(kin, species, rxns)
function n = stoichNet(kin, species, rxns)
% 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.
if nargin == 1
n = kin.stoichProduct - kin.stoichReactant;
elseif nargin == 3
@ -334,7 +320,16 @@ classdef Kinetics < handle
ddot = pt.Value;
end
function n = get.isReversible(kin, i)
function n = isReversible(kin, i)
% 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.
n = callct('kin_isReversible', kin.kinID, i);
end
@ -370,16 +365,24 @@ classdef Kinetics < handle
q = pt.Value;
end
function rxn = get.reactionEqn(kin, irxn)
output = callct2('kin_getReactionString', kin.kinID, irxn-1);
function rxn = reactionEqn(kin, irxn)
% Reaction equation of a reaction
%
% rxn = kin.reactionEqn(irxn)
%
% :param irxn:
% Integer index of the reaction.
% :return:
% String reaction equation.
rxn = callct2('kin_getReactionString', kin.kinID, irxn-1);
end
function rxn = get.reactionEqns(kin)
m = kin.nReactions;
irxn = (1:m);
rxns = cell(1, m);
for i = 1:m
rxns{i} = kin.reactionEqn(irxn(i)-1);
rxn{i} = kin.reactionEqn(i);
end
end
@ -460,7 +463,7 @@ classdef Kinetics < handle
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
callct('kin_getSourceTerms', kin.kinID, nsp, pt);
massProdRate = pt.Value;
ydot = pt.Value;
end
%% Kinetics Set Methods
@ -489,7 +492,7 @@ classdef Kinetics < handle
end
for i = 1:n
calct('kin_setMultiplier', kin.kinID, irxn(i)-1, v);
callct('kin_setMultiplier', kin.kinID, irxn(i)-1, v);
end
end

View File

@ -79,7 +79,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
function delete(s)
% Delete the kernel objects associated with a Solution.
disp('Solution class object has been deleted').
disp('Solution class object has been deleted');
end
end

View File

@ -11,12 +11,10 @@ classdef ThermoPhase < handle
% Instance of class :mat:func:`ThermoPhase`
%
properties (SetAccess = immutable)
tpID % ID of the ThermoPhase object.
end
properties (SetAccess = public)
tpID % ID of the ThermoPhase object.
T % Temperature. Units: K.
P % Pressure. Units: Pa.
@ -41,7 +39,6 @@ classdef ThermoPhase < handle
% String. Can be 'mole'/'molar'/'Molar'/'Mole' or 'mass'/'Mass'.
basis
end
properties (SetAccess = protected)
@ -50,47 +47,6 @@ classdef ThermoPhase < handle
charges % Species charges. Unit: elem. charge.
% Index of an element given its name.
%
% k = tp.elementIndex(name)
%
% The index is an integer assigned to each element in sequence as it
% is read in from the input file.
%
% If ``name`` is a single string, the return value will be a integer
% containing the corresponding index. If it is an cell array of
% strings, the output will be an array of the same shape
% containing the indices.
%
% NOTE: In keeping with the conventions used by Matlab, this method
% returns 1 for the first element. In contrast, the corresponding
% method elementIndex in the Cantera C++ and Python interfaces
% returns 0 for the first element, 1 for the second one, etc. ::
%
% >> ic = gas.elementIndex('C');
% >> ih = gas.elementIndex('H');
%
% :param name:
% String or cell array of strings of elements to look up
% :return:
% Integer or vector of integers of element indices
elementIndex
%
% Elemental mass fraction in gas object.
%
% elMassFrac = tp.elementalMassFraction(element)
%
% :param tp:
% Object representing the gas, instance of class :mat:func:`Solution`,
% and an ideal gas. The state of this object should be set to an
% estimate of the gas state before calling elementalMassFraction.
%
% :param element:
% String representing the element name.
% :return:
% Elemental mass fraction within a gas object.
elementalMassFraction
%
% Mean molecular weight.
%
% mmw = tp.meanMolecularWeight
@ -109,66 +65,10 @@ classdef ThermoPhase < handle
molecularWeights % Molecular weights of the species. Units: kg/kmol.
% Number of atoms of an element in a species.
%
% n = tp.nAtoms(k,m)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% object that derives from ThermoPhase)
% :param k:
% String species name or integer species number
% :param m:
% String element name or integer element number
% :return:
% Number of atoms of element ``m`` in species ``k``.
nAtoms
nElements % Number of elements in the phase.
nSpecies % Number of species in the phase.
% Index of a species given the name.
%
% k = tp.speciesIndex(name)
%
% The index is an integer assigned to each species in sequence as it
% is read in from the input file.
%
% NOTE: In keeping with the conventions used by Matlab, this method
% returns 1 for the first species, 2 for the second, etc. In
% contrast, the corresponding method speciesIndex in the Cantera C++
% and Python interfaces returns 0 for the first species, 1 for the
% second one, etc. ::
%
% >> ich4 = gas.speciesIndex('CH4');
% >> iho2 = gas.speciesIndex('HO2');
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% class derived from ThermoPhase)
% :param name:
% If name is a single string, the return value will be a integer
% containing the corresponding index. If it is an cell array of
% strings, the output will be an array of the same shape
% containing the indices.
% :return:
% Scalar or array of integers
speciesIndex
%
% Name of a species given the index.
%
% nm = tp.speciesName(k)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% class derived from ThermoPhase)
% :param k:
% Scalar or array of integer species numbers
% :return:
% Cell array of strings
speciesName
H % Enthalpy depending on the basis. Units: J/kmol (molar) J/kg (mass).
S % Entropy depending on the basis. Units: J/kmol-K (molar) J/kg-K (mass).
@ -267,32 +167,6 @@ classdef ThermoPhase < handle
refPressure % Reference pressure for standard-state. Units: Pa.
% Saturation pressure for a given temperature.
%
% p = tp.satPressure(t)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% object that derives from ThermoPhase)
% :param t:
% Temperature Units: K
% :return:
% Saturation pressure for temperature T. Units: Pa
satPressure
%
% Saturation temperature for a given pressure.
%
% t = tp.satTemperature(p)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% object that derives from ThermoPhase)
% :param p:
% Pressure. Units: Pa
% :return:
% Saturation temperature for pressure p. Units: K
satTemperature
%
% Speed of sound.
%
% c = tp.soundspeed
@ -323,7 +197,7 @@ classdef ThermoPhase < handle
thermalExpansionCoeff % Thermal expansion coefficient. Units: 1/K.
vaporFraciton % Vapor fraction of the phase.
vaporFraction % Vapor fraction of the phase.
end
@ -483,7 +357,32 @@ classdef ThermoPhase < handle
e = pt.Value;
end
function k = get.elementIndex(tp, name)
function k = elementIndex(tp, name)
% Index of an element given its name.
%
% k = tp.elementIndex(name)
%
% The index is an integer assigned to each element in sequence as it
% is read in from the input file.
%
% If ``name`` is a single string, the return value will be a integer
% containing the corresponding index. If it is an cell array of
% strings, the output will be an array of the same shape
% containing the indices.
%
% NOTE: In keeping with the conventions used by Matlab, this method
% returns 1 for the first element. In contrast, the corresponding
% method elementIndex in the Cantera C++ and Python interfaces
% returns 0 for the first element, 1 for the second one, etc. ::
%
% >> ic = gas.elementIndex('C');
% >> ih = gas.elementIndex('H');
%
% :param name:
% String or cell array of strings of elements to look up
% :return:
% Integer or vector of integers of element indices
if iscell(name)
[m, n] = size(name);
k = zeros(m, n);
@ -512,6 +411,20 @@ classdef ThermoPhase < handle
end
function elMassFrac = elementalMassFraction(tp, element)
% Elemental mass fraction in gas object.
%
% elMassFrac = tp.elementalMassFraction(element)
%
% :param tp:
% Object representing the gas, instance of class :mat:func:`Solution`,
% and an ideal gas. The state of this object should be set to an
% estimate of the gas state before calling elementalMassFraction.
%
% :param element:
% String representing the element name.
% :return:
% Elemental mass fraction within a gas object.
if nargin ~= 2
error('elementalMassFraction expects two input arguments.');
end
@ -537,7 +450,7 @@ classdef ThermoPhase < handle
eli = tp.elementIndex(element);
M = tp.atomicMasses;
Mel = M(eli);
MW = tp.MolecularWeights;
MW = tp.molecularWeights;
% Initialize the element mass fraction as zero.
elMassFrac = 0.0;
% Use loop to perform summation of elemental mass fraction over all species.
@ -556,7 +469,7 @@ classdef ThermoPhase < handle
density = callct('thermo_molarDensity', tp.tpID);
end
function mw = get.MolecularWeights(tp)
function mw = get.molecularWeights(tp)
nsp = tp.nSpecies;
yy = zeros(1, nsp);
pt = libpointer('doublePtr', yy);
@ -565,7 +478,21 @@ classdef ThermoPhase < handle
mw = pt.Value;
end
function n = get.nAtoms(tp, species, element)
function n = nAtoms(tp, species, element)
% Number of atoms of an element in a species.
%
% n = tp.nAtoms(k,m)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% object that derives from ThermoPhase)
% :param k:
% String species name or integer species number
% :param m:
% String element name or integer element number
% :return:
% Number of atoms of element ``m`` in species ``k``.
if nargin == 3
if ischar(species)
k = tp.speciesIndex(species);
@ -597,7 +524,34 @@ classdef ThermoPhase < handle
nsp = callct('thermo_nSpecies', tp.tpID);
end
function k = get.speciesIndex(tp, name)
function k = speciesIndex(tp, name)
% Index of a species given the name.
%
% k = tp.speciesIndex(name)
%
% The index is an integer assigned to each species in sequence as it
% is read in from the input file.
%
% NOTE: In keeping with the conventions used by Matlab, this method
% returns 1 for the first species, 2 for the second, etc. In
% contrast, the corresponding method speciesIndex in the Cantera C++
% and Python interfaces returns 0 for the first species, 1 for the
% second one, etc. ::
%
% >> ich4 = gas.speciesIndex('CH4');
% >> iho2 = gas.speciesIndex('HO2');
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% class derived from ThermoPhase)
% :param name:
% If name is a single string, the return value will be a integer
% containing the corresponding index. If it is an cell array of
% strings, the output will be an array of the same shape
% containing the indices.
% :return:
% Scalar or array of integers
if iscell(name)
[m, n] = size(name);
k = zeros(m, n);
@ -625,7 +579,7 @@ classdef ThermoPhase < handle
end
end
function nm = get.speciesName(tp, k)
function nm = speciesName(tp, k)
[m, n] = size(k);
nm = cell(m, n);
for i = 1:m
@ -826,11 +780,35 @@ classdef ThermoPhase < handle
p = callct('thermo_refPressure', tp.tpID, -1);
end
function p = get.satPressure(tp, t)
function p = satPressure(tp, t)
% Saturation pressure for a given temperature.
%
% p = tp.satPressure(t)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% object that derives from ThermoPhase)
% :param t:
% Temperature Units: K
% :return:
% Saturation pressure for temperature T. Units: Pa.
p = callct('thermo_satPressure', tp.tpID, t);
end
function t = get.satTemperature(tp, p)
function t = satTemperature(tp, p)
% Saturation temperature for a given pressure.
%
% t = tp.satTemperature(p)
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% object that derives from ThermoPhase)
% :param p:
% Pressure. Units: Pa
% :return:
% Saturation temperature for pressure p. Units: K.
t = callct('thermo_satTemperature', tp.tpID, p);
end

View File

@ -12,7 +12,7 @@ classdef Transport < handle
viscosity % Dynamic viscosity. Unit: Pa*s.
thermoConductivity % Thermal conductivity. Unit: W/m-K.
thermalConductivity % Thermal conductivity. Unit: W/m-K.
electricalConductivity % Electrical conductivity. Unit: S/m.

View File

@ -1,5 +1,6 @@
function r = fplus(a, b)
% Get a functor representing the sum of two input functors.
%
% r = fplus(a, b)
%
% :param a:

View File

@ -1,5 +1,6 @@
function r = frdivide(a, b)
% Get a functor that is the ratio of the input functors.
%
% r = frdivide(a,b)
%
% :param a:

View File

@ -1,5 +1,6 @@
function r = ftimes(a, b)
% Create a functor that multiplies two other functors.
%
% r = ftimes(a, b)
%
% :param a:

View File

@ -1,5 +1,6 @@
function g = gaussian(peak, center, width)
% Create a Gaussian :mat:func:`Func` instance.
%
% g = gaussian(peak, center, width)
%
% :param peak:

View File

@ -1,6 +1,8 @@
function poly = polynom(coeffs)
% Create a polynomial :mat:func:`Func` instance.
%
% poly = polynom(coeffs)
%
% The polynomial coefficients are specified by a vector
% ``[a0 a1 .... aN]``. Examples:
%
@ -13,7 +15,6 @@ function poly = polynom(coeffs)
% Vector of polynomial coefficients
% :return:
% Instance of class :mat:func:`Func`
%
[n m] = size(coeffs);
if n == 1

View File

@ -1,6 +1,8 @@
function r = ConstPressureReactor(contents)
% Create a constant pressure reactor object.
%
% 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
@ -18,7 +20,6 @@ function r = ConstPressureReactor(contents)
% reactor
% :return:
% Instance of class :mat:func:`Reactor`
%
if nargin == 0
contents = 0;

View File

@ -24,11 +24,14 @@ classdef FlowDevice < handle
%
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`.

View File

@ -1,6 +1,8 @@
function r = FlowReactor(contents)
% Create a flow reactor object.
%
% r = FlowReactor(contents)
%
% A reactor representing adiabatic plug flow in a constant-area
% duct. Examples:
%
@ -16,7 +18,6 @@ function r = FlowReactor(contents)
% reactor
% :return:
% Instance of class :mat:func:`Reactor`
%
if nargin == 0
contents = 0;

View File

@ -1,6 +1,8 @@
function r = IdealGasConstPressureReactor(contents)
% 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
@ -20,7 +22,6 @@ function r = IdealGasConstPressureReactor(contents)
% reactor
% :return:
% Instance of class :mat:func:`Reactor`
%
if nargin == 0
contents = 0;

View File

@ -1,6 +1,8 @@
function r = IdealGasReactor(contents)
% 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:
@ -17,7 +19,6 @@ function r = IdealGasReactor(contents)
% reactor
% :return:
% Instance of class :mat:func:`Reactor`
%
if nargin == 0
contents = 0;

View File

@ -1,8 +1,11 @@
function m = MassFlowController(upstream, downstream)
% Create a mass flow controller.
% Creates an instance of class 'FlowDevice' configured to simulate a
% mass flow controller that maintains a constant mass flow rate
% independent of upstream or downstream conditions. If two reactor
%
% m = MassFlowController(upstream, downstream)
%
% Creates an instance of class :mat:func:`FlowDevice` configured to
% simulate a mass flow controller that maintains a constant mass flow
% rate independent of upstream or downstream conditions. If two reactor
% objects are supplied as arguments, the controller is installed
% between the two reactors. Otherwise, the 'install' method should be
% used to install the mass flow controller between reactors.

View File

@ -38,19 +38,6 @@ classdef ReactorNet < handle
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
end
methods
@ -190,24 +177,30 @@ classdef ReactorNet < handle
end
function t = get.time(r)
% Get the current time in s.
t = callct('reactornet_time', r.id);
end
function t = get.atol(r)
% Get the absolute error tolerance.
t = callct('reactornet_atol', r.id);
end
function t = get.rtol(r)
% Get the relative error tolerance.
t = callct('reactornet_rtol', r.id);
end
function s = get.sensitivity(r, component, p, rxtr)
function s = sensitivity(r, component, p, rxtr)
% 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'.
if isa(component, 'string')
callct('reactornet_sensitivity', r.id, component, ...
p, rxtr.id);

View File

@ -41,13 +41,8 @@ classdef Wall < handle
end
properties (SetAccess = protected)
left
right
qdot % Total heat transfer through a wall at given time.
vdot % Rate of volumetric change at given time.
left % Reactor on the left.
right % Reactor on the right.
end
properties (SetAccess = public)
@ -117,11 +112,14 @@ classdef Wall < handle
a = callct('wall_area', w.id);
end
function q = get.qdot(w, t)
q = callct('wall_Q', w.id, t);
function q = qdot(w, t)
% Total heat transfer through a wall at a given time t.
q = callct('wall_Q', w.id, t);
end
function v = get.vdot(w, t)
function v = vdot(w, t)
% Rate of volumetric change at a given time t.
v = callct('wall_vdot', w.id, t);
end

View File

@ -7,9 +7,10 @@ Installation guide:
https://cantera.org/install/compiling-install.html.
2.5) The experimental Matlab Toolbox does not require a SCons option to install at this moment since it's stand-alone. It also does not require the current Matlab Toolbox to be installed.
3) For first time users, launch Matlab, then navigate to [/path/to/cantera/source/code] using "Browse for Folder".
3.5) Note for Ubuntu users, Matlab must be launched from the terminal using the following command: `LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libstdc++.so.6' matlab`. This is because Matlab does not load the correct GLIBC++ library on start-up and will return an error when loading the Cantera toolbox.
4) In the Maltab command window, run `addpath(genpath([pwd, '/interfaces/matlab_experimental']))` to add search path for the experimental toolbox.
5) In the Maltab command window, run `addpath(genpath([pwd, '/samples/matlab_experimental']))` to add search path for the sample files.
6) In the Matlab command window, run `cd([pwd, '/interfaces/matlab_experimental/Utility']) to navigate to the Utility folder.
6) In the Matlab command window, run `cd([pwd, '/interfaces/matlab_experimental/Utility'])` to navigate to the Utility folder.
7) Open the file named 'cantera_root.m', in the second line, edit `output=` to `output=[/path/to/conda/environment]`, then save the file. This sets the search path for the `LoadCantera` command to find the shared library file for Cantera.
8) After steps 3 to 7 are complete, make sure search paths to the current Matlab Toolbox and samples files are removed (if it's already installed). Having both the current and experimental version of the toolbox in the search path will lead to conflicts.
9) In the Matlab command window, run `savepath` to save all search paths.
@ -19,4 +20,4 @@ https://cantera.org/install/compiling-install.html.
`cleanup`
`UnloadCantera`
11) To switch back to the current matlab toolbox, undo steps 3, 4, 5, 8, and 9. The command to remove search path in Matlab is `rmpath`.
12) A future updates will add automated installation.
12) A future updates will add automated installation.

View File

@ -30,7 +30,7 @@ function F = PFR_Solver(x, soln_vector, gas, mdot, A_in, dAdx, k)
P = rho * R * T;
gas.basis = 'mass';
MW = gas.MolecularWeights;
MW = gas.molecularWeights;
h = gas.enthalpies_RT.*R.*T;
w = gas.netProdRates;
Cp = gas.cp;

View File

@ -18,7 +18,6 @@ help catcomb;
clear all
close all
cleanup
clc
t0 = cputime; % record the starting time
@ -112,7 +111,7 @@ inlt = Inlet('inlet');
% set the inlet parameters. Start with comp1 (hydrogen/air)
inlt.T = tinlet;
inlt.setMdot(mdot);
inlt.setMassFlowRate(mdot);
inlt.setMoleFractions(comp1);
%% create the surface

View File

@ -18,7 +18,6 @@ help diamond_cvd
clear all
close all
cleanup
clc
t0 = cputime; % record the starting time
@ -45,7 +44,7 @@ xh0 = x(ih);
% input file 'diamond.yaml'.
dbulk = Solution('diamond.yaml', 'diamond');
mw = dbulk.MolecularWeights;
mw = dbulk.molecularWeights;
%% Create the interface object
%

View File

@ -10,7 +10,6 @@
clear all
close all
cleanup
clc
tic % total running time of the script
@ -69,13 +68,13 @@ f.setTransientTolerances('default', tol_ts{:});
% Set the oxidizer inlet.
inlet_o = Inlet('air_inlet');
inlet_o.T = tin;
inlet_o.setMdot(mdot_o);
inlet_o.setMassFlowRate(mdot_o);
inlet_o.setMoleFractions(oxcomp);
% Set the fuel inlet.
inlet_f = Inlet('fuel_inlet');
inlet_f.T = tin;
inlet_f.setMdot(mdot_f);
inlet_f.setMassFlowRate(mdot_f);
inlet_f.setMoleFractions(fuelcomp);
%% Create the flame object.

View File

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

View File

@ -9,7 +9,6 @@
clear all
close all
cleanup
clc
tic
@ -64,7 +63,7 @@ f.setTransientTolerances('default', tol_ts{:});
% and composition (relative molar) may be specified.
burner = Inlet('burner');
burner.T = tburner;
burner.setMdot(mdot);
burner.setMassFlowRate(mdot);
burner.setMoleFractions(comp);
%% Create the outlet

View File

@ -8,7 +8,6 @@
clear all
close all
cleanup
clc
tic
@ -64,14 +63,14 @@ f.setTransientTolerances('default', tol_ts{:});
inlet_o = Inlet('air_inlet');
inlet_o.T = tin;
inlet_o.setMdot(mdot_o);
inlet_o.setMassFlowRate(mdot_o);
inlet_o.setMoleFractions(comp1);
%% Create the fuel inlet
%
inlet_f = Inlet('fuel_inlet');
inlet_f.T = tin;
inlet_f.setMdot(mdot_f);
inlet_f.setMassFlowRate(mdot_f);
inlet_f.setMoleFractions(comp2);
%% Create the flame object

View File

@ -1,7 +1,7 @@
function plotdata = ignite(g)
%% IGNITE Zero-dimensional kinetics: adiabatic, constant pressure.
%
% This example solves the same problem as 'reactor1,' but does
% This example solves the same problem as 'reactor1', but does
% it using one of MATLAB's ODE integrators, rather than using the
% Cantera Reactor class.
%
@ -9,7 +9,6 @@ function plotdata = ignite(g)
clear all
close all
cleanup
clc
tic
@ -52,16 +51,16 @@ function plotdata = ignite(g)
function v = vdot(t, vol, gas)
%v = 0.0; %uncomment for constant volume
v = 1.e11 * (gas.P - 101325.0); % holds pressure very
v = 1.e11 * (gas.P - 101325.0); % holds pressure very
% close to 1 atm
end
% heat flux (W/m^2).
function q = heatflux(t, gas)
q = 0.0; % adiabatic
q = 0.0; % adiabatic
end
% surface area (m^2). Used only to compute heat transfer.
function a = area(t,vol)
a = 1.0;
function a = area(t, vol)
a = 1.0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -6,7 +6,6 @@ function ignite_hp(gas)
clear all
close all
cleanup
clc
tic
@ -16,7 +15,7 @@ function ignite_hp(gas)
gas = Solution('gri30.yaml', 'gri30');
end
mw = gas.MolecularWeights;
mw = gas.molecularWeights;
gas.TPX = {1001.0, oneatm, 'H2:2,O2:1,N2:4'};
y0 = [gas.T

View File

@ -6,7 +6,6 @@ function ignite_uv(gas)
clear all
close all
cleanup
clc
tic
@ -16,7 +15,7 @@ function ignite_uv(gas)
gas = Solution('gri30.yaml', 'gri30');
end
mw = gas.MolecularWeights;
mw = gas.molecularWeights;
gas.TPX = {1001.0, oneatm, 'H2:2,O2:1,N2:4'};
y0 = [gas.T

View File

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

View File

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

View File

@ -21,7 +21,6 @@ function periodic_cstr
clear all
close all
cleanup
clc
tic

View File

@ -26,7 +26,6 @@
clear all
close all
cleanup
clc
tic
@ -122,7 +121,7 @@ for i = 2:length(x_calc)
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% These values are passed onto the ode15s solver
[~,y] = ode15s(@PFR_Solver, limits, inlet_soln, options, ...
[~,y] = ode15s(@PFR_solver, limits, inlet_soln, options, ...
gas_calc, mdot_calc, A_in, dAdx, k);
T_calc(i) = y(end, 2);
@ -143,7 +142,7 @@ for i=1:length(x_calc)
% Specific Gas Constant
R_calc(i) = gasconstant() / gas_calc.meanMolecularWeight;
% Mach No. is calculated from local velocity and local speed of sound
M_calc(i) = vx_calc(i) / gas_calc.soundspeed;
M_calc(i) = vx_calc(i) / gas_calc.soundSpeed;
% Pressure is calculated from density, temperature and gas constant
P_calc(i) = rho_calc(i) * R_calc(i) * T_calc(i);
end

View File

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

View File

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

View File

@ -4,7 +4,6 @@
clear all
close all
cleanup
help rankine
@ -12,6 +11,7 @@ help rankine
eta_pump = 0.6;
eta_turbine = 0.8;
p_max = 8.0 * oneatm;
t1 = 300.0;
% create an object representing water
w = Water;
@ -36,12 +36,12 @@ w
heat_added = h3 - h2;
% expand adiabatically back to the initial pressure
turbine_work = w.expand(p1, eta_turbine);
turbine_work = expand(w, p1, eta_turbine);
w
% compute the efficiency
efficiency = (turbine_work - pump_work)/heat_added;
disp('efficiency = ', eff);
disp(sprintf('efficiency = %d', efficiency));
function w = pump(fluid, pfinal, eta)
% PUMP - Adiabatically pump a fluid to pressure pfinal, using a pump

View File

@ -9,7 +9,6 @@ function reactor1(g)
clear all
close all
cleanup
clc
tic
@ -88,8 +87,6 @@ function reactor1(g)
plot(tim,x(:,3));
xlabel('Time (s)');
ylabel('H2 Mole Fraction (K)');
clear all
cleanup
toc
end

View File

@ -9,7 +9,6 @@ function reactor2(g)
clear all
close all
cleanup
clc
tic
@ -63,8 +62,6 @@ function reactor2(g)
plot(tim,x(:,3));
xlabel('Time (s)');
ylabel('H2 Mole Fraction (K)');
clear all
cleanup
toc
end

View File

@ -41,7 +41,7 @@ function dydt = reactor_ode(t, y, gas, vdot, area, heatflux)
udt = -p * vdt + a * q;
% species equations
ydt = total_mass * gas.ydot;
ydt = total_mass * gas.massProdRate;
% set up column vector for dydt
dydt(:,j) = [udt

View File

@ -9,7 +9,6 @@
clear all
close all
cleanup
clc
tic
@ -106,6 +105,5 @@ xlabel('Time (s)');
ylabel('Mole Fractions');
legend(names);
clear all
cleanup
toc

View File

@ -3,7 +3,6 @@
LoadCantera
clear all
close all
cleanup
equil();
isentropic();
@ -26,4 +25,4 @@ ignite_uv;
clear all
close all
cleanup
UnloadCantera
UnloadCantera