Skip to content

Commit

Permalink
GAS_BINARY_PARAMETERS implemented. gas_binary_parameters test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dlparkhurst committed Nov 9, 2024
1 parent 9be2174 commit 14b0fe8
Show file tree
Hide file tree
Showing 11 changed files with 963 additions and 2 deletions.
12 changes: 11 additions & 1 deletion database/phreeqc.dat
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,17 @@ Pb(OH)2 389
Pb(OH)2 + 2 H+ = Pb+2 + 2 H2O
-log_k 8.15
-delta_h -13.99 kcal

GAS_BINARY_PARAMETERS
H2O(g) CO2(g) 0.19
H2O(g) H2S(g) 0.19
H2O(g) H2Sg(g) 0.19
H2O(g) CH4(g) 0.49
H2O(g) Mtg(g) 0.49
H2O(g) Methane(g) 0.49
H2O(g) N2(g) 0.49
H2O(g) Ntg(g) 0.49
H2O(g) Ethane(g) 0.49
H2O(g) Propane(g) 0.55
EXCHANGE_MASTER_SPECIES
X X-
EXCHANGE_SPECIES
Expand Down
15 changes: 15 additions & 0 deletions mytest/gas_binary_parameters
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DATABASE ../database/phreeqc.dat
SELECTED_OUTPUT 101
-file gas_binary_parameters_101.sel
USER_PUNCH 101
-headings Mu SC
-start
10 PUNCH STR_F$(MU, 20, 12)
20 PUNCH STR_F$(SC, 20, 10)
-end
SOLUTION
GAS_PHASE
H2O(g) 0
CO2(g) 1
Hdg(g) 1
END
192 changes: 192 additions & 0 deletions mytest/gas_binary_parameters.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
Input file: gas_binary_parameters
Output file: gas_binary_parameters.out
Database file: ../database/phreeqc.dat

------------------
Reading data base.
------------------

SOLUTION_MASTER_SPECIES
SOLUTION_SPECIES
PHASES
GAS_BINARY_PARAMETERS
EXCHANGE_MASTER_SPECIES
EXCHANGE_SPECIES
SURFACE_MASTER_SPECIES
SURFACE_SPECIES
MEAN_GAMMAS
RATES
END
------------------------------------
Reading input data for simulation 1.
------------------------------------

DATABASE ../database/phreeqc.dat
SELECTED_OUTPUT 101
file gas_binary_parameters_101.sel
USER_PUNCH 101
headings Mu SC
start
10 PUNCH STR_F$(MU, 20, 12)
20 PUNCH STR_F$(SC, 20, 10)
end
SOLUTION
GAS_PHASE
H2O(g) 0
CO2(g) 1
Hdg(g) 1
END
-------------------------------------------
Beginning of initial solution calculations.
-------------------------------------------

Initial solution 1.

-----------------------------Solution composition------------------------------

Elements Molality Moles

Pure water

----------------------------Description of solution----------------------------

pH = 7.000
pe = 4.000
Specific Conductance (µS/cm, 25°C) = 0
Density (g/cm³) = 0.99704
Volume (L) = 1.00297
Viscosity (mPa s) = 0.89002
Activity of water = 1.000
Ionic strength (mol/kgw) = 1.007e-07
Mass of water (kg) = 1.000e+00
Total alkalinity (eq/kg) = 1.217e-09
Temperature (°C) = 25.00
Electrical balance (eq) = -1.217e-09
Percent error, 100*(Cat-|An|)/(Cat+|An|) = -0.60
Iterations = 0
Total H = 1.110124e+02
Total O = 5.550622e+01

----------------------------Distribution of species----------------------------

Log Log Log mole V
Species Molality Activity Molality Activity Gamma cm³/mol

OH- 1.013e-07 1.012e-07 -6.995 -6.995 -0.000 -4.14
H+ 1.001e-07 1.000e-07 -7.000 -7.000 -0.000 0.00
H2O 5.551e+01 1.000e+00 1.744 0.000 0.000 18.07
H(0) 1.416e-25
H2 7.079e-26 7.079e-26 -25.150 -25.150 0.000 28.61
O(0) 0.000e+00
O2 0.000e+00 0.000e+00 -42.080 -42.080 0.000 30.40

