SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
DEG_ID.hpp
Go to the documentation of this file.
1
7#pragma once
8
9#include <string>
10#include <cstdint>
11#include <array>
12#include <iostream>
13
14#include "../../../types/SmallVector.hpp"
15
17namespace slide {
18
22struct DEG_ID
23{
24 using data_t = uint_fast8_t;
25 constexpr static data_t len = 10;
26
30 struct DegArray : public SmallVector<data_t, len>
31 {
36 void add_model(data_t elem)
37 {
38 if (elem != 0)
39 push_back(std::move(elem));
40 }
41 };
42
88 auto print()
89 {
108 std::string id = "";
109 id.reserve(30);
110
111 // Print SEI models and SEI_porosity (decreasing the active volume fraction due to SEI growth), separated by -
112
113 if (SEI_id.empty()) // If zero we do not store so we need to print even not storing.
114 id += "0-";
115 else
116 for (const auto sei_id : SEI_id)
117 id += std::to_string(sei_id) + '-';
118
119 id += std::to_string(SEI_porosity);
120
121 // Mechanism separator
122 id += '_';
123
124 // Print CS models (surface cracking) and CS_diffusion (reducing the diffusion constant because of cracks), separated by -
125
126 if (CS_id.empty())
127 id += "0-";
128 else
129 for (const auto cs_id : CS_id)
130 id += std::to_string(cs_id) + '-';
131
132 id += std::to_string(CS_diffusion);
133
134 // Mechanism separator
135 id += '_';
136
137 // Print LAM models separated by -
138 if (LAM_id.empty())
139 id += "0-";
140 else
141 for (const auto lam_id : LAM_id)
142 id += std::to_string(lam_id) + '-';
143
144 // Mechanism separator
145 if (LAM_id.empty())
146 id += '_';
147 else
148 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 id += std::to_string(pl_id);
152
153 // Output
154 return id;
155 }
156};
157} // namespace slide
Definition: SmallVector.hpp:11
void push_back(const data_t &&elem)
Definition: SmallVector.hpp:29
auto empty()
Definition: SmallVector.hpp:50
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
DegArray class derived from SmallVector to handle degradation model arrays.
Definition: DEG_ID.hpp:31
void add_model(data_t elem)
Adds a model to the array.
Definition: DEG_ID.hpp:36
DEG_ID structure handles the identifications of which degradation model(s) to use.
Definition: DEG_ID.hpp:23
DegArray CS_id
Array with identifications for which model to use for surface cracking. Max length 10.
Definition: DEG_ID.hpp:57
data_t pl_id
Integer deciding which model is to be used for li-plating.
Definition: DEG_ID.hpp:82
data_t SEI_porosity
Integer deciding whether we reduce the active volume fraction due to SEI growth.
Definition: DEG_ID.hpp:51
static constexpr data_t len
Length of the arrays with identifications of which models to use.
Definition: DEG_ID.hpp:25
DegArray SEI_id
Array with identifications to decide which SEI models to use.
Definition: DEG_ID.hpp:43
data_t CS_diffusion
Integer deciding whether we reduce the negative diffusion constant due to surface cracks.
Definition: DEG_ID.hpp:67
DegArray LAM_id
Array with the integers deciding which models is to be used for loss of active material....
Definition: DEG_ID.hpp:73
auto print()
Definition: DEG_ID.hpp:88
uint_fast8_t data_t
Alias for uint_fast8_t as data_t.
Definition: DEG_ID.hpp:24