All Debye-Huckel tests use a shared copy of the test executable
This commit is contained in:
parent
ce5abaca0e
commit
de32aba15d
22 changed files with 31 additions and 751 deletions
|
|
@ -107,31 +107,37 @@ class CompileAndTest(Test):
|
||||||
return Test.clean(self, env, files=files)
|
return Test.clean(self, env, files=files)
|
||||||
|
|
||||||
|
|
||||||
CompileAndTest('DH_graph_1',
|
dhGraph = localenv.Program('cathermo/DH_graph_1/DH_graph_1',
|
||||||
pjoin('cathermo', 'DH_graph_1'),
|
mglob(env, 'cathermo/DH_graph_1', 'cpp'),
|
||||||
'DH_graph_1', 'DH_NaCl_dilute_blessed.csv',
|
LIBS=env['cantera_libs'])
|
||||||
artifacts=['DH_graph_1.log'],
|
dhGraph_name = dhGraph[0].name
|
||||||
arguments='DH_NaCl_dilute.xml')
|
|
||||||
CompileAndTest('DH_graph_acommon',
|
Test('DH_graph_dilute',
|
||||||
pjoin('cathermo', 'DH_graph_acommon'),
|
pjoin('cathermo', 'DH_graph_1'),
|
||||||
'DH_graph_acommon', 'DH_NaCl_acommon_blessed.csv',
|
dhGraph, 'DH_NaCl_dilute_blessed.csv',
|
||||||
artifacts=['DH_graph_1.log'],
|
artifacts=['DH_graph_1.log', dhGraph_name],
|
||||||
arguments='DH_NaCl_acommon.xml')
|
arguments='DH_NaCl_dilute.xml')
|
||||||
CompileAndTest('DH_graph_bdotak',
|
Test('DH_graph_acommon',
|
||||||
pjoin('cathermo', 'DH_graph_bdotak'),
|
pjoin('cathermo', 'DH_graph_1'),
|
||||||
'DH_graph_bdotak', 'DH_NaCl_bdotak_blessed.csv',
|
dhGraph, 'DH_NaCl_acommon_blessed.csv',
|
||||||
artifacts=['DH_graph_1.log'],
|
artifacts=['DH_graph_1.log', dhGraph_name],
|
||||||
arguments='DH_NaCl_bdotak.xml')
|
arguments='DH_NaCl_acommon.xml')
|
||||||
CompileAndTest('DH_graph_NM',
|
Test('DH_graph_bdotak',
|
||||||
pjoin('cathermo', 'DH_graph_NM'),
|
pjoin('cathermo', 'DH_graph_1'),
|
||||||
'DH_graph_NM', 'DH_NaCl_NM_blessed.csv',
|
dhGraph, 'DH_NaCl_bdotak_blessed.csv',
|
||||||
artifacts=['DH_graph_1.log'],
|
artifacts=['DH_graph_1.log', dhGraph_name],
|
||||||
arguments='DH_NaCl_NM.xml')
|
arguments='DH_NaCl_bdotak.xml')
|
||||||
CompileAndTest('DH_graph_Pitzer',
|
Test('DH_graph_NM',
|
||||||
pjoin('cathermo', 'DH_graph_Pitzer'),
|
pjoin('cathermo', 'DH_graph_1'),
|
||||||
'DH_graph_Pitzer', 'DH_NaCl_Pitzer_blessed.csv',
|
dhGraph, 'DH_NaCl_NM_blessed.csv',
|
||||||
artifacts=['DH_graph_1.log'],
|
artifacts=['DH_graph_1.log', dhGraph_name],
|
||||||
arguments='DH_NaCl_Pitzer.xml')
|
arguments='DH_NaCl_NM.xml')
|
||||||
|
Test('DH_graph_Pitzer',
|
||||||
|
pjoin('cathermo', 'DH_graph_1'),
|
||||||
|
dhGraph, 'DH_NaCl_Pitzer_blessed.csv',
|
||||||
|
artifacts=['DH_graph_1.log', dhGraph_name],
|
||||||
|
arguments='DH_NaCl_Pitzer.xml')
|
||||||
|
|
||||||
CompileAndTest('HMW_dupl_test',
|
CompileAndTest('HMW_dupl_test',
|
||||||
pjoin('cathermo', 'HMW_dupl_test'),
|
pjoin('cathermo', 'HMW_dupl_test'),
|
||||||
'HMW_dupl_test', 'output_blessed.txt',
|
'HMW_dupl_test', 'output_blessed.txt',
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Cantera;
|
using namespace Cantera;
|
||||||
|
|
||||||
typedef double doublereal;
|
|
||||||
|
|
||||||
void printUsage()
|
void printUsage()
|
||||||
{
|
{
|
||||||
cout << "usage: DH_test " << endl;
|
cout << "usage: DH_test " << endl;
|
||||||
|
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
/**
|
|
||||||
* @file DH_graph_1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "fileLog.h"
|
|
||||||
#include "cantera/thermo/DebyeHuckel.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace Cantera;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
cc_sources = DH_graph_1.cpp
|
|
||||||
|
|
||||||
INC = -I. -I$(top_builddir)/build/include/
|
|
||||||
AM_CPPFLAGS = $(INC)
|
|
||||||
AM_CXXFLAGS = $(AM_CPPFLAGS)
|
|
||||||
|
|
||||||
LINK = -lctcxx -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo
|
|
||||||
LINK += -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lcvode
|
|
||||||
LINK += -lctlapack -lctblas -lctf2c -lm -lstdc++
|
|
||||||
AM_LDFLAGS = -L$(top_builddir)/build/lib/
|
|
||||||
LIBS = $(LINK)
|
|
||||||
|
|
||||||
bin_PROGRAMS = DH_graph_1
|
|
||||||
library_includedir = $(INC)
|
|
||||||
|
|
||||||
#-----------------------
|
|
||||||
# Cantera DH graph test
|
|
||||||
#-----------------------
|
|
||||||
|
|
||||||
DH_graph_1_SOURCES = $(cc_sources)
|
|
||||||
|
|
||||||
TESTS_ENVIRONMENT =
|
|
||||||
TESTS = runtest
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# run_test
|
|
||||||
#
|
|
||||||
##########################################################################
|
|
||||||
# A couple of validity checks
|
|
||||||
if test ! $# -eq 0 ; then
|
|
||||||
echo 'usage: runtest'
|
|
||||||
echo ' '
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
temp_success="0"
|
|
||||||
/bin/rm -f output.txt outputa.txt
|
|
||||||
##########################################################################
|
|
||||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
|
||||||
|
|
||||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
|
||||||
|
|
||||||
prog=DH_graph_1
|
|
||||||
if test ! -x $prog ; then
|
|
||||||
echo $prog ' does not exist'
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
/bin/rm -f test.out test.diff DH_NaCl_NM.csv
|
|
||||||
|
|
||||||
./$prog DH_NaCl_NM.xml > DH_NaCl_NM.csv
|
|
||||||
retnStat=$?
|
|
||||||
diff DH_NaCl_NM.csv DH_NaCl_NM_blessed.csv > output.txt
|
|
||||||
zres=$?
|
|
||||||
if test "$zres" = "0" -a "$retnStat" = "0"; then
|
|
||||||
echo "successful diff comparison on $prog NM test"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "unsuccessful diff comparison on $prog NM test"
|
|
||||||
echo "FAILED" > csvCode.txt
|
|
||||||
temp_success="0"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
/**
|
|
||||||
* @file DH_graph_1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "fileLog.h"
|
|
||||||
#include "cantera/thermo/DebyeHuckel.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace Cantera;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
cc_sources = DH_graph_1.cpp
|
|
||||||
|
|
||||||
INC = -I. -I$(top_builddir)/build/include/
|
|
||||||
AM_CPPFLAGS = $(INC)
|
|
||||||
AM_CXXFLAGS = $(AM_CPPFLAGS)
|
|
||||||
|
|
||||||
LINK = -lctcxx -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo
|
|
||||||
LINK += -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lcvode
|
|
||||||
LINK += -lctlapack -lctblas -lctf2c -lm -lstdc++
|
|
||||||
AM_LDFLAGS = -L$(top_builddir)/build/lib/
|
|
||||||
LIBS = $(LINK)
|
|
||||||
|
|
||||||
bin_PROGRAMS = DH_graph_1
|
|
||||||
library_includedir = $(INC)
|
|
||||||
|
|
||||||
#-----------------------
|
|
||||||
# Cantera DH graph test
|
|
||||||
#-----------------------
|
|
||||||
|
|
||||||
DH_graph_1_SOURCES = $(cc_sources)
|
|
||||||
|
|
||||||
TESTS_ENVIRONMENT =
|
|
||||||
TESTS = runtest
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# run_test
|
|
||||||
#
|
|
||||||
##########################################################################
|
|
||||||
# A couple of validity checks
|
|
||||||
if test ! $# -eq 0 ; then
|
|
||||||
echo 'usage: runtest'
|
|
||||||
echo ' '
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
temp_success="0"
|
|
||||||
/bin/rm -f output.txt outputa.txt
|
|
||||||
##########################################################################
|
|
||||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
|
||||||
|
|
||||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
|
||||||
|
|
||||||
prog=DH_graph_1
|
|
||||||
if test ! -x $prog ; then
|
|
||||||
echo $prog ' does not exist'
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
/bin/rm -f test.out test.diff DH_NaCl_Pitzer.csv
|
|
||||||
|
|
||||||
./$prog DH_NaCl_Pitzer.xml > DH_NaCl_Pitzer.csv
|
|
||||||
retnStat=$?
|
|
||||||
diff DH_NaCl_Pitzer.csv DH_NaCl_Pitzer_blessed.csv > output.txt
|
|
||||||
zres=$?
|
|
||||||
if test "$zres" = "0" -a "$retnStat" = "0"; then
|
|
||||||
echo "successful diff comparison on $prog Pitzer test"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "unsuccessful diff comparison on $prog Pitzer test"
|
|
||||||
echo "FAILED" > csvCode.txt
|
|
||||||
temp_success="0"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
/**
|
|
||||||
* @file DH_graph_1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "fileLog.h"
|
|
||||||
#include "cantera/thermo/DebyeHuckel.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace Cantera;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
cc_sources = DH_graph_1.cpp
|
|
||||||
|
|
||||||
INC = -I. -I$(top_builddir)/build/include/
|
|
||||||
AM_CPPFLAGS = $(INC)
|
|
||||||
AM_CXXFLAGS = $(AM_CPPFLAGS)
|
|
||||||
|
|
||||||
LINK = -lctcxx -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo
|
|
||||||
LINK += -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lcvode
|
|
||||||
LINK += -lctlapack -lctblas -lctf2c -lm -lstdc++
|
|
||||||
AM_LDFLAGS = -L$(top_builddir)/build/lib/
|
|
||||||
LIBS = $(LINK)
|
|
||||||
|
|
||||||
bin_PROGRAMS = DH_graph_1
|
|
||||||
library_includedir = $(INC)
|
|
||||||
|
|
||||||
#-----------------------
|
|
||||||
# Cantera DH graph test
|
|
||||||
#-----------------------
|
|
||||||
|
|
||||||
DH_graph_1_SOURCES = $(cc_sources)
|
|
||||||
|
|
||||||
TESTS_ENVIRONMENT =
|
|
||||||
TESTS = runtest
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# run_test
|
|
||||||
#
|
|
||||||
##########################################################################
|
|
||||||
# A couple of validity checks
|
|
||||||
if test ! $# -eq 0 ; then
|
|
||||||
echo 'usage: runtest'
|
|
||||||
echo ' '
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
temp_success="0"
|
|
||||||
/bin/rm -f output.txt outputa.txt
|
|
||||||
##########################################################################
|
|
||||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
|
||||||
|
|
||||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
|
||||||
|
|
||||||
prog=DH_graph_1
|
|
||||||
if test ! -x $prog ; then
|
|
||||||
echo $prog ' does not exist'
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
/bin/rm -f test.out test.diff DH_NaCl_acommon.csv
|
|
||||||
|
|
||||||
./$prog DH_NaCl_acommon.xml > DH_NaCl_acommon.csv
|
|
||||||
retnStat=$?
|
|
||||||
diff DH_NaCl_acommon.csv DH_NaCl_acommon_blessed.csv > output.txt
|
|
||||||
zres=$?
|
|
||||||
if test "$zres" = "0" -a "$retnStat" = "0"; then
|
|
||||||
echo "successful diff comparison on $prog _acommon test"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "unsuccessful diff comparison on $prog _acommon test"
|
|
||||||
echo "FAILED" > csvCode.txt
|
|
||||||
temp_success="0"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
/**
|
|
||||||
* @file DH_graph_1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "fileLog.h"
|
|
||||||
#include "cantera/thermo/DebyeHuckel.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace Cantera;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
cc_sources = DH_graph_1.cpp
|
|
||||||
|
|
||||||
INC = -I. -I$(top_builddir)/build/include/
|
|
||||||
AM_CPPFLAGS = $(INC)
|
|
||||||
AM_CXXFLAGS = $(AM_CPPFLAGS)
|
|
||||||
|
|
||||||
LINK = -lctcxx -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo
|
|
||||||
LINK += -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lcvode
|
|
||||||
LINK += -lctlapack -lctblas -lctf2c -lm -lstdc++
|
|
||||||
AM_LDFLAGS = -L$(top_builddir)/build/lib/
|
|
||||||
LIBS = $(LINK)
|
|
||||||
|
|
||||||
bin_PROGRAMS = DH_graph_1
|
|
||||||
library_includedir = $(INC)
|
|
||||||
|
|
||||||
#-----------------------
|
|
||||||
# Cantera DH graph test
|
|
||||||
#-----------------------
|
|
||||||
|
|
||||||
DH_graph_1_SOURCES = $(cc_sources)
|
|
||||||
|
|
||||||
TESTS_ENVIRONMENT =
|
|
||||||
TESTS = runtest
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# run_test
|
|
||||||
#
|
|
||||||
##########################################################################
|
|
||||||
# A couple of validity checks
|
|
||||||
if test ! $# -eq 0 ; then
|
|
||||||
echo 'usage: runtest'
|
|
||||||
echo ' '
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
temp_success="0"
|
|
||||||
/bin/rm -f output.txt outputa.txt
|
|
||||||
##########################################################################
|
|
||||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
|
||||||
|
|
||||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
|
||||||
|
|
||||||
prog=DH_graph_1
|
|
||||||
if test ! -x $prog ; then
|
|
||||||
echo $prog ' does not exist'
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
/bin/rm -f test.out test.diff DH_NaCl_bdotak.csv
|
|
||||||
|
|
||||||
./$prog DH_NaCl_bdotak.xml > DH_NaCl_bdotak.csv
|
|
||||||
retnStat=$?
|
|
||||||
diff DH_NaCl_bdotak.csv DH_NaCl_bdotak_blessed.csv > output.txt
|
|
||||||
zres=$?
|
|
||||||
if test "$zres" = "0" -a "$retnStat" = "0"; then
|
|
||||||
echo "successful diff comparison on $prog bdotak test"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "unsuccessful diff comparison on $prog bdotak test"
|
|
||||||
echo "FAILED" > csvCode.txt
|
|
||||||
temp_success="0"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue