Nektar++
AlievPanfilov.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File AlievPanfilov.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Aliev-Panfilov phenomological cell model.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <iostream>
36 #include <string>
37 
40 
41 namespace Nektar
42 {
43 /**
44  * Registers the class with the Factory.
45  */
48  "AlievPanfilov", CellModelAlievPanfilov::create,
49  "Phenomological model of canine cardiac electrophysiology.");
50 
53  const MultiRegions::ExpListSharedPtr &pField)
54  : CellModel(pSession, pField)
55 {
56  pSession->LoadParameter("k", m_k, 0.0);
57  pSession->LoadParameter("a", m_a, 0.0);
58  pSession->LoadParameter("mu1", m_mu1, 0.0);
59  pSession->LoadParameter("mu2", m_mu2, 0.0);
60  pSession->LoadParameter("eps", m_eps, 0.0);
61 
66 
67  m_nvar = 2;
68  m_concentrations.push_back(1);
69 }
70 
72  const Array<OneD, const Array<OneD, NekDouble>> &inarray,
73  Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time)
74 {
75  // inarray[0] holds initial physical u values throughout
76  // inarray[1] holds initial physical v values throughout
77 
78  // compute u^2: m_u = u*u
79  Vmath::Vmul(m_nq, &inarray[0][0], 1, &inarray[0][0], 1, &m_uu[0], 1);
80 
81  // compute u^3: m_u = u*u*u
82  Vmath::Vmul(m_nq, &inarray[0][0], 1, &m_uu[0], 1, &m_uuu[0], 1);
83 
84  // --------------------------------------
85  // Compute reaction term f(u,v)
86  // --------------------------------------
87  // if (m_spatialParameters->Exists("a"))
88  // {
89  // Vmath::Vmul(m_nq,
90  // &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
91  // &inarray[0][0], 1, &m_tmp1[0], 1);
92  //
93  // Vmath::Vvtvm(m_nq,
94  // &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
95  // &m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
96  //
97  // Vmath::Svtvm(m_nq, -1.0, &m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0],
98  // 1);
99  // }
100  // else
101  // {
102  // Ru = au
103  Vmath::Smul(m_nq, m_a, &inarray[0][0], 1, &m_tmp1[0], 1);
104  // Ru = (-1-a)u*u + au
105  Vmath::Svtvp(m_nq, (-1.0 - m_a), &m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
106  // }
107  // Ru = u*u*u - (1+a)u*u + au
108  Vmath::Vadd(m_nq, &m_uuu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
109  // Ru = k(u*u*u - (1+a)u*u + au)
110  // if (m_spatialParameters->Exists("k"))
111  // {
112  // Vmath::Vmul(m_nq,
113  // &m_spatialParameters->GetData("k")->GetPhys()[0], 1,
114  // &m_tmp1[0], 1, &m_tmp1[0], 1);
115  // }
116  // else
117  // {
118  Vmath::Smul(m_nq, m_k, &m_tmp1[0], 1, &m_tmp1[0], 1);
119  // }
120 
121  // Ru = k(u*u*u - (1+a)u*u + au) + I_stim
122  Vmath::Vadd(m_nq, &outarray[0][0], 1, &m_tmp1[0], 1, &outarray[0][0], 1);
123 
124  // Ru = k(u*u*u - (1+a)u*u + au) + uv + I_stim
125  Vmath::Vvtvp(m_nq, &inarray[0][0], 1, &inarray[1][0], 1, &m_tmp1[0], 1,
126  &outarray[0][0], 1);
127  // Ru = -k(u*u*u - (1+a)u*u + au) - uv - I_stim
128  Vmath::Neg(m_nq, &outarray[0][0], 1);
129 
130  // --------------------------------------
131  // Compute reaction term g(u,v)
132  // --------------------------------------
133  // tmp2 = mu2 + u
134  Vmath::Sadd(m_nq, m_mu2, &inarray[0][0], 1, &m_tmp2[0], 1);
135 
136  // tmp2 = v/(mu2 + u)
137  Vmath::Vdiv(m_nq, &inarray[1][0], 1, &m_tmp2[0], 1, &m_tmp2[0], 1);
138 
139  // tmp2 = mu1*v/(mu2 + u)
140  Vmath::Smul(m_nq, m_mu1, &m_tmp2[0], 1, &m_tmp2[0], 1);
141 
142  // tmp1 = Eps + mu1*v/(mu2+u)
143  Vmath::Sadd(m_nq, m_eps, &m_tmp2[0], 1, &m_tmp2[0], 1);
144 
145  // tmp1 = (-a-1) + u
146  // if (m_spatialParameters->Exists("a"))
147  // {
148  // Vmath::Vsub(m_nq, &inarray[0][0], 1,
149  // &m_spatialParameters->GetData("a")->GetPhys()[0],
150  // 1, &m_tmp1[0], 1);
151  //
152  // Vmath::Sadd(m_nq, -1.0, &inarray[0][0], 1, &m_tmp1[0], 1);
153  // }
154  // else
155  // {
156  Vmath::Sadd(m_nq, (-m_a - 1), &inarray[0][0], 1, &m_tmp1[0], 1);
157  // }
158 
159  // tmp1 = k(u-a-1)
160  // if (m_spatialParameters->Exists("k"))
161  // {
162  // Vmath::Vmul(m_nq,
163  // &m_spatialParameters->GetData("k")->GetPhys()[0], 1,
164  // &m_tmp1[0], 1, &m_tmp1[0], 1);
165  // }
166  // else
167  // {
168  Vmath::Smul(m_nq, m_k, &m_tmp1[0], 1, &m_tmp1[0], 1);
169  // }
170 
171  // tmp1 = ku(u-a-1) + v
172  Vmath::Vvtvp(m_nq, &inarray[0][0], 1, &m_tmp1[0], 1, &inarray[1][0], 1,
173  &m_tmp1[0], 1);
174 
175  // tmp1 = -ku(u-a-1)-v
176  Vmath::Neg(m_nq, &m_tmp1[0], 1);
177 
178  // outarray = [Eps + mu1*v/(mu2+u)] * [-ku(u-a-1)-v]
179  Vmath::Vmul(m_nq, &m_tmp1[0], 1, &m_tmp2[0], 1, &outarray[1][0], 1);
180 }
181 
182 /**
183  *
184  */
186 {
187  SolverUtils::AddSummaryItem(s, "Cell model", "Aliev-Panfilov");
193 }
194 
195 /**
196  *
197  */
199 {
200  Vmath::Fill(m_nq, 0.0, m_cellSol[0], 1);
201  Vmath::Fill(m_nq, 0.0, m_cellSol[1], 1);
202 }
203 } // namespace Nektar
Array< OneD, NekDouble > m_tmp1
Workspace for computing reaction term.
Definition: AlievPanfilov.h:91
CellModelAlievPanfilov(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
static std::string className
Name of class.
Definition: AlievPanfilov.h:56
virtual void v_GenerateSummary(SummaryList &s)
Array< OneD, NekDouble > m_uuu
Temporary space for storing when computing reaction term.
Definition: AlievPanfilov.h:89
virtual void v_Update(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Array< OneD, NekDouble > m_uu
Temporary space for storing when computing reaction term.
Definition: AlievPanfilov.h:87
static CellModelSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Creates an instance of this class.
Definition: AlievPanfilov.h:47
NekDouble m_a
Trigger parameter a.
Definition: AlievPanfilov.h:76
NekDouble m_k
Scaling parameter k.
Definition: AlievPanfilov.h:78
NekDouble m_mu1
Restitution parameter .
Definition: AlievPanfilov.h:80
Array< OneD, NekDouble > m_tmp2
Workspace for computing reaction term.
Definition: AlievPanfilov.h:93
NekDouble m_eps
Restitution parameter .
Definition: AlievPanfilov.h:84
NekDouble m_mu2
Restitution parameter .
Definition: AlievPanfilov.h:82
Cell model base class.
Definition: CellModel.h:66
Array< OneD, Array< OneD, NekDouble > > m_cellSol
Cell model solution variables.
Definition: CellModel.h:126
int m_nq
Number of physical points.
Definition: CellModel.h:117
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
Definition: CellModel.h:139
int m_nvar
Number of variables in cell model (inc. transmembrane voltage)
Definition: CellModel.h:119
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:48
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:49
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:46
double NekDouble
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:209
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:622
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:518
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:574
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:359
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:248
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:284
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha - x.
Definition: Vmath.cpp:384