From a689717a7abb08aa5712da5b4f660786024b4789 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Wed, 8 Jan 2014 17:10:41 +0000 Subject: [PATCH] [Matlab] Add isothermalCompressibility and thermalExpansionCoeff functions Resolves Issue 157. --- .../@ThermoPhase/isothermalCompressibility.m | 8 ++++++++ .../@ThermoPhase/thermalExpansionCoeff.m | 8 ++++++++ src/clib/ct.cpp | 18 ++++++++++++++++++ src/clib/ct.h | 2 ++ src/matlab/thermomethods.cpp | 6 ++++++ 5 files changed, 42 insertions(+) create mode 100644 interfaces/matlab/toolbox/@ThermoPhase/isothermalCompressibility.m create mode 100644 interfaces/matlab/toolbox/@ThermoPhase/thermalExpansionCoeff.m diff --git a/interfaces/matlab/toolbox/@ThermoPhase/isothermalCompressibility.m b/interfaces/matlab/toolbox/@ThermoPhase/isothermalCompressibility.m new file mode 100644 index 000000000..26d41e540 --- /dev/null +++ b/interfaces/matlab/toolbox/@ThermoPhase/isothermalCompressibility.m @@ -0,0 +1,8 @@ +function b = isothermalCompressibility(a) +% ISOTHERMALCOMPRESSIBILITY - Isothermal Compressibility [1/Pa] +% +% b = isothermalCompressibility(a) +% Return the isothermal compressibility of ThermoPhase a +% in units of 1/Pa +% +b = thermo_get(a.tp_id,26); \ No newline at end of file diff --git a/interfaces/matlab/toolbox/@ThermoPhase/thermalExpansionCoeff.m b/interfaces/matlab/toolbox/@ThermoPhase/thermalExpansionCoeff.m new file mode 100644 index 000000000..2ccbac624 --- /dev/null +++ b/interfaces/matlab/toolbox/@ThermoPhase/thermalExpansionCoeff.m @@ -0,0 +1,8 @@ +function a = thermalExpansionCoeff(p) +% THERMALEXPANSIONCOEFF - Thermal Expansion Coefficient [1/K] +% +% a = thermalExpansionCoeff(p) +% Return the thermal expansion coefficient of ThermoPhase p +% in units of 1/K +% +a = thermo_get(p.tp_id,27); diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index ddcef1fb9..371ecf295 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -693,6 +693,24 @@ extern "C" { } } + doublereal th_thermalExpansionCoeff(int n) + { + try { + return ThermoCabinet::item(n).thermalExpansionCoeff(); + } catch (...) { + return handleAllExceptions(DERR, DERR); + } + } + + doublereal th_isothermalCompressibility(int n) + { + try { + return ThermoCabinet::item(n).isothermalCompressibility(); + } catch (...) { + return handleAllExceptions(DERR, DERR); + } + } + //-------------- pure fluids ---------------// double th_critTemperature(int n) diff --git a/src/clib/ct.h b/src/clib/ct.h index 2a0ffa9b7..390bc715e 100644 --- a/src/clib/ct.h +++ b/src/clib/ct.h @@ -65,6 +65,8 @@ extern "C" { CANTERA_CAPI double th_cp_mass(int n); CANTERA_CAPI double th_cv_mass(int n); CANTERA_CAPI double th_electricPotential(int n); + CANTERA_CAPI double th_thermalExpansionCoeff(int n); + CANTERA_CAPI double th_isothermalCompressibility(int n); CANTERA_CAPI int th_chemPotentials(int n, size_t lenm, double* murt); CANTERA_CAPI int th_elementPotentials(int n, size_t lenm, double* lambda); CANTERA_CAPI int th_getEnthalpies_RT(int n, size_t lenm, double* h_rt); diff --git a/src/matlab/thermomethods.cpp b/src/matlab/thermomethods.cpp index ec147f235..a0e8dc89e 100644 --- a/src/matlab/thermomethods.cpp +++ b/src/matlab/thermomethods.cpp @@ -175,6 +175,12 @@ static void thermoget(int nlhs, mxArray* plhs[], case 25: vv = th_electricPotential(n); break; + case 26: + vv = th_isothermalCompressibility(n); + break; + case 27: + vv = th_thermalExpansionCoeff(n); + break; default: ok = false; }