------------------------------Saturation indices-------------------------------

Phase SI** log IAP log K(298 K, 1 atm)

H2(g) -22.05 -25.15 -3.10 H2
H2O(g) -1.50 0.00 1.50 H2O
O2(g) -39.19 -42.08 -2.89 O2

**For a gas, SI = log10(fugacity). Fugacity = pressure * phi / 1 atm.
For ideal gases, phi = 1.

-----------------------------------------
Beginning of batch-reaction calculations.
-----------------------------------------

Reaction step 1.

Using solution 1.
Using gas phase 1.

-----------------------------------Gas phase-----------------------------------

Total pressure: 1.00 atmospheres (Peng-Robinson calculation)
Gas volume: 1.72e+00 liters
Molar volume: 2.44e+01 liters/mole
P * Vm / RT: 0.99861 (Compressibility Factor Z)

Moles in gas
----------------------------------
Component log P P phi Initial Final Delta

CO2(g) -0.41 3.924e-01 0.996 4.101e-02 2.763e-02 -1.338e-02
H2O(g) -1.50 3.165e-02 0.992 0.000e+00 2.229e-03 2.229e-03
Hdg(g) -0.24 5.759e-01 1.001 4.101e-02 4.056e-02 -4.568e-04

-----------------------------Solution composition------------------------------

Elements Molality Moles

C 1.338e-02 1.338e-02
Hdg 4.568e-04 4.568e-04

----------------------------Description of solution----------------------------

pH = 4.114 Charge balance
pe = 13.747 Adjusted to redox equilibrium
Specific Conductance (µS/cm, 25°C) = 30
Density (g/cm³) = 0.99716
Volume (L) = 1.00340
Viscosity (mPa s) = 0.89111
Activity of water = 1.000
Ionic strength (mol/kgw) = 7.767e-05
Mass of water (kg) = 1.000e+00
Total alkalinity (eq/kg) = 1.217e-09
Total CO2 (mol/kg) = 1.338e-02
Temperature (°C) = 25.00
Electrical balance (eq) = -1.217e-09
Percent error, 100*(Cat-|An|)/(Cat+|An|) = -0.00
Iterations = 15
Total H = 1.110080e+02
Total O = 5.553075e+01

----------------------------Distribution of species----------------------------

Log Log Log mole V
Species Molality Activity Molality Activity Gamma cm³/mol

H+ 7.767e-05 7.689e-05 -4.110 -4.114 -0.004 0.00
OH- 1.330e-10 1.316e-10 -9.876 -9.881 -0.004 -4.13
H2O 5.551e+01 9.998e-01 1.744 -0.000 0.000 18.07
C(-4) 0.000e+00
CH4 0.000e+00 0.000e+00 -120.374 -120.374 0.000 35.46
C(4) 1.338e-02
CO2 1.330e-02 1.330e-02 -1.876 -1.876 0.000 34.43
HCO3- 7.767e-05 7.689e-05 -4.110 -4.114 -0.004 24.56
(CO2)2 3.245e-06 3.245e-06 -5.489 -5.489 0.000 68.87
CO3-2 4.884e-11 4.689e-11 -10.311 -10.329 -0.018 -4.02
H(0) 2.685e-39
H2 1.343e-39 1.343e-39 -38.872 -38.872 0.000 28.61
Hdg 4.568e-04
Hdg 4.568e-04 4.568e-04 -3.340 -3.340 0.000 28.61
O(0) 4.623e-15
O2 2.312e-15 2.312e-15 -14.636 -14.636 0.000 30.40

------------------------------Saturation indices-------------------------------

Phase SI** log IAP log K(298 K, 1 atm)

CH4(g) -117.57 -120.37 -2.80 CH4
CO2(g) -0.41 -1.88 -1.47 CO2 Pressure 0.4 atm, phi 0.996
H2(g) -35.77 -38.87 -3.10 H2
H2O(g) -1.50 -0.00 1.50 H2O Pressure 0.0 atm, phi 0.992
Hdg(g) -0.24 -3.34 -3.10 Hdg Pressure 0.6 atm, phi 1.001
O2(g) -11.74 -14.64 -2.89 O2

**For a gas, SI = log10(fugacity). Fugacity = pressure * phi / 1 atm.
For ideal gases, phi = 1.

