/*------------------------------------------------------------------------- | The software accompanies the paper | | | | Classes and Objects of Chemical Thermodynamics in Object-Oriented | | Programming. 2. A Class of Chemical Species | | | | E.B. Rudnyi | | E-mail: rudnyi@comp.chem.msu.su | | Homepages: http://www.chem.msu.su/~rudnyi/welcome.html | | | | presented at Second Electronic Computational Chemistry Conference, | | November 1995, http://hackberry.chem.niu.edu/ECCC2/ | --------------------------------------------------------------------------*/ #include #include #include #include "species.h" #include "memtst.h" int main() { memory test; ifstream in("species.dat"); species a, b, c; int nua = 1; int nub = 2; int nuc = 2; in >> a >> b >> c; cout << a << endl; cout << "press RETURN to continue" << endl; cin.get(); cout << b << endl; cout << "press RETURN to continue" << endl; cin.get(); cout << c << endl; cout << "press RETURN to continue" << endl; cin.get(); cout.precision(3); cout.setf(ios::fixed | ios::showpoint); cout << nuc << formula(c) << " = " << nub << formula(b) << " + " << formula(a) << ", first way" << endl; cout << " T DelCp DelS DelH DelG log10(K)" << endl; for (global::T = 500.; global::T < 10001.; global::T += 1000.) { cout << setw(10) << global::T << setw(10) << nub*b.Cp() + nua*a.Cp() - nuc*c.Cp() << setw(10) << nub*b.S() + nua*a.S() - nuc*c.S() << setw(10) << (nub*b.H() + nua*a.H() - nuc*c.H())/1000. << setw(10) << (nub*b.mu() + nua*a.mu() - nuc*c.mu())/1000. << setw(10) << -(nub*b.mu() + nua*a.mu() - nuc*c.mu())/global::T/8.31441/log(10.) << endl; } cout << endl; cout << "press RETURN to continue" << endl; cin.get(); char buf[30]; species Del = function(itoa(nub, buf, 10))*b + a - function(itoa(nuc, buf, 10))*c; cout << Del << endl; cout << "press RETURN to continue" << endl; cin.get(); cout << nuc << formula(c) << " = " << nub << formula(b) << " + " << formula(a) << ", second way" << endl; cout << " T DelCp DelS DelH DelG log10(K)" << endl; for (global::T = 500.; global::T < 10001.; global::T += 1000.) { cout << setw(10) << global::T << setw(10) << Del.Cp() << setw(10) << Del.S() << setw(10) << Del.H()/1000. << setw(10) << Del.mu()/1000. << setw(10) << -Del.mu()/global::T/8.31441/log(10.) << endl; } return 0; }