commited a test problem.

This commit is contained in:
Harry Moffat 2007-12-20 23:46:27 +00:00
parent c97246f0af
commit 151bdcaa22
12 changed files with 4107 additions and 0 deletions

View file

@ -0,0 +1,13 @@
.d0.txt.swp
.depends
Makefile
diff_csv.txt
diff_dout.txt
diff_out.txt
dout.txt
err_dout.txt
err_out.txt
nacl_equil
nacl_equil.d
out.txt
vcs_equilibrate_res.csv

View file

@ -0,0 +1,243 @@
<?xml version="1.0"?>
<!--
$Id$
$Source$
$Name$
NaCl modeling Based on the Silvester&Pitzer 1977 treatment:
(L. F. Silvester, K. S. Pitzer, "Thermodynamics of Electrolytes:
8. High-Temperature Properties, including Enthalpy and Heat
Capacity, with application to sodium chloride",
J. Phys. Chem., 81, 19 1822 - 1828 (1977)
-->
<ctml>
<phase id="NaCl_electrolyte" dim="3">
<speciesArray datasrc="#species_waterSolution">
H2O(L) Cl- H+ Na+ OH-
</speciesArray>
<state>
<temperature units="K"> 298.15 </temperature>
<pressure units="Pa"> 101325.0 </pressure>
<soluteMolalities>
Na+:6.0954
Cl-:6.0954
H+:2.1628E-9
OH-:1.3977E-6
</soluteMolalities>
</state>
<thermo model="HMW">
<standardConc model="solvent_volume" />
<activityCoefficients model="Pitzer" TempModel="complex1">
<!-- Pitzer Coefficients
These coefficients are from Pitzer's main
paper, in his book.
-->
<A_Debye model="water" />
<ionicRadius default="3.042843" units="Angstroms">
</ionicRadius>
<binarySaltParameters cation="Na+" anion="Cl-">
<beta0> 0.0765, 0.008946, -3.3158E-6,
-777.03, -4.4706
</beta0>
<beta1> 0.2664, 6.1608E-5, 1.0715E-6, 0.0, 0.0 </beta1>
<beta2> 0.0, 0.0, 0.0, 0.0, 0.0 </beta2>
<Cphi> 0.00127, -4.655E-5, 0.0,
33.317, 0.09421
</Cphi>
<Alpha1> 2.0 </Alpha1>
</binarySaltParameters>
<binarySaltParameters cation="H+" anion="Cl-">
<beta0> 0.1775, 0.0, 0.0, 0.0, 0.0 </beta0>
<beta1> 0.2945, 0.0, 0.0, 0.0, 0.0 </beta1>
<beta2> 0.0, 0.0, 0.0, 0.0, 0.0 </beta2>
<Cphi> 0.0008, 0.0, 0.0, 0.0, 0.0 </Cphi>
<Alpha1> 2.0 </Alpha1>
</binarySaltParameters>
<binarySaltParameters cation="Na+" anion="OH-">
<beta0> 0.0864, 0.0, 0.0, 0.0, 0.0 </beta0>
<beta1> 0.253, 0.0, 0.0, 0.0, 0.0 </beta1>
<beta2> 0.0, 0.0, 0.0, 0.0, 0.0 </beta2>
<Cphi> 0.0044, 0.0, 0.0, 0.0, 0.0 </Cphi>
<Alpha1> 2.0 </Alpha1>
</binarySaltParameters>
<thetaAnion anion1="Cl-" anion2="OH-">
<Theta> -0.05 </Theta>
</thetaAnion>
<psiCommonCation cation="Na+" anion1="Cl-" anion2="OH-">
<Theta> -0.05 </Theta>
<Psi> -0.006 </Psi>
</psiCommonCation>
<thetaCation cation1="Na+" cation2="H+">
<Theta> 0.036 </Theta>
</thetaCation>
<psiCommonAnion anion="Cl-" cation1="Na+" cation2="H+">
<Theta> 0.036 </Theta>
<Psi> -0.004 </Psi>
</psiCommonAnion>
</activityCoefficients>
<solvent> H2O(L) </solvent>
</thermo>
<elementArray datasrc="elements.xml"> O H C Fe Si N Na Cl E </elementArray>
<kinetics model="none" >
</kinetics>
</phase>
<speciesData id="species_waterSolution">
<species name="H2O(L)">
<!-- H2O(L) liquid standard state -> pure H2O
The origin of the NASA polynomial is a bit murky. It does
fit the vapor pressure curve at 298K adequately.
-->
<atomArray>H:2 O:1 </atomArray>
<thermo>
<NASA Tmax="600.0" Tmin="273.14999999999998" P0="100000.0">
<floatArray name="coeffs" size="7">
7.255750050E+01, -6.624454020E-01, 2.561987460E-03, -4.365919230E-06,
2.781789810E-09, -4.188654990E+04, -2.882801370E+02
</floatArray>
</NASA>
</thermo>
<standardState model="waterPDSS">
<!--
Molar volume in m3 kmol-1.
(this is from Pitzer, Peiper, and Busey. However,
the result can be easily derived from ~ 1gm/cm**3)
-->
<molarVolume> 0.018068 </molarVolume>
</standardState>
</species>
<species name="Na+">
<!-- Na+ (aq) standard state based on the unity molality convention
The shomate polynomial was created from the SUPCRT92
J. Phys Chem Ref article, and the codata recommended
values. DelHf(298.15) = -240.34 kJ/gmol
S(298.15) = 58.45 J/gmolK
There was a slight discrepency between those two, which was
resolved in favor of codata.
Notes: the order of the polynomials can be decreased by
dropping terms from the complete Shomate poly.
-->
<atomArray> Na:1 E:-1 </atomArray>
<charge> +1 </charge>
<thermo>
<Shomate Pref="1 atm" Tmax=" 623.15" Tmin=" 298.00">
<floatArray size="7">
12321.25829 , -54984.45383 , 91695.71717 ,
-54412.15442 , -234.4221295 , -2958.883542 ,
26449.31197
</floatArray>
</Shomate>
</thermo>
<standardState model="constant_incompressible">
<!-- Na+ (aq) molar volume
Molar volume in m3 kmol-1.
(this is from Pitzer, Peiper, and Busey. We divide
NaCl (aq) value by 2 to get this)
-->
<molarVolume> 0.00834 </molarVolume>
</standardState>
</species>
<species name="Cl-">
<!-- Cl- (aq) standard state based on the unity molality convention
The shomate polynomial was created from the SUPCRT92
J. Phys Chem Ref article, and the codata recommended
values. DelHf(298.15) = -167.08 kJ/gmol
S(298.15) = 56.60 J/gmolK
There was a slight discrepency between those two, which was
resolved in favor of codata.
Notes: the order of the polynomials can be decreased by
dropping terms from the complete Shomate poly.
-->
<atomArray> Cl:1 E:1 </atomArray>
<charge> -1 </charge>
<standardState model="constant_incompressible">
<!-- Cl- (aq) molar volume
Molar volume in m3 kmol-1.
(this is from Pitzer, Peiper, and Busey. We divide
NaCl (aq) value by 2 to get this)
-->
<molarVolume> 0.00834 </molarVolume>
</standardState>
<thermo>
<Shomate Pref="1 atm" Tmax=" 623.15" Tmin=" 298.00">
<floatArray size="7">
56696.2042 , -297835.978 , 581426.549 ,
-401759.991 , -804.301136 , -10873.8257 ,
130650.697
</floatArray>
</Shomate>
</thermo>
</species>
<species name="H+">
<!-- H+ (aq) standard state based on the unity molality convention
The H+ standard state is set to zeroes by convention. This
includes it's contribution to the molar volume of solution.
-->
<atomArray> H:1 E:-1 </atomArray>
<charge> +1 </charge>
<standardState model="constant_incompressible">
<molarVolume> 0.0 </molarVolume>
</standardState>
<thermo>
<Mu0 Pref="100000.0" Tmax="625.15." Tmin="273.15">
<H298 units="cal/mol"> 0.0 </H298>
<numPoints> 3 </numPoints>
<floatArray size="3" title="Mu0Values" units="Dimensionless">
0.0 , 0.0, 0.0
</floatArray>
<floatArray size="3" title="Mu0Temperatures">
273.15, 298.15 , 623.15
</floatArray>
</Mu0>
</thermo>
</species>
<species name="OH-">
<!-- OH- (aq) standard state based on the unity molality convention
The shomate polynomial was created with data from the SUPCRT92
J. Phys Chem Ref article, and from the codata recommended
values. DelHf(298.15) = -230.015 kJ/gmol
S(298.15) = -10.90 J/gmolK
There was a slight discrepency between those two, which was
resolved in favor of codata.
Notes: the order of the polynomials can be decreased by
dropping terms from the complete Shomate poly.
-->
<atomArray> O:1 H:1 E:1 </atomArray>
<charge> -1 </charge>
<standardState model="constant_incompressible">
<!-- OH- (aq) molar volume
This value is currently made up.
-->
<molarVolume> 0.00834 </molarVolume>
</standardState>
<thermo>
<Shomate Pref="1 atm" Tmax=" 623.15" Tmin=" 298.00">
<floatArray size="7">
44674.99961 , -234943.0414 , 460522.8260 ,
-320695.1836 , -638.5044716 , -8683.955813 ,
102874.2667
</floatArray>
</Shomate>
</thermo>
</species>
</speciesData>
</ctml>

View file

@ -0,0 +1,119 @@
#!/bin/sh
############################################################################
#
# Makefile to compile and link a C++ application to
# Cantera.
#
#############################################################################
# addition to suffixes
.SUFFIXES : .d
# the name of the executable program to be created
PROG_NAME = nacl_equil
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = nacl_equil.o
# Location of the current build. Will assume that tests are run
# in the source directory tree location
src_dir_tree = 0
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS =
#############################################################################
# Check to see whether we are in the msvc++ environment
os_is_win = @OS_IS_WIN@
# Fortran libraries
FORT_LIBS = @FLIBS@
# the C++ compiler
CXX = @CXX@
#
# The directory where Cantera include files may be found.
#
CANTERA_INCDIR=@ctroot@/build/include/cantera
INCLUDE_DIRS = -I$(CANTERA_INCDIR)
# C++ compile flags
CXX_FLAGS = @CXXFLAGS@ $(INCLUDE_DIRS)
# Ending C++ linking libraries
LCXX_END_LIBS = @LCXX_END_LIBS@
# the directory where the Cantera libraries are located
CANTERA_LIBDIR=@buildlib@
#
# Setup The Cantera Interface
#
CANTERA_LIBS=-lequil -lVCSnonideal -lthermo -ltpx -lctnumerics \
-lctbase -lctlapack -lctblas -lctcxx
CANTERA_LIBDEP = \
$(CANTERA_LIBDIR)/libequil.a \
$(CANTERA_LIBDIR)/libVCSnonideal.a \
$(CANTERA_LIBDIR)/libthermo.a \
$(CANTERA_LIBDIR)/libtpx.a \
$(CANTERA_LIBDIR)/libctnumerics.a \
$(CANTERA_LIBDIR)/libctbase.a \
$(CANTERA_LIBDIR)/libctlapack.a \
$(CANTERA_LIBDIR)/libctblas.a \
$(CANTERA_LIBDIR)/libctcxx.a
# flags passed to the C++ compiler/linker for the linking step
LCXX_FLAGS = -L$(CANTERA_LIBDIR) @CXXFLAGS@
# How to compile C++ source files to object files
.cpp.o:
$(CXX) $(CXX_FLAGS) -c $<
# How to compile the dependency file
.cpp.d:
g++ -MM $(CXX_FLAGS) $*.cpp > $*.d
# List of dependency files to be created
DEPENDS=$(OBJS:.o=.d)
# Program Name
PROGRAM = $(PROG_NAME)$(EXE_EXT)
all: .depends $(PROGRAM)
$(PROGRAM): $(OBJS) $(CANTERA_LIBDEP)
$(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \
$(CANTERA_LIBS) @LIBS@ $(FORT_LIBS) $(LCXX_END_LIBS)
# depends target -> forces recalculation of dependencies
depends:
$(RM) *.d .depends
@MAKE@ .depends
.depends: $(DEPENDS)
cat *.d > .depends
# Do the test -> For the windows vc++ environment, we have to skip checking on
# whether the program is uptodate, because we don't utilize make
# in that environment to build programs.
test:
ifeq ($(os_is_win), 1)
else
@MAKE@ $(PROGRAM)
endif
./runtest
clean:
$(RM) $(OBJS) $(PROGRAM) $(DEPENDS) .depends diff.out out.txt \
diff_csv.txt diff_out.txt err_out.txt vcs_equilibrate_res.csv
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )

View file

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<ctml>
<validate reactions="yes" species="yes"/>
<!-- phase NaCl(S) -->
<phase dim="3" id="NaCl(S)">
<elementArray datasrc="elements.xml">
O H C Fe Ca N Na Cl
</elementArray>
<speciesArray datasrc="#species_NaCl(S)"> NaCl(S) </speciesArray>
<thermo model="StoichSubstance">
<density units="g/cm3">2.165</density>
</thermo>
<transport model="None"/>
<kinetics model="none"/>
</phase>
<!-- species definitions -->
<speciesData id="species_NaCl(S)">
<!-- species NaCl(S) -->
<species name="NaCl(S)">
<atomArray> Na:1 Cl:1 </atomArray>
<thermo>
<Shomate Pref="1 bar" Tmax="1075.0" Tmin="250.0">
<floatArray size="7">
50.72389, 6.672267, -2.517167,
10.15934, -0.200675, -427.2115,
130.3973
</floatArray>
</Shomate>
</thermo>
<density units="g/cm3">2.165</density>
</species>
</speciesData>
</ctml>

View file

@ -0,0 +1,152 @@
This is the classic problem of the solubility of NaCl in water.
The result is a saturated solution of Na+ and Cl- in water in equilibrium
with NaCl solid. This problem also has a gas phase consisting of N2, H2O,
H2, and O2. CO2 has been thrown in as well. However, the element abundance
of C is zero. So, CO2 should turn out to have a zero concentration.
The problem can be divided up into two parts: estimating the Gibbs
reaction delta for
Na+ + Cl- = NaCl(solid)
and estimating the activity coefficients for the electrolytes at
the solubility limit.
By far the most important as always is estimating the delta G
for the reaction above. Note the electrolytes are using the
molality basis.
Using the NASA basis we get
NaCl(solid) : Hf(298.15) = -411.1207 kJ/gmol
S(298.15) = 72.1093 J/(gmol K)
(from NIST Webbook)
Gf(298.15) = -432.6200 kJ/gmol
From Codata key values for Thermodynamics:
Cl- Hf(298.15) = -167.080 kJ/gmol
S(298.15) = 56.60 J/(gmol K)
Gf(298.15) = -183.9552 kJ/gmol
Na+ Hf(298.15) = -240.34 kJ/gmol
S(298.15) = 58.45 J/(gmol K)
-> Gf(298.15) = -257.7668 kJ/gmol
Del(Gf)(298.15) = 9.1020 kJ/gmol
In addition, the relative humidity of the salt solution may be compared
to the humidity above a pure water solution in order to understand
the effects of the lowering of the water activity.
If you run the equilibrium calculation without salt, you get the
equilibrium of water vapor above water, consistent with the
current thermo.
X_H2O(g) = 0.03169
at 25C and 1atm
If you then run the calculation with a saturated salt solution you
get a smaller amount of water vapor in equilibrium with the water
electrolyte:
X_H2O(g) = 0.023243
at 25V and 1atm
The ratio of these two numbers is the relative humidity at which
the a saturated salt solution deliqueses from a salt particle.
rel humidity = 0.733
This is a very important number in terms of its effect on aqueous
corrosion.
Next, let's compare the above calculation with the calculation presented
in the current directory. First, getting Gabs from the cttables calculation:
G(298.15) NaCl(solid) = -432.6201 kJ/gmol
G(298.15) Na+ = -257.7668 kJ/gmol
G(298.15) Cl- = -183.9552 kJ/gmol
(note, Na+ and Cl- have screwed up H and S values. However, the
G value seems to be correct).
Putting this together yields:
Delta G = 9.1019 kJ / gmol
----------------------------------------------------------------------------
H2O(l) = H+ + OH- Equilibrium Reaction
------------------------------------------------------------------------
The equilibrium constant for water is given in Robinson and Stokes, p. 363
and p.544.
10^(-13.996) = actCoef(H+) actCoef(OH-) Molal(H+) Molal(OH-) / activity_H2O.
This works out to a value of
DeltaG = 79.88936 kJ/gmol
DeltaH = 56.576 kJ/gmol
DeptaCp = -194.68 J/K gmol
In the current database:
G(298, OH-) = -226.7839 kJ / gmol
G(298 H+) = 0.0
G(298, H2O(L)) = -306.6858.
-------------------------
DeltaG = 79.902
Therefore, there is a slight error of 0.013 kJ/gmol, but the database is roughly correct.
Silvestre & Pitzer
------------------------------------------------------------------------
The equilibrium condition for this simple system comes down to the
following equation
Delta G = - 2 R T ln (m * actCoeff)
This is the basic test of the system.
Delta G = -2161 cal gmol-1 = -9.0416 kJ gmol-l
M_sat = 6.146
ActCoeff_mixed_molalityScale = 1.008
Using the given files and conditions, I calculate equilibrium as:
Delta G = 9.1019 kJ gmol-l
M_sat = 6.193
ActCoeff_mixed_molalityScale = 1.0132
Relative Humidity Lowering
------------------------------------------------------
from the saturated NaCl calculation using HMW
x_H2O = 0.0237641
From the pure water equilibrium case:
x_H2O = 0.0316882
Therefore the relative humidity lowering is 0.7504

View file

@ -0,0 +1,145 @@
<?xml version="1.0"?>
<ctml>
<validate reactions="yes" species="yes"/>
<!-- phase gas -->
<phase dim="3" id="air">
<elementArray datasrc="elements.xml">
O H C Fe Ca N Na Cl
</elementArray>
<speciesArray datasrc="#species_data">
O2 H2 CO2 H2O NaCl N2 OH
</speciesArray>
<state>
<temperature units="K">300.0</temperature>
<pressure units="Pa">101325.0</pressure>
</state>
<thermo model="IdealGas"/>
<kinetics model="GasKinetics"/>
<transport model="Mix"/>
</phase>
<!-- species definitions -->
<speciesData id="species_data">
<!-- species O2 -->
<species name="O2">
<atomArray>O:2 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
<floatArray name="coeffs" size="7">
3.782456360E+00, -2.996734150E-03, 9.847302000E-06, -9.681295080E-09,
3.243728360E-12, -1.063943560E+03, 3.657675730E+00</floatArray>
</NASA>
<NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
3.660960830E+00, 6.563655230E-04, -1.411494850E-07, 2.057976580E-11,
-1.299132480E-15, -1.215977250E+03, 3.415361840E+00</floatArray>
</NASA>
</thermo>
</species>
<!-- species H2 -->
<species name="H2">
<atomArray>H:2 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
<floatArray name="coeffs" size="7">
2.344331120E+00, 7.980520750E-03, -1.947815100E-05, 2.015720940E-08,
-7.376117610E-12, -9.179351730E+02, 6.830102380E-01</floatArray>
</NASA>
<NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
2.932865790E+00, 8.266079670E-04, -1.464023350E-07, 1.541003590E-11,
-6.888044320E-16, -8.130655970E+02, -1.024328870E+00</floatArray>
</NASA>
</thermo>
</species>
<!-- species CO2 -->
<species name="CO2">
<atomArray>C:1 O:2 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
<floatArray name="coeffs" size="7">
2.356773520E+00, 8.984596770E-03, -7.123562690E-06, 2.459190220E-09,
-1.436995480E-13, -4.837196970E+04, 9.901052220E+00</floatArray>
</NASA>
<NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
4.636594930E+00, 2.741319910E-03, -9.958285310E-07, 1.603730110E-10,
-9.161034680E-15, -4.902493410E+04, -1.935348550E+00</floatArray>
</NASA>
</thermo>
</species>
<!-- species H2O gas phase water -->
<species name="H2O">
<atomArray>H:2 O:1 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
<floatArray name="coeffs" size="7">
4.198640560E+00, -2.036434100E-03, 6.520402110E-06, -5.487970620E-09,
1.771978170E-12, -3.029372670E+04, -8.490322080E-01
</floatArray>
</NASA>
<NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
2.677037870E+00, 2.973183290E-03, -7.737696900E-07, 9.443366890E-11,
-4.269009590E-15, -2.988589380E+04, 6.882555710E+00
</floatArray>
</NASA>
</thermo>
</species>
<!-- species OH gas phase water -->
<species name="OH">
<atomArray>H:1 O:1 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
<floatArray name="coeffs" size="7">
7.25575E1, -0.7409634, 2.56198746E-3, -4.36591923E-6,
2.78178981E-9, -3.15909E4, -274.2698
</floatArray>
</NASA>
<NASA Tmax="2000.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
7.25575E1, -0.7409634, 2.56198746E-3, -4.36591923E-6,
2.78178981E-9, -3.15909E4, -274.2698
</floatArray>
</NASA>
</thermo>
</species>
<species name="NaCl">
<atomArray> Na:1 Cl:1 </atomArray>
<thermo>
<Shomate Tmax="1074.0" Tmin="250.0" P0="100000.0">
<floatArray name="coeffs" size="7">
37.33, 0.7364, 0.0, 0.0,
-0.1586, -193.113, 273.765
</floatArray>
</Shomate>
</thermo>
</species>
<!-- species N2 -->
<species name="N2">
<atomArray>N:2 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
<floatArray name="coeffs" size="7">
3.531005280E+00, -1.236609870E-04, -5.029994370E-07, 2.435306120E-09,
-1.408812350E-12, -1.046976280E+03, 2.967474680E+00</floatArray>
</NASA>
<NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
2.952576260E+00, 1.396900570E-03, -4.926316910E-07, 7.860103670E-11,
-4.607553210E-15, -9.239486450E+02, 5.871892520E+00</floatArray>
</NASA>
</thermo>
</species>
</speciesData>
</ctml>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,169 @@
================================================================================
==================== VCS_PROB: PROBLEM STATEMENT ===============================
================================================================================
Solve a constant T, P problem:
T = 298.15 K
Pres = 0.999951 atm
Phase IDs of species
species phaseID phaseName Initial_Estimated_Moles Species_Type
H2O(L) 0 NaCl_electrolyte 2 Mol_Num
Cl- 0 NaCl_electrolyte 0 Mol_Num
H+ 0 NaCl_electrolyte 0 Mol_Num
Na+ 0 NaCl_electrolyte 0 Mol_Num
OH- 0 NaCl_electrolyte 0 Mol_Num
O2 1 air 0 Mol_Num
H2 1 air 0 Mol_Num
CO2 1 air 0 Mol_Num
H2O 1 air 0 Mol_Num
NaCl 1 air 0 Mol_Num
N2 1 air 4 Mol_Num
OH 1 air 0 Mol_Num
NaCl(S) 2 NaCl(S) 5 Mol_Num
--------------------------------------------------------------------------------
Information about phases
PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec TMolesInert Tmoles
NaCl_electrolyte 0 0 0 UnkType: -1 5 0.000000e+00 2.000000e+00
air 1 0 1 Ideal Gas 7 0.000000e+00 4.000000e+00
NaCl(S) 2 1 0 Stoich Sub 1 0.000000e+00 5.000000e+00
Elemental Abundances: Target_gmol ElemType ElActive
O 2.000000000000E+03 0 1
H 4.000000000000E+03 0 1
C 0.000000000000E+00 0 1
Fe 0.000000000000E+00 0 1
Si 0.000000000000E+00 0 1
N 8.000000000000E+03 0 1
Na 5.000000000000E+03 0 1
Cl 5.000000000000E+03 0 1
E 0.000000000000E+00 1 0
cn 0.000000000000E+00 2 1
Ca 0.000000000000E+00 0 1
Chemical Potentials: (J/kmol)
Species (phase) SS0ChemPot StarChemPot
H2O(L) NaCl_electrolyte -3.06686e+08 -3.06686e+08
Cl- -1.83974e+08 -1.83974e+08
H+ 0 0
Na+ -2.57752e+08 -2.57752e+08
OH- -2.26784e+08 -2.26784e+08
O2 air -6.1165e+07 -6.1165e+07
H2 -3.89624e+07 -3.89624e+07
CO2 -4.57249e+08 -4.57249e+08
H2O -2.98124e+08 -2.98124e+08
NaCl -2.49904e+08 -2.49904e+08
N2 -5.71282e+07 -5.71282e+07
OH -2.26793e+08 -2.26793e+08
NaCl(S) NaCl(S) -4.3262e+08 -4.3262e+08
================================================================================
==================== VCS_PROB: END OF PROBLEM STATEMENT ========================
================================================================================
Results from vcs:
Temperature = 298.15 Kelvin
Pressure = 101325 Pa
-------------------------------------------------------------
Name Mole_Number(kmol) Mole_Fraction Chem_Potential (J/kmol)
-------------------------------------------------------------
H2O(L) 1.903e+00 8.176e-01 -3.074e+08
Cl- 2.123e-01 9.122e-02 -1.794e+08
H+ 1.842e-09 7.913e-10 -3.762e+07
Na+ 2.123e-01 9.122e-02 -2.532e+08
OH- 1.842e-09 7.913e-10 -2.698e+08
O2 8.947e-69 2.184e-69 -4.531e+08
H2 1.874e-07 4.573e-08 -8.086e+07
CO2 0.000e+00 0.000e+00 -1.000e+300
H2O 9.718e-02 2.372e-02 -3.074e+08
NaCl 4.000e-32 9.762e-33 -4.326e+08
N2 4.000e+00 9.763e-01 -5.719e+07
OH 3.747e-07 9.146e-08 -2.670e+08
NaCl(S) 4.788e+00 1.000e+00 -4.326e+08
-------------------------------------------------------------
*************** NaCl_electrolyte *****************
Moles: 2.32742
NaCl_electrolyte:
temperature 298.15 K
pressure 101325 Pa
density 1216.41 kg/m^3
mean mol. weight 20.0596 amu
1 kg 1 kmol
----------- ------------
enthalpy -1.35106e+07 -2.71e+08 J
internal energy -1.35107e+07 -2.71e+08 J
entropy 3304.61 6.629e+04 J/K
Gibbs function -1.44958e+07 -2.908e+08 J
heat capacity c_p 3053.16 6.125e+04 J/K
heat capacity c_v <not implemented>
X Y Chem. Pot. / RT
------------- ------------ ------------
H2O(L) 0.817565 0.734244 -124.003
Cl- 0.0912175 0.161217 -72.3775
H+ 7.91271e-10 3.97376e-11 -15.1739
Na+ 0.0912175 0.104539 -102.139
OH- 7.91271e-10 6.70891e-10 -108.829
*************** air *****************
Moles: 4.09718
air:
temperature 298.15 K
pressure 101325 Pa
density 1.13533 kg/m^3
mean mol. weight 27.7763 amu
1 kg 1 kmol
----------- ------------
enthalpy -206497 -5.736e+06 J
internal energy -295744 -8.215e+06 J
entropy 6929.48 1.925e+05 J/K
Gibbs function -2.27252e+06 -6.312e+07 J
heat capacity c_p 1052.34 2.923e+04 J/K
heat capacity c_v 753.001 2.092e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
O2 2.1836e-69 2.51554e-69 -182.771
H2 4.57308e-08 3.31893e-09 -32.6177
CO2 0 0
H2O 0.0237184 0.0153834 -124.003
NaCl 9.76193e-33 2.05395e-32 -174.517
N2 0.976281 0.984617 -23.0692
OH 9.14616e-08 5.60016e-08 -107.694
*************** NaCl(S) *****************
Moles: 4.7877
NaCl(S):
temperature 298.15 K
pressure 101325 Pa
density 2165 kg/m^3
mean mol. weight 58.4425 amu
1 kg 1 kmol
----------- ------------
enthalpy -7.03462e+06 -4.111e+08 J
internal energy -7.03467e+06 -4.111e+08 J
entropy 1233.85 7.211e+04 J/K
Gibbs function -7.4025e+06 -4.326e+08 J
heat capacity c_p 864.119 5.05e+04 J/K
heat capacity c_v 864.119 5.05e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
NaCl(S) 1 1 -174.517
NUMBER OF SUCCESSES = 1
NUMBER OF FAILURES = 0

View file

@ -0,0 +1,167 @@
/*
* $Author$
* $Date$
* $Revision$
*
* Copyright 2002 California Institute of Technology
*
*/
#include "Cantera.h"
#include "equilibrium.h"
#include "kernel/vcs_MultiPhaseEquil.h"
#include "kernel/ThermoFactory.h"
#include "kernel/IdealGasPhase.h"
#include "kernel/HMWSoln.h"
#include "kernel/StoichSubstanceSSTP.h"
using namespace Cantera;
using namespace std;
void printUsage() {
cout << "usage: nacl_equil [-h] [-help_cmdfile] [-d #] [HMW_NaCl.xml] "
<< endl;
cout << " -h help" << endl;
cout << " -d # : level of debug printing" << endl;
cout << " [HMW_NaCl.xml] - Optionally change the name of the input file " << endl;
cout << endl;
cout << endl;
}
int main(int argc, char **argv) {
// int solver = 2;
int numSucc = 0;
int numFail = 0;
int printLvl = 1;
string inputFile = "HMW_NaCl.xml";
bool printInputFormat = false; // print cmdfile.txt format
bool printedUsage = false;
/*
* Process the command line arguments
*/
if (argc > 1) {
string tok;
for (int j = 1; j < argc; j++) {
tok = string(argv[j]);
if (tok[0] == '-') {
int nopt = static_cast<int>(tok.size());
for (int n = 1; n < nopt; n++) {
if (!strcmp(tok.c_str() + 1, "help_cmdfile")) {
printInputFormat = true;
} else if (tok[n] == 'h') {
printUsage();
printedUsage = true;
exit(1);
} else if (tok[n] == 'd') {
printLvl = 2;
int lvl = 2;
if (j < (argc - 1)) {
string tokla = string(argv[j+1]);
if (strlen(tokla.c_str()) > 0) {
lvl = atoi(tokla.c_str());
n = nopt - 1;
j += 1;
if (lvl >= 0) {
printLvl = lvl;
}
}
}
} else {
printUsage();
printedUsage = true;
exit(1);
}
}
} else if (inputFile == "HMW_NaCl.xml") {
inputFile = tok;
} else {
printUsage();
printedUsage = true;
exit(1);
}
}
}
try {
int retnSub;
double T = 298.15;
double pres = OneAtm;
// Initialize the individual phases
HMWSoln hmw(inputFile, "");
int kk = hmw.nSpecies();
vector_fp Xmol(kk, 0.0);
int iH2OL = hmw.speciesIndex("H2O(L)");
Xmol[iH2OL] = 1.0;
hmw.setState_TPX(T, pres, DATA_PTR(Xmol));
ThermoPhase *gas = newPhase("gas.xml", "");
kk = gas->nSpecies();
Xmol.resize(kk, 0.0);
for (int i = 0; i < kk; i++) {
Xmol[i] = 0.0;
}
int iN2 = gas->speciesIndex("N2");
Xmol[iN2] = 1.0;
gas->setState_TPX(T, pres, DATA_PTR(Xmol));
StoichSubstanceSSTP ss("NaCl_Solid.xml", "");
ss.setState_TP(T, pres);
// Construct the multiphase object
MultiPhase *mp = new MultiPhase();
mp->addPhase(&hmw, 2.0);
mp->addPhase(gas, 4.0);
mp->addPhase(&ss, 5.0);
try {
retnSub = vcs_equilibrate(*mp, "TP", true, printLvl);
cout << *mp;
if (retnSub != 1) {
cerr << "ERROR: MultiEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: MultiEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
numSucc++;
} catch (CanteraError) {
cout << *mp;
showErrors(cerr);
cerr << "ERROR: MultiEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: MultiEqiul equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
cout << "NUMBER OF SUCCESSES = " << numSucc << endl;
cout << "NUMBER OF FAILURES = " << numFail << endl;
return numFail;
}
catch (CanteraError) {
showErrors(cerr);
cerr << "ERROR: program terminating due to unforeseen circumstances." << endl;
return -1;
}
}

View file

@ -0,0 +1,54 @@
#!/bin/sh
#
#
eCode=0
temp_success="1"
/bin/rm -f out.txt err_out.txt \
vcs_equilibrate_res.csv \
diff_csv.txt diff_out.txt
#
# Create a symbolic link to mpequil, if none exists already
#
testName=NaCl_equil
#################################################################
#
#################################################################
MPEQUIL_EXE=${MPEQUIL_EXE:=nacl_equil}
$MPEQUIL_EXE -d 2 > out.txt 2>err_out.txt
retnStat=$?
if test $retnStat != "0"
then
echo "mpequil returned with bad status, $retnStat, check output"
fi
diff good_out.txt out.txt > diff_out.txt
retnStat_txt=$?
csvdiff -a 1.0E-50 vcs_equilibrate_blessed.csv vcs_equilibrate_res.csv > diff_csv.txt
retnStat_csv=$?
if test $retnStat_csv = "1"
then
echo "Successful test comparison on "`pwd`
if [ $retnStat_txt != "0" ]
then
echo " But, text output files have differences. See diff_out.txt"
fi
else
echo "Unsuccessful test comparison on "`pwd` " test"
if test $retnStat_csv != "1"
then
echo " csv files are different - see diff_csv.txt"
fi
if test $retnStat_txt != "0"
then
echo " And, text output files have differences. See diff_out.txt"
fi
fi
#
# return 0 for no errors, 1 for errors
#
exit $eCode

View file

@ -0,0 +1,54 @@
#!/bin/sh
#
#
eCode=0
temp_success="1"
/bin/rm -f dout.txt err_dout.txt \
vcs_eqilibrate_res.csv \
diff_csv.txt diff_dout.txt
#
# Create a symbolic link to mpequil, if none exists already
#
testName=nacl_equil
#################################################################
#
#################################################################
MPEQUIL_EXE=${MPEQUIL_EXE:=nacl_equil}
$MPEQUIL_EXE -d 5 > dout.txt 2>err_dout.txt
retnStat=$?
if test $retnStat != "0"
then
echo "mpequil returned with bad status, $retnStat, check output"
fi
diff good_dout.txt dout.txt > diff_dout.txt
retnStat_txt=$?
csvdiff -a 1.0E-50 vcs_equilibrate_blessed.csv vcs_equilibrate_res.csv > diff_csv.txt
retnStat_csv=$?
if test $retnStat_csv = "1"
then
echo "Successful test comparison on "`pwd`
if [ $retnStat_txt != "0" ]
then
echo " But, text output files have differences. See diff_dout.txt"
fi
else
echo "Unsuccessful test comparison on "`pwd` " test"
if test $retnStat_csv != "1"
then
echo " csv files are different - see diff_csv.txt"
fi
if test $retnStat_txt != "0"
then
echo " And, text output files have differences. See diff_dout.txt"
fi
fi
#
# return 0 for no errors, 1 for errors
#
exit $eCode

View file

@ -0,0 +1,21 @@
--------------------- VCS_MULTIPHASE_EQUIL FINAL REPORT -----------------------------
Temperature = 298.15 kelvin
Pressure = 1.0132e+05 Pascal
Total Volume = 100.41 m**3
Number Basis optimizations = 3
Number VCS iterations = 36
Name, Phase, PhaseMoles, Mole_Fract, Molalities, ActCoeff, Activity,ChemPot_SS0, ChemPot, mole_num, PMVol, Phase_Volume
, , (kmol), , , , , (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)
H2O(L), NaCl_electrolyte, 2.327e+00, 8.176e-01, 5.551e+01, 9.173e-01, 7.500e-01, -3.067e+02, -3.074e+02, 1.903e+00, 1.800e-02, 3.838e-02
Cl-, NaCl_electrolyte, 2.327e+00, 9.122e-02, 6.193e+00, 1.239e+00, 6.275e+00, -1.840e+02, -1.794e+02, 2.123e-01, 9.713e-03, 3.838e-02
H+, NaCl_electrolyte, 2.327e+00, 7.913e-10, 5.372e-08, 5.853e+00, 2.571e-07, 0.000e+00, -3.762e+01, 1.842e-09, 1.373e-03, 3.838e-02
Na+, NaCl_electrolyte, 2.327e+00, 9.122e-02, 6.193e+00, 1.239e+00, 6.275e+00, -2.578e+02, -2.532e+02, 2.123e-01, 9.713e-03, 3.838e-02
OH-, NaCl_electrolyte, 2.327e+00, 7.913e-10, 5.372e-08, 6.669e-01, 2.929e-08, -2.268e+02, -2.698e+02, 1.842e-09, 9.713e-03, 3.838e-02
O2, air, 4.097e+00, 2.184e-69, 0.000e+00, 1.000e+00, 2.184e-69, -6.117e+01, -4.531e+02, 8.947e-69, 2.447e+01, 1.002e+02
H2, air, 4.097e+00, 4.573e-08, 0.000e+00, 1.000e+00, 4.573e-08, -3.896e+01, -8.086e+01, 1.874e-07, 2.447e+01, 1.002e+02
CO2, air, 4.097e+00, 0.000e+00, 0.000e+00, 1.000e+00, 0.000e+00, -4.572e+02, -2.170e+03, 0.000e+00, 2.447e+01, 1.002e+02
H2O, air, 4.097e+00, 2.372e-02, 0.000e+00, 1.000e+00, 2.372e-02, -2.981e+02, -3.074e+02, 9.718e-02, 2.447e+01, 1.002e+02
NaCl, air, 4.097e+00, 9.762e-33, 0.000e+00, 1.000e+00, 9.762e-33, -2.499e+02, -4.326e+02, 4.000e-32, 2.447e+01, 1.002e+02
N2, air, 4.097e+00, 9.763e-01, 0.000e+00, 1.000e+00, 9.763e-01, -5.713e+01, -5.719e+01, 4.000e+00, 2.447e+01, 1.002e+02
OH, air, 4.097e+00, 9.146e-08, 0.000e+00, 1.000e+00, 9.146e-08, -2.268e+02, -2.670e+02, 3.747e-07, 2.447e+01, 1.002e+02
NaCl(S), NaCl(S), 4.788e+00, 1.000e+00, 0.000e+00, 1.000e+00, 1.000e+00, -4.326e+02, -4.326e+02, 4.788e+00, 2.699e-02, 1.292e-01
1 --------------------- VCS_MULTIPHASE_EQUIL FINAL REPORT -----------------------------
2 Temperature = 298.15 kelvin
3 Pressure = 1.0132e+05 Pascal
4 Total Volume = 100.41 m**3
5 Number Basis optimizations = 3
6 Number VCS iterations = 36
7 Name, Phase, PhaseMoles, Mole_Fract, Molalities, ActCoeff, Activity,ChemPot_SS0, ChemPot, mole_num, PMVol, Phase_Volume
8 , , (kmol), , , , , (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)
9 H2O(L), NaCl_electrolyte, 2.327e+00, 8.176e-01, 5.551e+01, 9.173e-01, 7.500e-01, -3.067e+02, -3.074e+02, 1.903e+00, 1.800e-02, 3.838e-02
10 Cl-, NaCl_electrolyte, 2.327e+00, 9.122e-02, 6.193e+00, 1.239e+00, 6.275e+00, -1.840e+02, -1.794e+02, 2.123e-01, 9.713e-03, 3.838e-02
11 H+, NaCl_electrolyte, 2.327e+00, 7.913e-10, 5.372e-08, 5.853e+00, 2.571e-07, 0.000e+00, -3.762e+01, 1.842e-09, 1.373e-03, 3.838e-02
12 Na+, NaCl_electrolyte, 2.327e+00, 9.122e-02, 6.193e+00, 1.239e+00, 6.275e+00, -2.578e+02, -2.532e+02, 2.123e-01, 9.713e-03, 3.838e-02
13 OH-, NaCl_electrolyte, 2.327e+00, 7.913e-10, 5.372e-08, 6.669e-01, 2.929e-08, -2.268e+02, -2.698e+02, 1.842e-09, 9.713e-03, 3.838e-02
14 O2, air, 4.097e+00, 2.184e-69, 0.000e+00, 1.000e+00, 2.184e-69, -6.117e+01, -4.531e+02, 8.947e-69, 2.447e+01, 1.002e+02
15 H2, air, 4.097e+00, 4.573e-08, 0.000e+00, 1.000e+00, 4.573e-08, -3.896e+01, -8.086e+01, 1.874e-07, 2.447e+01, 1.002e+02
16 CO2, air, 4.097e+00, 0.000e+00, 0.000e+00, 1.000e+00, 0.000e+00, -4.572e+02, -2.170e+03, 0.000e+00, 2.447e+01, 1.002e+02
17 H2O, air, 4.097e+00, 2.372e-02, 0.000e+00, 1.000e+00, 2.372e-02, -2.981e+02, -3.074e+02, 9.718e-02, 2.447e+01, 1.002e+02
18 NaCl, air, 4.097e+00, 9.762e-33, 0.000e+00, 1.000e+00, 9.762e-33, -2.499e+02, -4.326e+02, 4.000e-32, 2.447e+01, 1.002e+02
19 N2, air, 4.097e+00, 9.763e-01, 0.000e+00, 1.000e+00, 9.763e-01, -5.713e+01, -5.719e+01, 4.000e+00, 2.447e+01, 1.002e+02
20 OH, air, 4.097e+00, 9.146e-08, 0.000e+00, 1.000e+00, 9.146e-08, -2.268e+02, -2.670e+02, 3.747e-07, 2.447e+01, 1.002e+02
21 NaCl(S), NaCl(S), 4.788e+00, 1.000e+00, 0.000e+00, 1.000e+00, 1.000e+00, -4.326e+02, -4.326e+02, 4.788e+00, 2.699e-02, 1.292e-01