Skip to content

Commit ace2234

Browse files
committed
[MATLAB] Added massDensity property to ThermoPhase
Modified several samples to include this change
1 parent f8ebb67 commit ace2234

File tree

8 files changed

+13
-7
lines changed

8 files changed

+13
-7
lines changed

interfaces/matlab_experimental/Base/ThermoPhase.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
% Scalar double mean molecular weight. Units: kg/kmol.
6767
meanMolecularWeight
6868

69+
massDensity % Mass basis density. Units: kg/m^3.
70+
6971
molarDensity % Molar basis density. Units: kmol/m^3.
7072

7173
molecularWeights % Molecular weights of the species. Units: kg/kmol.
@@ -903,6 +905,10 @@ function display(tp)
903905
mmw = ctFunc('thermo_meanMolecularWeight', tp.tpID);
904906
end
905907

908+
function density = get.massDensity(tp)
909+
density = ctFunc('thermo_density', tp.tpID);
910+
end
911+
906912
function density = get.molarDensity(tp)
907913
density = ctFunc('thermo_molarDensity', tp.tpID);
908914
end

samples/matlab_experimental/conhp.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
% It assumes that the ``gas`` object represents a reacting ideal gas mixture.
77

88
% Set the state of the gas, based on the current solution vector.
9+
gas.basis = 'mass';
910
gas.Y = y(2:end);
1011
gas.TP = {y(1), gas.P};
1112
nsp = gas.nSpecies;
1213

1314
% energy equation
1415
wdot = gas.netProdRates;
1516
H = gas.partialMolarEnthalpies';
16-
gas.basis = 'mass';
1717
tdot =- 1 / (gas.D * gas.cp) .* wdot * H;
1818

1919
% set up column vector for dydt

samples/matlab_experimental/conuv.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
% It assumes that the ``gas`` object represents a reacting ideal gas mixture.
77

88
% Set the state of the gas, based on the current solution vector.
9+
gas.basis = 'mass';
910
gas.Y = y(2:end);
1011
gas.TD = {y(1), gas.D};
1112
nsp = gas.nSpecies;
1213

1314
% energy equation
1415
wdot = gas.netProdRates;
1516
U = gas.partialMolarIntEnergies';
16-
gas.basis = 'mass';
1717
tdot =- 1 / (gas.D * gas.cv) .* wdot * U;
1818

1919
% set up column vector for dydt

samples/matlab_experimental/diamond_cvd.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
r = surf_phase.netProdRates;
7070
carbon_dot = r(iC);
7171
mdot = mw * carbon_dot;
72-
rate = mdot / dbulk.D;
72+
rate = mdot / dbulk.massDensity;
7373
xx = [xx; x(ih)];
7474
rr = [rr; rate * 1.0e6 * 3600.0];
7575
cov = [cov; surf_phase.coverages];

samples/matlab_experimental/flame.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
f = Sim1D({left flow right});
3333

3434
% set default initial profiles.
35-
rho0 = gas.D;
35+
rho0 = gas.massDensity;
3636

3737
% find the adiabatic flame temperature and corresponding
3838
% equilibrium composition

samples/matlab_experimental/ignite.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
gas.TPX = {1001.0, OneAtm, 'H2:2,O2:1,N2:4'};
2626
gas.basis = 'mass';
2727
y0 = [gas.U
28-
1.0 / gas.D
28+
1.0 / gas.massDensity
2929
gas.Y'];
3030

3131
time_interval = [0 0.001];

samples/matlab_experimental/periodic_cstr.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
% controller (constant mdot). Set the mass flow rate to 1.25 sccm.
7373
sccm = 1.25;
7474
vdot = sccm * 1.0e-6/60.0 * ((OneAtm / gas.P) * (gas.T / 273.15)); % m^3/s
75-
mdot = gas.D * vdot; % kg/s
75+
mdot = gas.massDensity * vdot; % kg/s
7676
mfc = MassFlowController(upstream, cstr);
7777
mfc.massFlowRate = mdot;
7878

samples/matlab_experimental/plug_flow_reactor.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100
T_calc(1) = gas_calc.T;
101101
Y_calc(1, :) = gas_calc.Y;
102-
rho_calc(1) = gas_calc.D;
102+
rho_calc(1) = gas_calc.massDensity;
103103

104104
for i = 2:length(x_calc)
105105

0 commit comments

Comments
 (0)