diff --git a/interfaces/matlab_experimental/1D/CounterFlowDiffusionFlame.m b/interfaces/matlab_experimental/1D/CounterFlowDiffusionFlame.m index b544403ae0..8f454a1b5c 100644 --- a/interfaces/matlab_experimental/1D/CounterFlowDiffusionFlame.m +++ b/interfaces/matlab_experimental/1D/CounterFlowDiffusionFlame.m @@ -44,7 +44,7 @@ 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 @@ % 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ eli = tp.elementIndex(element); M = tp.atomicMasses; Mel = M(eli); - moles = elMassFrac/Mel; + moles = elMassFrac / Mel; end diff --git a/interfaces/matlab_experimental/1D/Domain1D.m b/interfaces/matlab_experimental/1D/Domain1D.m index 0b9385025a..eb581642dd 100644 --- a/interfaces/matlab_experimental/1D/Domain1D.m +++ b/interfaces/matlab_experimental/1D/Domain1D.m @@ -36,43 +36,6 @@ 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 @@ % 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 @@ % 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 @@ % :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 @@ function delete(d) %% 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 @@ function delete(d) 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 @@ function delete(d) 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 @@ function delete(d) 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 @@ function delete(d) 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 @@ function setID(d, id) function setMassFlowRate(d, mdot) % Set the mass flow rate. % - % d.setMdot(mdot) + % d.setMassFlowRate(mdot) % % :param d: % Instance of class :mat:func:`Domain1D` diff --git a/interfaces/matlab_experimental/1D/Sim1D.m b/interfaces/matlab_experimental/1D/Sim1D.m index f632754bb1..c45f04ab2f 100644 --- a/interfaces/matlab_experimental/1D/Sim1D.m +++ b/interfaces/matlab_experimental/1D/Sim1D.m @@ -22,49 +22,6 @@ 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 @@ function getInitialSoln(s) 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 @@ function getInitialSoln(s) 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; diff --git a/interfaces/matlab_experimental/Base/Interface.m b/interfaces/matlab_experimental/Base/Interface.m index b2ed936c00..81ce904e74 100644 --- a/interfaces/matlab_experimental/Base/Interface.m +++ b/interfaces/matlab_experimental/Base/Interface.m @@ -23,7 +23,6 @@ % 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 @@ %% 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 @@ 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 @@ % ``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 @@ % :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); diff --git a/interfaces/matlab_experimental/Base/Kinetics.m b/interfaces/matlab_experimental/Base/Kinetics.m index e2ec5d73e2..9ac512afac 100644 --- a/interfaces/matlab_experimental/Base/Kinetics.m +++ b/interfaces/matlab_experimental/Base/Kinetics.m @@ -6,89 +6,12 @@ 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 @@ 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. + % + % ydot = kin.massProdRate % - % n = kin.isReversible(i) + % Evaluates the source term :math:`\dot{\omega}_k M_k /\rho` % - % :param i: - % Integer reaction number. + % :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 @@ 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 @@ function delete(kin) %% 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 @@ function delete(kin) 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 @@ function delete(kin) 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 @@ function delete(kin) 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 @@ function delete(kin) 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 @@ function delete(kin) 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 @@ function delete(kin) 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 @@ function delete(kin) 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 diff --git a/interfaces/matlab_experimental/Base/Solution.m b/interfaces/matlab_experimental/Base/Solution.m index 759c0bda6b..20a4bca063 100644 --- a/interfaces/matlab_experimental/Base/Solution.m +++ b/interfaces/matlab_experimental/Base/Solution.m @@ -79,7 +79,7 @@ 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 diff --git a/interfaces/matlab_experimental/Base/ThermoPhase.m b/interfaces/matlab_experimental/Base/ThermoPhase.m index 28a7360ac7..b9981a12c6 100644 --- a/interfaces/matlab_experimental/Base/ThermoPhase.m +++ b/interfaces/matlab_experimental/Base/ThermoPhase.m @@ -11,12 +11,10 @@ % 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 @@ % String. Can be 'mole'/'molar'/'Molar'/'Mole' or 'mass'/'Mass'. basis - end properties (SetAccess = protected) @@ -50,47 +47,6 @@ 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 @@ 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 @@ 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 @@ thermalExpansionCoeff % Thermal expansion coefficient. Units: 1/K. - vaporFraciton % Vapor fraction of the phase. + vaporFraction % Vapor fraction of the phase. end @@ -483,7 +357,32 @@ function display(tp) 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 @@ function display(tp) 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 @@ function display(tp) 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 @@ function display(tp) 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 @@ function display(tp) 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 @@ function display(tp) 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 @@ function display(tp) 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 @@ function display(tp) 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 diff --git a/interfaces/matlab_experimental/Base/Transport.m b/interfaces/matlab_experimental/Base/Transport.m index 3cc130adea..1f8dd89c41 100644 --- a/interfaces/matlab_experimental/Base/Transport.m +++ b/interfaces/matlab_experimental/Base/Transport.m @@ -12,7 +12,7 @@ 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. diff --git a/interfaces/matlab_experimental/Func/fplus.m b/interfaces/matlab_experimental/Func/fplus.m index a12639a521..b4a63780e1 100644 --- a/interfaces/matlab_experimental/Func/fplus.m +++ b/interfaces/matlab_experimental/Func/fplus.m @@ -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: diff --git a/interfaces/matlab_experimental/Func/frdivide.m b/interfaces/matlab_experimental/Func/frdivide.m index 01aae259ea..1dd993f45c 100644 --- a/interfaces/matlab_experimental/Func/frdivide.m +++ b/interfaces/matlab_experimental/Func/frdivide.m @@ -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: diff --git a/interfaces/matlab_experimental/Func/ftimes.m b/interfaces/matlab_experimental/Func/ftimes.m index 572bc6055c..4a3e32394c 100644 --- a/interfaces/matlab_experimental/Func/ftimes.m +++ b/interfaces/matlab_experimental/Func/ftimes.m @@ -1,5 +1,6 @@ function r = ftimes(a, b) % Create a functor that multiplies two other functors. + % % r = ftimes(a, b) % % :param a: diff --git a/interfaces/matlab_experimental/Func/gaussian.m b/interfaces/matlab_experimental/Func/gaussian.m index 69a4ecf115..1657d17805 100644 --- a/interfaces/matlab_experimental/Func/gaussian.m +++ b/interfaces/matlab_experimental/Func/gaussian.m @@ -1,5 +1,6 @@ function g = gaussian(peak, center, width) % Create a Gaussian :mat:func:`Func` instance. + % % g = gaussian(peak, center, width) % % :param peak: diff --git a/interfaces/matlab_experimental/Func/polynom.m b/interfaces/matlab_experimental/Func/polynom.m index b2bcb754b8..2ff0e9230c 100644 --- a/interfaces/matlab_experimental/Func/polynom.m +++ b/interfaces/matlab_experimental/Func/polynom.m @@ -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 @@ % Vector of polynomial coefficients % :return: % Instance of class :mat:func:`Func` - % [n m] = size(coeffs); if n == 1 diff --git a/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m b/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m index e1d6451b56..afd81b343b 100644 --- a/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m +++ b/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m @@ -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 @@ % reactor % :return: % Instance of class :mat:func:`Reactor` - % if nargin == 0 contents = 0; diff --git a/interfaces/matlab_experimental/Reactor/FlowDevice.m b/interfaces/matlab_experimental/Reactor/FlowDevice.m index 9d6ccf2d45..7aef25d4ea 100644 --- a/interfaces/matlab_experimental/Reactor/FlowDevice.m +++ b/interfaces/matlab_experimental/Reactor/FlowDevice.m @@ -24,11 +24,14 @@ % 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`. diff --git a/interfaces/matlab_experimental/Reactor/FlowReactor.m b/interfaces/matlab_experimental/Reactor/FlowReactor.m index 8e7d7d218d..c177cc8c90 100644 --- a/interfaces/matlab_experimental/Reactor/FlowReactor.m +++ b/interfaces/matlab_experimental/Reactor/FlowReactor.m @@ -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 @@ % reactor % :return: % Instance of class :mat:func:`Reactor` - % if nargin == 0 contents = 0; diff --git a/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m b/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m index 5724f5d00a..fba0df777e 100644 --- a/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m +++ b/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m @@ -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 @@ % reactor % :return: % Instance of class :mat:func:`Reactor` - % if nargin == 0 contents = 0; diff --git a/interfaces/matlab_experimental/Reactor/IdealGasReactor.m b/interfaces/matlab_experimental/Reactor/IdealGasReactor.m index 451f527ebb..61c9111f8b 100644 --- a/interfaces/matlab_experimental/Reactor/IdealGasReactor.m +++ b/interfaces/matlab_experimental/Reactor/IdealGasReactor.m @@ -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 @@ % reactor % :return: % Instance of class :mat:func:`Reactor` - % if nargin == 0 contents = 0; diff --git a/interfaces/matlab_experimental/Reactor/MassFlowController.m b/interfaces/matlab_experimental/Reactor/MassFlowController.m index 99eb007768..bd1f20113a 100644 --- a/interfaces/matlab_experimental/Reactor/MassFlowController.m +++ b/interfaces/matlab_experimental/Reactor/MassFlowController.m @@ -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. diff --git a/interfaces/matlab_experimental/Reactor/ReactorNet.m b/interfaces/matlab_experimental/Reactor/ReactorNet.m index 5e0573cf61..352456dd22 100644 --- a/interfaces/matlab_experimental/Reactor/ReactorNet.m +++ b/interfaces/matlab_experimental/Reactor/ReactorNet.m @@ -38,19 +38,6 @@ 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 @@ function setTolerances(r, rerr, aerr) 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); diff --git a/interfaces/matlab_experimental/Reactor/Wall.m b/interfaces/matlab_experimental/Reactor/Wall.m index 1085b9a19d..9bbfa3b06b 100644 --- a/interfaces/matlab_experimental/Reactor/Wall.m +++ b/interfaces/matlab_experimental/Reactor/Wall.m @@ -41,13 +41,8 @@ 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 @@ function install(w, l, r) 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 diff --git a/interfaces/matlab_experimental/readme.md b/interfaces/matlab_experimental/readme.md index 545713b0a3..774388bbd7 100644 --- a/interfaces/matlab_experimental/readme.md +++ b/interfaces/matlab_experimental/readme.md @@ -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. \ No newline at end of file +12) A future updates will add automated installation. diff --git a/samples/matlab_experimental/PFR_solver.m b/samples/matlab_experimental/PFR_solver.m index 02844583af..8c9afd30ea 100644 --- a/samples/matlab_experimental/PFR_solver.m +++ b/samples/matlab_experimental/PFR_solver.m @@ -30,7 +30,7 @@ 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; diff --git a/samples/matlab_experimental/catcomb.m b/samples/matlab_experimental/catcomb.m index e6a4018eaf..58fa6fabab 100644 --- a/samples/matlab_experimental/catcomb.m +++ b/samples/matlab_experimental/catcomb.m @@ -18,7 +18,6 @@ clear all close all -cleanup clc t0 = cputime; % record the starting time @@ -112,7 +111,7 @@ % set the inlet parameters. Start with comp1 (hydrogen/air) inlt.T = tinlet; -inlt.setMdot(mdot); +inlt.setMassFlowRate(mdot); inlt.setMoleFractions(comp1); %% create the surface diff --git a/samples/matlab_experimental/diamond_cvd.m b/samples/matlab_experimental/diamond_cvd.m index 54d37c208d..d728b8a15a 100644 --- a/samples/matlab_experimental/diamond_cvd.m +++ b/samples/matlab_experimental/diamond_cvd.m @@ -18,7 +18,6 @@ clear all close all -cleanup clc t0 = cputime; % record the starting time @@ -45,7 +44,7 @@ % input file 'diamond.yaml'. dbulk = Solution('diamond.yaml', 'diamond'); -mw = dbulk.MolecularWeights; +mw = dbulk.molecularWeights; %% Create the interface object % diff --git a/samples/matlab_experimental/diff_flame.m b/samples/matlab_experimental/diff_flame.m index 3e82cbe817..3092683799 100644 --- a/samples/matlab_experimental/diff_flame.m +++ b/samples/matlab_experimental/diff_flame.m @@ -10,7 +10,6 @@ clear all close all -cleanup clc tic % total running time of the script @@ -69,13 +68,13 @@ % 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. diff --git a/samples/matlab_experimental/equil.m b/samples/matlab_experimental/equil.m index 5a35703d2f..4d4ab70d18 100644 --- a/samples/matlab_experimental/equil.m +++ b/samples/matlab_experimental/equil.m @@ -8,7 +8,6 @@ function equil(g) clear all close all - cleanup clc tic diff --git a/samples/matlab_experimental/flame1.m b/samples/matlab_experimental/flame1.m index a806274831..8d1d073cab 100644 --- a/samples/matlab_experimental/flame1.m +++ b/samples/matlab_experimental/flame1.m @@ -9,7 +9,6 @@ clear all close all -cleanup clc tic @@ -64,7 +63,7 @@ % 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 diff --git a/samples/matlab_experimental/flame2.m b/samples/matlab_experimental/flame2.m index 9c16c0e85d..56036fef9e 100644 --- a/samples/matlab_experimental/flame2.m +++ b/samples/matlab_experimental/flame2.m @@ -8,7 +8,6 @@ clear all close all -cleanup clc tic @@ -64,14 +63,14 @@ 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 diff --git a/samples/matlab_experimental/ignite.m b/samples/matlab_experimental/ignite.m index 09b79ef943..4cd5f16545 100644 --- a/samples/matlab_experimental/ignite.m +++ b/samples/matlab_experimental/ignite.m @@ -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 @@ clear all close all - cleanup clc tic @@ -52,16 +51,16 @@ 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/samples/matlab_experimental/ignite_hp.m b/samples/matlab_experimental/ignite_hp.m index a8f948142a..20580fb8ff 100644 --- a/samples/matlab_experimental/ignite_hp.m +++ b/samples/matlab_experimental/ignite_hp.m @@ -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 diff --git a/samples/matlab_experimental/ignite_uv.m b/samples/matlab_experimental/ignite_uv.m index 27405cf144..6d85ebeb3c 100644 --- a/samples/matlab_experimental/ignite_uv.m +++ b/samples/matlab_experimental/ignite_uv.m @@ -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 diff --git a/samples/matlab_experimental/isentropic.m b/samples/matlab_experimental/isentropic.m index 686b2a886b..019645bc78 100644 --- a/samples/matlab_experimental/isentropic.m +++ b/samples/matlab_experimental/isentropic.m @@ -8,7 +8,6 @@ function isentropic(g) clear all close all - cleanup clc tic diff --git a/samples/matlab_experimental/lithium_ion_battery.m b/samples/matlab_experimental/lithium_ion_battery.m index 8af5ff3d04..6f0c3ede33 100644 --- a/samples/matlab_experimental/lithium_ion_battery.m +++ b/samples/matlab_experimental/lithium_ion_battery.m @@ -25,7 +25,6 @@ clear all close all -cleanup clc tic diff --git a/samples/matlab_experimental/periodic_cstr.m b/samples/matlab_experimental/periodic_cstr.m index cbd659842a..9ad858dda1 100644 --- a/samples/matlab_experimental/periodic_cstr.m +++ b/samples/matlab_experimental/periodic_cstr.m @@ -21,7 +21,6 @@ clear all close all - cleanup clc tic diff --git a/samples/matlab_experimental/plug_flow_reactor.m b/samples/matlab_experimental/plug_flow_reactor.m index 618642767e..7374202189 100644 --- a/samples/matlab_experimental/plug_flow_reactor.m +++ b/samples/matlab_experimental/plug_flow_reactor.m @@ -26,7 +26,6 @@ clear all close all -cleanup clc tic @@ -122,7 +121,7 @@ %-------------------------------------------------------------------------- %-------------------------------------------------------------------------- % 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 @@ % 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 diff --git a/samples/matlab_experimental/prandtl1.m b/samples/matlab_experimental/prandtl1.m index fa9a1ab08e..5dd2956818 100644 --- a/samples/matlab_experimental/prandtl1.m +++ b/samples/matlab_experimental/prandtl1.m @@ -9,7 +9,6 @@ function prandtl1(g) clear all close all - cleanup clc tic diff --git a/samples/matlab_experimental/prandtl2.m b/samples/matlab_experimental/prandtl2.m index 9126fa7d89..e50d1c4961 100644 --- a/samples/matlab_experimental/prandtl2.m +++ b/samples/matlab_experimental/prandtl2.m @@ -8,7 +8,6 @@ function prandtl2(g) clear all close all - cleanup clc tic diff --git a/samples/matlab_experimental/rankine.m b/samples/matlab_experimental/rankine.m index 4607ca8d0f..95b9d72887 100644 --- a/samples/matlab_experimental/rankine.m +++ b/samples/matlab_experimental/rankine.m @@ -4,7 +4,6 @@ clear all close all -cleanup help rankine @@ -12,6 +11,7 @@ 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 @@ 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 diff --git a/samples/matlab_experimental/reactor1.m b/samples/matlab_experimental/reactor1.m index b7c1900e41..4300a8dc0c 100644 --- a/samples/matlab_experimental/reactor1.m +++ b/samples/matlab_experimental/reactor1.m @@ -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 diff --git a/samples/matlab_experimental/reactor2.m b/samples/matlab_experimental/reactor2.m index 3453b1ad72..af57a28c31 100644 --- a/samples/matlab_experimental/reactor2.m +++ b/samples/matlab_experimental/reactor2.m @@ -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 diff --git a/samples/matlab_experimental/reactor_ode.m b/samples/matlab_experimental/reactor_ode.m index fa3caa7d6f..acd297f5c0 100644 --- a/samples/matlab_experimental/reactor_ode.m +++ b/samples/matlab_experimental/reactor_ode.m @@ -41,7 +41,7 @@ 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 diff --git a/samples/matlab_experimental/surfreactor.m b/samples/matlab_experimental/surfreactor.m index 3ed133eb4d..449169058d 100644 --- a/samples/matlab_experimental/surfreactor.m +++ b/samples/matlab_experimental/surfreactor.m @@ -9,7 +9,6 @@ clear all close all -cleanup clc tic @@ -106,6 +105,5 @@ ylabel('Mole Fractions'); legend(names); clear all -cleanup toc diff --git a/samples/matlab_experimental/test_examples.m b/samples/matlab_experimental/test_examples.m index e7504042b2..2658d52444 100644 --- a/samples/matlab_experimental/test_examples.m +++ b/samples/matlab_experimental/test_examples.m @@ -3,7 +3,6 @@ LoadCantera clear all close all -cleanup equil(); isentropic(); @@ -26,4 +25,4 @@ clear all close all cleanup -UnloadCantera \ No newline at end of file +UnloadCantera