Skip to content

Commit 3aac5c6

Browse files
committed
Added a unit test for the FORGE reaction system, currently just to test the convergence and not validate against a known solution
1 parent 4a7a310 commit 3aac5c6

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

src/reactions/geochemistry/GeochemicalSystems.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ namespace hpcReact
2222

2323
namespace geochemistry
2424
{
25-
using systemTypes = std::variant< ultramaficSystemType,
26-
carbonateSystemType,
25+
using systemTypes = std::variant< carbonateSystemType,
2726
carbonateSystemAllEquilibriumType,
27+
ultramaficSystemType,
2828
forgeSystemType >;
2929

3030
} // namespace geochemistry

src/reactions/geochemistry/unitTests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set( testSourceFiles
33
testGeochemicalEquilibriumReactions.cpp
44
testGeochemicalKineticReactions.cpp
55
testGeochemicalMixedReactions.cpp
6+
testForgeReactions.cpp
67
)
78

89
set( dependencyList hpcReact gtest )
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* ------------------------------------------------------------------------------------------------------------
3+
* SPDX-License-Identifier: (BSD-3-Clause)
4+
*
5+
* Copyright (c) 2025- Lawrence Livermore National Security LLC
6+
* All rights reserved
7+
*
8+
* See top level LICENSE files for details.
9+
* ------------------------------------------------------------------------------------------------------------
10+
*/
11+
12+
#include "reactions/unitTestUtilities/mixedReactionsTestUtilities.hpp"
13+
#include "../GeochemicalSystems.hpp"
14+
15+
16+
using namespace hpcReact;
17+
using namespace hpcReact::unitTest_utilities;
18+
19+
20+
TEST( testForgeReactions, testTimeStep_forgeSystem )
21+
{
22+
using namespace hpcReact::geochemistry;
23+
24+
static constexpr int numPrimarySpecies = forgeSystemType::numPrimarySpecies();
25+
26+
double const surfaceArea[forgeSystemType::numKineticReactions()] =
27+
{
28+
1.0, 1.0, 1.0, 1.0, 1.0 // SiO2(s), KAlMg3Si3O10(OH)2(s), CaAl2(SiO4)2(s), KAlSi3O8(s), Al2Si2O5(OH)4(s)
29+
};
30+
31+
double const initialAggregateSpeciesConcentration[numPrimarySpecies] =
32+
{
33+
5e-08, // H+
34+
8.3991e-0, // Ca+2
35+
0.00014146, // Mg+2
36+
0.0034061, // Na+
37+
0.00020949, // K+
38+
2.3494e-08, // Al+++
39+
0.0016047, // HCO3-
40+
0.00038069, // SO4-2
41+
0.0010018, // Cl-
42+
4.4047e-06 //SiO2(aq)
43+
};
44+
45+
double const expectedSpeciesConcentrations[numPrimarySpecies] =
46+
{
47+
5e-08, // H+
48+
8.3991e-0, // Ca+2
49+
0.00014146, // Mg+2
50+
0.0034061, // Na+
51+
0.00020949, // K+
52+
2.3494e-08, // Al+++
53+
0.0016047, // HCO3-
54+
0.00038069, // SO4-2
55+
0.0010018, // Cl-
56+
4.4047e-06 //SiO2(aq)
57+
};
58+
59+
timeStepTest< double, true >( forgeSystem,
60+
1.e-3,
61+
10,
62+
initialAggregateSpeciesConcentration,
63+
surfaceArea,
64+
expectedSpeciesConcentrations );
65+
66+
}
67+
68+
int main( int argc, char * * argv )
69+
{
70+
::testing::InitGoogleTest( &argc, argv );
71+
int const result = RUN_ALL_TESTS();
72+
return result;
73+
}

src/reactions/unitTestUtilities/mixedReactionsTestUtilities.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void timeStepTest( PARAMS_DATA const & params,
130130
}
131131
};
132132

133-
nonlinearSolvers::newtonRaphson< numPrimarySpecies >( logPrimarySpeciesConcentration, computeResidualAndJacobian );
133+
nonlinearSolvers::newtonRaphson< numPrimarySpecies >( logPrimarySpeciesConcentration, computeResidualAndJacobian, 25 );
134134

135135
time += dt;
136136
}

0 commit comments

Comments
 (0)