diff --git a/interfaces/matlab_experimental/Base/ThermoPhase.m b/interfaces/matlab_experimental/Base/ThermoPhase.m index 6ab85f8a868..a5b8821ddeb 100644 --- a/interfaces/matlab_experimental/Base/ThermoPhase.m +++ b/interfaces/matlab_experimental/Base/ThermoPhase.m @@ -1030,11 +1030,7 @@ function display(tp) end function volume = get.V(tp) - if strcmp(tp.basis, 'molar') - volume = 1 / tp.molarDensity; - else - volume = 1 / tp.D; - end + volume = 1 / tp.D; end function moleFractions = get.X(tp) @@ -1404,6 +1400,9 @@ function display(tp) function set.HP(tp, input) h = input{1}; p = input{2}; + if strcmp(tp.basis, 'molar') + h = h/tp.meanMolecularWeight; + end ctFunc('thermo_set_HP', tp.tpID, [h, p]); end @@ -1442,6 +1441,10 @@ function display(tp) function set.SH(tp, input) s = input{1}; h = input{2}; + if strcmp(tp.basis, 'molar') + s = s/tp.meanMolecularWeight; + h = h/tp.meanMolecularWeight; + end ctFunc('thermo_set_SH', tp.tpID, [s, h]); end @@ -1458,6 +1461,9 @@ function display(tp) function set.SP(tp, input) s = input{1}; p = input{2}; + if strcmp(tp.basis, 'molar') + s = s/tp.meanMolecularWeight; + end ctFunc('thermo_set_SP', tp.tpID, [s, p]); end @@ -1474,6 +1480,9 @@ function display(tp) function set.ST(tp, input) s = input{1}; t = input{2}; + if strcmp(tp.basis, 'molar') + s = s/tp.meanMolecularWeight; + end ctFunc('thermo_set_ST', tp.tpID, [s, t]); end @@ -1490,6 +1499,9 @@ function display(tp) function set.SV(tp, input) s = input{1}; v = input{2}; + if strcmp(tp.basis, 'molar') + s = s/tp.meanMolecularWeight; + end ctFunc('thermo_set_SV', tp.tpID, [s, v]); end @@ -1500,7 +1512,7 @@ function display(tp) function set.SVY(tp, input) tp.Y = input{3}; - tp.SP = input(1:2); + tp.SV = input(1:2); end function set.TD(tp, input) @@ -1522,6 +1534,9 @@ function display(tp) function set.TH(tp, input) t = input{1}; h = input{2}; + if strcmp(tp.basis, 'molar') + h = h/tp.meanMolecularWeight; + end ctFunc('thermo_set_TH', tp.tpID, [t, h]); end @@ -1576,6 +1591,9 @@ function display(tp) function set.UP(tp, input) u = input{1}; p = input{2}; + if strcmp(tp.basis, 'molar') + u = u/tp.meanMolecularWeight; + end ctFunc('thermo_set_UP', tp.tpID, [u, p]); end @@ -1592,6 +1610,9 @@ function display(tp) function set.UV(tp, input) u = input{1}; v = input{2}; + if strcmp(tp.basis, 'molar') + u = u/tp.meanMolecularWeight; + end ctFunc('thermo_set_UV', tp.tpID, [u, v]); end @@ -1608,6 +1629,9 @@ function display(tp) function set.VH(tp, input) v = input{1}; h = input{2}; + if strcmp(tp.basis, 'molar') + h = h/tp.meanMolecularWeight; + end ctFunc('thermo_set_VH', tp.tpID, [v, h]); end diff --git a/test/matlab_experimental/ctTestThermo.m b/test/matlab_experimental/ctTestThermo.m index 7377b3d9566..78e8bc441cd 100644 --- a/test/matlab_experimental/ctTestThermo.m +++ b/test/matlab_experimental/ctTestThermo.m @@ -233,8 +233,8 @@ function testNAtoms(self) self.verifyEqual(n2, n); end - self.getInvalidValue('nAtoms', {'C', 'H2'}, 'outside valid range'); - self.getInvalidValue('nAtoms', {'H', 'CH4'}, 'outside valid range'); + self.getInvalidValue('nAtoms', {'C', 'H2'}, 'No such species'); + self.getInvalidValue('nAtoms', {'H', 'CH4'}, 'No such element'); end function testElementalMassFraction(self) @@ -251,7 +251,7 @@ function testElementalMassFraction(self) self.verifyEqual(Zh, exp2, 'AbsTol', self.atol); self.verifyEqual(Zar, exp3, 'AbsTol', self.atol); - self.getInvalidValue('elementalMassFraction', {'C'}, 'outside valid range'); + self.getInvalidValue('elementalMassFraction', {'C'}, 'No such element'); self.getInvalidValue('elementalMassFraction', {5}, 'Wrong type'); end @@ -322,16 +322,6 @@ function testSingleGetters(self) (GasConstant * self.phase.T); self.verifyEqual(val, exp, 'RelTol', self.rtol); - self.phase.basis = 'mass'; - val = self.phase.V; - exp = 1/exp; - self.verifyEqual(val, exp, 'RelTol', self.rtol); - - self.phase.basis = 'molar'; - val = self.phase.V; - exp = exp * self.phase.meanMolecularWeight; - self.verifyEqual(val, exp, 'RelTol', self.rtol); - val = self.phase.molarDensity; exp = self.phase.D/self.phase.meanMolecularWeight; self.verifyEqual(val, exp, 'RelTol', self.rtol); @@ -411,17 +401,11 @@ function testSetCompositionStringBad(self) end function testSetStateMole(self) - self.assumeFail(['Fails because multi-property setters could not', ... - ' set correct values']); - self.checkSetters(750, 0.07, [0.2, 0.1, 0.0, 0.3, 0.1, ... 0.0, 0.0, 0.2, 0.1, 0.0]); end function testSetStateMass(self) - self.assumeFail(['Fails because multi-property setters could not', ... - ' set correct values']); - self.phase.basis = 'mass'; self.checkSetters(500, 1.5, [0.1, 0.0, 0.0, 0.1, 0.4, ... 0.2, 0.0, 0.0, 0.2, 0.0]);