SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
Cell.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include "cell_limits.hpp"
11#include "../settings/settings.hpp"
12#include "../StorageUnit.hpp"
13#include "../types/Histogram.hpp"
14#include "../types/data_storage/CellData.hpp"
15#include "../types/Status.hpp"
16#include "../utility/utility.hpp"
17
18#include <cassert>
19#include <iostream>
20#include <fstream>
21#include <cstring>
22#include <cmath>
23#include <string>
24#include <vector>
25#include <span>
26
27namespace slide {
28
32class Cell : public StorageUnit
33{
34protected:
35 double capNom{ 16 };
36
38
39public:
40 constexpr static CellLimits limits{ defaultCellLimits }; // Default cell limits. #TODO make it changable.
41
42 Cell() : StorageUnit("cell") {}
43
44 Cell(const std::string &ID_) : StorageUnit(ID_) {}
45 virtual ~Cell() = default;
46
47 double Cap() const final override { return capNom; }
48 void setCapacity(double capacity) { capNom = capacity; }
49
50 constexpr double Vmin() const override { return limits.Vmin; }
51 constexpr double VMIN() const override { return limits.VMIN; }
52 constexpr double VMAX() const override { return limits.VMAX; }
53 constexpr double Vmax() const override { return limits.Vmax; }
54 constexpr double Tmax() { return limits.Tmax; }
55 constexpr double Tmin() { return limits.Tmin; }
56
57 double getVhigh() final { return V(); }
58 double getVlow() final { return V(); }
59
60 virtual Status setSOC(double SOCnew, bool checkV = true, bool print = true) = 0;
61 virtual double SOC() = 0;
62 virtual double getThotSpot() override { return T(); }
63 size_t getNcells() override final { return 1; }
64
65 virtual Status checkCurrent(bool checkV, bool print) noexcept
66 {
67 double v;
68 Status Vstatus = checkV ? checkVoltage(v, print) : Status::Success;
70 return Vstatus;
71 }
72
79 virtual Status checkVoltage(double &v, bool print) noexcept override { return free::check_voltage(v, *this); }
80
81
84
96 virtual double thermalModel(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim) override
97 {
98 return T();
99 }
100
102 virtual void storeData() override { cellData.storeData(*this); }
103 virtual void writeData(const std::string &prefix) override { cellData.writeData(*this, prefix); } // #TODO *this may be Cell not actual type.
104
105 virtual ThroughputData getThroughputs() { return {}; }
106
107 virtual std::array<double, 4> getVariations() const noexcept { return {}; } // #TODO will be deleted in future.
108};
109
110} // namespace slide
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
virtual double SOC()=0
void setCapacity(double capacity)
Definition: Cell.hpp:48
Cell()
Definition: Cell.hpp:42
virtual Status checkVoltage(double &v, bool print) noexcept override
Check the voltage status of the cell.
Definition: Cell.hpp:79
constexpr double VMIN() const override
safety cut off
Definition: Cell.hpp:51
double Cap() const final override
Definition: Cell.hpp:47
virtual ThroughputData getThroughputs()
Definition: Cell.hpp:105
double capNom
capacity [Ah].
Definition: Cell.hpp:35
CellData< settings::DATASTORE_CELL > cellData
Cell data storage.
Definition: Cell.hpp:37
constexpr double VMAX() const override
safety cut off
Definition: Cell.hpp:52
constexpr double Tmax()
Definition: Cell.hpp:54
virtual Status checkCurrent(bool checkV, bool print) noexcept
Definition: Cell.hpp:65
constexpr double Vmin() const override
lower voltage limit of the cell
Definition: Cell.hpp:50
double getVlow() final
return the voltage of the cell with the lowest voltage
Definition: Cell.hpp:58
constexpr double Tmin()
Definition: Cell.hpp:55
virtual ~Cell()=default
size_t getNcells() override final
this is a single cell
Definition: Cell.hpp:63
double getVhigh() final
return the voltage of the cell with the highest voltage
Definition: Cell.hpp:57
virtual Status setSOC(double SOCnew, bool checkV=true, bool print=true)=0
virtual void writeData(const std::string &prefix) override
Definition: Cell.hpp:103
virtual void storeData() override
Add another data point in the array.
Definition: Cell.hpp:102
virtual double getThotSpot() override
the T of the hottest element in the SU
Definition: Cell.hpp:62
virtual std::array< double, 4 > getVariations() const noexcept
Definition: Cell.hpp:107
virtual double thermalModel(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim) override
Calculate the thermal model of the cell.
Definition: Cell.hpp:96
static constexpr CellLimits limits
Definition: Cell.hpp:40
Cell(const std::string &ID_)
Definition: Cell.hpp:44
Definition: StorageUnit.hpp:27
virtual double T()=0
virtual double V()=0
print is an optional argument
auto check_voltage(double &v, auto &su)
Definition: free_functions.hpp:138
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
Status
Definition: Status.hpp:15
constexpr CellLimits defaultCellLimits
Definition: cell_limits.hpp:21
void storeData(Cell_t &)
Do nothing.
Definition: CellDataStorage.hpp:28
Definition: CellData.hpp:19
auto writeData(auto &cell, const std::string &prefix)
Definition: CellData.hpp:20
Definition: cell_limits.hpp:14
data_type Vmin
Definition: cell_limits.hpp:16
data_type VMIN
Definition: cell_limits.hpp:17
data_type Vmax
minimum / maximum voltage [V]
Definition: cell_limits.hpp:16
data_type Tmin
Definition: cell_limits.hpp:18
data_type Tmax
minimum / maximum temperature;
Definition: cell_limits.hpp:18
data_type VMAX
lower / upper safety cut-off limit [V]
Definition: cell_limits.hpp:17
Definition: State.hpp:24