MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MgBlock.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2007 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #include "header.h"
11 #include "ChanBase.h"
12 #include "ChanCommon.h"
13 #include "MgBlock.h"
14 
15 const double EPSILON = 1.0e-12;
16 
18 {
20  // Shared messages
23  // Dest definitions
25  static DestFinfo origChannel( "origChannel",
26  "",
28  );
30  // Field definitions
32  static ValueFinfo< MgBlock, double > KMg_A( "KMg_A",
33  "1/eta",
36  );
37  static ValueFinfo< MgBlock, double > KMg_B( "KMg_B",
38  "1/gamma",
41  );
42  static ValueFinfo< MgBlock, double > CMg( "CMg",
43  "[Mg] in mM",
46  );
47  static ValueFinfo< MgBlock, double > Zk( "Zk",
48  "Charge on ion",
51  );
53  static Finfo* MgBlockFinfos[] =
54  {
55  &origChannel, // Dest
56  &KMg_A, // Value
57  &KMg_B, // Value
58  &CMg, // Value
59  &Zk, // Value
60  };
61 
62  static string doc[] =
63  {
64  "Name", "MgBlock",
65  "Author", "Upinder S. Bhalla, 2007, NCBS",
66  "Description", "MgBlock: Hodgkin-Huxley type voltage-gated Ion channel. Something "
67  "like the old tabchannel from GENESIS, but also presents "
68  "a similar interface as hhchan from GENESIS. ",
69  };
70  static Dinfo< MgBlock > dinfo;
71  static Cinfo MgBlockCinfo(
72  "MgBlock",
74  MgBlockFinfos,
75  sizeof( MgBlockFinfos )/sizeof(Finfo *),
76  &dinfo,
77  doc,
78  sizeof( doc ) / sizeof( string )
79  );
80 
81  return &MgBlockCinfo;
82 }
83 
85 
87 // Constructor
90  : Zk_( 0.0 ),
91  KMg_A_( 1.0 ), // These are NOT the same as the A, B state
92  KMg_B_( 1.0 ), // variables used for Exp Euler integration.
93  CMg_( 1.0 ), // Conc of Mg in mM
94  origGk_(0.0)
95 {;}
96 
98 // Field function definitions
100 
101 void MgBlock::setKMg_A( double KMg_A )
102 {
103  if ( KMg_A < EPSILON ) {
104  cout << "Error: KMg_A=" << KMg_A << " must be > 0. Not set.\n";
105  } else {
106  KMg_A_ = KMg_A;
107  }
108 }
109 double MgBlock::getKMg_A() const
110 {
111  return KMg_A_;
112 }
113 void MgBlock::setKMg_B( double KMg_B )
114 {
115  if ( KMg_B < EPSILON ) {
116  cout << "Error: KMg_B=" << KMg_B << " must be > 0. Not set.\n";
117  } else {
118  KMg_B_ = KMg_B;
119  }
120 }
121 double MgBlock::getKMg_B() const
122 {
123  return KMg_B_;
124 }
125 void MgBlock::setCMg( double CMg )
126 {
127  if ( CMg < EPSILON ) {
128  cout << "Error: CMg = " << CMg << " must be > 0. Not set.\n";
129  } else {
130  CMg_ = CMg;
131  }
132 }
133 double MgBlock::getCMg() const
134 {
135  return CMg_;
136 }
137 double MgBlock::getZk() const
138 {
139  return Zk_;
140 }
141 void MgBlock::setZk( double Zk )
142 {
143  Zk_ = Zk;
144 }
145 
147 // Process functions
149 
151 {
152  double KMg = KMg_A_ * exp(Vm_/KMg_B_);
153  ChanBase::setGk( e, origGk_ * KMg / ( KMg + CMg_ ) );
154  // ChanBase::setGk( ChanBase::getGk() * KMg / ( KMg + CMg_ ) );
155  // Gk_ = Gk_ * KMg / (KMg + CMg_);
156 
157  updateIk();
158  // send2< double, double >( e, channelSlot, Gk_, Ek_ );
159  // Ik_ = Gk_ * (Ek_ - Vm_);
160  sendProcessMsgs( e, info );
161 }
162 
164 {
165  Zk_ = 0;
166  if ( CMg_ < EPSILON || KMg_B_ < EPSILON || KMg_A_ < EPSILON ) {
167  cout << "Error: MgBlock::innerReinitFunc: fields KMg_A, KMg_B, CMg\nmust be greater than zero. Resetting to 1 to avoid numerical errors\n";
168  if ( CMg_ < EPSILON ) CMg_ = 1.0;
169  if ( KMg_B_ < EPSILON ) KMg_B_ = 1.0;
170  if ( KMg_A_ < EPSILON ) KMg_A_ = 1.0;
171  }
172  sendReinitMsgs( e, info );
173 }
174 
176 // Dest functions
178 void MgBlock::origChannel( const Eref& e, double Gk, double Ek )
179 {
180  // setGk( Gk );
181  origGk_ = Gk;
182  setEk( e, Ek );
183 }
184 
186 // Unit tests
double Zk_
charge
Definition: MgBlock.h:69
void vProcess(const Eref &e, ProcPtr p)
Definition: MgBlock.cpp:150
double CMg_
[Mg] in mM
Definition: MgBlock.h:75
void setKMg_B(double Ek)
Definition: MgBlock.cpp:113
static const Cinfo * MgBlockCinfo
Definition: MgBlock.cpp:84
const double EPSILON
Definition: MgBlock.cpp:15
void setEk(const Eref &e, double Ek)
Definition: ChanBase.cpp:207
void origChannel(const Eref &e, double Gk, double Ek)
Definition: MgBlock.cpp:178
Definition: Dinfo.h:60
MgBlock()
Definition: MgBlock.cpp:89
void updateIk()
Definition: ChanCommon.cpp:119
double origGk_
Definition: MgBlock.h:80
double getKMg_B() const
Definition: MgBlock.cpp:121
double KMg_A_
1/eta
Definition: MgBlock.h:71
void setGk(const Eref &e, double Gk)
Definition: ChanBase.cpp:216
double Vm_
Vm_ is input variable from compartment, used for most rates.
Definition: ChanCommon.h:80
double getKMg_A() const
Definition: MgBlock.cpp:109
double getCMg() const
Definition: MgBlock.cpp:133
Definition: Eref.h:26
void vReinit(const Eref &e, ProcPtr p)
Definition: MgBlock.cpp:163
void setCMg(double CMg)
Definition: MgBlock.cpp:125
void setKMg_A(double Gbar)
Definition: MgBlock.cpp:101
double getZk() const
Definition: MgBlock.cpp:137
void sendReinitMsgs(const Eref &e, const ProcPtr info)
Definition: ChanCommon.cpp:111
void setZk(double Zk)
Definition: MgBlock.cpp:141
void sendProcessMsgs(const Eref &e, const ProcPtr info)
Definition: ChanCommon.cpp:100
double KMg_B_
1/gamma
Definition: MgBlock.h:73
Definition: Cinfo.h:18
static const Cinfo * initCinfo()
Specify the Class Info static variable for initialization.
Definition: ChanBase.cpp:36
Definition: EpFunc.h:79
static const Cinfo * initCinfo()
Definition: MgBlock.cpp:17
Definition: Finfo.h:12