void MineralEQ3::convertDGFormation() { // Ok let's get the element compositions and conversion factors. doublereal totalSum = 0.0; for (size_t m = 0; m < nElements(); m++) { double na = nAtoms(0, m); if (na > 0.0) { totalSum += na * LookupGe(elementName(m)); } } // Ok, now do the calculation. Convert to joules kmol-1 doublereal dg = m_deltaG_formation_pr_tr * toSI("cal/gmol"); //! Store the result into an internal variable. m_Mu0_pr_tr = dg + totalSum; double Hcalc = m_Mu0_pr_tr + 298.15 * m_Entrop_pr_tr * toSI("cal/gmol"); double DHjmol = m_deltaH_formation_pr_tr * toSI("kal/gmol"); // If the discrepancy is greater than 100 cal gmol-1, print an error if (fabs(Hcalc -DHjmol) > 100 * toSI("cal/gmol")) { throw CanteraError("installMinEQ3asShomateThermoFromXML()", "DHjmol is not consistent with G and S: {} vs {}", Hcalc, DHjmol); } }
void MineralEQ3::convertDGFormation() { /* * Ok let's get the element compositions and conversion factors. */ int ne = nElements(); doublereal na; doublereal ge; string ename; doublereal totalSum = 0.0; for (int m = 0; m < ne; m++) { na = nAtoms(0, m); if (na > 0.0) { ename = elementName(m); ge = LookupGe(ename); totalSum += na * ge; } } // Add in the charge // if (m_charge_j != 0.0) { // ename = "H"; // ge = LookupGe(ename); // totalSum -= m_charge_j * ge; //} // Ok, now do the calculation. Convert to joules kmol-1 doublereal dg = m_deltaG_formation_pr_tr * 4.184 * 1.0E3; //! Store the result into an internal variable. m_Mu0_pr_tr = dg + totalSum; }
static doublereal convertDGFormation(int k, ThermoPhase *th_ptr) { /* * Ok let's get the element compositions and conversion factors. */ int ne = th_ptr->nElements(); doublereal na; doublereal ge; string ename; doublereal totalSum = 0.0; for (int m = 0; m < ne; m++) { na = th_ptr->nAtoms(k, m); if (na > 0.0) { ename = th_ptr->elementName(m); ge = LookupGe(ename, th_ptr); totalSum += na * ge; } } return totalSum; }