Skip to content
Open
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
8 changes: 6 additions & 2 deletions src/reactions/exampleSystems/BulkGeneric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ simpleKineticTestRateParams =
// forward rate constants
{ 1.0, 0.5 },
// reverse rate constants
{ 1.0, 0.5 }
{ 1.0, 0.5 },
// flag of mobile secondary species
{ 1, 1 }
};

using simpleTestType = reactionsSystems::MixedReactionsParameters< double, int, int, 5, 2, 2 >;
Expand All @@ -80,7 +82,9 @@ simpleTestRateParams =
// forward rate constants
{ 1.0, 0.5 },
// reverse rate constants
{ 1.0, 0.5 }
{ 1.0, 0.5 },
// flag of mobile secondary species
{ 1, 1 }
};

// *****UNCRUSTIFY-ON******
Expand Down
30 changes: 20 additions & 10 deletions src/reactions/exampleSystems/MoMasBenchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace MomMasBenchmark
// Columns 7–11 are primary species: {X1, X2, X3, X4, S}
{
// C1 C2 C3 C4 C5 CS1 CS2 | X1 X2 X3 X4 S
{ -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 }, // C1 = X2
{ 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }, // C2 = X2 * X3
{ 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 1, 0 }, // C3 = X2 * X4
{ -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 }, // C1 = -X2
{ 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }, // C2 = X2 + X3
{ 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 1, 0 }, // C3 = X2 + X4
{ 0, 0, 0, -1, 0, 0, 0, 0, -4, 1, 3, 0 }, // C4 = -4X2 + X3 + 3X4
{ 0, 0, 0, 0, -1, 0, 0, 0, 4, 3, 1, 0 }, // C5 = 4X2 + 3X3 + X4
{ 0, 0, 0, 0, 0, -1, 0, 0, 3, 1, 0, 1 }, // CS1 = 3X2 + X3 + S
Expand All @@ -39,13 +39,13 @@ namespace MomMasBenchmark

// Equilibrium constants K
{
1.0e-12, // C1
1.0, // C2
1.0, // C3
0.1, // C4
1.0e35, // C5
1.0e6, // CS1
1.0e-1 // CS2
1.0e12, // C1 + X2 = ??
1.0, // C2 = X2 + X3
1.0, // C3 = X2 + X4
1.0e1, // C4 + 4X2 = X3 + 3X4
1.0e-35, // C5 = 4X2 + 3X3 + X4
1.0e-6, // CS1 = 3X2 + X3 + S
1.0e1 // CS2 + 3X2 = + X4 + 2S
},

// Forward rate constants
Expand All @@ -67,6 +67,16 @@ namespace MomMasBenchmark
0.0,
0.0
},

// Flag of mobile secondary species
{ 1, // C1 = - X2
1, // C2 = X2 + X3
1, // C3 = -X2 + X4
1, // C4 = -4X2 + X3 + 3X4
1, // C5 = 4X2 + 3X3 + X4
0, // CS1 = 3X2 + X3 + S
0 // CS2 = -3X2 + X4 + 2S
}
};

// *****UNCRUSTIFY-ON******
Expand Down
26 changes: 20 additions & 6 deletions src/reactions/geochemistry/Carbonate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ constexpr CArrayWrapper<double, 11> equilibriumConstants =
3.98E+00, // CaCl2 = Ca+2 + 2Cl-
3.72E-03, // MgSO4 = Mg+2 + SO4-2
1.51E-01, // NaSO4- = Na+ + SO4-2
1.17E+07 // CaCO3 + H+ = Ca+2 + HCO3- (kinetic)
70.55 // CaCO3 + H+ = Ca+2 + HCO3- (kinetic)
// 1
}; // Ca(OH)2​(s) + 2H+ = Ca2+ + 2H2​O (kinetic)

