[Matlab] Add interface to setChemistry
This commit is contained in:
parent
0e835e4aa2
commit
8ada40f0be
5 changed files with 47 additions and 1 deletions
29
interfaces/matlab/toolbox/@Reactor/setChemistry.m
Normal file
29
interfaces/matlab/toolbox/@Reactor/setChemistry.m
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
function setChemistry(r, flag)
|
||||
% SETCHEMISTRY Enable or disable changing reactor composition by reactions.
|
||||
% setChemistry(r, flag)
|
||||
% If the chemistry is disabled, then the reactor composition is
|
||||
% constant. The parameter should be the string ``'on'`` to enable the
|
||||
% species equations, or ``'off'`` to disable it.
|
||||
%
|
||||
% By default, Reactor objects are created with the species equations
|
||||
% enabled if there are reactions present in the mechanism file, and
|
||||
% disabled otherwise. ::
|
||||
%
|
||||
% >> setChemistry(r, 'on');
|
||||
% >> setChemistry(r, 'off');
|
||||
%
|
||||
% :param r:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
% :param flag:
|
||||
% String, either ``'on'`` or ``'off'`` to enable and disable
|
||||
% solving the energy equation, respectively
|
||||
%
|
||||
|
||||
if strcmp(flag, {'on'})
|
||||
iflag = true;
|
||||
elseif strcmp(flag, {'off'})
|
||||
iflag = false;
|
||||
else
|
||||
error('Input to setChemistry not understood. It must be either "on" or "off".');
|
||||
end
|
||||
reactormethods(8, r.index, iflag);
|
||||
|
|
@ -15,7 +15,7 @@ function setEnergy(r, flag)
|
|||
% :param r:
|
||||
% Instance of class :mat:func:`Reactor`
|
||||
% :param flag:
|
||||
% String, either ``'on'`` or ``'off`` to enable and disable
|
||||
% String, either ``'on'`` or ``'off'`` to enable and disable
|
||||
% solving the energy equation, respectively
|
||||
%
|
||||
|
||||
|
|
|
|||
|
|
@ -169,6 +169,19 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
int reactor_setChemistry(int i, bool cflag)
|
||||
{
|
||||
try {
|
||||
// @todo This should not fail silently
|
||||
if (ReactorCabinet::item(i).type() >= ReactorType) {
|
||||
ReactorCabinet::get<Reactor>(i).setChemistry(cflag);
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_setEnergy(int i, int eflag)
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ extern "C" {
|
|||
CANTERA_CAPI int reactor_del(int i);
|
||||
CANTERA_CAPI int reactor_copy(int i);
|
||||
CANTERA_CAPI int reactor_setInitialVolume(int i, double v);
|
||||
CANTERA_CAPI int reactor_setChemistry(int i, bool cflag);
|
||||
CANTERA_CAPI int reactor_setEnergy(int i, int eflag);
|
||||
CANTERA_CAPI int reactor_setThermoMgr(int i, int n);
|
||||
CANTERA_CAPI int reactor_setKineticsMgr(int i, int n);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ void reactormethods(int nlhs, mxArray* plhs[],
|
|||
case 7:
|
||||
iok = reactor_setKineticsMgr(i, int(v));
|
||||
break;
|
||||
case 8:
|
||||
iok = reactor_setChemistry(i, bool(v));
|
||||
break;
|
||||
case 9:
|
||||
iok = reactor_setEnergy(i, int(v));
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue