Line data Source code
1 : /** \file DEG_ID.hpp
2 : * \brief Defines a structure for handling degradation models.
3 : * \author Jorn Reniers, Volkan Kumtepeli
4 : * \date 12 May 2022
5 : */
6 :
7 : #pragma once
8 :
9 : #include <string>
10 : #include <cstdint>
11 : #include <array>
12 : #include <iostream>
13 :
14 : #include "../../../types/SmallVector.hpp"
15 :
16 : //! Slide namespace contains all the types, classes, and functions for the simulation framework.
17 : namespace slide {
18 :
19 : /**
20 : * @brief DEG_ID structure handles the identifications of which degradation model(s) to use.
21 : */
22 : struct DEG_ID
23 : {
24 : using data_t = uint_fast8_t; //!< Alias for uint_fast8_t as data_t.
25 : constexpr static data_t len = 10; //!< Length of the arrays with identifications of which models to use.
26 :
27 : /**
28 : * @brief DegArray class derived from SmallVector to handle degradation model arrays.
29 : */
30 : struct DegArray : public SmallVector<data_t, len>
31 : {
32 : /**
33 : * @brief Adds a model to the array.
34 : * @param elem Model identification number.
35 : */
36 29 : void add_model(data_t elem)
37 : {
38 29 : if (elem != 0) //!< If element is 0 then there is no need to add.
39 18 : push_back(std::move(elem)); //!< #TODO better push_back needed.
40 29 : }
41 : };
42 :
43 : DegArray SEI_id{}; //!< Array with identifications to decide which SEI models to use.
44 : /**
45 : * - 0: no SEI growth
46 : * - 1: kinetic model only (Tafel kinetics), ref: Ning & Popov, Journal of the Electrochemical Society 151 (10), 2004
47 : * - 2: Pinson&Bazant model: linear diffusion + Tafel kinetics, ref: Pinson & Bazant, Journal of the Electrochemical society 160 (2), 2013
48 : * - 3: Christensen and Newman model, ref: Christensen & Newmann, Journal of the Electrochemical Society 152 (4), 2005
49 : */
50 :
51 : data_t SEI_porosity{ 0 }; //!< Integer deciding whether we reduce the active volume fraction due to SEI growth.
52 : /**
53 : * - 0: don't reduce it
54 : * - 1: use correlation from Ashwin et al. 2016, ref: Ashwin, Chung, Wang, Journal of Power Sources 328, 2016
55 : */
56 :
57 : DegArray CS_id; //!< Array with identifications for which model to use for surface cracking. Max length 10.
58 : /**
59 : * - 0: no surface cracking
60 : * - 1: Laresgoiti's stress + crack growth model, ref: Laresgoiti, Kablitz, Ecker, Sauer, Journal of Power Sources 300, 2015
61 : * - 2: Dai stress model + Laresgoiti crack growth, ref: Laresgoiti, Kablitz, Ecker, Sauer, Journal of Power Sources 300, 2015; Dai, Cai, White, Journal of Power sources 247, 2014
62 : * - 3: model based on Deshpande and Bernardi, ref: Deshpande & Bernardi, Journal of the Electrochemical Society 164 (2), 2017
63 : * - 4: model from Barai et al, ref: Barai, Smith, Chen, Kim, Mukherjee, Journal of the Electrochemical Society 162 (9), 2015
64 : * - 5: model from Ekstrom et al, ref: Ekstrom and Lindbergh, Journal of the Electrochemical Society 162 (6), 2015
65 : */
66 :
67 : data_t CS_diffusion{ 0 }; //!< Integer deciding whether we reduce the negative diffusion constant due to surface cracks.
68 : /**
69 : * - 0: don't decrease diffusion
70 : * - 1: decrease according to Barai et al. 2015
71 : */
72 :
73 : DegArray LAM_id; //!< Array with the integers deciding which models is to be used for loss of active material. Max length 10.
74 : /**
75 : * - 0: no LAM
76 : * - 1: Dai's stress model and Laresgoiti's correlation to get LAM
77 : * - 2: delacourt's correlation between abs(j) and porosity
78 : * - 3: Kindermann's model for cathode dissolution: tafel kinetics for increased porosity
79 : * - 4: Narayanrao's correlation which decreases the effective surface area proportionally to itself and j
80 : */
81 :
82 : data_t pl_id{ 0 }; //!< Integer deciding which model is to be used for li-plating.
83 : /**
84 : * - 0: no plating
85 : * - 1: Yang et al thermodynamic plating (Tafel kinetics)
86 : */
87 :
88 12 : auto print()
89 : {
90 : /**
91 : * Function to get a string representation of the struct with the degradation settings.
92 : * This string is part of the names of the subfolders in which results are written.
93 : *
94 : * @return std::string representation of the degradation identifiers.
95 : * Identifiers of the same mechanism are separated by -.
96 : * Identifiers of different mechanisms are separated by _.
97 : * e.g., if we use SEI model 1, no SEI porosity effect, no surface cracks, LAM model 2 and LAM model 3 and lithium plating model 1:
98 : * 2-0_0-0_2-3_1
99 : * 2: SEI model 1
100 : * 0: no SEI porosity
101 : * 0: no surface cracks
102 : * 0: don't decrease the diffusion due to surface cracks
103 : * 2: LAM model 2
104 : * 3: LAM model 3
105 : * 1: lithium plating model 1
106 : */
107 :
108 12 : std::string id = "";
109 12 : id.reserve(30);
110 :
111 : // Print SEI models and SEI_porosity (decreasing the active volume fraction due to SEI growth), separated by -
112 :
113 12 : if (SEI_id.empty()) // If zero we do not store so we need to print even not storing.
114 0 : id += "0-";
115 : else
116 24 : for (const auto sei_id : SEI_id)
117 12 : id += std::to_string(sei_id) + '-';
118 :
119 12 : id += std::to_string(SEI_porosity);
120 :
121 : // Mechanism separator
122 12 : id += '_';
123 :
124 : // Print CS models (surface cracking) and CS_diffusion (reducing the diffusion constant because of cracks), separated by -
125 :
126 12 : if (CS_id.empty())
127 10 : id += "0-";
128 : else
129 4 : for (const auto cs_id : CS_id)
130 2 : id += std::to_string(cs_id) + '-';
131 :
132 12 : id += std::to_string(CS_diffusion);
133 :
134 : // Mechanism separator
135 12 : id += '_';
136 :
137 : // Print LAM models separated by -
138 12 : if (LAM_id.empty())
139 4 : id += "0-";
140 : else
141 16 : for (const auto lam_id : LAM_id)
142 8 : id += std::to_string(lam_id) + '-';
143 :
144 : // Mechanism separator
145 12 : if (LAM_id.empty())
146 4 : id += '_';
147 : else
148 8 : id.back() = '_'; // If LAM_id is not empty then it will print an extra '-' therefore we need to replace it with mechanism separator.
149 :
150 : // Print plating model
151 12 : id += std::to_string(pl_id);
152 :
153 : // Output
154 12 : return id;
155 0 : }
156 : };
157 : } // namespace slide
|