Skip to content

Commit

Permalink
[Thermo] Remove incorrect partialMolarCp from RedlichKwong
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Mar 14, 2022
1 parent 719275e commit 83b65c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
4 changes: 3 additions & 1 deletion include/cantera/thermo/RedlichKwongMFTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
//! @}

Expand Down
29 changes: 17 additions & 12 deletions interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,20 +663,22 @@ 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
s_yaml = yamlPhase.partial_molar_entropies
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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -889,20 +891,23 @@ 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
s_yaml = yamlPhase.partial_molar_entropies
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)

Expand Down Expand Up @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions src/thermo/RedlichKwongMFTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 83b65c4

Please sign in to comment.