Skip to content

Commit 1af4b64

Browse files
author
Dilawar Singh
committed
Some more tweaks to get CaConc working with NML.
1 parent f2bc3aa commit 1af4b64

File tree

4 files changed

+396
-304
lines changed

4 files changed

+396
-304
lines changed

biophysics/CaConc.cpp

Lines changed: 104 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,43 @@
1414

1515
const Cinfo* CaConc::initCinfo()
1616
{
17-
static string doc[] =
18-
{
19-
"Name", "CaConc \n",
20-
"Author", "Upinder S. Bhalla, 2014, NCBS \n",
21-
"Description", "CaConc: Calcium concentration pool. Takes current from a \n"
22-
"channel and keeps track of calcium buildup and depletion by a \n"
23-
"single exponential process. \n",
24-
};
25-
26-
static Dinfo< CaConc > dinfo;
27-
28-
static Cinfo CaConcCinfo(
29-
"CaConc",
30-
CaConcBase::initCinfo(),
31-
0,
32-
0,
33-
&dinfo,
34-
doc,
35-
sizeof(doc)/sizeof(string)
36-
);
37-
38-
return &CaConcCinfo;
17+
static string doc[] =
18+
{
19+
"Name", "CaConc \n",
20+
"Author", "Upinder S. Bhalla, 2014, NCBS \n",
21+
"Description", "CaConc: Calcium concentration pool. Takes current from a \n"
22+
"channel and keeps track of calcium buildup and depletion by a \n"
23+
"single exponential process. \n",
24+
};
25+
26+
static Dinfo< CaConc > dinfo;
27+
28+
static Cinfo CaConcCinfo(
29+
"CaConc",
30+
CaConcBase::initCinfo(),
31+
0,
32+
0,
33+
&dinfo,
34+
doc,
35+
sizeof(doc)/sizeof(string)
36+
);
37+
38+
return &CaConcCinfo;
3939
}
4040
///////////////////////////////////////////////////
4141

4242
static const Cinfo* caConcCinfo = CaConc::initCinfo();
4343

4444
CaConc::CaConc()
45-
: CaConcBase(),
46-
Ca_( 0.0 ),
47-
CaBasal_( 0.0 ),
48-
tau_( 1.0 ),
49-
B_( 1.0 ),
50-
c_( 0.0 ),
51-
activation_( 0.0 ),
52-
ceiling_( 1.0e9 ),
53-
floor_( 0.0 )
45+
: CaConcBase(),
46+
Ca_( 0.0 ),
47+
CaBasal_( 0.0 ),
48+
tau_( 1.0 ),
49+
B_( 1.0 ),
50+
c_( 0.0 ),
51+
activation_( 0.0 ),
52+
ceiling_( 1.0e9 ),
53+
floor_( 0.0 )
5454
{;}
5555

5656
///////////////////////////////////////////////////
@@ -59,46 +59,46 @@ CaConc::CaConc()
5959

6060
void CaConc::vSetCa( const Eref& e, double Ca )
6161
{
62-
Ca_ = Ca;
62+
Ca_ = Ca;
6363
}
6464
double CaConc::vGetCa( const Eref& e ) const
6565
{
66-
return Ca_;
66+
return Ca_;
6767
}
6868

6969
void CaConc::vSetCaBasal( const Eref& e, double CaBasal )
7070
{
71-
CaBasal_ = CaBasal;
71+
CaBasal_ = CaBasal;
7272
}
7373
double CaConc::vGetCaBasal( const Eref& e ) const
7474
{
75-
return CaBasal_;
75+
return CaBasal_;
7676
}
7777

7878
void CaConc::vSetTau( const Eref& e, double tau )
7979
{
80-
tau_ = tau;
80+
tau_ = tau;
8181
}
8282
double CaConc::vGetTau( const Eref& e ) const
8383
{
84-
return tau_;
84+
return tau_;
8585
}
8686

8787
void CaConc::vSetB( const Eref& e, double B )
8888
{
89-
B_ = B;
89+
B_ = B;
9090
}
9191
double CaConc::vGetB( const Eref& e ) const
9292
{
93-
return B_;
93+
return B_;
9494
}
9595
void CaConc::vSetCeiling( const Eref& e, double ceiling )
9696
{
9797
ceiling_ = ceiling;
9898
}
9999
double CaConc::vGetCeiling( const Eref& e ) const
100100
{
101-
return ceiling_;
101+
return ceiling_;
102102
}
103103

104104
void CaConc::vSetFloor( const Eref& e, double floor )
@@ -107,7 +107,7 @@ void CaConc::vSetFloor( const Eref& e, double floor )
107107
}
108108
double CaConc::vGetFloor( const Eref& e ) const
109109
{
110-
return floor_;
110+
return floor_;
111111
}
112112

113113
///////////////////////////////////////////////////
@@ -116,45 +116,48 @@ double CaConc::vGetFloor( const Eref& e ) const
116116

