Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break out thermo consistency tests #1501

Merged
merged 5 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/thermo/WaterPropsIAPWSphi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ doublereal WaterPropsIAPWSphi::dfind(doublereal p_red, doublereal tau, doublerea
doublereal dd = deltaGuess;
bool conv = false;
doublereal deldd = dd;
doublereal pcheck = 1.0E-30 + 1.0E-8 * p_red;
doublereal pcheck = 1.0E-30 + 1.0E-14 * p_red;
for (int n = 0; n < 200; n++) {

// Calculate the internal polynomials, and then calculate the phi deriv
Expand Down
2 changes: 2 additions & 0 deletions test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ addTestProgram('general', 'general')
addTestProgram('kinetics', 'kinetics')
addTestProgram('oneD', 'oneD')
addTestProgram('thermo', 'thermo')
addTestProgram('thermo_consistency', 'thermo-consistency',
env_vars={'GTEST_BRIEF': '0' if env['verbose_tests'] else '1'})
addTestProgram('transport', 'transport')
addTestProgram('zeroD', 'zeroD')

Expand Down
48 changes: 48 additions & 0 deletions test/data/consistency-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,82 @@ debye-huckel-dilute:
molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.05e-08, OH-: 1.3765e-06,
NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06}}

debye-huckel-dilute-IAPWS:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-dilute-IAPWS
rtol_fd: 1e-5 # Good finite difference results with IAPWS are challenging
known-failures:
cv_eq_.+: cv not implemented
activity_coeffs: "Activity coeffs are incorrect. See GitHub Issue #1311"
cp_eq_.+: "cp with variable A_Debye is incorrect. See GitHub Issue #1500"
dsdP_const_T_eq_minus_dV_dT_const_P.+:
"Error with dilute limit with variable A_Debye. See GitHub Issue #1502"
states: *debye-huckel-states

debye-huckel-B-dot-ak:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-B-dot-ak
known-failures: *debye-huckel-failures
states: *debye-huckel-states

debye-huckel-B-dot-ak-IAPWS:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-B-dot-ak-IAPWS
rtol_fd: 1e-5 # Good finite difference results with IAPWS are challenging
known-failures: &debye-huckel-IAPWS-failures
cv_eq_.+: cv not implemented
activity_coeffs: "Activity coeffs are incorrect. See GitHub Issue #1311"
cp_eq_.+: "cp with variable A_debye is incorrect. See GitHub Issue #1500"
states: *debye-huckel-states

debye-huckel-B-dot-a:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-B-dot-a
known-failures: *debye-huckel-failures
states: *debye-huckel-states

debye-huckel-B-dot-a-IAPWS:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-B-dot-a-IAPWS
rtol_fd: 1e-5 # Good finite difference results with IAPWS are challenging
known-failures: *debye-huckel-IAPWS-failures
states: *debye-huckel-states

debye-huckel-pitzer-beta_ij:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-pitzer-beta_ij
known-failures: *debye-huckel-failures
states: *debye-huckel-states

debye-huckel-pitzer-beta_ij-IAPWS:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-pitzer-beta_ij-IAPWS
rtol_fd: 1e-5 # Good finite difference results with IAPWS are challenging
known-failures: *debye-huckel-IAPWS-failures
states: *debye-huckel-states

debye-huckel-beta_ij:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-beta_ij
known-failures: *debye-huckel-failures
states: *debye-huckel-states

debye-huckel-beta_ij-IAPWS:
setup:
file: debye-huckel-all.yaml
phase: debye-huckel-beta_ij-IAPWS
rtol_fd: 1e-5 # Good finite difference results with IAPWS are challenging
known-failures: *debye-huckel-IAPWS-failures
states: *debye-huckel-states

