![]() |
SLIDE
3.0.0
A simulator for lithium-ion battery pack degradation
|
#include <Module.hpp>
Public Types | |
using | SU_t = Deep_ptr< StorageUnit > |
< connected child SUs More... | |
using | SUs_t = std::vector< SU_t > |
using | SUs_span_t = std::span< SU_t > |
using | CoolSystem_t = Deep_ptr< CoolSystem > |
Public Member Functions | |
Module () | |
Module (std::string_view ID_) | |
Module (std::string_view ID_, double Ti, bool print, bool pari, int Ncells, int coolControl, int cooltype) | |
Module (std::string_view ID_, double Ti, bool print, bool pari, int Ncells, CoolSystem_t &&coolControlPtr, int cooltype) | |
common implementation for all base-modules More... | |
size_t | getNSUs () |
note that these child-SUs can be modules themselves (or they can be cells) More... | |
SUs_t & | getSUs () |
const auto & | operator[] (size_t i) const |
auto & | operator[] (size_t i) |
virtual Status | checkVoltage (double &v, bool print) noexcept override |
get the voltage and check if it is valid More... | |
double | getVhigh () override |
return the voltage of the cell with the highest voltage More... | |
double | getVlow () override |
return the voltage of the cell with the lowest voltage More... | |
void | getStates (getStates_t &s) override |
returns one long array with the states: getStates-array of each cell followed by the states of the module (Tmod) More... | |
virtual bool | validStates (bool print=true) override |
check if a state-array is valid for this module (uses setStates) More... | |
virtual Status | setStates (setStates_t s, bool checkV=true, bool print=true) override |
thermal model More... | |
double | T () override |
get the temperature of this module More... | |
double | getThermalSurface () override |
return the 'A' for the thermal model of this SU (Q = hA*dT) More... | |
double | getCoolingLoad () |
return the energy required to run the entire coolingsystem of this module and all its children More... | |
double | thermalModel (int Nneighbours, double Tneighbours[], double Kneighbours[], double Aneighb[], double tim) override |
calculate the thermal model of this SU More... | |
virtual void | setSUs (SUs_span_t c, bool checkCells=true, bool print=true) |
CoolSystem * | getCoolSystem () |
void | setRcontact (std::span< double > Rc) |
virtual Module * | copy () override=0 |
copy this SU to a new object More... | |
void | storeData () override |
void | writeData (const std::string &prefix) override |
void | setBlockDegAndTherm (bool block) |
void | setT (double Tnew) override |
set a module temperature More... | |
size_t | getNcells () override |
double | getThotSpot () override |
< get the maximum temperature of the cells or the module More... | |
![]() | |
StorageUnit ()=default | |
< basic getters and setters More... | |
StorageUnit (std::string_view ID_) | |
StorageUnit (std::string_view ID_, StorageUnit *parent_, bool blockDegAndTherm_) | |
virtual | ~StorageUnit ()=default |
const std::string & | getID () |
void | setID (std::string IDi) |
Return the full ID string, including the ID of the parent module. More... | |
virtual std::string | getFullID () |
virtual double | Cap () const =0 |
auto * | getParent () |
virtual double | I () const =0 |
virtual double | getRtot ()=0 |
virtual size_t | getNcells ()=0 |
return the number of single cells connected to this SU More... | |
bool | isCharging () |
negative means charge. More... | |
bool | isDischarging () |
positive means discharge. More... | |
virtual void | getStates (getStates_t s)=0 |
returns one long array with the states More... | |
virtual viewStates_t | viewStates () |
Only for cells to see individual states. More... | |
void | setBlockDegAndTherm (bool block) |
virtual void | setParent (StorageUnit *p) |
set the parent More... | |
virtual Status | setCurrent (double Inew, bool checkV=true, bool print=true)=0 |
virtual Status | setVoltage (double Vnew, bool checkI=true, bool print=true) |
virtual Status | setStates (setStates_t s, bool checkStates=true, bool print=true)=0 |
opposite of getStates, check the states are valid? More... | |
virtual void | backupStates () |
Back-up states. More... | |
virtual void | restoreStates () |
restore backed-up states. More... | |
virtual double | getOCV ()=0 |
virtual double | V ()=0 |
print is an optional argument More... | |
virtual Status | checkVoltage (double &v, bool print) noexcept=0 |
get the voltage and check if it is valid More... | |
virtual double | getVhigh ()=0 |
return the voltage of the cell with the highest voltage More... | |
virtual double | getVlow ()=0 |
return the voltage of the cell with the lowest voltage More... | |
virtual double | Vmin () const =0 |
lower voltage limit of the cell More... | |
virtual double | VMIN () const =0 |
safety cut off More... | |
virtual double | Vmax () const =0 |
upper voltage limit of the cell More... | |
virtual double | VMAX () const =0 |
safety cut off More... | |
virtual double | T ()=0 |
virtual double | getThotSpot ()=0 |
the T of the hottest element in the SU More... | |
virtual double | getThermalSurface ()=0 |
return the 'A' for the thermal model of this SU (Q = hA*dT) More... | |
virtual double | thermalModel (int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim)=0 |
calculate the thermal model of this SU More... | |
virtual void | setT (double Tnew)=0 |
functionality More... | |
virtual bool | validStates (bool print=true)=0 |
checks if a state array is valid More... | |
virtual StorageUnit * | copy ()=0 |
copy this SU to a new object More... | |
virtual void | timeStep_CC (double dt, int steps=1)=0 |
take a number of time steps More... | |
virtual void | storeData ()=0 |
virtual void | writeData (const std::string &prefix)=0 |
Protected Member Functions | |
size_t | calculateNcells () override |
double | thermalModel_cell () |
double | thermalModel_coupled (int Nneighbours, double Tneighbours[], double Kneighbours[], double Aneighb[], double tim) |
virtual size_t | calculateNcells () |
Protected Attributes | |
SUs_t | SUs |
std::vector< double > | Rcontact |
array with the contact resistance for cell i More... | |
CoolSystem_t | cool { nullptr } |
cooling system of this module //!< make<CoolSystem>(settings::MODULE_NSUs_MAX, 1); More... | |
ModuleThermalParam | therm |
voltage More... | |
size_t | Ncells |
Number of cells this module contains. More... | |
double | Vmodule { 0 } |
voltage of the module More... | |
bool | Vmodule_valid { false } |
boolean indicating if stored the voltage of the module is valid More... | |
bool | par { true } |
State< 0, settings::data::N_CumulativeModule > | st_module |
std::vector< double > | data |
Time data. More... | |
![]() | |
std::string | ID { "StorageUnit" } |
identification string More... | |
StorageUnit * | parent { nullptr } |
pointer to the SU 'above' this one [e.g. the module to which a cell is connected] More... | |
bool | blockDegAndTherm { false } |
if true, degradation and the thermal ODE are ignored More... | |
Additional Inherited Members | |
![]() | |
using | setStates_t = std::span< double > & |
To pass states to read, non-expandable container. More... | |
using | getStates_t = std::vector< double > & |
To pass states to save, expandable container. More... | |
using | viewStates_t = std::span< double > |
using slide::Module::SU_t = Deep_ptr<StorageUnit> |
< connected child SUs
using slide::Module::SUs_span_t = std::span<SU_t> |
using slide::Module::SUs_t = std::vector<SU_t> |
|
inline |
|
inline |
slide::Module::Module | ( | std::string_view | ID_, |
double | Ti, | ||
bool | print, | ||
bool | pari, | ||
int | Ncells, | ||
int | coolControl, | ||
int | cooltype | ||
) |
< Set the module temperature
< thermally active surface area. The first number is the thermal active surface area of a cell
< constant ancillary losses. There are none since a module only has cells
slide::Module::Module | ( | std::string_view | ID_, |
double | Ti, | ||
bool | print, | ||
bool | pari, | ||
int | Ncells, | ||
CoolSystem_t && | coolControlPtr, | ||
int | cooltype | ||
) |
common implementation for all base-modules
< thermally active surface area. The first number is the thermal active surface area of a cell
|
inlineoverrideprotectedvirtual |
< #TODO this function needs to call parent to update their number of cells if they are module.
Reimplemented from slide::StorageUnit.
|
overridevirtualnoexcept |
get the voltage and check if it is valid
< const bool printCrit = print && (settings::printBool::printCrit); //!< print if the (global) verbose-setting is above the threshold const bool printNonCrit = print && (settings::printBool::printNonCrit); //!< print if the (global) verbose-setting is above the threshold
< check the voltage of the module
< #TODO here was a not useful chuck of code for repeated checking. We may have constant limits for module voltage.
< check the voltages of the connected cells
Implements slide::StorageUnit.
|
overridepure virtual |
copy this SU to a new object
Implements slide::StorageUnit.
Implemented in slide::Module_p, and slide::Module_s.
double slide::Module::getCoolingLoad | ( | ) |
return the energy required to run the entire coolingsystem of this module and all its children
< energy to run coolsystem of this module
< reset to 0
< loop for the children, and if they are modules, add their cooling energy
< cast to a module pointer instead of storage unit
< add energy
< reset cooling energy for that child
|
inline |
|
inlineoverridevirtual |
Return the temperature of the hottest element of the module. Note that this will be the T of a cell, since child-modules will pass on this function to their cells
Implements slide::StorageUnit.
|
inline |
note that these child-SUs can be modules themselves (or they can be cells)
|
override |
returns one long array with the states: getStates-array of each cell followed by the states of the module (Tmod)
< pass a vector, the next nsi locations will be automatically filled with the states of cell i
< store the module temperature
|
inline |
|
inlineoverridevirtual |
return the 'A' for the thermal model of this SU (Q = hA*dT)
Implements slide::StorageUnit.
|
inlineoverridevirtual |
< get the maximum temperature of the cells or the module
Implements slide::StorageUnit.
|
overridevirtual |
return the voltage of the cell with the highest voltage
< return the voltage of the cell with the highest voltage note CELL not child SU
< will be called recursively to the cell levels
Implements slide::StorageUnit.
|
overridevirtual |
return the voltage of the cell with the lowest voltage
< return the voltage of the cell with the lowest voltage note CELL not child SU
< will be called recursively to the cell levels
Implements slide::StorageUnit.
|
inline |
|
inline |
|
inline |
|
inline |
< we are changing the resistance, so the stored voltage is no longer valid
Rc | #TODO if ok. |
|
overridevirtual |
thermal model
Set the states of this module to the given one note: setStates is the master function to check if states and cells are valid if checkV=true, then also the cell and module voltages are checked the other functions just call setStates to check validity
< we are changing the states, so the stored voltage is no longer valid
< set the new cell states
< set the states
< restore the original states without checking validity (they should be valid)
< set the module temperature
< #TODO here we are checking but should we?
< check that the cells are valid for this module configuration (same I if series, same V if parallel)
< return success.
Implements slide::StorageUnit.
|
virtual |
Sets the cells of this module. Checks module-constraints does not check if the states of cells are valid, nor the voltages of the cells and module it only checks whether the cells are ok for this module (same current if series, same voltage if parallel) note on virtual functions, see StorageUnit.hpp
< check the cells don't have parents yet (unless it is this module)
< #TODO probably cannot be this since it is a unique_ptr
< connect the cells to this module
< we are changing the SUs, so the stored voltage is no longer valid
< Set the parent of all cells/ Does not throw.
< Make Rcontact zero? #TODO
|
inlineoverridevirtual |
set a module temperature
Implements slide::StorageUnit.
|
inlineoverridevirtual |
< Tell all connected cells to store their data
< Store data for the coolsystem
< Store data of this module
Implements slide::StorageUnit.
|
inlineoverridevirtual |
get the temperature of this module
Implements slide::StorageUnit.
|
overridevirtual |
calculate the thermal model of this SU
< indicate we have ran the thermal model
< control the cooling system is done at the time integration function
Implements slide::StorageUnit.
|
protected |
< array with the new temperatures of the child SUs
< dummy arrays
< calculate cells' temperature
< the temperature of a module doesn't change
|
protected |
< Check the time keeping
< then check whether our internal time keeping matches up with the external one
< array with the new temperatures of the child SUs
< ************************************************************* heat exchange with child SUs ******************************************************************* Make the arrays for heat exchange to each child SU. They have max length 3 (cooling from here, and 2 neighbours)
< parent, left neighbour, right neighbour
< The first element is the cooling from the parent module to the child SUs
< Loop to cool each child SU
< left cell
< conductive heat exchange via long sides of cell
< left is cell i-1
< left is module
< Last cell. getNSUs() is unsigned therefore getNSUs() -1 is omitted.
< right is edge of module
< additional cooling to the first and last cell of the stack (which both have 1 edge from the coolsystem)
< #TODO problem.
< cooling energy extracted from the children
< *********************************************************** Heat exchange with neighbours and parent **********************************************************
< The module exchanges heat with its parent and neighbours
< Calculate the new temperature of the coolant rho * cp * dT/dt = Qtot / V where Qtot is total power in W V is the total volume of fluid over the time period, the product of the flow rate and the time (therm_v*tim) so integrated over time this is rho * cp * (Tnew - Told) = Etot / V
< Set all the new temperatures to the children
< reset the time since the last update of the thermal model
< Check the new temperature is valid
< no time has passed -> no heat generated -> just return present temperature
|
overridevirtual |
check if a state-array is valid for this module (uses setStates)
< print if the (global) verbose-setting is above the threshold
Implements slide::StorageUnit.
|
inlineoverridevirtual |
< Tell all connected cells to write their data
< Write data for this module
< name of the file, start with the full hierarchy-ID to identify this cell
< append the new data to the existing file
Implements slide::StorageUnit.
|
protected |
cooling system of this module //!< make<CoolSystem>(settings::MODULE_NSUs_MAX, 1);
|
protected |
Time data.
|
protected |
Number of cells this module contains.
|
protected |
if true, some functions will be calculated parallel using multithreaded computing data storage
|
protected |
array with the contact resistance for cell i
thermal model
|
protected |
|
protected |
|
protected |
voltage
|
protected |
voltage of the module
|
protected |
boolean indicating if stored the voltage of the module is valid