Skip to content

Commit

Permalink
Fixed all issues caused by modifying class methods into properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and speth committed May 11, 2023
1 parent 0c6920a commit b227b27
Show file tree
Hide file tree
Showing 44 changed files with 445 additions and 489 deletions.
44 changes: 22 additions & 22 deletions interfaces/matlab_experimental/1D/CounterFlowDiffusionFlame.m
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -204,5 +204,5 @@
eli = tp.elementIndex(element);
M = tp.atomicMasses;
Mel = M(eli);
moles = elMassFrac/Mel;
moles = elMassFrac / Mel;
end
165 changes: 82 additions & 83 deletions interfaces/matlab_experimental/1D/Domain1D.m
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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`
Expand Down

0 comments on commit b227b27

Please sign in to comment.