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
41namespace Nektar
42{
43/**
44 * Registers the class with the Factory.
45 */
48 "FitzHughNagumo", CellModelFitzHughNagumo::create,
49 "Phenomological model of squid nerve cell.");
50
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,
68 [[maybe_unused]] const NekDouble time)
69{
70 NekDouble m_gamma = 0.5;
71
72 // compute u^2: m_u = u*u
73 Vmath::Vmul(m_nq, &inarray[0][0], 1, &inarray[0][0], 1, &m_uuu[0], 1);
74
75 // compute u^3: m_u = u*u*u
76 Vmath::Vmul(m_nq, &inarray[0][0], 1, &m_uuu[0], 1, &m_uuu[0], 1);
77
78 // For u: (1/m_epsilon)*( u*-u*u*u/3 - v )
79 // physfield = u - (1.0/3.0)*u*u*u
80 Vmath::Svtvp(m_nq, (-1.0 / 3.0), &m_uuu[0], 1, &inarray[0][0], 1,
81 &outarray[0][0], 1);
82
83 Vmath::Vsub(m_nq, &inarray[1][0], 1, &outarray[0][0], 1, &outarray[0][0],
84 1);
85 Vmath::Smul(m_nq, -1.0 / m_epsilon, &outarray[0][0], 1, &outarray[0][0], 1);
86
87 // For v: m_epsilon*( u + m_beta - m_gamma*v )
88 Vmath::Svtvp(m_nq, -1.0 * m_gamma, &inarray[1][0], 1, &inarray[0][0], 1,
89 &outarray[1][0], 1);
90 Vmath::Sadd(m_nq, m_beta, &outarray[1][0], 1, &outarray[1][0], 1);
91 Vmath::Smul(m_nq, m_epsilon, &outarray[1][0], 1, &outarray[1][0], 1);
92}
93
94/**
95 *
96 */
98{
99 SolverUtils::AddSummaryItem(s, "Cell model", "FitzHugh-Nagumo");
100 SolverUtils::AddSummaryItem(s, "Cell model beta", m_beta);
101}
102
103/**
104 *
105 */
107{
108 Vmath::Fill(m_nq, 0.0, m_cellSol[0], 1);
109 Vmath::Fill(m_nq, 0.0, m_cellSol[1], 1);
110}
111
112} // namespace Nektar
void v_Update(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time) override
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.
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.
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:46
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:47
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.hpp:72
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.hpp:396
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.hpp:100
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.hpp:54
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.hpp:194
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.hpp:220