SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
util_error.hpp
Go to the documentation of this file.
1/*
2 * Util_error.hpp
3 *
4 * Utility functions for error. So the code is less verbose.
5 *
6 * A cycler implements check-up procedures and degradation procedures.
7 * The data from the check-up procedures is written in csv files in the same subfolder as where the cycling data of a cell is written (see BasicCycler.cpp).
8 * There is one file per 'type' of check-up (capacity measurement, OCV measurement, CCCV cycles and a pulse discharge).
9 *
10 * Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
11 * of Oxford, VITO nv, and the 'Slide' Developers.
12 * See the licence file LICENCE.txt for more information.
13 */
14
15#pragma once
16
17#include "../cells/Cell.hpp"
18
19class Cell;
20
22void checkInputParam_CalAge(Cell &c, double V, double Ti, int Time, int timeCheck, int mode);
23void checkInputParam_CC_V_CV_I(Cell &c, double Crate, double Vset, double Ccut);
24void checkInputParam_CycAge(Cell &c, double Vma, double Vmi, double Ccha, double Ccutcha,
25 double Cdis, double Ccutdis, double Ti, int nrCycles, int nrCap);
26
27inline void checkInputParam_CalAge(Cell &c, double V, double Ti, int Time, int timeCheck, int mode)
28{
29
31 bool vmax = V > c.Vmax();
32 if (vmax)
33 std::cerr << "Error in Cycler::CalendarAgeing. The voltage " << V << " is too high. The maximum value is " << c.Vmax() << ".\n";
34
35 bool vmin = V < c.Vmin();
36 if (vmin)
37 std::cerr << "Error in Cycler::CalendarAgeing. The voltage " << V << " is too low. The minimum value is " << c.Vmin() << ".\n";
38
39 bool Temin = Ti < settings::Tmin_K;
40 if (Temin)
41 std::cerr << "Error in Cycler::CalendarAgeing. The temperature " << Ti << "K is too low. The minimum value is 273.\n";
42
43 bool Temax = Ti > settings::Tmax_K;
44 if (Temax)
45 std::cerr << "Error in Cycler::CalendarAgeing. The temperature " << Ti << " is too high. The maximum value is (273+60).\n";
46
47 bool mod = (mode < 0 || mode > 2);
48 if (mod)
49 std::cerr << "Error in Cycler::CalendarAgeing. The resting mode " << mode << " is illegal. Only values of 0, 1 or 2 are allowed.\n";
50
51 bool cycles = (std::fmod(Time, timeCheck) > 1);
52 if (cycles)
53 std::cerr << "Error in Cycler::CalendarAgeing. The total resting time " << Time
54 << " is not a multiple of the time between two check ups " << timeCheck << ".\n";
55
56 if (vmax || vmin || Temin || Temax || mod || cycles)
57 throw 1014;
58
60 if (mode == 2)
61 std::cout << "Warning in Cycler::CalendarAgeing. You have chosen to float the cell at a constant voltage for a long period. "
62 "It will take long to simulate this.\n";
63}
64
65inline void checkInputParam_CC_V_CV_I(Cell &c, double Crate, double Vset, double Ccut)
66{
67
69 bool vmax = Vset > c.Vmax();
70 if (vmax)
71 std::cerr << "Error in BasicCycler::CC_V_CV_I. The voltage " << Vset << " is too high. The maximum value is " << c.Vmax() << ".\n";
72
73 bool vmin = Vset < c.Vmin();
74 if (vmin)
75 std::cerr << "Error in BasicCycler::CC_V_CV_I. The voltage " << Vset << " is too low. The minimum value is " << c.Vmin() << ".\n";
76
77 if (vmax || vmin)
78 throw 1005;
79
81 bool currCV = Ccut < 0;
82 if (currCV) {
83 std::cerr << "Error in BasicCycler::CC_V_CV_I. The cutoff C rate " << Ccut << " is negative. It must be positive.\n";
84
85 throw 1008;
86 }
87
89 bool currCC = Crate < 0;
90 if (currCC) {
91 std::cerr << "Error in BasicCycler::CC_V_CV_I. The Crate " << Crate << " is negative. It must be positive.\n";
92 throw 1010;
93 }
94}
95
96inline void checkInputParam_CycAge(Cell &c, double Vma, double Vmi, double Ccha, double Ccutcha,
97 double Cdis, double Ccutdis, double Ti, int nrCycles, int nrCap)
98{
100 bool vmax = Vma > c.Vmax();
101 if (vmax)
102 std::cerr << "Error in Cycler::cycleAgeing. The maximum voltage " << Vma << " is too high. The maximum value is " << c.Vmax() << ".\n";
103
104 bool vmin = Vmi < c.Vmin();
105 if (vmin)
106 std::cerr << "Error in Cycler::cycleAgeing. The minimum voltage " << Vmi << " is too low. The minimum value is " << c.Vmin() << ".\n";
107
108 bool Temin = Ti < settings::Tmin_Cell_K;
109 if (Temin)
110 std::cerr << "Error in Cycler::cycleAgeing. The temperature " << Ti << "K is too low. The minimum value is 273.\n";
111
112 bool Temax = Ti > settings::Tmax_Cell_K;
113 if (Temax)
114 std::cerr << "Error in Cycler::cycleAgeing. The temperature " << Ti << " is too high. The maximum value is (273+60).\n";
115
116 bool cchar = Ccha <= 0;
117 if (cchar)
118 std::cerr << "Error in Cycler::cycleAgeing. The charging Crate " << Ccha << " is negative. It must be positive.\n";
119
120 bool cdis = Cdis <= 0;
121 if (cdis)
122 std::cerr << "Error in Cycler::cycleAgeing. The discharging Crate " << Cdis << " is negative. It must be positive.\n";
123
124 bool ccvchar = Ccutcha <= 0;
125 if (ccvchar)
126 std::cerr << "Error in Cycler::cycleAgeing. The Crate of the cutoff current for the CV charge " << Ccutcha << " is negative. It must be positive.\n";
127
128 bool ccvdis = Ccutdis <= 0;
129 if (ccvdis)
130 std::cerr << "Error in Cycler::cycleAgeing. The Crate of the cutoff current for the CV discharge " << Ccutdis << " is negative. It must be positive.\n";
131
132 bool cycles = nrCycles <= nrCap;
133 if (cycles)
134 std::cerr << "Error in Cycler::cycleAgeing. The number of cycles between two check ups " << nrCap << " is higher than the total number of cycles " << nrCycles << ".\n";
135
136 if (vmax || vmin || Temin || Temax || cchar || cdis || ccvchar || ccvdis || cycles)
137 throw 1014;
138}
139
140} // namespace slide::util::error
Abstract Class representing a single battery cell.
Definition: Cell.hpp:33
constexpr double Vmax() const override
upper voltage limit of the cell
Definition: Cell.hpp:53
constexpr double Vmin() const override
lower voltage limit of the cell
Definition: Cell.hpp:50
constexpr double Tmax_Cell_K
the maximum temperature allowed in the simulation [K]
Definition: settings.hpp:44
constexpr double Tmin_Cell_K
the minimum temperature allowed in the simulation [K]
Definition: settings.hpp:43
Definition: util_error.hpp:21
void checkInputParam_CycAge(Cell &c, double Vma, double Vmi, double Ccha, double Ccutcha, double Cdis, double Ccutdis, double Ti, int nrCycles, int nrCap)
Definition: util_error.hpp:96
void checkInputParam_CC_V_CV_I(Cell &c, double Crate, double Vset, double Ccut)
Definition: util_error.hpp:65
void checkInputParam_CalAge(Cell &c, double V, double Ti, int Time, int timeCheck, int mode)
Definition: util_error.hpp:27
out V
Definition: squeeze_variables.m:16