SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
State_SPM.hpp
Go to the documentation of this file.
1/*
2 * State_SPM.hpp
3 *
4 * Implements a class State which defines the state-variables of a cell for the state-space model formulation
5 *
6 * Created on: 12 Apr 2022
7 * Author(s): Jorn Reniers, Volkan Kumtepeli
8 */
9
10#pragma once
11
12#include "../../settings/settings.hpp"
13#include "../../types/State.hpp"
14
15#include <cstdlib>
16#include <array>
17#include <span>
18
19namespace slide {
20class State_SPM : public State<29>
21{
22public:
23 constexpr static auto nch = settings::nch;
24
25 enum Index : size_t
26 {
49 N_save = i_zp
50 };
51
52 /* (OLD NOTE) Note on ri:
53 * this is the resistance times the electrode surface, averaged between both electrodes.
54 * The total cell resistance is (see Cell::getR() ): r /( (thickp*ap*elec_surf + thickn*an*elec_surf)/2 )
55 * with r the resistance times the average electrode surface
56 * thicki the thickness of electrode i
57 * ai the specific surface area of electrode i
58 * elec_surf the geometric surface area of the electrode (height of the electrode * width of the electrode)
59 * so if the measured DC resistance of the cell is R, the value of r can be calculated using:
60 * ri = R * ( (thickp*ap*elec_surf + thickn*an*elec_surf)/2 )
61 */
62
63 using z_type = std::array<value_type, nch>;
64 using states_type = std::array<value_type, N_states>;
65
68
69 inline auto &zp(size_t i) { return (*this)[i_zp + i]; }
70 inline auto &zn(size_t i) { return (*this)[i_zn + i]; }
71 inline auto &z(size_t i) { return (*this)[i_zp + i]; }
72
73 inline auto zp() { return std::span<double>(&zp(0), &zn(0)); }
74 inline auto zn() { return std::span<double>(&zn(0), &zn(0) + nch); }
75 inline auto z() { return std::span<double>(&zp(0), &zn(0) + nch); }
76
77
78 inline auto &T() { return (*this)[i_T]; }
79 inline auto &delta() { return (*this)[i_delta]; }
80 inline auto &LLI() { return (*this)[i_LLI]; }
81 inline auto &thickp() { return (*this)[i_thickp]; }
82 inline auto &thickn() { return (*this)[i_thickn]; }
83 inline auto &ep() { return (*this)[i_ep]; }
84 inline auto &en() { return (*this)[i_en]; }
85 inline auto &ap() { return (*this)[i_ap]; }
86 inline auto &an() { return (*this)[i_an]; }
87 inline auto &CS() { return (*this)[i_CS]; }
88 inline auto &Dp() { return (*this)[i_Dp]; }
89 inline auto &Dn() { return (*this)[i_Dn]; }
90 inline auto &rDCp() { return (*this)[i_rDCp]; }
91 inline auto &rDCn() { return (*this)[i_rDCn]; }
92 inline auto &rDCcc() { return (*this)[i_rDCcc]; }
93 inline auto &delta_pl() { return (*this)[i_delta_pl]; }
94 inline auto &SOC() { return (*this)[i_SOC]; }
95 inline auto &I() { return (*this)[i_I]; }
96 inline auto &V() { return (*this)[i_V]; }
97
99 void overwriteGeometricStates(double thickpi, double thickni, double epi, double eni, double api, double ani);
100 void overwriteCharacterisationStates(double Dpi, double Dni, double ri);
101
102 std::span<double> viewGeometricStates() { return std::span<double>(&delta(), &delta_pl() + 1); }
103
104 // Const methods:
105
106 inline auto I() const { return (*this)[i_I]; }
107};
108
109inline void State_SPM::overwriteGeometricStates(double thickpi, double thickni, double epi, double eni, double api, double ani)
110{
111 /*
112 * Function to overwrite the geometric parameters of the state.
113 * It also overwrites the initial states, so use it with extreme caution.
114 * It should only be called when you are parametrising a cell (determineCharacterisation.cpp), never while cycling a cell.
115 *
116 * IN
117 * thickpi thickness of the cathode [m]
118 * thickni thickness of the anode [m]
119 * epi volume fraction of active material in the cathode [-]
120 * eni volume fraction of active material in the anode [-]
121 * api effective surface area of the porous cathode [m2 m-3]
122 * ani effective surface area of the porous anode [m2 m-3]
123 */
124
126 this->thickp() = thickpi;
127 this->thickn() = thickni;
128 this->ep() = epi;
129 this->en() = eni;
130 this->ap() = api;
131 this->an() = ani;
132}
133
134inline void State_SPM::overwriteCharacterisationStates(double Dpi, double Dni, double ri)
135{
136 /*
137 * Function to overwrite the parameters related to the characterisation of the cell.
138 * The states and initial states are overwritten so use this function with caution.
139 * It should only be called when you are parametrising a cell (determineCharacterisation.cpp), never while cycling a cell.
140 *
141 * IN
142 * Dpi diffusion constant of the cathode at rate temperature [m s-1]
143 * Dni diffusion constant of the anode at rate temperature [m s-1]
144 * r specific resistance of the combined electrodes [Ohm m2]
145 */
146
148 this->Dp() = Dpi;
149 this->Dn() = Dni;
150 this->rDCp() = ri;
151 this->rDCn() = ri;
153}
154} // namespace slide
< #TODO how can we make this so it takes 29=N_states from enum?
Definition: State_SPM.hpp:21
auto & z(size_t i)
Both z_p and z_n;.
Definition: State_SPM.hpp:71
auto & zn(size_t i)
z_type, transformed li concentration at the positive inner nodes of the negative particle
Definition: State_SPM.hpp:70
auto & rDCp()
specific resistance (resistance times real surface area of the combined electrodes) [Ohm m2]
Definition: State_SPM.hpp:90
auto & Dn()
diffusion constant at reference temperature of the anode [m s-1]
Definition: State_SPM.hpp:89
void overwriteCharacterisationStates(double Dpi, double Dni, double ri)
overwrite the states related to the characterisation of a cell
Definition: State_SPM.hpp:134
auto & LLI()
lost lithium [As]
Definition: State_SPM.hpp:80
auto & ep()
volume fraction of active material in the cathode [-]
Definition: State_SPM.hpp:83
auto & T()
cell temperature [K]
Definition: State_SPM.hpp:78
auto & Dp()
diffusion constant at reference temperature of the cathode [m s-1]
Definition: State_SPM.hpp:88
auto & thickp()
thickness of the cathode [m]
Definition: State_SPM.hpp:81
auto & SOC()
thickness of the plated lithium layer [m]
Definition: State_SPM.hpp:94
std::array< value_type, N_states > states_type
Definition: State_SPM.hpp:67
auto & zp(size_t i)
z_type, transformed li concentration at the positive inner nodes of the positive particle
Definition: State_SPM.hpp:69
std::span< double > viewGeometricStates()
#Check and fix. Why this also checks SOC?
Definition: State_SPM.hpp:100
auto & rDCn()
specific resistance (resistance times real surface area of the combined electrodes) [Ohm m2]
Definition: State_SPM.hpp:91
auto & V()
voltage [V]
Definition: State_SPM.hpp:96
static constexpr auto nch
Definition: State_SPM.hpp:23
auto & I()
current [A]
Definition: State_SPM.hpp:95
std::array< value_type, nch > z_type
Definition: State_SPM.hpp:63
auto & delta_pl()
thickness of the plated lithium layer [m]
Definition: State_SPM.hpp:93
auto zn()
Definition: State_SPM.hpp:74
auto & delta()
thickness of the SEI layer [m]
Definition: State_SPM.hpp:79
auto & thickn()
thickness of the anode [m]
Definition: State_SPM.hpp:82
auto & rDCcc()
specific resistance (resistance times real surface area of the combined electrodes) [Ohm m2]
Definition: State_SPM.hpp:92
Index
Definition: State_SPM.hpp:26
@ i_CS
surface area of the cracks at the surface of the negative particle [m2]
Definition: State_SPM.hpp:38
@ i_rDCp
(ONLY CATHODE) specific resistance of both electrodes combined [Ohm m2]
Definition: State_SPM.hpp:44
@ i_en
volume fraction of active material in the anode [-]
Definition: State_SPM.hpp:35
@ i_delta_pl
thickness of the plated lithium layer [m]
Definition: State_SPM.hpp:41
@ i_rDCn
(ONLY ANODE) specific resistance of both electrodes combined [Ohm m2]
Definition: State_SPM.hpp:45
@ i_rDCcc
(ONLY SEPARATOR) specific resistance of both electrodes combined [Ohm m2]
Definition: State_SPM.hpp:46
@ i_LLI
lost lithium inventory [As]
Definition: State_SPM.hpp:31
@ N_states
Definition: State_SPM.hpp:48
@ i_zp
transformed concentration at the positive inner Chebyshev nodes of the positive particle
Definition: State_SPM.hpp:42
@ i_I
Definition: State_SPM.hpp:27
@ i_T
cell temperature [K]
Definition: State_SPM.hpp:29
@ i_zn
transformed concentration at the positive inner Chebyshev nodes of the negative particle
Definition: State_SPM.hpp:43
@ i_ap
effective surface area of the porous cathode [m2 m-3]
Definition: State_SPM.hpp:36
@ i_Dp
diffusion constant of the cathode at reference temperature [m s-1]
Definition: State_SPM.hpp:39
@ i_thickp
thickness of the cathode [m]
Definition: State_SPM.hpp:32
@ i_SOC
Definition: State_SPM.hpp:47
@ N_save
Save until i_zp.
Definition: State_SPM.hpp:49
@ i_an
effective surface area of the porous anode [m2 m-3]
Definition: State_SPM.hpp:37
@ i_Dn
diffusion constant of the anode at reference temperature [m s-1]
Definition: State_SPM.hpp:40
@ i_ep
volume fraction of active material in the cathode [-]
Definition: State_SPM.hpp:34
@ i_delta
thickness of the SEI layer [m]
Definition: State_SPM.hpp:30
@ i_thickn
thickness of the anode [m]
Definition: State_SPM.hpp:33
@ i_V
Definition: State_SPM.hpp:28
auto & an()
effective surface area of the anode [m2 m-3]
Definition: State_SPM.hpp:86
void overwriteGeometricStates(double thickpi, double thickni, double epi, double eni, double api, double ani)
overwrite the states related to the geometry of a cell
Definition: State_SPM.hpp:109
auto & ap()
effective surface area of the cathode [m2 m-3]
Definition: State_SPM.hpp:85
auto & en()
volume fraction of active material in the anode [-]
Definition: State_SPM.hpp:84
auto & CS()
surface area of the cracks at the surface of the negative particle [m2]
Definition: State_SPM.hpp:87
auto z()
Definition: State_SPM.hpp:75
auto zp()
Definition: State_SPM.hpp:73
constexpr size_t nch
Definition: settings.hpp:33
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
Definition: State.hpp:24