Expand All @@ -85,7 +85,7 @@ constexpr CArrayWrapper<double, 11> forwardRates =
1.0e7, // CaCl2 = Ca+2 + 2Cl-
1.0e5, // MgSO4 = Mg+2 + SO4-2
1.0e7, // NaSO4- = Na+ + SO4-2
1.0e5 // CaCO3 + H+ = Ca+2 + HCO3- (kinetic)
1.55e-6 // CaCO3 + H+ = Ca+2 + HCO3- (kinetic)

// 1
}; // Ca(OH)2​(s) + 2H+ = Ca2+ + 2H2​O (kinetic)
Expand All @@ -101,17 +101,31 @@ constexpr CArrayWrapper<double, 11> reverseRates =
2.51E+06, // CaCl2 = Ca+2 + 2Cl-
2.69E+07, // MgSO4 = Mg+2 + SO4-2
6.62E+07, // NaSO4- = Na+ + SO4-2
8.55E-03 // CaCO3 + H+ = Ca+2 + HCO3-
2.197e-8 // CaCO3 + H+ = Ca+2 + HCO3-
// 1 // Ca(OH)2​(s) + 2H+ = Ca2+ + 2H2​O (kinetic)
};

constexpr CArrayWrapper<int, 11> mobileSpeciesFlag =
{ 1, // OH- + H+ = H2O
1, // CO2 + H2O = H+ + HCO3-
1, // CO3-2 + H+ = HCO3-
1, // H2CO3 = H+ + HCO3-
1, // CaHCO3+ = Ca+2 + HCO3-
1, // CaSO4 = Ca+2 + SO4-2
1, // CaCl+ = Ca+2 + Cl-
1, // CaCl2 = Ca+2 + 2Cl-
1, // MgSO4 = Mg+2 + SO4-2
1, // NaSO4- = Na+ + SO4-2
1 // CaCO3 + H+ = Ca+2 + HCO3-
};
}
using carbonateSystemAllKineticType = reactionsSystems::MixedReactionsParameters< double, int, int, 18, 11, 0 >;
using carbonateSystemAllEquilibriumType = reactionsSystems::MixedReactionsParameters< double, int, int, 18, 11, 11 >;
using carbonateSystemType = reactionsSystems::MixedReactionsParameters< double, int, int, 17, 11, 10 >;

constexpr carbonateSystemAllKineticType carbonateSystemAllKinetic( carbonate::stoichMatrix, carbonate::equilibriumConstants, carbonate::forwardRates, carbonate::reverseRates );
constexpr carbonateSystemAllEquilibriumType carbonateSystemAllEquilibrium( carbonate::stoichMatrix, carbonate::equilibriumConstants, carbonate::forwardRates, carbonate::reverseRates );
constexpr carbonateSystemType carbonateSystem( carbonate::stoichMatrixNosolid, carbonate::equilibriumConstants, carbonate::forwardRates, carbonate::reverseRates );
constexpr carbonateSystemAllKineticType carbonateSystemAllKinetic( carbonate::stoichMatrix, carbonate::equilibriumConstants, carbonate::forwardRates, carbonate::reverseRates, carbonate::mobileSpeciesFlag );
constexpr carbonateSystemAllEquilibriumType carbonateSystemAllEquilibrium( carbonate::stoichMatrix, carbonate::equilibriumConstants, carbonate::forwardRates, carbonate::reverseRates, carbonate::mobileSpeciesFlag );
constexpr carbonateSystemType carbonateSystem( carbonate::stoichMatrixNosolid, carbonate::equilibriumConstants, carbonate::forwardRates, carbonate::reverseRates, carbonate::mobileSpeciesFlag );

// *****UNCRUSTIFY-ON******
} // namespace geochemistry
Expand Down
25 changes: 24 additions & 1 deletion src/reactions/geochemistry/Forge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,35 @@ constexpr CArrayWrapper< double, 19 > reverseRateConstant =
1.0 // Albite: NaAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + Na⁺ + 3SiO₂(aq)
};

