Skip to content

Commit eaae504

Browse files
committed
some more intermediate additions for liquid battery chemistry
1 parent b905b98 commit eaae504

File tree

7 files changed

+218
-6
lines changed

7 files changed

+218
-6
lines changed

src/common/constants.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
namespace hpcReact
4+
{
5+
namespace constants
6+
{
7+
8+
constexpr double R = 8.31446261815324; // J/(mol K)
9+
constexpr double F = 96485.3321233100184; // C/mol
10+
11+
} // namespace constants
12+
} // namespace hpcReact

src/reactions/geochemistry/KineticReactions.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class KineticReactions : public ReactionsBase< REAL_TYPE,
3333
using typename Base::IntType;
3434
using typename Base::IndexType;
3535

36-
37-
static constexpr RealType RConst = 0; //constants::gasConstant;
38-
3936
template< typename PARAMS_DATA >
4037
static HPCREACT_HOST_DEVICE inline void
4138
computeReactionRates( RealType const & temperature,

src/reactions/geochemistry/Parameters.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
namespace hpcReact
55
{
6-
6+
namespace geochemistry
7+
{
78

89
template< typename REAL_TYPE,
910
typename INT_TYPE,
@@ -131,5 +132,5 @@ struct Parameters
131132
}
132133
};
133134

134-
135-
}
135+
} // namespace geochemistry
136+
} // namespace hpcReact
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#pragma once
2+
3+
#include "ReactionsBase.hpp"
4+
#include "common/macros.hpp"
5+
6+
namespace hpcReact
7+
{
8+
namespace liquidElectrolyteBatteryChemistry
9+
{
10+
11+
template< typename REAL_TYPE,
12+
typename REAL_DATA_ARRAY_1D_VIEW_TYPE,
13+
typename REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE,
14+
typename INT_TYPE,
15+
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 >
21+
{
22+
public:
23+
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;
35+
36+
template< typename PARAMS_DATA >
37+
static HPCREACT_HOST_DEVICE inline void
38+
computeReactionRates( RealType const & temperature,
39+
PARAMS_DATA const & params,
40+
RealConstDataArrayView1d & primarySpeciesConcentration,
41+
RealConstDataArrayView1d & secondarySpeciesConcentration,
42+
RealDataArrayView1d & reactionRates );
43+
44+
45+
};
46+
47+
} // namespace geochemistry
48+
} // namespace hpcReact
49+
50+
#include "common/macrosCleanup.hpp"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include "KineticReactions.hpp"
2+
#include "common/macros.hpp"
3+
4+
namespace hpcReact
5+
{
6+
namespace liquidElectrolyteBatteryChemistry
7+
{
8+
9+
// function to the reaction rate. Includes impact of temperature, concentration, surface area, volume fraction and porosity
10+
template< typename REAL_TYPE,
11+
typename REAL_DATA_ARRAY_1D_VIEW_TYPE,
12+
typename REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE,
13+
typename INT_TYPE,
14+
typename INDEX_TYPE >
15+
template< typename PARAMS_DATA >
16+
HPCREACT_HOST_DEVICE inline void
17+
KineticReactions< REAL_TYPE,
18+
REAL_DATA_ARRAY_1D_VIEW_TYPE,
19+
REAL_CONST_DATA_ARRAY_1D_VIEW_TYPE,
20+
INT_TYPE,
21+
INDEX_TYPE
22+
>::computeReactionRates( RealType const & temperature,
23+
PARAMS_DATA const & params,
24+
RealConstDataArrayView1d & primarySpeciesConcentration,
25+
RealConstDataArrayView1d & secondarySpeciesConcentration,
26+
RealDataArrayView1d & reactionRates )
27+
{
28+
for( int iRxn = 0; iRxn < PARAMS_DATA::numKineticReactions; iRxn++ )
29+
{
30+
RealType const forwardRateConstant = params.m_reactionRateConstant[iRxn] * exp( -params.m_activationEnergy[iRxn] / ( constants::R * temperature ) );
31+
RealType const reverseRateConstant = params.equilibriumConstant[iRxn] / forwardRateConstant;
32+
33+
for( int iPri = 0; iPri < PARAMS_DATA::numPrimarySpecies; ++iPri )
34+
{
35+
RealType const stoichiometricCoefficient = params.m_stoichiometricMatrix[iRxn][iPri];
36+
RealType const primarySpeciesConcentration = primarySpeciesConcentration[iPri];
37+
RealType const secondarySpeciesConcentration = secondarySpeciesConcentration[iPri];
38+
39+
if( stoichiometricCoefficient < 0.0 )
40+
{
41+
reactionRates[iPri] = reactionRates[iRxn] + stoichiometricCoefficient * forwardRateConstant * primarySpeciesConcentration;
42+
}
43+
else if( stoichiometricCoefficient > 0.0 )
44+
{
45+
reactionRates[iPri] = reactionRates[iRxn] - stoichiometricCoefficient * reverseRateConstant * primarySpeciesConcentration;
46+
}
47+
}
48+
}
49+
}
50+
51+
} // namespace geochemistry
52+
} // namespace hpcReact
53+
54+
#include "common/macrosCleanup.hpp"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
3+
#include "common/constants.hpp"
4+
5+
6+
namespace hpcReact
7+
{
8+
namespace solidStateBattery
9+
{
10+
11+
12+
13+
14+
template< typename REAL_TYPE,
15+
typename INT_TYPE,
16+
int NUM_PRIMARY_SPECIES,
17+
int NUM_SECONDARY_SPECIES,
18+
int NUM_KINETIC_REACTIONS >
19+
struct KineticParameters
20+
{
21+
using RealType = REAL_TYPE;
22+
using IntType = INT_TYPE;
23+
24+
static constexpr IntType numPrimarySpecies = NUM_PRIMARY_SPECIES;
25+
static constexpr IntType numSecondarySpecies = NUM_SECONDARY_SPECIES;
26+
static constexpr IntType numKineticReactions = NUM_KINETIC_REACTIONS;
27+
28+
RealType m_activationEnergy[numKineticReactions];
29+
RealType m_equilibriumConstant[numKineticReactions];
30+
CArrayWrapper< RealType, numKineticReactions, numPrimarySpecies> m_stoichiometricMatrix[numKineticReactions][numPrimarySpecies];
31+
32+
RealType m_reactionRateConstant[numKineticReactions];
33+
};
34+
35+
36+
37+
38+
} // namespace solidStateBattery
39+
} // namespace hpcReact
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#pragma once
2+
3+
#include "Parameters.hpp"
4+
5+
namespace hpcReact
6+
{
7+
namespace geochemistry
8+
{
9+
10+
constexpr
11+
Parameters< double, int, 7, 11, 2 > chemicalReactionsParams =
12+
{
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 } }
49+
},
50+
// m_kineticLog10EqConst
51+
{ 20.19, 1.32 },
52+
// m_reactionRateConstant
53+
{ 9.95e-1, 9.95e-3 },
54+
// m_specificSurfaceArea
55+
1.0
56+
};
57+
58+
} // namespace geochemistry
59+
} // namespace hpcReact

0 commit comments

Comments
 (0)