-
Notifications
You must be signed in to change notification settings - Fork 0
/
HSolveStruct.cpp
155 lines (132 loc) · 3.22 KB
/
HSolveStruct.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**********************************************************************
** This program is part of 'MOOSE', the
** Messaging Object Oriented Simulation Environment.
** copyright (C) 2003-2007 Upinder S. Bhalla. and NCBS
** It is made available under the terms of the
** GNU Lesser General Public License version 2.1
** See the file COPYING.LIB for the full notice.
**********************************************************************/
#include <cmath>
#include "header.h"
#include "../biophysics/SpikeGen.h"
#include "HSolveStruct.h"
void ChannelStruct::setPowers(
double Xpower,
double Ypower,
double Zpower )
{
Xpower_ = Xpower;
takeXpower_ = selectPower( Xpower );
Ypower_ = Ypower;
takeYpower_ = selectPower( Ypower );
Zpower_ = Zpower;
takeZpower_ = selectPower( Zpower );
}
double ChannelStruct::powerN( double x, double p )
{
if ( x > 0.0 )
return exp( p * log( x ) );
return 0.0;
}
PFDD ChannelStruct::selectPower( double power )
{
if ( power == 0.0 )
return powerN;
else if ( power == 1.0 )
return power1;
else if ( power == 2.0 )
return power2;
else if ( power == 3.0 )
return power3;
else if ( power == 4.0 )
return power4;
else
return powerN;
}
void ChannelStruct::process( double*& state, CurrentStruct& current )
{
double fraction = 1.0;
if( Xpower_ > 0.0 )
fraction *= takeXpower_( *( state++ ), Xpower_ );
if( Ypower_ > 0.0 )
fraction *= takeYpower_( *( state++ ), Ypower_ );
if( Zpower_ > 0.0 )
fraction *= takeZpower_( *( state++ ), Zpower_ );
current.Gk = Gbar_ * fraction;
}
void SpikeGenStruct::reinit( ProcPtr info )
{
SpikeGen* spike = reinterpret_cast< SpikeGen* >( e_.data() );
spike->reinit( e_, info );
}
void SpikeGenStruct::send( ProcPtr info )
{
SpikeGen* spike = reinterpret_cast< SpikeGen* >( e_.data() );
spike->handleVm( *Vm_ );
spike->process( e_, info );
}
CaConcStruct::CaConcStruct()
:
c_( 0.0 ),
CaBasal_( 0.0 ),
factor1_( 0.0 ),
factor2_( 0.0 ),
ceiling_( 0.0 ),
floor_( 0.0 )
{ ; }
CaConcStruct::CaConcStruct(
double Ca,
double CaBasal,
double tau,
double B,
double ceiling,
double floor,
double dt )
{
setCa( Ca );
setCaBasal( CaBasal );
setTauB( tau, B, dt );
ceiling_ = ceiling;
floor_ = floor;
}
void CaConcStruct::setCa( double Ca ) {
c_ = Ca - CaBasal_;
}
void CaConcStruct::setCaBasal( double CaBasal ) {
/*
* Also updating 'c_' here, so that only 'CaBasal' changes, and 'Ca'
* remains the same. This is good because otherwise one has to bother about
* the order in which 'setCa()' and 'setCaBasal()' are called.
*
* 'Ca' is:
* Ca = CaBasal_ + c_
*
* if:
* Ca_new = Ca_old
*
* then:
* CaBasal_new + c_new = CaBasal_old + c_old
*
* so:
* c_new = c_old + CaBasal_old - CaBasal_new
*/
c_ += CaBasal_ - CaBasal;
CaBasal_ = CaBasal;
}
void CaConcStruct::setTauB( double tau, double B, double dt ) {
factor1_ = 4.0 / ( 2.0 + dt / tau ) - 1.0;
factor2_ = 2.0 * B * dt / ( 2.0 + dt / tau );
}
double CaConcStruct::process( double activation ) {
c_ = factor1_ * c_ + factor2_ * activation;
double ca = CaBasal_ + c_;
if ( ceiling_ > 0 && ca > ceiling_ ) {
ca = ceiling_;
setCa( ca );
}
if ( ca < floor_ ) {
ca = floor_;
setCa( ca );
}
return ca;
}