Skip to content

Commit 33e1c6d

Browse files
committed
add parameter set for bicarbonate reactions...and add sample test
1 parent d4bc33b commit 33e1c6d

File tree

8 files changed

+97
-76
lines changed

8 files changed

+97
-76
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ set( hpcReact_headers
33
common/macros.hpp
44
common/CArrayWrapper.hpp
55
reactions/base/ReactionsParametersBase.hpp
6-
reactions/bulkGeneric/EquilibriumReactions.hpp
76
reactions/bulkGeneric/KineticReactions.hpp
8-
reactions/bulkGeneric/ReactionsBase.hpp
97
reactions/bulkGeneric/Parameters.hpp
108
reactions/bulkGeneric/ParametersPredefined.hpp
119
)
@@ -53,6 +51,7 @@ target_include_directories( hpcReact
5351
# hpcReact_add_code_checks( PREFIX hpcReact
5452
# EXCLUDES "blt/*" )
5553

54+
add_subdirectory( reactions/bulkDebyeHuckel/unitTests )
5655
add_subdirectory( reactions/bulkGeneric/unitTests )
5756

5857

src/reactions/bulkDebyeHuckel/unitTests/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Specify list of tests
22
set( testSourceFiles
3-
testEquilibriumReactions.cpp
4-
testKineticReactions.cpp
53
testReactionsBase.cpp )
64

75
set( dependencyList hpcReact gtest )

src/reactions/bulkGeneric/KineticReactions.hpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,32 @@
11
#pragma once
22

3-
#include "ReactionsBase.hpp"
43
#include "common/macros.hpp"
54

65
namespace hpcReact
76
{
8-
namespace bulkDebyeHuckel
7+
namespace bulkGeneric
98
{
109

1110
template< typename REAL_TYPE,
1211
typename REAL_DATA_ARRAY_1D_VIEW_TYPE,
1312
typename REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE,
1413
typename INT_TYPE,
1514
typename INDEX_TYPE >
16-
class KineticReactions : public ReactionsBase< REAL_TYPE,
17-
REAL_DATA_ARRAY_1D_VIEW_TYPE,
18-
REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE,
19-
INT_TYPE,
20-
INDEX_TYPE >
15+
class KineticReactions
2116
{
2217
public:
2318

24-
using Base = ReactionsBase< REAL_TYPE,
25-
REAL_DATA_ARRAY_1D_VIEW_TYPE,
26-
REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE,
27-
INT_TYPE,
28-
INDEX_TYPE >;
29-
30-
using typename Base::RealType;
31-
using typename Base::RealDataArrayView1d;
32-
using typename Base::RealConstDataArrayView1d;
33-
using typename Base::IntType;
34-
using typename Base::IndexType;
19+
using RealType = REAL_TYPE;
20+
using RealDataArrayView1d = REAL_DATA_ARRAY_1D_VIEW_TYPE;
21+
using RealConstDataArrayView1d = REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE;
22+
using IntType = INT_TYPE;
23+
using IndexType = INDEX_TYPE;
3524

3625
template< typename PARAMS_DATA >
3726
static HPCREACT_HOST_DEVICE inline void
3827
computeReactionRates( RealType const & temperature,
3928
PARAMS_DATA const & params,
40-
RealConstDataArrayView1d & primarySpeciesConcentration,
41-
RealConstDataArrayView1d & secondarySpeciesConcentration,
29+
RealConstDataArrayView1d const & primarySpeciesConcentration,
4230
RealDataArrayView1d & reactionRates );
4331

4432

src/reactions/bulkGeneric/KineticReactions_impl.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include "KineticReactions.hpp"
2+
#include "common/constants.hpp"
23
#include "common/macros.hpp"
34

5+
#include <cmath>
6+
47
namespace hpcReact
58
{
6-
namespace bulkDebyeHuckel
9+
namespace bulkGeneric
710
{
811

912
// function to the reaction rate. Includes impact of temperature, concentration, surface area, volume fraction and porosity
@@ -21,17 +24,16 @@ KineticReactions< REAL_TYPE,
2124
INDEX_TYPE
2225
>::computeReactionRates( RealType const & temperature,
2326
PARAMS_DATA const & params,
24-
RealConstDataArrayView1d & primarySpeciesConcentration,
25-
RealConstDataArrayView1d & secondarySpeciesConcentration,
27+
RealConstDataArrayView1d const & primarySpeciesConcentration,
2628
RealDataArrayView1d & reactionRates )
2729
{
2830
for( IntType i = 0; i < PARAMS_DATA::numPrimarySpecies; ++i )
2931
{
3032
reactionRates[i] = 0.0;
3133
for( IntType r=0; r<PARAMS_DATA::numKineticReactions; ++r )
3234
{
33-
RealType const forwardRateConstant = params.m_reactionRateConstant[r] * exp( -params.m_activationEnergy[r] / ( constants::R * temperature ) );
34-
RealType const reverseRateConstant = params.equilibriumConstant[r] / forwardRateConstant;
35+
RealType const forwardRateConstant = params.m_rateConstant[r] * exp( -params.m_activationEnergy[r] / ( constants::R * temperature ) );
36+
RealType const reverseRateConstant = params.m_equilibriumConstant[r] / forwardRateConstant;
3537
RealType const s_ir = params.m_stoichiometricMatrix[r][i];
3638

3739
RealType productConcPlus = 1.0;

src/reactions/bulkGeneric/Parameters.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#pragma once
22

33
#include "common/constants.hpp"
4+
#include "common/CArrayWrapper.hpp"
45

56

67
namespace hpcReact
78
{
8-
namespace solidStateBattery
9+
namespace bulkGeneric
910
{
1011

1112

@@ -14,20 +15,18 @@ namespace solidStateBattery
1415
template< typename REAL_TYPE,
1516
typename INT_TYPE,
1617
int NUM_PRIMARY_SPECIES,
17-
int NUM_SECONDARY_SPECIES,
1818
int NUM_KINETIC_REACTIONS >
1919
struct KineticParameters
2020
{
2121
using RealType = REAL_TYPE;
2222
using IntType = INT_TYPE;
2323

2424
static constexpr IntType numPrimarySpecies = NUM_PRIMARY_SPECIES;
25-
static constexpr IntType numSecondarySpecies = NUM_SECONDARY_SPECIES;
2625
static constexpr IntType numKineticReactions = NUM_KINETIC_REACTIONS;
2726

2827
RealType m_activationEnergy[numKineticReactions];
2928
RealType m_equilibriumConstant[numKineticReactions];
30-
CArrayWrapper< RealType, numKineticReactions, numPrimarySpecies> m_stoichiometricMatrix[numKineticReactions][numPrimarySpecies];
29+
CArrayWrapper< RealType, numKineticReactions, numPrimarySpecies> m_stoichiometricMatrix;
3130

3231
RealType m_rateConstant[numKineticReactions];
3332
};

src/reactions/bulkGeneric/ParametersPredefined.hpp

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,28 @@ namespace bulkGeneric
88
{
99

1010
constexpr
11-
Parameters< double, int, 7, 11, 2 > chemicalReactionsParams =
11+
KineticParameters< double, int, 5, 5 > bicarbonateBuffer =
1212
{
13-
// m_ionSizePrimary
14-
{ 9.00, 4.00, 6.00, 4.00, 3.00, 8.00, 4.00 },
15-
// m_ionSizeSec
16-
{ 3.50, 3.00, 4.50, 3.00, 4.00, 3.00, 3.00, 4.00, 3.00, 3.00, 4.00 },
17-
// m_chargePrimary
18-
{ 1, -1, 2, -2, -1, 2, 1 },
19-
// m_chargeSec
20-
{ -1, 0, -2, 0, 1, 0, 0, 1, 0, 0, -1 },
21-
// m_DebyeHuckelA
22-
0.5465,
23-
// m_DebyeHuckelB
24-
0.3346,
25-
// m_WATEQBDot
26-
0.0438,
27-
// m_eqStoichMatrix
28-
// First index: 0 = OH-, 1 = CO2, 2 = CO3-2, 3 = H2CO3, 4 = CaHCO3+, 5 = CaCO3, 6 = CaSO4, 7 = CaCl+, 8 = CaCl2, 9 = MgSO4, 10 = NaSO4-
29-
// Second index: 0 = H+, 1 = HCO3-, 2 = Ca+2, 3 = SO4-2, 4 = Cl-, 5 = Mg+2, 6 = Na+1
30-
{ { { -1, 0, 0, 0, 0, 0, 0 },
31-
{ 1, 1, 0, 0, 0, 0, 0 },
32-
{ -1, 1, 0, 0, 0, 0, 0 },
33-
{ 1, 1, 0, 0, 0, 0, 0 },
34-
{ 0, 1, 1, 0, 0, 0, 0 },
35-
{ -1, 1, 1, 0, 0, 0, 0 },
36-
{ 0, 0, 1, 1, 0, 0, 0 },
37-
{ 0, 0, 1, 1, 0, 0, 0 },
38-
{ 0, 0, 1, 0, 2, 0, 0 },
39-
{ 0, 0, 0, 1, 0, 1, 0 },
40-
{ 0, 0, 0, 1, 0, 0, 1 } }
41-
},
42-
// m_eqLog10EqConst
43-
{ 13.99, -6.36, 10.33, -3.77, -1.09, 7.07, -2.16, 0.67, 0.60, -2.43, -0.82 },
44-
// m_kineticStoichMatrix
45-
// First index: 0 = Ca(OH)2 dissolution, 1 = CaCO3 dissolution
46-
// Second index: 0 = H+, 1 = HCO3-, 2 = Ca+2, 3 = SO4-2, 4 = Cl-, 5 = Mg+2, 6 = Na+1
47-
{ { { -2, 0, 1, 0, 0, 0, 0 },
48-
{ -1, 1, 1, 0, 0, 0, 0 } }
13+
// taken from
14+
// Simplified Models of the Bicarbonate Buffer for Scaled Simulations of CO2 Electrolyzers
15+
// Thomas Moore, Tiras Y. Lin, Thomas Roy, Sarah E. Baker, Eric B. Duoss, Christopher Hahn, and Victor A. Beck
16+
// Industrial & Engineering Chemistry Research 2023 62 (40), 16291-16301
17+
// DOI: 10.1021/acs.iecr.3c02504
18+
19+
// C02, OH-, HCO3-, CO3^2-, H+
20+
// m_activationEnergy
21+
{ 0.0, 0.0, 0.0, 0.0, 0.0 },
22+
// m_equilibriumConstant
23+
{ 4.27E+07, 4.27E-07, 2.09E-04, 2.09E+10, 1.00E+14 },
24+
// m_stoichiometricMatrix
25+
{ { { 1, 1, -1, 0, 0 },
26+
{ 1, 0, -1, 0, -1 },
27+
{ 0, -1, -1, 1, 0 },
28+
{ 0, 0, -1, 1, 1 },
29+
{ 0, 1, 0, 0, 1 } }
4930
},
50-
// m_kineticLog10EqConst
51-
{ 20.19, 1.32 },
52-
// m_reactionRateConstant
53-
{ 9.95e-1, 9.95e-3 },
54-
// m_specificSurfaceArea
55-
1.0
31+
// m_rateConstant
32+
{ 8.42E+03, 3.71E-02, 1.25E+06, 1.24E+12, 2.30E+10 }
5633
};
5734

5835
} // namespace bulkGeneric
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Specify list of tests
2+
set( testSourceFiles
3+
testKineticReactions.cpp
4+
)
5+
6+
set( dependencyList hpcReact gtest )
7+
8+
# Add gtest C++ based tests
9+
foreach(test ${testSourceFiles})
10+
get_filename_component( test_name ${test} NAME_WE )
11+
blt_add_executable( NAME ${test_name}
12+
SOURCES ${test}
13+
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
14+
DEPENDS_ON ${dependencyList} )
15+
blt_add_test( NAME ${test_name}
16+
COMMAND ${test_name} )
17+
endforeach()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
#include "../KineticReactions_impl.hpp"
3+
#include "../ParametersPredefined.hpp"
4+
5+
#include <gtest/gtest.h>
6+
7+
8+
using namespace hpcReact;
9+
using namespace hpcReact::bulkGeneric;
10+
11+
TEST( bulkGeneric, test_computeReactionRates )
12+
{
13+
using KineticReactionsType = KineticReactions< double,
14+
double * const,
15+
double const * const,
16+
int,
17+
int >;
18+
19+
double const temperature = 298.15;
20+
double const primarySpeciesConcentration[] = { 1.0, 1.0, 1.0, 1.0, 1.0 };
21+
double reactionRates[] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
22+
23+
KineticReactionsType::computeReactionRates( temperature,
24+
bicarbonateBuffer,
25+
primarySpeciesConcentration,
26+
reactionRates );
27+
28+
EXPECT_NEAR( reactionRates[0], 0.0, 1.0e-8 );
29+
EXPECT_NEAR( reactionRates[1], 0.0, 1.0e-8 );
30+
EXPECT_NEAR( reactionRates[2], 0.0, 1.0e-8 );
31+
EXPECT_NEAR( reactionRates[3], 0.0, 1.0e-8 );
32+
EXPECT_NEAR( reactionRates[4], 0.0, 1.0e-8 );
33+
34+
}
35+
36+
int main( int argc, char * * argv )
37+
{
38+
::testing::InitGoogleTest( &argc, argv );
39+
int const result = RUN_ALL_TESTS();
40+
return result;
41+
}

0 commit comments

Comments
 (0)