SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
slide_aux.hpp
Go to the documentation of this file.
1/*
2 * slide_aux.hpp
3 *
4 * Auxillary classes and functions. 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 "array_util.hpp"
18#include "interpolation.hpp"
19#include "../types/matrix.hpp"
20#include "../types/XYdata.hpp"
21#include "../types/FixedData.hpp"
22
23#include <stdexcept>
24#include <vector>
25#include <array>
26#include <functional>
27#include <cmath>
28#include <filesystem>
29
30namespace slide {
31template <typename StoredClass, int N>
33{
35};
36
37template <int N, typename T>
38double norm_sq(const T &x)
39{
40 if constexpr (N < -1)
41 throw 12345;
42 else if (N == -1)
43 throw 12344;
44 else if (N == 0)
45 throw 333456;
46 else {
47 double sum = 0;
48 for (const auto &x_i : x)
49 sum += std::pow(x_i, N);
50
51 return sum;
52 }
53 throw 345789;
54}
55
56template <int N, typename T>
57double norm(const T &x)
58{
59 const double norm_square = norm_sq(x);
60
61 if (N < 2)
62 return norm_square;
63 else {
64 const double N_double = N;
65 return std::pow(norm_square, 1.0 / N_double);
66 }
67}
68
70{
71};
72
74{
75 double a, inv_b, scale;
77 GammaDensityFunctor(double a_, double b_) : a(a_), inv_b(1 / b_), scale(1 / std::tgamma(a_) / std::pow(b_, a_)) {}
78 double operator()(double x) { return scale * std::exp(-inv_b * x) * std::pow(x, a - 1); }
79};
80
81} // namespace slide
Definition: slide_aux.hpp:70
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
double norm_sq(const T &x)
< Takes vector or array:
Definition: slide_aux.hpp:38
double norm(const T &x)
< Takes vector or array:
Definition: slide_aux.hpp:57
Definition: slide_aux.hpp:33
Definition: slide_aux.hpp:74
double a
Definition: slide_aux.hpp:75
GammaDensityFunctor(double a_, double b_)
Definition: slide_aux.hpp:77
double operator()(double x)
Definition: slide_aux.hpp:78
double scale
Definition: slide_aux.hpp:75
double inv_b
Definition: slide_aux.hpp:75
GammaDensityFunctor()=delete
Even it is delete, it constructs with default values.