constexpr CArrayWrapper< int, 19 > mobileSpeciesFlag =
{
1, // CaCO₃(aq) + H⁺ ⇌ Ca²⁺ + HCO₃⁻
1, // CaHCO₃⁺ ⇌ Ca²⁺ + HCO₃⁻
1, // CaSO₄ ⇌ Ca²⁺ + SO₄²⁻
1, // CaCl⁺ ⇌ Ca²⁺ + Cl⁻
1, // CaCl₂ ⇌ Ca²⁺ + 2Cl⁻ (approximate, same source)
1, // MgHCO₃⁺ ⇌ Mg²⁺ + HCO₃⁻
1, // MgCO₃(aq) + H⁺ ⇌ Mg²⁺ + HCO₃⁻
1, // MgCl⁺ ⇌ Mg²⁺ + Cl⁻
1, // CO₂(aq) + H₂O ⇌ H⁺ + HCO₃⁻
1, // HSO₄⁻ ⇌ H⁺ + SO₄²⁻
1, // KHSO₄ ⇌ H⁺ + K⁺ + SO₄²⁻
1, // HSiO₃⁻ ⇌ H⁺ + SiO₂(aq)
1, // NaHSilO₃ ⇌ H⁺ + Na⁺ + SiO₂(aq)
1, // NaCl ⇌ Na⁺ + Cl⁻
1, // KCl ⇌ K⁺ + Cl⁻
1, // KSO₄⁻ ⇌ K⁺ + SO₄²⁻
1, // Dolomite: CaMg(CO₃)₂(s) + 2H⁺ ⇌ Ca²⁺ + Mg²⁺ + 2HCO₃⁻
1, // Microcline: KAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + K⁺ + 3SiO₂(aq)
1 // Albite: NaAlSi₃O₈(s) + 4H⁺ ⇌ Al³⁺ + Na⁺ + 3SiO₂(aq)
};

}

using forgeSystemType = reactionsSystems::MixedReactionsParameters< double, int, int, 26, 19, 16 >;


constexpr forgeSystemType forgeSystem( forge::soichMatrix, forge::equilibriumConstants, forge::fwRateConstant, forge::reverseRateConstant );
constexpr forgeSystemType forgeSystem( forge::soichMatrix, forge::equilibriumConstants, forge::fwRateConstant, forge::reverseRateConstant, forge::mobileSpeciesFlag );


// *****UNCRUSTIFY-ON******
Expand Down
93 changes: 93 additions & 0 deletions src/reactions/geochemistry/Momas.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: (BSD-3-Clause)
*
* Copyright (c) 2025- Lawrence Livermore National Security LLC
* All rights reserved
*
* See top level LICENSE files for details.
* ------------------------------------------------------------------------------------------------------------
*/

#pragma once

#include "../reactionsSystems/Parameters.hpp"