117117
void CaConc::vReinit( const Eref& e, ProcPtr p )
118118
{
119-
activation_ = 0.0;
120-
c_ = 0.0;
121-
Ca_ = CaBasal_;
122-
concOut()->send( e, Ca_ );
119+
activation_ = 0.0;
120+
c_ = 0.0;
121+
Ca_ = CaBasal_;
122+
concOut()->send( e, Ca_ );
123123
}
124124

125125
void CaConc::vProcess( const Eref& e, ProcPtr p )
126126
{
127-
double x = exp( -p->dt / tau_ );
128-
Ca_ = CaBasal_ + c_ * x + ( B_ * activation_ * tau_ ) * (1.0 - x);
129-
if ( ceiling_ > 0.0 && Ca_ > ceiling_ ) {
130-
Ca_ = ceiling_;
131-
} else if ( Ca_ < floor_ ){
132-
Ca_ = floor_;
133-
}
134-
c_ = Ca_ - CaBasal_;
135-
concOut()->send( e, Ca_ );
136-
activation_ = 0;
127+
double x = exp( -p->dt / tau_ );
128+
Ca_ = CaBasal_ + c_ * x + ( B_ * activation_ * tau_ ) * (1.0 - x);
129+
if ( ceiling_ > 0.0 && Ca_ > ceiling_ )
130+
{
131+
Ca_ = ceiling_;
132+
}
133+
else if ( Ca_ < floor_ )
134+
{
135+
Ca_ = floor_;
136+
}
137+
c_ = Ca_ - CaBasal_;
138+
concOut()->send( e, Ca_ );
139+
activation_ = 0;
137140
}
138141

139142

140143
void CaConc::vCurrent( const Eref& e, double I )
141144
{
142-
activation_ += I;
145+
activation_ += I;
143146
}
144147

145148
void CaConc::vCurrentFraction( const Eref& e, double I, double fraction )
146149
{
147-
activation_ += I * fraction;
150+
activation_ += I * fraction;
148151
}
149152

150153
void CaConc::vIncrease( const Eref& e, double I )
151154
{
152-
activation_ += fabs( I );
155+
activation_ += fabs( I );
153156
}
154157

155158
void CaConc::vDecrease( const Eref& e, double I )
156159
{
157-
activation_ -= fabs( I );
160+
activation_ -= fabs( I );
158161
}
159162

160163
///////////////////////////////////////////////////
@@ -165,52 +168,52 @@ void CaConc::vDecrease( const Eref& e, double I )
165168
void testCaConc()
166169
{
167170
/*
168-
CaConc cc;
169-
double tau = 0.10;
170-
double basal = 0.0001;
171-
172-
cc.setCa( basal );
173-
cc.setCaBasal( basal );
174-
cc.setTau( tau );
175-
// Here we use a volume of 1e-15 m^3, i.e., a 10 micron cube.
176-
cc.setB( 5.2e-6 / 1e-15 );
177-
// Faraday constant = 96485.3415 s A / mol
178-
// Use a 1 pA input current. This should give (0.5e-12/F) moles/sec
179-
// influx, because Ca has valence of 2.
180-
// So we get 5.2e-18 moles/sec coming in.
181-
// Our volume is 1e-15 m^3
182-
// So our buildup should be at 5.2e-3 moles/m^3/sec = 5.2 uM/sec
183-
double curr = 1e-12;
184-
// This will settle when efflux = influx
185-
// dC/dt = B*Ik - C/tau = 0.
186-
// so Ca = CaBasal + tau * B * Ik =
187-
// 0.0001 + 0.1 * 5.2e-6 * 1e3 = 0.000626
188-
189-
ProcInfo p;
190-
p.dt = 0.001;
191-
p.currTime = 0.0;
171+
CaConc cc;
172+
double tau = 0.10;
173+
double basal = 0.0001;
174+
175+
cc.setCa( basal );
176+
cc.setCaBasal( basal );
177+
cc.setTau( tau );
178+
// Here we use a volume of 1e-15 m^3, i.e., a 10 micron cube.
179+
cc.setB( 5.2e-6 / 1e-15 );
180+
// Faraday constant = 96485.3415 s A / mol
181+
// Use a 1 pA input current. This should give (0.5e-12/F) moles/sec
182+
// influx, because Ca has valence of 2.
183+
// So we get 5.2e-18 moles/sec coming in.
184+
// Our volume is 1e-15 m^3
185+
// So our buildup should be at 5.2e-3 moles/m^3/sec = 5.2 uM/sec
186+
double curr = 1e-12;
187+
// This will settle when efflux = influx
188+
// dC/dt = B*Ik - C/tau = 0.
189+
// so Ca = CaBasal + tau * B * Ik =
190+
// 0.0001 + 0.1 * 5.2e-6 * 1e3 = 0.000626
191+
192+
ProcInfo p;
193+
p.dt = 0.001;
194+
p.currTime = 0.0;
192195
Eref sheller(Id().eref());
193196
Shell * shell = reinterpret_cast<Shell*> (sheller.data());
194197
Id temp = shell->doCreate("CaConc", Id(), "caconc", 1);
195198
assert(temp.element()->getName() == "caconc");
196-
// Id tempId = Id::nextId();
197-
// Element temp( tempId, CaConc::initCinfo(), "temp", 0 );
198-
Eref er( &temp, 0 );
199-
cc.reinit( er, &p );
200-
201-
double y;
202-
double conc;
203-
double delta = 0.0;
204-
for ( p.currTime = 0.0; p.currTime < 0.5; p.currTime += p.dt )
205-
{
206-
cc.current( curr );
207-
cc.process( er, &p );
208-
y = basal + 526.0e-6 * ( 1.0 - exp( -p.currTime / tau ) );
209-
conc = cc.getCa();
210-
delta += ( y - conc ) * ( y - conc );
211-
}
212-
assert( delta < 1e-6 );
213-
cout << "." << flush;
199+
// Id tempId = Id::nextId();
200+
// Element temp( tempId, CaConc::initCinfo(), "temp", 0 );
201+
Eref er( &temp, 0 );
202+
cc.reinit( er, &p );
203+
204+
double y;
205+
double conc;
206+
double delta = 0.0;
207+
for ( p.currTime = 0.0; p.currTime < 0.5; p.currTime += p.dt )
208+
{
209+
cc.current( curr );
210+
cc.process( er, &p );
211+
y = basal + 526.0e-6 * ( 1.0 - exp( -p.currTime / tau ) );
212+
conc = cc.getCa();
213+
delta += ( y - conc ) * ( y - conc );
214+
}
215+
assert( delta < 1e-6 );
216+
cout << "." << flush;
214217
*/
215218
}
216219
#endif

