Skip to content

Commit d0d3834

Browse files
committed
Add Forge system
1 parent e901104 commit d0d3834

File tree

3 files changed

+128
-2
lines changed

3 files changed

+128
-2
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ set( hpcReact_headers
33
common/macros.hpp
44
common/CArrayWrapper.hpp
55
reactions/exampleSystems/BulkGeneric.hpp
6-
reactions/geochemistry/GeochemicalSystems.hpp
76
reactions/geochemistry/Carbonate.hpp
7+
reactions/geochemistry/Forge.hpp
8+
reactions/geochemistry/GeochemicalSystems.hpp
89
reactions/geochemistry/Ultramafics.hpp
910
reactions/massActions/MassActions.hpp
1011
reactions/reactionsSystems/EquilibriumReactions.hpp
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#pragma once
2+
3+
#include "../reactionsSystems/Parameters.hpp"
4+
5+
namespace hpcReact
6+
{
7+
8+
namespace geochemistry
9+
{
10+
11+
namespace forge
12+
{
13+
14+
// Stoichiometric matrix [13 reactions × 23 species]
15+
// Columns 0–12: secondary species (must be -1 on diagonal)
16+
// Columns 13–22: primary species
17+
constexpr CArrayWrapper< double, 19, 26 > soichMatrix =
18+
{// CaCO₃ CaHCO₃⁺ CaSO₄ CaCl⁺ CaCl₂ MgHCO₃⁺ MgCO₃ MgCl⁺ CO₂(aq) HSO₄⁻ KHSO₄ HSiO₃⁻ NaHSilO₃ NaCl KCl KSO₄⁻ | H⁺ Ca²⁺ Mg²⁺ Na⁺ K⁺ Al³⁺ HCO₃⁻ SO₄²⁻ Cl⁻ SiO₂(aq)
19+
{ -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, 0, 0, 0 }, // CaCO₃(aq) + H⁺ ⇌ Ca²⁺ + HCO₃⁻
20+
{ 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1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 0, 1, 0, 1, 0, 3 } // Albite: NaAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + Na⁺ + 3SiO₂(aq)
38+
};
39+
40+
constexpr CArrayWrapper< double, 19 > equilibriumConstants =
41+
{
42+
5.9636, // CaCO₃(aq) + H⁺ ⇌ Ca²⁺ + HCO₃⁻
43+
-1.4181, // CaHCO₃⁺ ⇌ Ca²⁺ + HCO₃⁻
44+
-2.5111, // CaSO₄ ⇌ Ca²⁺ + SO₄²⁻
45+
0.3811, // CaCl⁺ ⇌ Ca²⁺ + Cl⁻
46+
0.3811, // CaCl₂ ⇌ Ca²⁺ + 2Cl⁻ (approximate, same source)
47+
-1.4355, // MgHCO₃⁺ ⇌ Mg²⁺ + HCO₃⁻
48+
-6.5632, // MgCO₃(aq) + H⁺ ⇌ Mg²⁺ + HCO₃⁻
49+
-0.1820, // MgCl⁺ ⇌ Mg²⁺ + Cl⁻
50+
-6.3882, // CO₂(aq) + H₂O ⇌ H⁺ + HCO₃⁻
51+
-3.0020, // HSO₄⁻ ⇌ H⁺ + SO₄²⁻
52+
-2.2935, // KHSO₄ ⇌ H⁺ + K⁺ + SO₄²⁻
53+
-9.0844, // HSiO₃⁻ ⇌ H⁺ + SiO₂(aq)
54+
-7.8291, // NaHSilO₃ ⇌ H⁺ + Na⁺ + SiO₂(aq)
55+
0.4730, // NaCl ⇌ Na⁺ + Cl⁻
56+
0.9240, // KCl ⇌ K⁺ + Cl⁻
57+
-1.1946, // KSO₄⁻ ⇌ K⁺ + SO₄²⁻
58+
0.0944, // Dolomite: CaMg(CO₃)₂(s) + 2H⁺ ⇌ Ca²⁺ + Mg²⁺ + 2HCO₃⁻
59+
-1.8683, // Microcline: KAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + K⁺ + 3SiO₂(aq)
60+
0.2236 // Albite: NaAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + Na⁺ + 3SiO₂(aq)
61+
};
62+
63+
constexpr CArrayWrapper< double, 19 > fwRateConstant =
64+
{
65+
0.0, // CaCO₃(aq) + H⁺ ⇌ Ca²⁺ + HCO₃⁻
66+
0.0, // CaHCO₃⁺ ⇌ Ca²⁺ + HCO₃⁻
67+
0.0, // CaSO₄ ⇌ Ca²⁺ + SO₄²⁻
68+
0.0, // CaCl⁺ ⇌ Ca²⁺ + Cl⁻
69+
0.0, // CaCl₂ ⇌ Ca²⁺ + 2Cl⁻ (approximate, same source)
70+
0.0, // MgHCO₃⁺ ⇌ Mg²⁺ + HCO₃⁻
71+
0.0, // MgCO₃(aq) + H⁺ ⇌ Mg²⁺ + HCO₃⁻
72+
0.0, // MgCl⁺ ⇌ Mg²⁺ + Cl⁻
73+
0.0, // CO₂(aq) + H₂O ⇌ H⁺ + HCO₃⁻
74+
0.0, // HSO₄⁻ ⇌ H⁺ + SO₄²⁻
75+
0.0, // KHSO₄ ⇌ H⁺ + K⁺ + SO₄²⁻
76+
0.0, // HSiO₃⁻ ⇌ H⁺ + SiO₂(aq)
77+
0.0, // NaHSilO₃ ⇌ H⁺ + Na⁺ + SiO₂(aq)
78+
0.0, // NaCl ⇌ Na⁺ + Cl⁻
79+
0.0, // KCl ⇌ K⁺ + Cl⁻
80+
0.0, // KSO₄⁻ ⇌ K⁺ + SO₄²⁻
81+
1.0, // Dolomite: CaMg(CO₃)₂(s) + 2H⁺ ⇌ Ca²⁺ + Mg²⁺ + 2HCO₃⁻
82+
1.0, // Microcline: KAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + K⁺ + 3SiO₂(aq)
83+
1.0 // Albite: NaAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + Na⁺ + 3SiO₂(aq)
84+
};
85+
86+
87+
constexpr CArrayWrapper< double, 19 > reverseRateConstant =
88+
{
89+
0.0, // CaCO₃(aq) + H⁺ ⇌ Ca²⁺ + HCO₃⁻
90+
0.0, // CaHCO₃⁺ ⇌ Ca²⁺ + HCO₃⁻
91+
0.0, // CaSO₄ ⇌ Ca²⁺ + SO₄²⁻
92+
0.0, // CaCl⁺ ⇌ Ca²⁺ + Cl⁻
93+
0.0, // CaCl₂ ⇌ Ca²⁺ + 2Cl⁻ (approximate, same source)
94+
0.0, // MgHCO₃⁺ ⇌ Mg²⁺ + HCO₃⁻
95+
0.0, // MgCO₃(aq) + H⁺ ⇌ Mg²⁺ + HCO₃⁻
96+
0.0, // MgCl⁺ ⇌ Mg²⁺ + Cl⁻
97+
0.0, // CO₂(aq) + H₂O ⇌ H⁺ + HCO₃⁻
98+
0.0, // HSO₄⁻ ⇌ H⁺ + SO₄²⁻
99+
0.0, // KHSO₄ ⇌ H⁺ + K⁺ + SO₄²⁻
100+
0.0, // HSiO₃⁻ ⇌ H⁺ + SiO₂(aq)
101+
0.0, // NaHSilO₃ ⇌ H⁺ + Na⁺ + SiO₂(aq)
102+
0.0, // NaCl ⇌ Na⁺ + Cl⁻
103+
0.0, // KCl ⇌ K⁺ + Cl⁻
104+
0.0, // KSO₄⁻ ⇌ K⁺ + SO₄²⁻
105+
1.0, // Dolomite: CaMg(CO₃)₂(s) + 2H⁺ ⇌ Ca²⁺ + Mg²⁺ + 2HCO₃⁻
106+
1.0, // Microcline: KAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + K⁺ + 3SiO₂(aq)
107+
1.0 // Albite: NaAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + Na⁺ + 3SiO₂(aq)
108+
};
109+
110+
111+
112+
113+
}
114+
115+
using forgeSystemType = reactionsSystems::MixedReactionsParameters< double, int, int, 26, 19, 16 >;
116+
117+
118+
constexpr forgeSystemType forgeSystem( forge::soichMatrix, forge::equilibriumConstants, forge::fwRateConstant, forge::reverseRateConstant );
119+
120+
121+
}
122+
123+
}

src/reactions/geochemistry/GeochemicalSystems.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "Carbonate.hpp"
44
#include "Ultramafics.hpp"
5+
#include "Forge.hpp"
56

67
namespace hpcReact
78
{
@@ -10,7 +11,8 @@ namespace geochemistry
1011
{
1112
using systemTypes = std::variant< ultramaficSystemType,
1213
carbonateSystemType,
13-
carbonateSystemAllEquilibriumType >;
14+
carbonateSystemAllEquilibriumType,
15+
forgeSystemType >;
1416

1517
} // namespace geochemistry
1618
} // namespace hpcReact

0 commit comments

Comments
 (0)