diff --git a/interfaces/matlab/toolbox/@ThermoPhase/calculatePsat.m b/interfaces/matlab/toolbox/@ThermoPhase/calculatePsat.m new file mode 100644 index 000000000..83efa2624 --- /dev/null +++ b/interfaces/matlab/toolbox/@ThermoPhase/calculatePsat.m @@ -0,0 +1,4 @@ +function v = calculatePsat(a, T) +% calcPsat - Calculate saturation pressure for temperature T (in K) for a +% fluid with the MFTP thermo model. +v = thermo_get(a.tp_id,26,T); diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 911189e71..54f6f0607 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -21,6 +21,7 @@ #include "Cabinet.h" #include "cantera/kinetics/InterfaceKinetics.h" #include "cantera/thermo/PureFluidPhase.h" +#include "cantera/thermo/MixtureFugacityTP.h" using namespace std; using namespace Cantera; @@ -605,7 +606,7 @@ extern "C" { return handleAllExceptions(-1, ERR); } } - + doublereal th_refPressure(int n) { try { @@ -767,6 +768,19 @@ extern "C" { return handleAllExceptions(-1, ERR); } } + + //-------------MFTP Models------------------// + + + double th_calculatePsat(int n, double TKelvin, double molarVolGas, double molarVolLiquid) + { + try { + return ThermoCabinet::get(n).calculatePsat(TKelvin, molarVolGas, molarVolLiquid); + } catch (...) { + return handleAllExceptions(DERR, DERR); + } + } + //-------------- Kinetics ------------------// diff --git a/src/clib/ct.h b/src/clib/ct.h index 324ff21fd..86185cdff 100644 --- a/src/clib/ct.h +++ b/src/clib/ct.h @@ -58,6 +58,7 @@ extern "C" { CANTERA_CAPI double th_cv_mole(int n); CANTERA_CAPI double th_pressure(int n); CANTERA_CAPI int th_setPressure(int n, double p); + CANTERA_CAPI double th_calculatePsat(int n, double TKelvin, double molarVolGas, double molarVolLiquid); CANTERA_CAPI double th_enthalpy_mass(int n); CANTERA_CAPI double th_intEnergy_mass(int n); CANTERA_CAPI double th_entropy_mass(int n); diff --git a/src/matlab/thermomethods.cpp b/src/matlab/thermomethods.cpp index e2d8a6bc3..a508eefa0 100644 --- a/src/matlab/thermomethods.cpp +++ b/src/matlab/thermomethods.cpp @@ -91,7 +91,7 @@ static void thermoset(int nlhs, mxArray* plhs[], static void thermoget(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { - double vv, psat, tsat; + double vv, psat, tsat, TK; int n = getInt(prhs[1]); int job = getInt(prhs[2]); @@ -174,6 +174,11 @@ static void thermoget(int nlhs, mxArray* plhs[], break; case 25: vv = th_electricPotential(n); + break; + case 26: + double molarVolGas, molarVolLiquid; + TK = getDouble(prhs[3]); + vv = th_calculatePsat(n,TK,molarVolGas,molarVolLiquid); break; default: ok = false;