This merge skips some of the source tree rearrangement from the autotools branch, so the autotools build system is not presently working. Conflicts: Cantera/cxx/include/kinetics.h Cantera/cxx/include/zerodim.h Cantera/cxx/src/Cantera.h Cantera/cxx/src/importPhase.cpp Cantera/cxx/src/importPhase.h Cantera/cxx/src/thermo.h Cantera/cxx/src/transport.h Cantera/ext/f2c_libs/arith.hwin32 Cantera/ext/f2c_libs/arithchk.c Cantera/ext/f2c_libs/ftell64_.c Cantera/ext/f2c_libs/pow_qq.c Cantera/ext/f2c_libs/qbitbits.c Cantera/ext/f2c_libs/qbitshft.c Cantera/ext/f2c_math/mkl_cblas.h Cantera/ext/f2c_recipes/Makefile.in Cantera/ext/f2c_recipes/simp1.c Cantera/ext/f2c_recipes/simp2.c Cantera/ext/f2c_recipes/simp3.c Cantera/ext/f2c_recipes/simplx.c Cantera/ext/f2c_recipes/splie2.c Cantera/ext/f2c_recipes/splin2.c Cantera/ext/f2c_recipes/spline.c Cantera/ext/f2c_recipes/splint.c Cantera/ext/recipes/Makefile.in Cantera/ext/recipes/simp1.f Cantera/ext/recipes/simp2.f Cantera/ext/recipes/simp3.f Cantera/ext/recipes/simplx.f Cantera/ext/recipes/splie2.f Cantera/ext/recipes/splin2.f Cantera/ext/recipes/spline.f Cantera/ext/recipes/splint.f Cantera/ext/tpx/CMakeLists.txt Cantera/ext/tpx/ideal.cpp Cantera/ext/tpx/lkw.cpp Cantera/ext/tpx/lkw.h Cantera/src/base/config.h.in Cantera/src/converters/ck2ctml.cpp Cantera/src/converters/ck2ctml.h Cantera/src/numerics/NonlinearSolver.cpp Cantera/src/numerics/ctlapack.h Cantera/src/numerics/sort.cpp ChangeLog License.rtf docs/install_examples/cygwin_gcc344_f2c_numeric.sh docs/install_examples/linux.64_sierra_gcc444_python264_numpy docs/install_examples/linux_rhel5_64_gcc424_dbg_python264_numpy docs/install_examples/sol10_64bit_CC57_py24_numarray examples/cxx/flame1.cpp ext/f2c_libs/arithchk.c ext/f2c_libs/arithchk/arithchk.c ext/math/gmres.h test_problems/ChemEquil_gri_pairs/runtest test_problems/ChemEquil_ionizedGas/runtest test_problems/ChemEquil_red1/basopt_red1.cpp test_problems/VCSnonideal/NaCl_equil/Makefile.in test_problems/VPsilane_test/runtest test_problems/cathermo/DH_graph_1/runtest test_problems/cathermo/DH_graph_NM/runtest test_problems/cathermo/DH_graph_Pitzer/runtest test_problems/cathermo/DH_graph_acommon/runtest test_problems/cathermo/DH_graph_bdotak/runtest test_problems/cathermo/HMW_dupl_test/runtest test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp test_problems/cathermo/VPissp/runtest test_problems/cathermo/ims/runtest test_problems/cathermo/issp/runtest test_problems/cathermo/stoichSubSSTP/runtest test_problems/cathermo/testIAPWS/runtest test_problems/cathermo/testIAPWSPres/runtest test_problems/cathermo/testIAPWSTripP/runtest test_problems/cathermo/testWaterPDSS/runtest test_problems/cathermo/testWaterTP/runtest test_problems/cathermo/wtWater/runtest test_problems/cxx_ex/equil_example1.cpp test_problems/cxx_ex/examples.cpp test_problems/cxx_ex/kinetics_example1.cpp test_problems/cxx_ex/kinetics_example2.cpp test_problems/cxx_ex/kinetics_example3.cpp test_problems/cxx_ex/rxnpath_example1.cpp test_problems/cxx_ex/transport_example1.cpp test_problems/cxx_ex/transport_example2.cpp test_problems/mixGasTransport/runtest test_problems/nasa9_reader/runtest test_problems/negATest/runtest test_problems/printUtilUnitTest/runtest test_problems/pureFluidTest/runtest test_problems/rankine_democxx/runtest test_problems/silane_equil/runtest test_problems/surfSolverTest/runtest test_problems/surfSolverTest/runtest2 test_problems/surfkin/runtest tools/testtools/Makefile.in
143 lines
3.1 KiB
C++
143 lines
3.1 KiB
C++
/**
|
|
*
|
|
* @file DH_graph_1
|
|
*/
|
|
#ifdef SRCDIRTREE
|
|
#include "ct_defs.h"
|
|
#include "logger.h"
|
|
#include "DebyeHuckel.h"
|
|
#else
|
|
#include "Cantera.h"
|
|
#include "kernel/logger.h"
|
|
#include "kernel/DebyeHuckel.h"
|
|
#endif
|
|
#include <cstdio>
|
|
|
|
using namespace std;
|
|
using namespace Cantera;
|
|
|
|
typedef double doublereal;
|
|
|
|
class fileLog: public Logger {
|
|
public:
|
|
fileLog(string fName) {
|
|
m_fName = fName;
|
|
m_fs.open(fName.c_str());
|
|
}
|
|
|
|
virtual void write(const string& msg) {
|
|
m_fs << msg;
|
|
m_fs << endl;
|
|
}
|
|
|
|
virtual ~fileLog() {
|
|
m_fs.close();
|
|
}
|
|
|
|
string m_fName;
|
|
ofstream m_fs;
|
|
|
|
};
|
|
|
|
void printUsage() {
|
|
cout << "usage: DH_test " << endl;
|
|
cout <<" -> Everything is hardwired" << endl;
|
|
}
|
|
|
|
void pAtable(DebyeHuckel *DH) {
|
|
int nsp = DH->nSpecies();
|
|
double acMol[100];
|
|
double mf[100];
|
|
double activities[100];
|
|
double moll[100];
|
|
|
|
DH->getMolalityActivityCoefficients(acMol);
|
|
DH->getMoleFractions(mf);
|
|
DH->getActivities(activities);
|
|
DH->getMolalities(moll);
|
|
string sName;
|
|
printf(" Name Activity ActCoeffMolal "
|
|
" MoleFract Molality\n");
|
|
for (int k = 0; k < nsp; k++) {
|
|
sName = DH->speciesName(k);
|
|
printf("%16s %13g %13g %13g %13g\n",
|
|
sName.c_str(), activities[k], acMol[k], mf[k], moll[k]);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
|
|
int retn = 0;
|
|
int i;
|
|
string fName = "DH_graph_1.log";
|
|
fileLog *fl = new fileLog(fName);
|
|
try {
|
|
|
|
char iFile[80];
|
|
strcpy(iFile, "DH_NaCl.xml");
|
|
if (argc > 1) {
|
|
strcpy(iFile, argv[1]);
|
|
}
|
|
setLogger(fl);
|
|
|
|
DebyeHuckel *DH = new DebyeHuckel(iFile, "NaCl_electrolyte");
|
|
|
|
int nsp = DH->nSpecies();
|
|
double acMol[100];
|
|
double mf[100];
|
|
double moll[100];
|
|
DH->getMoleFractions(mf);
|
|
string sName;
|
|
|
|
DH->setState_TP(298.15, 1.01325E5);
|
|
|
|
int i1 = DH->speciesIndex("Na+");
|
|
int i2 = DH->speciesIndex("Cl-");
|
|
int i3 = DH->speciesIndex("H2O(L)");
|
|
for (i = 1; i < nsp; i++) {
|
|
moll[i] = 0.0;
|
|
}
|
|
DH->setMolalities(moll);
|
|
double Itop = 10.;
|
|
double Ibot = 0.0;
|
|
double ISQRTtop = sqrt(Itop);
|
|
double ISQRTbot = sqrt(Ibot);
|
|
double ISQRT;
|
|
double Is = 0.0;
|
|
int its = 100;
|
|
printf(" Is, sqrtIs, meanAc,"
|
|
" log10(meanAC), acMol_Na+,"
|
|
", acMol_Cl-, ac_Water\n");
|
|
for (i = 0; i < its; i++) {
|
|
ISQRT = ISQRTtop*((double)i)/(its - 1.0)
|
|
+ ISQRTbot*(1.0 - (double)i/(its - 1.0));
|
|
Is = ISQRT * ISQRT;
|
|
moll[i1] = Is;
|
|
moll[i2] = Is;
|
|
DH->setMolalities(moll);
|
|
DH->getMolalityActivityCoefficients(acMol);
|
|
double meanAC = sqrt(acMol[i1] * acMol[i2]);
|
|
printf("%15g, %15g, %15g, %15g, %15g, %15g, %15g\n",
|
|
Is, ISQRT, meanAC, log10(meanAC),
|
|
acMol[i1], acMol[i2], acMol[i3]);
|
|
}
|
|
|
|
|
|
delete DH;
|
|
DH = 0;
|
|
/*
|
|
* This delete the file logger amongst other things.
|
|
*/
|
|
Cantera::appdelete();
|
|
|
|
return retn;
|
|
|
|
} catch (CanteraError) {
|
|
showErrors();
|
|
if (fl) {
|
|
delete fl;
|
|
}
|
|
return -1;
|
|
}
|
|
}
|