24#include "../../utility/utility.hpp"
25#include "../../settings/settings.hpp"
26#include "../../types/OCVcurves.hpp"
42 using sigma_type = std::array<double, settings::nch + 2>;
57 double kn{ 1.7640e-11 };
61 double Dn_T{ 35000.0 / 5.0 };
83 double rsei{ 2037.4 * 50 };
118 std::pair<double, double>
calcOverPotential(
double cps,
double cns,
double i_app);
128 void SEI(
double OCVnt,
double etan,
double *isei,
double *den);
129 void CS(
double OCVnt,
double etan,
double *isei_multiplyer,
double *dCS,
double *dDn);
130 void LAM(
bool critical,
double zp_surf,
double etap,
double *dthickp,
double *dthickn,
double *dap,
double *dan,
double *dep,
double *den);
131 double LiPlating(
double OCVnt,
double etan);
141 double thermalModel_coupled(
int Nneighb,
double Tneighb[],
double Kneighb[],
double Aneighb[],
double tim);
152 Cell_SPM(std::string IDi,
const DEG_ID °id,
double capf,
double resf,
double degfsei,
double degflam);
159 double T() noexcept
override {
return st.
T(); }
162 Status setCurrent(
double Inew,
bool checkV =
true,
bool print =
true)
override;
163 Status setSOC(
double SOCnew,
bool checkV =
true,
bool print =
true)
override;
188 double thermalModel(
int Nneighb,
double Tneighb[],
double Kneighb[],
double Aneighb[],
double tim)
override;
208 double I()
const override {
return st.
I(); }
211 bool getCSurf(
double &cps,
double &cns,
bool print);
212 void getC(
double cp[],
double cn[])
noexcept;
213 int getVoltage(
bool print,
double *
V,
double *OCVp,
double *OCVn,
double *etap,
double *etan,
double *Rdrop,
double *Temp);
214 int getVoltage_ne(
bool print,
double *
V,
double *OCVp,
double *OCVn,
double *etap,
double *etan,
double *Rdrop,
double *Temp);
223 void setT(
double T) override;
226 void setC(
double cp0,
double cn0);
271 std::span<double>
viewStates()
override {
return std::span<double>(
st.begin(),
st.end()); }
275 inline double SOC()
override {
return st.
SOC(); }
276 void timeStep_CC(
double dt,
int steps = 1)
override;
280 void ETI(
bool print,
double dti,
bool blockDegradation);
283 void setOCVcurve(
const std::string &namepos,
const std::string &nameneg);
285 void setGeometricParameters(
double capnom,
double elec_surf,
double ep,
double en,
double thickp,
double thickn);
Definition: Cell_SPM.hpp:39
double var_degSEI
relative factor to speed up or slow down the rate of SEI growth
Definition: Cell_SPM.hpp:146
void getTemperatures(double *Tenv, double *Tref) noexcept
< get the environmental and reference temperature
Definition: Cell_SPM.hpp:174
void getC(double cp[], double cn[]) noexcept
get the concentrations at all nodes
Definition: Cell_SPM.cpp:149
double calcArrheniusCoeff()
Calculates Arrhenius coefficient.
Definition: Cell_SPM.hpp:120
double alphasei
charge transfer coefficient of the SEI reaction [-]
Definition: Cell_SPM.hpp:85
OCVcurves OCV_curves
Definition: Cell_SPM.hpp:112
void dState_diffusion(bool print, State_SPM &d_state)
just diffusion PDE
Definition: Cell_SPM_dstate.cpp:23
void ETI(bool print, double dti, bool blockDegradation)
step forward in time using forward Eurler time integration
void CS(double OCVnt, double etan, double *isei_multiplyer, double *dCS, double *dDn)
calculate the effect of surface crack growth
Definition: Cell_SPM_degradation.cpp:129
double C_elec
Li- concentration in electrolyte [mol m-3] standard concentration of 1 molar.
Definition: Cell_SPM.hpp:50
double kp_T
activation energy for the Arrhenius relation of kp
Definition: Cell_SPM.hpp:56
bool Vcell_valid
Functions.
Definition: Cell_SPM.hpp:114
void setTenv(double Tenv)
void setStates(const State_SPM &si, double I); //!< set the cell's states to the states in the State ...
Definition: Cell_SPM.cpp:488
double T_env
environment temperature [K]
Definition: Cell_SPM.hpp:67
double getRdc() noexcept
calculate the resistance from every component
Definition: Cell_SPM.cpp:24
double getThermalSurface() override
return the 'A' for the thermal model of this SU (Q = hA*dT)
Definition: Cell_SPM_thermal.cpp:23
double SOC() override
Definition: Cell_SPM.hpp:267
Cell_SPM(OCVcurves OCV_curves_)
< Constructor
Definition: Cell_SPM.hpp:151
double Cp
thermal capacity of the battery #TODO = units missing.
Definition: Cell_SPM.hpp:74
void dState_degradation(bool print, State_SPM &d_state)
calculate the effect of lithium plating
Definition: Cell_SPM_dstate.cpp:126
double OCVnmc
equilibrium potential of the NMC dissolution side reaction [V]
Definition: Cell_SPM.hpp:98
double thermalModel(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim) override
Definition: Cell_SPM_thermal.cpp:193
bool validStates(bool print=true) override
checks if a state array is valid
Definition: Cell_SPM.cpp:378
void getDaiStress(double *sigma_p, double *sigma_n, sigma_type &sigma_r_p, sigma_type &sigma_r_n, sigma_type &sigma_t_p, sigma_type &sigma_t_n, sigma_type &sigma_h_p, sigma_type &sigma_h_n) noexcept
get the stresses at all nodes according to Dai's stress model
Definition: Cell_SPM_degradation.cpp:484
double OCVpl
OCV of the plating reaction [V].
Definition: Cell_SPM.hpp:104
param::StressParam sparam
Stress parameters.
Definition: Cell_SPM.hpp:80
double I() const override
get the cell current [A] positive for discharging
Definition: Cell_SPM.hpp:208
DEG_ID deg_id
structure with the identification of which degradation model(s) to use #TODO may be protected.
Definition: Cell_SPM.hpp:41
void overwriteCharacterisationStates(double Dpi, double Dni, double ri)
Definition: Cell_SPM.hpp:238
double kn_T
The diffusion constants at reference temperature are part of State because they can change over the b...
Definition: Cell_SPM.hpp:58
double Therm_Qgen
total heat generation since the last update [J]
Definition: Cell_SPM.hpp:64
void setOCVcurve(const std::string &namepos, const std::string &nameneg)
sets the OCV curve of the cell to the given value
Definition: Cell_SPM_fitting.cpp:210
double Vmain
partial molar volume of the main reaction, see Ashwin et al, 2016
Definition: Cell_SPM.hpp:89
double kp
rate constant of main reaction at positive electrode at reference temperature
Definition: Cell_SPM.hpp:55
double n
number of electrons involved in the main reaction [-] #TODO if really constant?
Definition: Cell_SPM.hpp:52
std::array< double, 2 > calcDiffConstant()
Calculate the diffusion constant at the battery temperature using an Arrhenius relation.
Definition: Cell_SPM_diffusion.cpp:76
double thermalModel_cell()
Definition: Cell_SPM_thermal.cpp:34
bool getCSurf(double &cps, double &cns, bool print)
get the surface concentrations
Definition: Cell_SPM.cpp:123
auto & getStateObj()
Definition: Cell_SPM.hpp:165
double alphapl
charge transfer constant for the plating reaction [-]
Definition: Cell_SPM.hpp:103
void timeStep_CC(double dt, int steps=1) override
setStates(std::move(states)); //!< store new states, checks if they are illegal (throws an error in t...
Definition: Cell_SPM_dstate.cpp:252
void setGeometricParameters(double capnom, double elec_surf, double ep, double en, double thickp, double thickn)
void setRamping(double Istep, double tstep); //!< sets the ramping parameters
Definition: Cell_SPM_fitting.cpp:261
State_SPM s_ini
the battery current/initial state, grouping all parameter which change over the battery's lifetime (s...
Definition: Cell_SPM.hpp:45
std::span< double > viewStates() override
Only for cells to see individual states.
Definition: Cell_SPM.hpp:263
void dState_all(bool print, State_SPM &d_state)
individual functions are combined in one function to gain speed.
double rhosei
partial molar volume of the SEI layer [m3 mol-1]
Definition: Cell_SPM.hpp:87
double Cmaxpos
maximum lithium concentration in the cathode [mol m-3] value for NMC
Definition: Cell_SPM.hpp:48
void updateLaresgoitiStress(bool print)
update the stored stress values for Laresgoiti's stress model
Definition: Cell_SPM_degradation.cpp:676
double Therm_Qgentot
variable for unit testing, total heat generation since the beginning of this cell's life [J]
Definition: Cell_SPM.hpp:65
void setCharacterisationParam(double Dp, double Dn, double kp, double kn, double Rdc)
sets the parameters related to the characterisation of the cell
Definition: Cell_SPM_fitting.cpp:288
void peekVoltage(double I)
Peeks voltage for state for given I.
void SEI(double OCVnt, double etan, double *isei, double *den)
calculate the effect of SEI growth
Definition: Cell_SPM_degradation.cpp:23
param::PLparam pl_p
structure with the fitting parameters of the different plating models
Definition: Cell_SPM.hpp:106
double T() noexcept override
returns the uniform battery temperature in [K]
Definition: Cell_SPM.hpp:159
double getRtot() override
Definition: Cell_SPM.hpp:204
double c_elec0
bulk concentration of the electrolyte molecule participating in the SEI growth (e....
Definition: Cell_SPM.hpp:88
void updateDaiStress() noexcept
updated the stored stress values for Dai's stress model
Definition: Cell_SPM_degradation.cpp:617
double rhopl
density of the plated lithium layer
Definition: Cell_SPM.hpp:105
auto setStateObj(State_SPM &st_new)
Definition: Cell_SPM.hpp:166
param::CSparam csparam
structure with the fitting parameters of the different crack growth models
Definition: Cell_SPM.hpp:95
int getVoltage(bool print, double *V, double *OCVp, double *OCVn, double *etap, double *etan, double *Rdrop, double *Temp)
get the cell's voltage
double rsei
specific resistance times real surface area of the SEI film [Ohm m] ? #TODO if unit is correct....
Definition: Cell_SPM.hpp:83
Status setCurrent(double Inew, bool checkV=true, bool print=true) override
Definition: Cell_SPM.cpp:77
Status setStates(setStates_t sSpan, bool checkV, bool print) override
opposite of getStates, check the states are valid?
Definition: Cell_SPM.cpp:355
double getOCV() override
Definition: Cell_SPM.cpp:201
double npl
number of electrons involved in the plating reaction [-]
Definition: Cell_SPM.hpp:102
double LiPlating(double OCVnt, double etan)
state space model
Definition: Cell_SPM_degradation.cpp:448
void getLaresgoitiStress(bool print, double *sigma_n)
get the stresses at all nodes according to Laresgoiti's stress model
Definition: Cell_SPM_degradation.cpp:632
Cell_SPM()
Default constructor.
Definition: Cell_SPM.cpp:307
double var_R
relative factor increasing the DC resistance
Definition: Cell_SPM.hpp:145
int getVoltage_ne(bool print, double *V, double *OCVp, double *OCVn, double *etap, double *etan, double *Rdrop, double *Temp)
get the cell's voltage noexcept
void setInitialConcentration(double cmaxp, double cmaxn, double lifracp, double lifracn)
sets the initial concentration
Definition: Cell_SPM_fitting.cpp:234
double var_degLAM
relative factor to speed up or slow down the rate of LAM
Definition: Cell_SPM.hpp:147
void dState_thermal(bool print, double &dQgen)
calculate the heat generation
Definition: Cell_SPM_dstate.cpp:57
Cell_SPM * copy() override
Obsolete functions (do not use):
Definition: Cell_SPM.hpp:270
double nsei
number of electrons involved in the SEI reaction [-]
Definition: Cell_SPM.hpp:84
double Dn_T
activation energy for the Arrhenius relation of Dn
Definition: Cell_SPM.hpp:61
param::LAMparam lam_p
structure with the fitting parameters of the different LAM models
Definition: Cell_SPM.hpp:99
double getTenv() const noexcept
get the environmental temperature [K]
Definition: Cell_SPM.hpp:160
double Therm_time
time since the last update of the thermal model
Definition: Cell_SPM.hpp:66
ThroughputData getThroughputs() override
Definition: Cell_SPM.hpp:236
std::array< double, settings::nch+2 > sigma_type
Definition: Cell_SPM.hpp:42
double Dp_T
activation energy for the Arrhenius relation of Dp
Definition: Cell_SPM.hpp:60
double rho
density of the battery
Definition: Cell_SPM.hpp:73
double Qch
convective heat transfer coefficient per volume [W K-1 m-3]
Definition: Cell_SPM.hpp:72
double thermal_getTotalHeat()
function for unit testing
Definition: Cell_SPM_thermal.cpp:171
double kn
rate constant of main reaction at negative electrode at reference temperature
Definition: Cell_SPM.hpp:57
void getStates(getStates_t s) override
returns the states of the cell collectively.
Definition: Cell_SPM.hpp:262
double thermalModel_coupled(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim)
cell to cell variations // #TODO why do we store variations?
Definition: Cell_SPM_thermal.cpp:80
param::SEIparam sei_p
structure with the fitting parameters of the different SEI growth models
Definition: Cell_SPM.hpp:92
double OCVsei
equilibrium potential of the SEI side reaction [V]
Definition: Cell_SPM.hpp:86
double Vsei
partial molar volume of the SEI side reaction, see Ashwin et al., 2016
Definition: Cell_SPM.hpp:90
Status setSOC(double SOCnew, bool checkV=true, bool print=true) override
Definition: Cell_SPM.cpp:39
double V() override
print is an optional argument
Definition: Cell_SPM.cpp:234
void setT(double T) override
set the cell's temperature
Definition: Cell_SPM.cpp:540
std::array< double, 3 > calcMolarFlux()
Calculate molar flux.
Definition: Cell_SPM_diffusion.cpp:66
Cell_SPM(Model_SPM *M_ptr)
getters
Definition: Cell_SPM.hpp:156
std::pair< double, double > calcOverPotential(double cps, double cns, double i_app)
Should not throw normally, except divide by zero?
Definition: Cell_SPM_diffusion.cpp:43
void overwriteGeometricStates(double thickpi, double thickni, double epi, double eni, double api, double ani)
void ETI_electr(bool print, double I, double dti, bool blockDegradation, bool pos); //!...
Definition: Cell_SPM.hpp:245
double var_cap
relative factor increasing the capacity of the cell
Definition: Cell_SPM.hpp:144
void checkModelparam()
check if the inputs to the MATLAB code are the same as the ones here in the C++ code
Definition: Cell_SPM.cpp:660
void LAM(bool critical, double zp_surf, double etap, double *dthickp, double *dthickn, double *dap, double *dan, double *dep, double *den)
calculate the effect of LAM
Definition: Cell_SPM_degradation.cpp:288
double T_ref
reference temperature [K]
Definition: Cell_SPM.hpp:68
void setC(double cp0, double cn0)
void setCurrent(bool critical, bool check, double I); //!< set the cell's current to the specified va...
Definition: Cell_SPM.cpp:556
double getAnodeSurface() noexcept
get the anode pure surface area (without cracks) product of the effective surface area (an) with the ...
Definition: Cell_SPM.hpp:206
param::Geometry_SPM geo
other geometric parameters are part of State because they can change over the battery's lifetime
Definition: Cell_SPM.hpp:77
double Cmaxneg
maximum lithium concentration in the anode [mol m-3] value for C
Definition: Cell_SPM.hpp:49
std::pair< double, double > calcSurfaceConcentration(double jp, double jn, double Dpt, double Dnt)
Definition: Cell_SPM_diffusion.cpp:23
State_SPM::states_type dState(bool print, State_SPM &d_state)
Utility.
State_SPM st
< protected such that child classes can access the class variables
Definition: Cell_SPM.hpp:45
Model_SPM * M
OCV curves.
Definition: Cell_SPM.hpp:109
std::array< double, 4 > getVariations() const noexcept override
Definition: Cell_SPM.hpp:172
Abstract Class representing a single battery cell.
Definition: Cell.hpp:33
< #TODO how can we make this so it takes 29=N_states from enum?
Definition: State_SPM.hpp:21
void overwriteCharacterisationStates(double Dpi, double Dni, double ri)
overwrite the states related to the characterisation of a cell
Definition: State_SPM.hpp:134
auto & T()
cell temperature [K]
Definition: State_SPM.hpp:78
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 & I()
current [A]
Definition: State_SPM.hpp:95
auto & thickn()
thickness of the anode [m]
Definition: State_SPM.hpp:82
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
std::span< double > & setStates_t
To pass states to read, non-expandable container.
Definition: StorageUnit.hpp:32
std::vector< double > & getStates_t
To pass states to save, expandable container.
Definition: StorageUnit.hpp:33
constexpr double Rg
ideal gas constant
Definition: constants.hpp:22
constexpr LAMparam LAMparam_Kokam
lam1p
Definition: LAMparam_default.hpp:16
constexpr SEIparam SEIparam_Kokam
< fitting parameters of the models
Definition: SEIparam_default.hpp:17
constexpr StressParam StressParam_Kokam
< omegap, from Wu, Xiao, Wen, Zhang, Three-dimensional finite element study on stress generation in s...
Definition: StressParam_default.hpp:16
constexpr double T_ENV
environmental temperature
Definition: settings.hpp:70
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
void validState(State_SPM &s, State_SPM &s_ini)
< State related functions
Status
Definition: Status.hpp:15
DEG_ID structure handles the identifications of which degradation model(s) to use.
Definition: DEG_ID.hpp:23
Definition: Model_SPM.hpp:24
static Model_SPM * makeModel()
Definition: Model_SPM.hpp:79
Definition: OCVcurves.hpp:16
auto Wh() const
Energy throughput [Wh].
Definition: State.hpp:35
auto Ah() const
Current throughput [Ah].
Definition: State.hpp:34
auto time() const
time [s]
Definition: State.hpp:33
< Define a structure with the fitting parameters of the surface crack growth models (CS)
Definition: CSparam.hpp:15
< Define a structure with the fitting parameters of the SEI growth models (SEI)
Definition: Geometry_SPM.hpp:16
double elec_surf
geometric surface area of the electrodes (electrode height * electrode width*layers) [m2] Doubly coat...
Definition: Geometry_SPM.hpp:19
< Define a structure with the fitting parameters of the models for loss of active material (LAM)
Definition: LAMparam.hpp:16
< Define a structure with the fitting parameters of the li-plating models (PL)
Definition: PLparam.hpp:16
Definition: SEIparam.hpp:15
Definition: StressParam.hpp:15