SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
Battery.hpp
Go to the documentation of this file.
1/*
2 * Battery.hpp
3 *
4 * Created on: 11 Jun 2020
5 * Author(s): Jorn Reniers, Volkan Kumtepeli
6 */
7
8#pragma once
9
10#include "../StorageUnit.hpp"
11#include "../modules/Module.hpp"
12#include "../cooling/CoolSystem_HVAC.hpp"
13#include "../power_conversion/Converter.hpp"
14#include "../types/data_storage/cell_data.hpp"
15
16#include <memory>
17#include <vector>
18#include <span>
19
20namespace slide {
21
22class Battery : public StorageUnit
23{
24protected:
28 unsigned int nseries{ 1 }, nparallel{ 1 };
29
30 double convlosses{};
31 double convlosses_tot{};
32
33#if DATASTORE_BATT > 1
34 double timetot{ 0 };
35 BatteryData batData;
36#endif
37
38public:
39 Battery();
40 Battery(std::string IDi);
41 void setModule(Deep_ptr<Module> &&module);
42 void setSeriesandParallel(unsigned int ser, unsigned int par);
43
45 double Cap() const override { return cells->Cap() * nparallel; }
46 double Vmin() const override { return cells->Vmin() * nseries; }
47 double VMIN() const override { return cells->VMIN() * nseries; }
48 double Vmax() const override { return cells->Vmax() * nseries; }
49 double VMAX() const override { return cells->VMAX() * nseries; }
50 double I() const override { return cells->I() * nparallel; }
51 double getRtot() override { return cells->getRtot() * nseries / static_cast<double>(nparallel); }
52 size_t getNcells() override { return cells->getNcells() * nseries * nparallel; }
53
54 Module *getCells() { return cells.get(); }
56 void getStates(getStates_t &s) override;
57 void setBlockDegAndTherm(bool block);
58
59 Status setCurrent(double Inew, bool checkV = true, bool print = true) override
60 {
61 return cells->setCurrent(Inew / nparallel, checkV, print);
62 }
63
64 Status setStates(setStates_t s, bool checkStates = true, bool print = true) override;
65 double getAndResetConvLosses();
68
70 double getOCV() override { return cells->getOCV() * nseries; }
71 double V() override { return cells->V() * nseries; }
72 Status checkVoltage(double &v, bool print) noexcept override;
73 double getVhigh() override { return cells->getVhigh() * nseries; }
74 double getVlow() override { return cells->getVlow() * nseries; }
77 double T() override { return cool->T(); }
78 double getThotSpot() override { return std::max(cells->getThotSpot(), T()); }
79 double getThermalSurface() override { return cells->getThermalSurface(); }
81 double thermalModel(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim) override;
82 void setT(double Tnew) override { cool->setT(Tnew); }
83 auto *getCoolSystem() { return cool.get(); }
84 double getCoolingLoad();
87 bool validStates(bool print = true) override { return cells->validStates(print); }
89 void timeStep_CC(double dt, int steps = 1) override;
90
92 void storeData() override;
93 void writeData(const std::string &prefix) override;
94
95 Battery *copy() override { return new Battery(*this); }
96};
97
98} // namespace slide
Definition: Battery.hpp:23
Status setCurrent(double Inew, bool checkV=true, bool print=true) override
Definition: Battery.hpp:59
double convlosses
losses in the converter during a given period (set to 0 by reset_convlosses)
Definition: Battery.hpp:30
double getThotSpot() override
the T of the hottest element in the SU
Definition: Battery.hpp:76
double I() const override
Definition: Battery.hpp:50
double getAndResetConvLosses()
Definition: Battery.cpp:113
double getThermalSurface() override
return the 'A' for the thermal model of this SU (Q = hA*dT)
Definition: Battery.hpp:77
void storeData() override
Definition: Battery.cpp:228
double getVhigh() override
return the voltage of the cell with the highest voltage
Definition: Battery.hpp:73
unsigned int nparallel
number of series/parallel 'copies' of this module
Definition: Battery.hpp:28
Battery()
Definition: Battery.cpp:19
double VMAX() const override
safety cut off
Definition: Battery.hpp:49
void getStates(getStates_t &s) override
returns one long array with the states
Definition: Battery.cpp:93
Module * getCells()
int getNstates() { return cells->getNstates() + 1; } //!< +1 for the temperature of this battery
Definition: Battery.hpp:54
size_t getNcells() override
return the number of single cells connected to this SU
Definition: Battery.hpp:52
auto * getCoolSystem()
Definition: Battery.hpp:81
void setT(double Tnew) override
functionality
Definition: Battery.hpp:80
double Vmax() const override
upper voltage limit of the cell
Definition: Battery.hpp:48
Battery * copy() override
copy this SU to a new object
Definition: Battery.hpp:93
double Cap() const override
Definition: Battery.hpp:45
void setSeriesandParallel(unsigned int ser, unsigned int par)
basic getters and setters
Definition: Battery.cpp:22
void resetConvLosses()
voltage
Definition: Battery.hpp:67
double getRtot() override
Definition: Battery.hpp:51
double getConvLosses_total()
Definition: Battery.hpp:66
double T() override
Definition: Battery.hpp:75
Status setStates(setStates_t s, bool checkStates=true, bool print=true) override
opposite of getStates, check the states are valid?
Definition: Battery.cpp:106
void timeStep_CC(double dt, int steps=1) override
take a number of time steps
Definition: Battery.cpp:200
unsigned int nseries
Definition: Battery.hpp:28
void writeData(const std::string &prefix) override
Definition: Battery.cpp:240
double VMIN() const override
safety cut off
Definition: Battery.hpp:47
double Vmin() const override
lower voltage limit of the cell
Definition: Battery.hpp:46
Deep_ptr< CoolSystem_HVAC > cool
HVAC system of the battery.
Definition: Battery.hpp:26
double getVlow() override
return the voltage of the cell with the lowest voltage
Definition: Battery.hpp:74
Status checkVoltage(double &v, bool print) noexcept override
get the voltage and check if it is valid
Definition: Battery.cpp:86
double getCoolingLoad()
return the energy required to run the entire coolingsystem of this module and all its children
Definition: Battery.cpp:177
void setModule(Deep_ptr< Module > &&module)
Definition: Battery.cpp:28
void setBlockDegAndTherm(bool block)
Definition: Battery.cpp:100
bool validStates(bool print=true) override
checks if a state array is valid
Definition: Battery.hpp:85
double thermalModel(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim) override
calculate the thermal model of this SU
Definition: Battery.cpp:120
double getOCV() override
Definition: Battery.hpp:70
Deep_ptr< Module > cells
Module with the cells of this battery.
Definition: Battery.hpp:25
double convlosses_tot
total cumulative losses in the converter during the entire lifetime
Definition: Battery.hpp:31
double V() override
print is an optional argument
Definition: Battery.hpp:71
Converter conv
power electronic converter. Dual step DC/DC and DC/AC
Definition: Battery.hpp:27
Definition: Converter.hpp:15
Definition: Deep_ptr.hpp:23
Definition: Module.hpp:34
Definition: StorageUnit.hpp:27
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
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
Status
Definition: Status.hpp:15