Skip to content

Fix MATLAB interface samples #1911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interfaces/matlab_experimental/Base/Interface.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end

function c = get.concentrations(s)
surfID = s.tr_id;
surfID = s.tpID;

Check warning on line 87 in interfaces/matlab_experimental/Base/Interface.m

View check run for this annotation

Codecov / codecov/patch

interfaces/matlab_experimental/Base/Interface.m#L87

Added line #L87 was not covered by tests
nsp = s.nSpecies;
xx = zeros(1, nsp);
pt = libpointer('doublePtr', xx);
Expand Down
6 changes: 6 additions & 0 deletions interfaces/matlab_experimental/Base/ThermoPhase.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
% Scalar double mean molecular weight. Units: kg/kmol.
meanMolecularWeight

massDensity % Mass basis density. Units: kg/m^3.

molarDensity % Molar basis density. Units: kmol/m^3.

molecularWeights % Molecular weights of the species. Units: kg/kmol.
Expand Down Expand Up @@ -903,6 +905,10 @@
mmw = ctFunc('thermo_meanMolecularWeight', tp.tpID);
end

function density = get.massDensity(tp)
density = ctFunc('thermo_density', tp.tpID);

Check warning on line 909 in interfaces/matlab_experimental/Base/ThermoPhase.m

View check run for this annotation

Codecov / codecov/patch

interfaces/matlab_experimental/Base/ThermoPhase.m#L909

Added line #L909 was not covered by tests
end

function density = get.molarDensity(tp)
density = ctFunc('thermo_molarDensity', tp.tpID);
end
Expand Down
9 changes: 2 additions & 7 deletions interfaces/matlab_experimental/OneDim/Sim1D.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,9 @@

%% Sim1D Utility Methods

function display(s, fname)
function display(s)
% Show all domains.

if nargin == 1
fname = '-';
end

ctFunc('sim1D_show', s.stID, fname);
ctFunc('sim1D_show', s.stID);

Check warning on line 63 in interfaces/matlab_experimental/OneDim/Sim1D.m

View check run for this annotation

Codecov / codecov/patch

interfaces/matlab_experimental/OneDim/Sim1D.m#L63

Added line #L63 was not covered by tests
end

function restore(s, fname, id)
Expand Down
2 changes: 1 addition & 1 deletion interfaces/matlab_experimental/Reactor/ReactorSurface.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
name = '(none)';
end

s.surfID = ctFunc('reactor_new', 'ReactorSurface', surf.solnID, name);
s@Reactor(surf, 'ReactorSurface', name)

Check warning on line 43 in interfaces/matlab_experimental/Reactor/ReactorSurface.m

View check run for this annotation

Codecov / codecov/patch

interfaces/matlab_experimental/Reactor/ReactorSurface.m#L43

Added line #L43 was not covered by tests
ctFunc('reactorsurface_install', s.id, reactor.id);
end

Expand Down
2 changes: 1 addition & 1 deletion samples/matlab_experimental/conhp.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
% It assumes that the ``gas`` object represents a reacting ideal gas mixture.

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

% energy equation
wdot = gas.netProdRates;
H = gas.partialMolarEnthalpies';
gas.basis = 'mass';
tdot =- 1 / (gas.D * gas.cp) .* wdot * H;

% set up column vector for dydt
Expand Down
2 changes: 1 addition & 1 deletion samples/matlab_experimental/conuv.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
% It assumes that the ``gas`` object represents a reacting ideal gas mixture.

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

% energy equation
wdot = gas.netProdRates;
U = gas.partialMolarIntEnergies';
gas.basis = 'mass';
tdot =- 1 / (gas.D * gas.cv) .* wdot * U;

% set up column vector for dydt
Expand Down
2 changes: 1 addition & 1 deletion samples/matlab_experimental/diamond_cvd.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
r = surf_phase.netProdRates;
carbon_dot = r(iC);
mdot = mw * carbon_dot;
rate = mdot / dbulk.D;
rate = mdot / dbulk.massDensity;
xx = [xx; x(ih)];
rr = [rr; rate * 1.0e6 * 3600.0];
cov = [cov; surf_phase.coverages];
Expand Down
2 changes: 1 addition & 1 deletion samples/matlab_experimental/diff_flame.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
% ``help setRefineCriteria``.

f.energyEnabled = true;
fl.setRefineCriteria(2, 200.0, 0.1, 0.2);
fl.setRefineCriteria(2, 4, 0.2, 0.3, 0.04);
fl.solve(loglevel, refine_grid);

%% Show statistics of solution and elapsed time
Expand Down
2 changes: 1 addition & 1 deletion samples/matlab_experimental/flame.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
f = Sim1D({left flow right});

% set default initial profiles.
rho0 = gas.D;
rho0 = gas.massDensity;

% find the adiabatic flame temperature and corresponding
% equilibrium composition
Expand Down
2 changes: 1 addition & 1 deletion samples/matlab_experimental/ignite.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
gas.TPX = {1001.0, OneAtm, 'H2:2,O2:1,N2:4'};
gas.basis = 'mass';
y0 = [gas.U
1.0 / gas.D
1.0 / gas.massDensity
gas.Y'];

time_interval = [0 0.001];
Expand Down
4 changes: 3 additions & 1 deletion samples/matlab_experimental/periodic_cstr.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
% controller (constant mdot). Set the mass flow rate to 1.25 sccm.
sccm = 1.25;
vdot = sccm * 1.0e-6/60.0 * ((OneAtm / gas.P) * (gas.T / 273.15)); % m^3/s
mdot = gas.D * vdot; % kg/s
mdot = gas.massDensity * vdot; % kg/s
mfc = MassFlowController(upstream, cstr);
mfc.massFlowRate = mdot;

Expand Down Expand Up @@ -109,6 +109,8 @@
plot(tm, y)
legend('H2', 'O2', 'H2O')
title('Mass Fractions')
ylabel('Mass Fractions')
xlabel('Time (s)')

toc
end
2 changes: 1 addition & 1 deletion samples/matlab_experimental/plug_flow_reactor.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

T_calc(1) = gas_calc.T;
Y_calc(1, :) = gas_calc.Y;
rho_calc(1) = gas_calc.D;
rho_calc(1) = gas_calc.massDensity;

for i = 2:length(x_calc)

Expand Down
Loading