SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
Model_SPM.hpp
Go to the documentation of this file.
1/*
2 * Model_SPM.hpp
3 *
4 * Defines a struct to store the matrices for the spatial discretisation of the solid diffusion PDE
5 *
6 * Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
7 * of Oxford, VITO nv, and the 'Slide' Developers.
8 * See the licence file LICENCE.txt for more information.
9 */
10
11#pragma once
12
13#include "../../types/matrix.hpp"
14#include "../../settings/settings.hpp"
15#include "../../utility/utility.hpp"
16
17#include <array>
18
19namespace slide {
24{
25 constexpr static auto nch = settings::nch;
26 std::array<double, 4> Input;
27
28 std::array<double, nch> xch;
29
31 // dzpos/dt = Ap*zpos + Bp*jp time derivative of (transformed) concentration at the inner nodes
32 // dzneg/dt = An*zneg + Bn*jn
33 // cp = Cp*zpos + Dp*jp actual concentration [mol m-3] of the nodes (surface, inner)
35
36 std::array<double, nch> Ap, An;
37 std::array<double, nch> Bp, Bn;
38
40
41 std::array<double, nch + 1> Cc, Dp, Dn;
42
44
46
48 {
49 /*
50 * Constructor to initialise the matrices of the spatial discretisation of the solid diffusion PDE.
51 * The matrices are calculated by the MATLAB function modelSetup.m and written to csv files.
52 * This function reads those csv files.
53 */
54 try {
56 loadCSV_1col(PathVar::data / "Cheb_Nodes.csv", xch);
57 loadCSV_1col(PathVar::data / "Cheb_An.csv", An);
58 loadCSV_1col(PathVar::data / "Cheb_Ap.csv", Ap);
59 loadCSV_1col(PathVar::data / "Cheb_Bn.csv", Bn);
60 loadCSV_1col(PathVar::data / "Cheb_Bp.csv", Bp);
61 loadCSV_1col(PathVar::data / "Cheb_Cc.csv", Cc);
62 loadCSV_1col(PathVar::data / "Cheb_Dn.csv", Dn);
63 loadCSV_1col(PathVar::data / "Cheb_Dp.csv", Dp);
64 loadCSV_1col(PathVar::data / "Cheb_input.csv", Input);
65
67 loadCSV_mat(PathVar::data / "Cheb_Cn.csv", Cn);
68 loadCSV_mat(PathVar::data / "Cheb_Cp.csv", Cp);
69 loadCSV_mat(PathVar::data / "Cheb_Vn.csv", Vn);
70 loadCSV_mat(PathVar::data / "Cheb_Vp.csv", Vp);
71 loadCSV_mat(PathVar::data / "Cheb_Q.csv", Q);
72 } catch (int e) {
73 std::cout << "Error in Model_SPM::Model_SPM() when reading the files: "
74 << e << ".\n";
75 throw e;
76 }
77 }
78
80 {
81 static Model_SPM M;
82 return &M;
83 }
84};
85
86} // namespace slide
constexpr size_t nch
Definition: settings.hpp:33
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
std::array< std::array< T, COL >, ROW > Matrix
See source: http://cpptruths.blogspot.com/2011/10/multi-dimensional-arrays-in-c11....
Definition: matrix.hpp:21
void loadCSV_mat(const Tpath &name, Matrix< T, ROW, COL > &x)
Definition: read_CSVfiles.hpp:57
void loadCSV_1col(const Tpath &name, std::array< T, ROW > &x)
Definition: read_CSVfiles.hpp:94
Definition: Model_SPM.hpp:24
std::array< double, nch > Ap
< cn = Cn*zpos + Dn*jn
Definition: Model_SPM.hpp:36
slide::Matrix< double, nch+1, nch > Cp
Definition: Model_SPM.hpp:39
std::array< double, nch > Bp
Definition: Model_SPM.hpp:37
std::array< double, 4 > Input
array with the input parameters of the MATLAB files
Definition: Model_SPM.hpp:26
std::array< double, nch > Bn
Definition: Model_SPM.hpp:37
std::array< double, nch+1 > Dn
matrix to get the concentration at the centre node
Definition: Model_SPM.hpp:41
slide::Matrix< double, nch, nch > Vp
Definition: Model_SPM.hpp:43
std::array< double, nch+1 > Dp
Definition: Model_SPM.hpp:41
std::array< double, nch > An
only main diagonal is non-zero, so only store those values
Definition: Model_SPM.hpp:36
std::array< double, nch > xch
location of the Chebyshev nodes in the positive domain EXCLUDING centre and surface
Definition: Model_SPM.hpp:28
Model_SPM()
Definition: Model_SPM.hpp:47
std::array< double, nch+1 > Cc
Definition: Model_SPM.hpp:41
slide::Matrix< double, nch, nch > Vn
inverse of the eigenvectors for the positive/negative electrode
Definition: Model_SPM.hpp:43
static Model_SPM * makeModel()
Definition: Model_SPM.hpp:79
slide::Matrix< double, 2 *nch+3, 2 *nch+3 > Q
Matrix for Chebyshev integration.
Definition: Model_SPM.hpp:45
static constexpr auto nch
Definition: Model_SPM.hpp:25
slide::Matrix< double, nch+1, nch > Cn
Definition: Model_SPM.hpp:39