diff --git a/src/thermo/PDSS_HKFT.cpp b/src/thermo/PDSS_HKFT.cpp index 8c4d0fd74..072880649 100644 --- a/src/thermo/PDSS_HKFT.cpp +++ b/src/thermo/PDSS_HKFT.cpp @@ -27,10 +27,10 @@ PDSS_HKFT::PDSS_HKFT() , m_densWaterSS(-1.0) , m_born_coeff_j(-1.0) , m_r_e_j(-1.0) - , m_deltaG_formation_tr_pr(0.0) - , m_deltaH_formation_tr_pr(0.0) + , m_deltaG_formation_tr_pr(NAN) + , m_deltaH_formation_tr_pr(NAN) , m_Mu0_tr_pr(0.0) - , m_Entrop_tr_pr(0.0) + , m_Entrop_tr_pr(NAN) , m_a1(0.0) , m_a2(0.0) , m_a3(0.0) @@ -239,6 +239,28 @@ void PDSS_HKFT::initThermo() { PDSS::initThermo(); + // Ok, if we are missing one, then we construct its value from the other two. + // This code has been internally verified. + m_charge_j = m_tp->charge(m_spindex); + if (std::isnan(m_deltaH_formation_tr_pr)) { + convertDGFormation(); + doublereal Hcalc = m_Mu0_tr_pr + 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol")); + m_deltaH_formation_tr_pr = Hcalc / toSI("cal/gmol"); + } else if (std::isnan(m_deltaG_formation_tr_pr)) { + doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol"); + m_Mu0_tr_pr = DHjmol - 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol")); + m_deltaG_formation_tr_pr = m_Mu0_tr_pr / toSI("cal/gmol"); + double tmp = m_Mu0_tr_pr; + convertDGFormation(); + double totalSum = m_Mu0_tr_pr - tmp; + m_Mu0_tr_pr = tmp; + m_deltaG_formation_tr_pr = (m_Mu0_tr_pr - totalSum)/ toSI("cal/gmol"); + } else if (std::isnan(m_Entrop_tr_pr)) { + convertDGFormation(); + doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol"); + m_Entrop_tr_pr = (DHjmol - m_Mu0_tr_pr) / (298.15 * toSI("cal/gmol")); + } + m_waterSS = &dynamic_cast(*m_tp->providePDSS(0)); // Section to initialize m_Z_pr_tr and m_Y_pr_tr @@ -253,7 +275,6 @@ void PDSS_HKFT::initThermo() m_waterProps.reset(new WaterProps(m_waterSS)); m_presR_bar = OneAtm / 1.0E5; m_presR_bar = 1.0; - m_charge_j = m_tp->charge(m_spindex); convertDGFormation(); // Ok, we have mu. Let's check it against the input value @@ -408,31 +429,6 @@ void PDSS_HKFT::setParametersFromXML(const XML_Node& speciesNode) "Missing 2 or more of DG0_f_Pr_Tr, DH0_f_Pr_Tr, or S0_f_Pr_Tr fields. " "Need to supply at least two of these fields"); } - // Ok, if we are missing one, then we construct its value from the other two. - // This code has been internally verified. - if (hasDHO == 0) { - m_charge_j = m_tp->charge(m_spindex); - convertDGFormation(); - doublereal Hcalc = m_Mu0_tr_pr + 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol")); - m_deltaH_formation_tr_pr = Hcalc / toSI("cal/gmol"); - } - if (hasDGO == 0) { - doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol"); - m_Mu0_tr_pr = DHjmol - 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol")); - m_deltaG_formation_tr_pr = m_Mu0_tr_pr / toSI("cal/gmol"); - double tmp = m_Mu0_tr_pr; - m_charge_j = m_tp->charge(m_spindex); - convertDGFormation(); - double totalSum = m_Mu0_tr_pr - tmp; - m_Mu0_tr_pr = tmp; - m_deltaG_formation_tr_pr = (m_Mu0_tr_pr - totalSum)/ toSI("cal/gmol"); - } - if (hasSO == 0) { - m_charge_j = m_tp->charge(m_spindex); - convertDGFormation(); - doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol"); - m_Entrop_tr_pr = (DHjmol - m_Mu0_tr_pr) / (298.15 * toSI("cal/gmol")); - } } doublereal PDSS_HKFT::deltaH() const diff --git a/test_problems/simpleTransport/HMW_NaCl_pdss.xml b/test_problems/simpleTransport/HMW_NaCl_pdss.xml index bc77ac981..3f08a1ff3 100644 --- a/test_problems/simpleTransport/HMW_NaCl_pdss.xml +++ b/test_problems/simpleTransport/HMW_NaCl_pdss.xml @@ -133,7 +133,7 @@ +1 - -62591. + -57433. 13.96 @@ -161,7 +161,7 @@ -31379. - -39933. + 13.56 @@ -189,7 +189,7 @@ 0.0 0.0 - 0.0 +