namespace hpcReact
{

namespace geochemistry
{
// turn off uncrustify to allow for better readability of the parameters
// *****UNCRUSTIFY-OFF******

namespace momas
{

constexpr CArrayWrapper<double, 7, 12> stoichMatrix =
{
// C1 C2 C3 C4 C5 CS1 CS2 | X1 X2 X3 X4 S
{ -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 }, // C1 = -X2
{ 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }, // C2 = X2 + X3
{ 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 1, 0 }, // C3 = X2 + X4
{ 0, 0, 0, -1, 0, 0, 0, 0, -4, 1, 3, 0 }, // C4 = -4X2 + X3 + 3X4
{ 0, 0, 0, 0, -1, 0, 0, 0, 4, 3, 1, 0 }, // C5 = 4X2 + 3X3 + X4
{ 0, 0, 0, 0, 0, -1, 0, 0, 3, 1, 0, 1 }, // CS1 = 3X2 + X3 + S
{ 0, 0, 0, 0, 0, 0, -1, 0, -3, 0, 1, 2 } // CS2 = -3X2 + X4 + 2S
};

constexpr CArrayWrapper<double, 7> equilibriumConstants =
{
1.0e12, // C1 + X2 = ??
1.0, // C2 = X2 + X3
1.0, // C3 = X2 + X4
1.0e1, // C4 + 4X2 = X3 + 3X4
1.0e-35, // C5 = 4X2 + 3X3 + X4
1.0e-6, // CS1 = 3X2 + X3 + S
1.0e1 // CS2 + 3X2 = + X4 + 2S
};

constexpr CArrayWrapper<double, 7> forwardRates =
{
0.0, // C1 = -X2
0.0, // C2 = X2 + X3
0.0, // C3 = X2 + X4
0.0, // C4 = -4X2 + X3 + 3X4
0.0, // C5 = 4X2 + 3X3 + X4
0.0, // CS1 = 3X2 + X3 + S
0.0 // CS2 = -3X2 + X4 + 2S
};

constexpr CArrayWrapper<double, 7> reverseRates =
{
0.0, // C1 = -X2
0.0, // C2 = X2 + X3
0.0, // C3 = X2 + X4
0.0, // C4 = -4X2 + X3 + 3X4
0.0, // C5 = 4X2 + 3X3 + X4
0.0, // CS1 = 3X2 + X3 + S
0.0 // CS2 = -3X2 + X4 + 2S
};

constexpr CArrayWrapper<int, 7> mobileSpeciesFlag =
{
1, // C1 = -X2
1, // C2 = X2 + X3
1, // C3 = X2 + X4
1, // C4 = -4X2 + X3 + 3X4
1, // C5 = 4X2 + 3X3 + X4
0, // CS1 = 3X2 + X3 + S
0 // CS2 = -3X2 + X4 + 2S
};
}
using momasSystemAllKineticType = reactionsSystems::MixedReactionsParameters< double, int, int, 12, 7, 0 >;
using momasSystemAllEquilibriumType = reactionsSystems::MixedReactionsParameters< double, int, int, 12, 7, 7 >;
using momasSystemType = reactionsSystems::MixedReactionsParameters< double, int, int, 12, 7, 7 >;

constexpr momasSystemAllKineticType momasSystemAllKinetic( momas::stoichMatrix, momas::equilibriumConstants, momas::forwardRates, momas::reverseRates, momas::mobileSpeciesFlag );
constexpr momasSystemAllEquilibriumType momasSystemAllEquilibrium( momas::stoichMatrix, momas::equilibriumConstants, momas::forwardRates, momas::reverseRates, momas::mobileSpeciesFlag );
constexpr momasSystemType carbonateSystem( momas::stoichMatrix, momas::equilibriumConstants, momas::forwardRates, momas::reverseRates, momas::mobileSpeciesFlag );

// *****UNCRUSTIFY-ON******
} // namespace geochemistry
} // namespace hpcReact
33 changes: 29 additions & 4 deletions src/reactions/geochemistry/Ultramafics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,40 @@ constexpr CArrayWrapper<double, 21> reverseRates =
2.83E-44, // Mg3Si2O5(OH)4 + 6H+ = 3Mg++ + 2SiO2(aq) + 5H2O
2.10E-25 // Mg(OH)2 + 2H+ = Mg++ + 2H2O
};
};

