Add MATLAB interface to the setState_RP function

This commit is contained in:
Bryan W. Weber 2015-06-13 20:28:30 -04:00 committed by Ray Speth
parent ca6e228e22
commit 60827267b7
5 changed files with 32 additions and 0 deletions

View file

@ -170,6 +170,8 @@ elseif ntot == 2
elseif nt == 1 && np == 1
setTemperature(tp, tval);
setPressure(tp, pval);
elseif np == 1 && nv == 1
setState_RP(tp, [1.0/vval, pval])
elseif nt == 1 && nq == 1
setState_Tsat(tp, [tval,qval]);
elseif np == 1 && nq == 1

View file

@ -0,0 +1,16 @@
function setState_RP(tp, rp)
% SETSTATE_RP Set the density and pressure.
% setState_RP(tp, [density,p])
% The density is set first, then the pressure is set by
% changing the temperature holding the density and
% chemical composition fixed.
%
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% class derived from ThermoPhase)
% :param rp:
% Vector of length 2 containing the desired values for the density (kg/m^3)
% and pressure (Pa)
%
thermo_set(tp.tp_id, 26, rp);

View file

@ -535,6 +535,16 @@ extern "C" {
}
}
int th_set_RP(int n, double* vals)
{
try{
ThermoCabinet::item(n).setState_RP(vals[0], vals[1]);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int th_set_HP(int n, double* vals)
{
try {

View file

@ -73,6 +73,7 @@ extern "C" {
CANTERA_CAPI int th_getEntropies_R(int n, size_t lenm, double* s_r);
CANTERA_CAPI int th_getCp_R(int n, size_t lenm, double* cp_r);
CANTERA_CAPI int th_setElectricPotential(int n, double v);
CANTERA_CAPI int th_set_RP(int n, double* vals);
CANTERA_CAPI int th_set_HP(int n, double* vals);
CANTERA_CAPI int th_set_UV(int n, double* vals);
CANTERA_CAPI int th_set_SV(int n, double* vals);

View file

@ -60,6 +60,9 @@ static void thermoset(int nlhs, mxArray* plhs[],
case 25:
ierr = th_setState_Tsat(th,ptr[0],ptr[1]);
break;
case 26:
ierr = th_set_RP(th,ptr);
break;
default:
mexErrMsgTxt("unknown pair attribute.");
}