From 83b65c48bb8b66fdd9894121b3be302c8c87c99e Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 14 Mar 2022 16:38:25 -0400 Subject: [PATCH] [Thermo] Remove incorrect partialMolarCp from RedlichKwong --- include/cantera/thermo/RedlichKwongMFTP.h | 4 ++- .../cython/cantera/test/test_convert.py | 29 +++++++++++-------- src/thermo/RedlichKwongMFTP.cpp | 6 ---- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/cantera/thermo/RedlichKwongMFTP.h b/include/cantera/thermo/RedlichKwongMFTP.h index 4eb4e151ffa..9d89bf8ba82 100644 --- a/include/cantera/thermo/RedlichKwongMFTP.h +++ b/include/cantera/thermo/RedlichKwongMFTP.h @@ -117,7 +117,9 @@ class RedlichKwongMFTP : public MixtureFugacityTP virtual void getPartialMolarEnthalpies(doublereal* hbar) const; virtual void getPartialMolarEntropies(doublereal* sbar) const; virtual void getPartialMolarIntEnergies(doublereal* ubar) const; - virtual void getPartialMolarCp(doublereal* cpbar) const; + virtual void getPartialMolarCp(double* cpbar) const { + throw NotImplementedError("RedlichKwongMFTP::getPartialMolarCp"); + } virtual void getPartialMolarVolumes(doublereal* vbar) const; //! @} diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index ebf939be90e..d4baa953314 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -663,12 +663,13 @@ def checkConversion(self, basename, cls=ct.Solution, ctiphases=(), return ctiPhase, yamlPhase - def checkThermo(self, ctiPhase, yamlPhase, temperatures, tol=1e-7): + def checkThermo(self, ctiPhase, yamlPhase, temperatures, tol=1e-7, check_cp=True): for T in temperatures: ctiPhase.TP = T, ct.one_atm yamlPhase.TP = T, ct.one_atm - cp_cti = ctiPhase.partial_molar_cp - cp_yaml = yamlPhase.partial_molar_cp + if check_cp: + cp_cti = ctiPhase.partial_molar_cp + cp_yaml = yamlPhase.partial_molar_cp h_cti = ctiPhase.partial_molar_enthalpies h_yaml = yamlPhase.partial_molar_enthalpies s_cti = ctiPhase.partial_molar_entropies @@ -676,7 +677,8 @@ def checkThermo(self, ctiPhase, yamlPhase, temperatures, tol=1e-7): self.assertNear(ctiPhase.density, yamlPhase.density) for i in range(ctiPhase.n_species): message = ' for species {0} at T = {1}'.format(i, T) - self.assertNear(cp_cti[i], cp_yaml[i], tol, msg='cp'+message) + if check_cp: + self.assertNear(cp_cti[i], cp_yaml[i], tol, msg='cp'+message) self.assertNear(h_cti[i], h_yaml[i], tol, msg='h'+message) self.assertNear(s_cti[i], s_yaml[i], tol, msg='s'+message) @@ -779,13 +781,13 @@ def test_Redlich_Kwong_CO2(self): ctiGas, yamlGas = self.checkConversion('co2_RK_example') for P in [1e5, 2e6, 1.3e7]: yamlGas.TP = ctiGas.TP = 300, P - self.checkThermo(ctiGas, yamlGas, [300, 400, 500]) + self.checkThermo(ctiGas, yamlGas, [300, 400, 500], check_cp=False) @utilities.slow_test def test_Redlich_Kwong_ndodecane(self): self.convert("nDodecane_Reitz", self.cantera_data_path) ctiGas, yamlGas = self.checkConversion('nDodecane_Reitz') - self.checkThermo(ctiGas, yamlGas, [300, 400, 500]) + self.checkThermo(ctiGas, yamlGas, [300, 400, 500], check_cp=False) self.checkKinetics(ctiGas, yamlGas, [300, 500, 1300], [1e5, 2e6, 1.4e7], 1e-6) @@ -889,12 +891,14 @@ def checkConversion(self, basename, cls=ct.Solution, ctmlphases=(), return ctmlPhase, yamlPhase - def checkThermo(self, ctmlPhase, yamlPhase, temperatures, pressure=ct.one_atm, tol=1e-7): + def checkThermo(self, ctmlPhase, yamlPhase, temperatures, pressure=ct.one_atm, + tol=1e-7, check_cp=True): for T in temperatures: ctmlPhase.TP = T, pressure yamlPhase.TP = T, pressure - cp_ctml = ctmlPhase.partial_molar_cp - cp_yaml = yamlPhase.partial_molar_cp + if check_cp: + cp_ctml = ctmlPhase.partial_molar_cp + cp_yaml = yamlPhase.partial_molar_cp h_ctml = ctmlPhase.partial_molar_enthalpies h_yaml = yamlPhase.partial_molar_enthalpies s_ctml = ctmlPhase.partial_molar_entropies @@ -902,7 +906,8 @@ def checkThermo(self, ctmlPhase, yamlPhase, temperatures, pressure=ct.one_atm, t self.assertNear(ctmlPhase.density, yamlPhase.density) for i in range(ctmlPhase.n_species): message = ' for species {0} at T = {1}'.format(ctmlPhase.species_names[i], T) - self.assertNear(cp_ctml[i], cp_yaml[i], tol, msg='cp'+message) + if check_cp: + self.assertNear(cp_ctml[i], cp_yaml[i], tol, msg='cp'+message) self.assertNear(h_ctml[i], h_yaml[i], tol, msg='h'+message) self.assertNear(s_ctml[i], s_yaml[i], tol, msg='s'+message) @@ -1002,13 +1007,13 @@ def test_Redlich_Kwong_CO2(self): ctmlGas, yamlGas = self.checkConversion('co2_RK_example') for P in [1e5, 2e6, 1.3e7]: yamlGas.TP = ctmlGas.TP = 300, P - self.checkThermo(ctmlGas, yamlGas, [300, 400, 500]) + self.checkThermo(ctmlGas, yamlGas, [300, 400, 500], check_cp=False) @utilities.slow_test def test_Redlich_Kwong_ndodecane(self): self.convert("nDodecane_Reitz", self.cantera_data_path) ctmlGas, yamlGas = self.checkConversion('nDodecane_Reitz') - self.checkThermo(ctmlGas, yamlGas, [300, 400, 500]) + self.checkThermo(ctmlGas, yamlGas, [300, 400, 500], check_cp=False) self.checkKinetics(ctmlGas, yamlGas, [300, 500, 1300], [1e5, 2e6, 1.4e7], 1e-6) diff --git a/src/thermo/RedlichKwongMFTP.cpp b/src/thermo/RedlichKwongMFTP.cpp index bd88331ccbc..011a2f1dab5 100644 --- a/src/thermo/RedlichKwongMFTP.cpp +++ b/src/thermo/RedlichKwongMFTP.cpp @@ -341,12 +341,6 @@ void RedlichKwongMFTP::getPartialMolarIntEnergies(doublereal* ubar) const scale(ubar, ubar+m_kk, ubar, RT()); } -void RedlichKwongMFTP::getPartialMolarCp(doublereal* cpbar) const -{ - getCp_R(cpbar); - scale(cpbar, cpbar+m_kk, cpbar, GasConstant); -} - void RedlichKwongMFTP::getPartialMolarVolumes(doublereal* vbar) const { for (size_t k = 0; k < m_kk; k++) {