constexpr CArrayWrapper<int, 21> mobileSpeciesFlag =
{
1, // OH- + H+ = H2O
1, // CO2(aq) + H2O = HCO3- + H+
1, // CO3-- + H+ = HCO3-
1, // Mg2OH+++ + H+ = 2Mg++ + H2O
1, // Mg4(OH)++++ + 4H+ = 4Mg++ + 4H2O
1, // MgOH+ + H+ = Mg++ + H2O
1, // Mg2CO3++ + H+ = 2Mg++ + HCO3-
1, // MgCO3 + H+ = Mg++ + HCO3-
1, // MgHCO3+ = Mg++ + HCO3-
1, // Mg(H3SiO4)2 + 2H+ = Mg++ + SiO2(aq) + 4H2O
1, // MgH2SiO4 + 2H+ = Mg++ + SiO2(aq) + 2H2O
1, // MgH3SiO4+ + H+ = Mg++ + SiO2(aq) + 2H2O
1, // H2SiO4-- + 2H+ = SiO2(aq) + 2H2O
1, // H3SiO4- + H+ = SiO2(aq) + 2H2O
1, // H4(H2SiO4)---- + 4H+ = 4SiO2(aq) + 8H2O
1, // H6(H2SiO4)-- + 2H+ = 4SiO2 + 8H2O
1, // Mg2SiO4 + 4H+ = 2Mg++ + SiO2(aq) + 2H2O
1, // MgCO3 + H+ = Mg++ + HCO3-
1, // SiO2 = SiO2(aq)
1, // Mg3Si2O5(OH)4 + 6H+ = 3Mg++ + 2SiO2(aq) + 5H2O
1 // Mg(OH)2 + 2H+ = Mg++ + 2H2O
};
}

using ultramaficSystemAllKineticType = reactionsSystems::MixedReactionsParameters< double, int, int, 25, 21, 0 >;
using ultramaficSystemAllEquilibriumType = reactionsSystems::MixedReactionsParameters< double, int, int, 25, 21, 21 >;
using ultramaficSystemType = reactionsSystems::MixedReactionsParameters< double, int, int, 25, 21, 16 >;

constexpr ultramaficSystemAllKineticType ultramaficSystemAllKinetic( ultramafics::stoichMatrix, ultramafics::equilibriumConstants, ultramafics::forwardRates, ultramafics::reverseRates );
constexpr ultramaficSystemAllEquilibriumType ultramaficSystemAllEquilibrium( ultramafics::stoichMatrix, ultramafics::equilibriumConstants, ultramafics::forwardRates, ultramafics::reverseRates );
constexpr ultramaficSystemType ultramaficSystem( ultramafics::stoichMatrix, ultramafics::equilibriumConstants, ultramafics::forwardRates, ultramafics::reverseRates );
constexpr ultramaficSystemAllKineticType ultramaficSystemAllKinetic( ultramafics::stoichMatrix, ultramafics::equilibriumConstants, ultramafics::forwardRates, ultramafics::reverseRates, ultramafics::mobileSpeciesFlag );
constexpr ultramaficSystemAllEquilibriumType ultramaficSystemAllEquilibrium( ultramafics::stoichMatrix, ultramafics::equilibriumConstants, ultramafics::forwardRates, ultramafics::reverseRates, ultramafics::mobileSpeciesFlag );
constexpr ultramaficSystemType ultramaficSystem( ultramafics::stoichMatrix, ultramafics::equilibriumConstants, ultramafics::forwardRates, ultramafics::reverseRates, ultramafics::mobileSpeciesFlag );

// *****UNCRUSTIFY-ON******
} // namespace geochemistry
Expand Down
1 change: 1 addition & 0 deletions src/reactions/geochemistry/unitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set( testSourceFiles
testGeochemicalEquilibriumReactions.cpp
testGeochemicalKineticReactions.cpp
testGeochemicalMixedReactions.cpp
testMomasEasyCase.cpp
)

set( dependencyList hpcReact gtest )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ TEST( testEquilibriumReactions, testcarbonateSystemAllEquilibrium2 )
};

double logPrimarySpeciesConcentration[numPrimarySpecies];
EquilibriumReactionsType::enforceEquilibrium_Aggregate( 0,
hpcReact::geochemistry::carbonateSystemAllEquilibrium.equilibriumReactionsParameters(),
logInitialPrimarySpeciesConcentration,
logPrimarySpeciesConcentration );
EquilibriumReactionsType::enforceEquilibrium_LogAggregate( 0,
hpcReact::geochemistry::carbonateSystemAllEquilibrium.equilibriumReactionsParameters(),
logInitialPrimarySpeciesConcentration,
logPrimarySpeciesConcentration );

double const expectedPrimarySpeciesConcentrations[numPrimarySpecies] =
{
Expand Down
Loading
Loading