[Matlab] Add interface to setChemistry

This commit is contained in:
Bryan W. Weber 2016-08-09 13:58:21 -04:00
parent 0e835e4aa2
commit 8ada40f0be
No known key found for this signature in database
GPG key ID: DEE60DAAA4195429
5 changed files with 47 additions and 1 deletions

View 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);

View file

@ -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
%

View file

@ -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 {

View file

@ -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);

View file

@ -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;