LifeV
IonicFitzHughNagumo.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Ionic model of FitzHugh-Nagumo
30  @date 01-2013
31  @author Giacomo Rosilho de Souza <giacomo.rosilhodesouza@epfl.ch>
32 
33  @contributors
34  @mantainer Giacomo Rosilho de Souza <giacomo.rosilhodesouza@epfl.ch>
35  @last update 01-2013
36  */
37 
38 #include <lifev/electrophysiology/solver/IonicModels/IonicFitzHughNagumo.hpp>
39 
40 namespace LifeV
41 {
42 // ===================================================
43 //! Constructors
44 // ===================================================
46  super ( 2 ),
47  M_G ( 1.5 ),
48  M_Vth ( 13. ),
49  M_Vp ( 100. ),
50  M_Eta1 ( 4.4 ),
51  M_Eta2 ( 0.012 ),
52  M_Eta3 ( 1.),
53  M_Eta (M_Eta2 / M_Vp),
55 
56 {
57  M_restingConditions.at (0) = 1e-8;
58  M_restingConditions.at (1) = 0.3;
59 }
60 
61 IonicFitzHughNagumo::IonicFitzHughNagumo ( Teuchos::ParameterList& parameterList ) :
62  super ( 2 )
63 {
64  setup ( parameterList );
65 
66  M_restingConditions.at (0) = 1e-8;
67  M_restingConditions.at (1) = 0.3;
68 }
69 
71 {
72  M_G = model.M_G;
73  M_Vth = model.M_Vth;
74  M_Vp = model.M_Vp;
75  M_Eta1 = model.M_Eta1;
76  M_Eta2 = model.M_Eta2;
77  M_Eta3 = model.M_Eta3;
78  M_Eta = model.M_Eta;
79  M_Gamma = model.M_Gamma;
80 
81  M_numberOfEquations = model.M_numberOfEquations;
82  M_restingConditions = model.M_restingConditions;
83 }
84 
85 // ===================================================
86 //! Operator
87 // ===================================================
89 {
90  M_G = model.M_G;
91  M_Vth = model.M_Vth;
92  M_Vp = model.M_Vp;
93  M_Eta1 = model.M_Eta1;
94  M_Eta2 = model.M_Eta2;
95  M_Eta3 = model.M_Eta3;
96  M_Eta = model.M_Eta;
97  M_Gamma = model.M_Gamma;
98 
99  M_numberOfEquations = model.M_numberOfEquations;
100  M_restingConditions = model.M_restingConditions;
101 
102  return *this;
103 }
104 
105 
106 // ===================================================
107 //! Methods
108 // ===================================================
109 void IonicFitzHughNagumo::setup ( Teuchos::ParameterList& parameterList )
110 {
111  M_G = parameterList.get ("G", 1.5);
112  M_Vth = parameterList.get ("Vth", 13.);
113  M_Vp = parameterList.get ("Vp", 100.);
114  M_Eta1 = parameterList.get ("Eta1", 4.4);
115  M_Eta2 = parameterList.get ("Eta2", 0.012);
116  M_Eta3 = parameterList.get ("Eta3", 1.);
117  M_Eta = M_Eta2 / M_Vp;
118  M_Gamma = M_Eta2 * M_Eta3;
119 }
120 
121 
122 //Only gating variables
123 void IonicFitzHughNagumo::computeGatingRhs ( const std::vector<Real>& v,
124  std::vector<Real>& rhs )
125 {
126  Real dr = M_Eta * v[0] - M_Gamma * v[1] ;
127 
128  rhs[0] = dr;
129 }
130 
131 //Potential and gating variables
132 void IonicFitzHughNagumo::computeRhs ( const std::vector<Real>& v,
133  std::vector<Real>& rhs )
134 {
135  Real dV = - ( M_G * v[0] * ( 1.0 - v[0] / M_Vth ) * ( 1.0 - v[0] / M_Vp ) + M_Eta1 * v[0] * v[1] );
136  Real dr = M_Eta * v[0] - M_Gamma * v[1] ;
137 
138  rhs[0] = dV;
139  rhs[1] = dr;
140 
141 }
143 {
144  Real dV = - ( M_G * v[0] * ( 1.0 - v[0] / M_Vth ) * ( 1.0 - v[0] / M_Vp ) + M_Eta1 * v[0] * v[1] );
145  Real dr = M_Eta * v[0] - M_Gamma * v[1] ;
146 
147  rhs[0] = dV;
148  rhs[1] = dr;
149 
150 }
151 
152 Real IonicFitzHughNagumo::computeLocalPotentialRhs ( const std::vector<Real>& v)
153 {
154  return ( - ( M_G * v[0] * ( 1.0 - v[0] / M_Vth ) * ( 1.0 - v[0] / M_Vp ) + M_Eta1 * v[0] * v[1] ) );
155 }
156 
158 {
159  std::vector< std::vector<Real> > J (2, std::vector<Real> (2, 0.0) );
160  J[0][0] = - ( M_G / ( M_Vth * M_Vp ) ) * ( M_Vth * ( M_Vp - 2.0 * v[0] ) + v[0] * ( 3.0 * v[0] - 2.0 * M_Vp ) ) - M_Eta1 * v[1];
161  J[0][1] = -M_Eta1 * v[0];
162  J[1][0] = M_Eta;
163  J[1][1] = -M_Gamma;
164 
165  return J;
166 }
167 
168 MatrixSmall<2, 2> IonicFitzHughNagumo::getJac (const VectorSmall<2>& v, Real /*h*/)
169 {
170  MatrixSmall<2, 2> J;
171  J (0, 0) = - ( M_G / ( M_Vth * M_Vp ) ) * ( M_Vth * ( M_Vp - 2.0 * v[0] ) + v[0] * ( 3.0 * v[0] - 2.0 * M_Vp ) ) - M_Eta1 * v[1];
172  J (0, 1) = -M_Eta1 * v[0];
173  J (1, 0) = M_Eta;
174  J (1, 1) = -M_Gamma;
175 
176  return J;
177 }
178 
179 matrix_Type IonicFitzHughNagumo::getJac (const vector_Type& v, Real h)
180 {
181  matrix_Type J (v.map(), M_numberOfEquations, false);
182  const Int* k = v.blockMap().MyGlobalElements();
183 
184  int* Indices = new int[M_numberOfEquations];
185  double* Values = new double[M_numberOfEquations];
186  Indices[0] = 0;
187  Indices[1] = 1;
188 
189  MatrixSmall<2, 2> df;
190  VectorSmall<2> y;
191  y (0) = v[k[0]];
192  y (1) = v[k[1]];
193 
194  df = getJac (y, h);
195 
196  Values[0] = df (0, 0);
197  Values[1] = df (0, 1);
198  J.matrixPtr()->InsertGlobalValues (0, M_numberOfEquations, Values, Indices);
199  Values[0] = df (1, 0);
200  Values[1] = df (1, 1);
201  J.matrixPtr()->InsertGlobalValues (1, M_numberOfEquations, Values, Indices);
202 
203  J.globalAssemble();
204 
205  delete[] Indices;
206  delete[] Values;
207 
208  return J;
209 }
210 
212 {
213  std::cout << "\n\n\t\tIonicFitzHughNagumo Informations\n\n";
214  std::cout << "number of unkowns: " << this->Size() << std::endl;
215 
216  std::cout << "\n\t\tList of model parameters:\n\n";
217  std::cout << "G : " << this->G() << std::endl;
218  std::cout << "Vth : " << this->Vth() << std::endl;
219  std::cout << "Vp : " << this->Vp() << std::endl;
220  std::cout << "Eta1 : " << this->Eta1() << std::endl;
221  std::cout << "Eta2 : " << this->Eta2() << std::endl;
222  std::cout << "Eta3 : " << this->Eta3() << std::endl;
223  std::cout << "Eta : " << this->Eta() << std::endl;
224  std::cout << "Gamma: " << this->Gamma() << std::endl;
225 
226  std::cout << "\n\t\t End of IonicFitzHughNagumo Informations\n\n\n";
227 
228 }
229 
230 
231 }
IonicFitzHughNagumo(const IonicFitzHughNagumo &model)
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
void updateInverseJacobian(const UInt &iQuadPt)
void computeRhs(const VectorSmall< 2 > &v, VectorSmall< 2 > &rhs)
void showMe()
Display information about the model.
void computeGatingRhs(const std::vector< Real > &v, std::vector< Real > &rhs)
A new ionic model must have the following methods ///.
IonicFitzHughNagumo & operator=(const IonicFitzHughNagumo &model)
Operator.
double Real
Generic real data.
Definition: LifeV.hpp:175
Real computeLocalPotentialRhs(const std::vector< Real > &v)
This methods contains the actual evaluation of the rhs of the voltage equation only (0D version) ...
MatrixEpetra< Real > matrix_Type
IonicFitzHughNagumo(Teuchos::ParameterList &parameterList)
ElectroIonicModel super
MatrixSmall< 2, 2 > getJac(const VectorSmall< 2 > &v, Real h=1.0e-8)
void setup(Teuchos::ParameterList &parameterList)
Methods.
void computeRhs(const std::vector< Real > &v, std::vector< Real > &rhs)
This methods contains the actual evaluation of the rhs of all state variablesin the model (0D version...
std::vector< std::vector< Real > > getJac(const std::vector< Real > &v, Real h=1.0e-8)
This methods computes the Jacobian numerically.
matrix_Type getJac(const vector_Type &v, Real h=1.0e-8)
This methods computes the Jacobian numerically.