Nektar++
FitzhughNagumo.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: FitzhughNagumo.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: FitzhughNagumo 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  "FitzHughNagumo", CellModelFitzHughNagumo::create,
49  "Phenomological model of squid nerve cell.");
50 
53  const MultiRegions::ExpListSharedPtr &pField)
54  : CellModel(pSession, pField)
55 {
56  pSession->LoadParameter("beta", m_beta, 0.0);
57  pSession->LoadParameter("epsilon", m_epsilon, 1.0);
58 
60 
61  m_nvar = 2;
62  m_concentrations.push_back(1);
63 }
64 
66  const Array<OneD, const Array<OneD, NekDouble>> &inarray,
67  Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time)
68 {
69  boost::ignore_unused(time);
70 
71  NekDouble m_gamma = 0.5;
72 
73  // compute u^2: m_u = u*u
74  Vmath::Vmul(m_nq, &inarray[0][0], 1, &inarray[0][0], 1, &m_uuu[0], 1);
75 
76  // compute u^3: m_u = u*u*u
77  Vmath::Vmul(m_nq, &inarray[0][0], 1, &m_uuu[0], 1, &m_uuu[0], 1);
78 
79  // For u: (1/m_epsilon)*( u*-u*u*u/3 - v )
80  // physfield = u - (1.0/3.0)*u*u*u
81  Vmath::Svtvp(m_nq, (-1.0 / 3.0), &m_uuu[0], 1, &inarray[0][0], 1,
82  &outarray[0][0], 1);
83 
84  Vmath::Vsub(m_nq, &inarray[1][0], 1, &outarray[0][0], 1, &outarray[0][0],
85  1);
86  Vmath::Smul(m_nq, -1.0 / m_epsilon, &outarray[0][0], 1, &outarray[0][0], 1);
87 
88  // For v: m_epsilon*( u + m_beta - m_gamma*v )
89  Vmath::Svtvp(m_nq, -1.0 * m_gamma, &inarray[1][0], 1, &inarray[0][0], 1,
90  &outarray[1][0], 1);
91  Vmath::Sadd(m_nq, m_beta, &outarray[1][0], 1, &outarray[1][0], 1);
92  Vmath::Smul(m_nq, m_epsilon, &outarray[1][0], 1, &outarray[1][0], 1);
93 }
94 
95 /**
96  *
97  */
99 {
100  SolverUtils::AddSummaryItem(s, "Cell model", "FitzHugh-Nagumo");
101  SolverUtils::AddSummaryItem(s, "Cell model beta", m_beta);
102 }
103 
104 /**
105  *
106  */
108 {
109  Vmath::Fill(m_nq, 0.0, m_cellSol[0], 1);
110  Vmath::Fill(m_nq, 0.0, m_cellSol[1], 1);
111 }
112 
113 } // namespace Nektar
virtual void v_Update(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time) override
virtual void v_GenerateSummary(SummaryList &s) override
Array< OneD, NekDouble > m_uuu
Temporary space for storing when computing reaction term.
CellModelFitzHughNagumo(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
static CellModelSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Creates an instance of this class.
virtual void v_SetInitialConditions() override
static std::string className
Name of class.
Cell model base class.
Definition: CellModel.h:66
Array< OneD, Array< OneD, NekDouble > > m_cellSol
Cell model solution variables.
Definition: CellModel.h:126
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
Definition: CellModel.h:139
size_t m_nq
Number of physical points.
Definition: CellModel.h:117
size_t 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:2
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 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 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 scalar y = alpha + x.
Definition: Vmath.cpp:384
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:419