------------------
End of simulation.
------------------

------------------------------------
Reading input data for simulation 2.
------------------------------------

-------------------------------
End of Run after 0.063 Seconds.
-------------------------------

3 changes: 3 additions & 0 deletions mytest/gas_binary_parameters_101.sel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Mu SC
0.000000100661 0.0546997633
0.000077673739 30.2878526752
1 change: 1 addition & 0 deletions src/Phreeqc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,7 @@ Phreeqc::InternalCopy(const Phreeqc* pSrc)
b2 = pSrc->b2;
b_sum = pSrc->b_sum;
R_TK = pSrc->R_TK;
gas_binary_parameters = pSrc->gas_binary_parameters;
/* input.cpp ------------------------------- */
check_line_return = 0;
reading_db = FALSE;
Expand Down
2 changes: 2 additions & 0 deletions src/Phreeqc.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ class Phreeqc
int read_rate_parameters_svd(void);
int read_rate_parameters_hermanska(void);
int read_mean_gammas(void);
int read_gas_binary_parameters(void);
int read_mix(void);
int read_entity_mix(std::map<int, cxxMix>& mix_map);
//int read_solution_mix(void);
Expand Down Expand Up @@ -1674,6 +1675,7 @@ class Phreeqc
std::vector<double> x_arg, res_arg, scratch;
/* gases.cpp ------------------------------- */
LDBLE a_aa_sum, b2, b_sum, R_TK;
std::map < std::pair<std::string, std::string>, double > gas_binary_parameters;

/* input.cpp ------------------------------- */
int check_line_return;
Expand Down
4 changes: 3 additions & 1 deletion src/PhreeqcKeywords/Keywords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ std::map<const std::string, Keywords::KEYWORDS>::value_type("rate_parameters_pk"
std::map<const std::string, Keywords::KEYWORDS>::value_type("rate_parameters_svd", Keywords::KEY_RATE_PARAMETERS_SVD),
std::map<const std::string, Keywords::KEYWORDS>::value_type("rate_parameters_hermanska", Keywords::KEY_RATE_PARAMETERS_HERMANSKA),
std::map<const std::string, Keywords::KEYWORDS>::value_type("mean_gammas", Keywords::KEY_MEAN_GAMMAS),
std::map<const std::string, Keywords::KEYWORDS>::value_type("gas_binary_parameters", Keywords::KEY_GAS_BINARY_PARAMETERS),
std::map<const std::string, Keywords::KEYWORDS>::value_type("solution_mix", Keywords::KEY_SOLUTION_MIX),
std::map<const std::string, Keywords::KEYWORDS>::value_type("mix_solution", Keywords::KEY_SOLUTION_MIX),
std::map<const std::string, Keywords::KEYWORDS>::value_type("exchange_mix", Keywords::KEY_EXCHANGE_MIX),
Expand Down Expand Up @@ -228,7 +229,8 @@ std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTI
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_RATE_PARAMETERS_PK, "RATE_PARAMETERS_PK"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_RATE_PARAMETERS_SVD, "RATE_PARAMETERS_SVD"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_RATE_PARAMETERS_HERMANSKA, "RATE_PARAMETERS_HERMANSKA"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_MEAN_GAMMAS, "RATE_MEAN_GAMMAS"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_MEAN_GAMMAS, "MEAN_GAMMAS"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_GAS_BINARY_PARAMETERS, "GAS_BINARY_PARAMETERS"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_SOLUTION_MIX, "SOLUTION_MIX"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_EXCHANGE_MIX, "EXCHANGE_MIX"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_GAS_PHASE_MIX, "GAS_PHASE_MIX"),
Expand Down
1 change: 1 addition & 0 deletions src/PhreeqcKeywords/Keywords.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Keywords
KEY_RATE_PARAMETERS_SVD,
KEY_RATE_PARAMETERS_HERMANSKA,
KEY_MEAN_GAMMAS,
KEY_GAS_BINARY_PARAMETERS,
KEY_SOLUTION_MIX,
KEY_EXCHANGE_MIX,
KEY_GAS_PHASE_MIX,
Expand Down
Loading

0 comments on commit 14b0fe8

Please # to comment.