SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
State.hpp
Go to the documentation of this file.
1/*
2 * State.hpp
3 *
4 * Generic State class to hold time, Ah, Wh.
5 *
6 * Created on: 02 Sep 2022
7 * Author(s): Jorn Reniers, Volkan Kumtepeli
8 */
9
10#pragma once
11
12#include "../settings/settings.hpp"
13#include "../utility/array_util.hpp"
14
15#include <array>
16#include <algorithm>
17
18namespace slide {
19
20static double EMPTY_STATE{ 0 }; // To return reference when a state is not defined.
21
22template <size_t N, size_t N_cumulative = settings::data::N_CumulativeCell>
23struct State : public std::array<double, N + N_cumulative>
24{
25 enum Index : size_t
26 {
27 i_time = N,
31 };
32
33 inline auto time() const { return (N_cumulative != 3) ? EMPTY_STATE : (*this)[i_time]; }
34 inline auto Ah() const { return (N_cumulative != 3) ? EMPTY_STATE : (*this)[i_Ah]; }
35 inline auto Wh() const { return (N_cumulative != 3) ? EMPTY_STATE : (*this)[i_Wh]; }
36
37 inline auto &time() { return (N_cumulative != 3) ? EMPTY_STATE : (*this)[i_time]; }
38 inline auto &Ah() { return (N_cumulative != 3) ? EMPTY_STATE : (*this)[i_Ah]; }
39 inline auto &Wh() { return (N_cumulative != 3) ? EMPTY_STATE : (*this)[i_Wh]; }
40
41 constexpr static auto description(size_t i)
42 {
43 if constexpr (N_cumulative != 3)
44 return "";
45 else {
46 if (i == i_time)
47 return "time [s]";
48 else if (i == i_Ah)
49 return "Current throughput [Ah]";
50 else if (i == i_Wh)
51 return "Energy throughput [Wh]";
52 else
53 return "";
54 }
55 }
56
57 inline auto reset() { this->fill(0); }
58};
59
60} // namespace slide
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
Definition: State.hpp:24
static constexpr auto description(size_t i)
Definition: State.hpp:41
auto Wh() const
Energy throughput [Wh].
Definition: State.hpp:35
Index
Definition: State.hpp:26
@ i_Wh
Definition: State.hpp:29
@ i_Ah
Definition: State.hpp:28
@ N_states
Definition: State.hpp:30
@ i_time
Definition: State.hpp:27
auto & time()
time [s]
Definition: State.hpp:37
auto Ah() const
Current throughput [Ah].
Definition: State.hpp:34
auto time() const
time [s]
Definition: State.hpp:33
auto reset()
Definition: State.hpp:57
auto & Wh()
Energy throughput [Wh].
Definition: State.hpp:39
auto & Ah()
Current throughput [Ah].
Definition: State.hpp:38