biophysics/CaConc.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,44 @@
3535

3636
class CaConc: public CaConcBase
3737
{
38-
public:
39-
CaConc();
40-
///////////////////////////////////////////////////////////////
41-
// Message handling functions
42-
///////////////////////////////////////////////////////////////
43-
void vReinit( const Eref&, ProcPtr info );
44-
void vProcess( const Eref&, ProcPtr info );
38+
public:
39+
CaConc();
40+
///////////////////////////////////////////////////////////////
41+
// Message handling functions
42+
///////////////////////////////////////////////////////////////
43+
void vReinit( const Eref&, ProcPtr info );
44+
void vProcess( const Eref&, ProcPtr info );
4545

46-
void vCurrent( const Eref& e, double I );
47-
void vCurrentFraction( const Eref& e, double I, double fraction );
48-
void vIncrease( const Eref& e, double I );
49-
void vDecrease( const Eref& e, double I );
50-
///////////////////////////////////////////////////////////////
51-
// Field handling functions
52-
///////////////////////////////////////////////////////////////
53-
void vSetCa( const Eref& e, double val );
54-
double vGetCa( const Eref& e ) const;
55-
void vSetCaBasal( const Eref& e, double val );
56-
double vGetCaBasal( const Eref& e ) const;
57-
void vSetTau( const Eref& e, double val );
58-
double vGetTau( const Eref& e ) const;
59-
void vSetB( const Eref& e, double val );
60-
double vGetB( const Eref& e ) const;
61-
void vSetCeiling( const Eref& e, double val );
62-
double vGetCeiling( const Eref& e ) const;
63-
void vSetFloor( const Eref& e, double val );
64-
double vGetFloor( const Eref& e ) const;
46+
void vCurrent( const Eref& e, double I );
47+
void vCurrentFraction( const Eref& e, double I, double fraction );
48+
void vIncrease( const Eref& e, double I );
49+
void vDecrease( const Eref& e, double I );
50+
///////////////////////////////////////////////////////////////
51+
// Field handling functions
52+
///////////////////////////////////////////////////////////////
53+
void vSetCa( const Eref& e, double val );
54+
double vGetCa( const Eref& e ) const;
55+
void vSetCaBasal( const Eref& e, double val );
56+
double vGetCaBasal( const Eref& e ) const;
57+
void vSetTau( const Eref& e, double val );
58+
double vGetTau( const Eref& e ) const;
59+
void vSetB( const Eref& e, double val );
60+
double vGetB( const Eref& e ) const;
61+
void vSetCeiling( const Eref& e, double val );
62+
double vGetCeiling( const Eref& e ) const;
63+
void vSetFloor( const Eref& e, double val );
64+
double vGetFloor( const Eref& e ) const;
6565

66-
static const Cinfo* initCinfo();
67-
private:
68-
double Ca_;
69-
double CaBasal_;
70-
double tau_;
71-
double B_;
72-
double c_;
73-
double activation_;
74-
double ceiling_;
75-
double floor_;
66+
static const Cinfo* initCinfo();
67+
private:
68+
double Ca_;
69+
double CaBasal_;
70+
double tau_;
71+
double B_;
72+
double c_;
73+
double activation_;
74+
double ceiling_;
75+
double floor_;
7676
};
7777

7878

0 commit comments

Comments
 (0)