margules:
setup:
file: LiKCl_liquid.yaml
Expand Down
102 changes: 102 additions & 0 deletions test/data/debye-huckel-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ phases:
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-dilute-IAPWS
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
species:
- water_IAPWS: [H2O(L)]
- species_waterSolution: [Na+, Cl-, H+, OH-, NaCl(aq), NaOH(aq), SiO2(aq),
NaH3SiO4(aq), H3SiO4-]
thermo: Debye-Huckel
activity-data:
model: dilute-limit
A_Debye: variable
B_Debye: 3.28640E9 kg^0.5/gmol^0.5/m
max-ionic-strength: 3.0
use-Helgeson-fixed-form: true
default-ionic-radius: 3.5 angstrom
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-B-dot-ak
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
Expand All @@ -36,6 +54,23 @@ phases:
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-B-dot-ak-IAPWS
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
- water_IAPWS: [H2O(L)]
- species_waterSolution: [Na+, Cl-, H+, OH-, NaCl(aq), NaOH(aq), SiO2(aq),
NaH3SiO4(aq), H3SiO4-]
thermo: Debye-Huckel
activity-data:
model: B-dot-with-variable-a
A_Debye: variable
B_Debye: 3.28640E9 kg^0.5/gmol^0.5/m
max-ionic-strength: 50.0
B-dot: 0.041
default-ionic-radius: 4.0 angstrom
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-B-dot-a
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
Expand All @@ -52,6 +87,23 @@ phases:
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-B-dot-a-IAPWS
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
- water_IAPWS: [H2O(L)]
- species_waterSolution: [Na+, Cl-, H+, OH-, NaCl(aq), NaOH(aq), SiO2(aq),
NaH3SiO4(aq), H3SiO4-]
thermo: Debye-Huckel
activity-data:
model: B-dot-with-common-a
A_Debye: variable
B_Debye: 3.28640E9 kg^0.5/gmol^0.5/m
max-ionic-strength: 50.0
B-dot: 0.0
default-ionic-radius: 3.5 angstrom
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 9.3549, Cl-: 9.3549, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-pitzer-beta_ij
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
Expand All @@ -73,6 +125,28 @@ phases:
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 3.0, Cl-: 3.0, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-pitzer-beta_ij-IAPWS
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
- water_IAPWS: [H2O(L)]
- species_waterSolution: [Na+, Cl-, H+, OH-, NaCl(aq), NaOH(aq), SiO2(aq),
NaH3SiO4(aq), H3SiO4-]
thermo: Debye-Huckel
activity-data:
model: Pitzer-with-beta_ij
A_Debye: variable
B_Debye: 3.28640E9 kg^0.5/gmol^0.5/m
default-ionic-radius: 3.042843 angstrom
beta:
- species: [H+, Cl-]
beta: 0.27
- species: [Na+, Cl-]
beta: 0.15
- species: [Na+, OH-]
beta: 0.06
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 3.0, Cl-: 3.0, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-beta_ij
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
Expand All @@ -94,6 +168,28 @@ phases:
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 3.0, Cl-: 3.0, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}
- name: debye-huckel-beta_ij-IAPWS
elements: [O, H, C, E, Fe, Si, N, Na, Cl]
species:
- water_IAPWS: [H2O(L)]
- species_waterSolution: [Na+, Cl-, H+, OH-, NaCl(aq), NaOH(aq), SiO2(aq),
NaH3SiO4(aq), H3SiO4-]
thermo: Debye-Huckel
activity-data:
model: beta_ij
A_Debye: variable
B_Debye: 3.28640E9 kg^0.5/gmol^0.5/m
default-ionic-radius: 3.042843 angstrom
beta:
- species: [H+, Cl-]
beta: 0.27
- species: [Na+, Cl-]
beta: 0.15
- species: [Na+, OH-]
beta: 0.06
state: {T: 300.0 K, P: 1.01325e+05 Pa, molalities: {Na+: 3.0, Cl-: 3.0, H+: 1.0499e-08,
OH-: 1.3765e-06, NaCl(aq): 0.98492, NaOH(aq): 3.8836e-06, NaH3SiO4(aq): 6.8798e-05,
SiO2(aq): 3.0179e-05, H3SiO4-: 1.0231e-06}}

species_waterSolution:
- name: H2O(L)
Expand Down Expand Up @@ -266,3 +362,9 @@ species_waterSolution:
Debye-Huckel:
electrolyte-species-type: charged-species
weak-acid-charge: -1.0

water_IAPWS:
- name: H2O(L)
composition: {H: 2, O: 1}
equation-of-state:
model: liquid-water-IAPWS95
10 changes: 5 additions & 5 deletions test/thermo/water_iapws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ TEST_F(WaterPropsIAPWS_Test, normal_boiling_point)

rho = water.density(T, P, WATER_GAS);
EXPECT_NEAR(rho, 0.597651, 2e-6);
EXPECT_NEAR(water.isothermalCompressibility(), 1.003322548320e-05, 2e-17);
EXPECT_NEAR(water.isothermalCompressibility(), 1.003322546019e-05, 2e-17);

rho = water.density(T, P * 0.999, WATER_GAS);
EXPECT_NEAR(rho, 0.597043, 2e-6);
EXPECT_NEAR(water.isothermalCompressibility(), 1.004307957351e-05, 2e-17);
EXPECT_NEAR(water.isothermalCompressibility(), 1.004307955057e-05, 2e-17);
}

TEST_F(WaterPropsIAPWS_Test, saturation_pressure_estimate)
Expand All @@ -126,9 +126,9 @@ TEST_F(WaterPropsIAPWS_Test, expansion_coeffs)
{
vector_fp TT{300.0, 300.0, 700.0};
vector_fp PP{10.0, 10.0e6, 10.0e6};
vector_fp alpha{0.003333433139236, -0.02277763412159, 0.002346416497423};
vector_fp beta{1.000020308917, 1265.572840683, 1.240519801360};
vector_fp beta_num{1.0000203087, 1265.46651311, 1.2405192825};
vector_fp alpha{0.003333433139236, -0.02277763412159, 0.002346416506367};
vector_fp beta{1.000020308917, 1265.572840683, 1.240519803181};
vector_fp beta_num{1.0000203087, 1265.46651311, 1.2405192843};
for (size_t i = 0; i < TT.size(); i++) {
double rho = water.density(TT[i], PP[i], WATER_GAS);
water.setState_TD(TT[i], rho);
Expand Down
Loading