MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HSolveStruct.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 <cmath>
11 #include "header.h"
12 #include "../biophysics/SpikeGen.h"
13 #include "HSolveStruct.h"
14 
16  double Xpower,
17  double Ypower,
18  double Zpower )
19 {
20  Xpower_ = Xpower;
21  takeXpower_ = selectPower( Xpower );
22 
23  Ypower_ = Ypower;
24  takeYpower_ = selectPower( Ypower );
25 
26  Zpower_ = Zpower;
27  takeZpower_ = selectPower( Zpower );
28 }
29 
30 double ChannelStruct::powerN( double x, double p )
31 {
32  if ( x > 0.0 )
33  return exp( p * log( x ) );
34  return 0.0;
35 }
36 
38 {
39  if ( power == 0.0 )
40  return powerN;
41  else if ( power == 1.0 )
42  return power1;
43  else if ( power == 2.0 )
44  return power2;
45  else if ( power == 3.0 )
46  return power3;
47  else if ( power == 4.0 )
48  return power4;
49  else
50  return powerN;
51 }
52 
53 void ChannelStruct::process( double*& state, CurrentStruct& current )
54 {
55  double fraction = modulation_;
56 
57  if( Xpower_ > 0.0 )
58  fraction *= takeXpower_( *( state++ ), Xpower_ );
59  if( Ypower_ > 0.0 )
60  fraction *= takeYpower_( *( state++ ), Ypower_ );
61  if( Zpower_ > 0.0 )
62  fraction *= takeZpower_( *( state++ ), Zpower_ );
63 
64  current.Gk = Gbar_ * fraction;
65 }
66 
68 {
69  SpikeGen* spike = reinterpret_cast< SpikeGen* >( e_.data() );
70 
71  spike->reinit( e_, info );
72 }
73 
75 {
76  SpikeGen* spike = reinterpret_cast< SpikeGen* >( e_.data() );
77 
78  spike->handleVm( *Vm_ );
79  spike->process( e_, info );
80 }
81 
83  :
84  c_( 0.0 ),
85  CaBasal_( 0.0 ),
86  factor1_( 0.0 ),
87  factor2_( 0.0 ),
88  ceiling_( 0.0 ),
89  floor_( 0.0 )
90 { ; }
91 
93  double Ca,
94  double CaBasal,
95  double tau,
96  double B,
97  double ceiling,
98  double floor,
99  double dt )
100 {
101  setCa( Ca );
102  setCaBasal( CaBasal );
103  setTauB( tau, B, dt );
104  ceiling_ = ceiling;
105  floor_ = floor;
106 }
107 
108 void CaConcStruct::setCa( double Ca ) {
109  c_ = Ca - CaBasal_;
110 }
111 
112 void CaConcStruct::setCaBasal( double CaBasal ) {
113  /*
114  * Also updating 'c_' here, so that only 'CaBasal' changes, and 'Ca'
115  * remains the same. This is good because otherwise one has to bother about
116  * the order in which 'setCa()' and 'setCaBasal()' are called.
117  *
118  * 'Ca' is:
119  * Ca = CaBasal_ + c_
120  *
121  * if:
122  * Ca_new = Ca_old
123  *
124  * then:
125  * CaBasal_new + c_new = CaBasal_old + c_old
126  *
127  * so:
128  * c_new = c_old + CaBasal_old - CaBasal_new
129  */
130  c_ += CaBasal_ - CaBasal;
131  CaBasal_ = CaBasal;
132 }
133 
134 void CaConcStruct::setTauB( double tau, double B, double dt ) {
135  factor1_ = 4.0 / ( 2.0 + dt / tau ) - 1.0;
136  factor2_ = 2.0 * B * dt / ( 2.0 + dt / tau );
137 }
138 
139 double CaConcStruct::process( double activation ) {
140  c_ = factor1_ * c_ + factor2_ * activation;
141 
142  double ca = CaBasal_ + c_;
143 
144  if ( ceiling_ > 0 && ca > ceiling_ ) {
145  ca = ceiling_;
146  setCa( ca );
147  }
148 
149  if ( ca < floor_ ) {
150  ca = floor_;
151  setCa( ca );
152  }
153 
154  return ca;
155 }
char * data() const
Definition: Eref.cpp:41
double(* PFDD)(double, double)
Definition: HHChannel2D.h:23
double ceiling_
Definition: HSolveStruct.h:143
double Xpower_
Definition: HSolveStruct.h:62
static double power3(double x, double p)
Definition: HSolveStruct.h:101
void send(ProcPtr info)
double Zpower_
Definition: HSolveStruct.h:64
void log(string msg, serverity_level_ type=debug, bool redirectToConsole=true, bool removeTicks=true)
Log to console (and to a log-file)
void setCaBasal(double CaBasal)
double factor1_
Reference calcium concentration
Definition: HSolveStruct.h:141
void process(const Eref &e, ProcPtr p)
Definition: SpikeGen.cpp:192
static double power4(double x, double p)
Definition: HSolveStruct.h:104
static double power1(double x, double p)
Definition: HSolveStruct.h:95
static double powerN(double x, double p)
double process(double activation)
void handleVm(double val)
Definition: SpikeGen.cpp:214
void setPowers(double Xpower, double Ypower, double Zpower)
double floor_
Ceiling and floor for lookup tables
Definition: HSolveStruct.h:144
void setCa(double Ca)
static PFDD selectPower(double power)
void reinit(ProcPtr info)
void reinit(const Eref &e, ProcPtr p)
Definition: SpikeGen.cpp:209
double CaBasal_
Dynamic calcium concentration, over CaBasal_
Definition: HSolveStruct.h:140
double Ypower_
Definition: HSolveStruct.h:63
double factor2_
Both these factors are functions of tau, B and dt.
Definition: HSolveStruct.h:142
void setTauB(double tau, double B, double dt)
static double power2(double x, double p)
Definition: HSolveStruct.h:98
void process(double *&state, CurrentStruct &current)
double modulation_
Definition: HSolveStruct.h:77