Skip to content

NeuroML2 improvements #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 104 additions & 101 deletions biophysics/CaConc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@

const Cinfo* CaConc::initCinfo()
{
static string doc[] =
{
"Name", "CaConc \n",
"Author", "Upinder S. Bhalla, 2014, NCBS \n",
"Description", "CaConc: Calcium concentration pool. Takes current from a \n"
"channel and keeps track of calcium buildup and depletion by a \n"
"single exponential process. \n",
};

static Dinfo< CaConc > dinfo;

static Cinfo CaConcCinfo(
"CaConc",
CaConcBase::initCinfo(),
0,
0,
&dinfo,
doc,
sizeof(doc)/sizeof(string)
);

return &CaConcCinfo;
static string doc[] =
{
"Name", "CaConc \n",
"Author", "Upinder S. Bhalla, 2014, NCBS \n",
"Description", "CaConc: Calcium concentration pool. Takes current from a \n"
"channel and keeps track of calcium buildup and depletion by a \n"
"single exponential process. \n",
};

static Dinfo< CaConc > dinfo;

static Cinfo CaConcCinfo(
"CaConc",
CaConcBase::initCinfo(),
0,
0,
&dinfo,
doc,
sizeof(doc)/sizeof(string)
);

return &CaConcCinfo;
}
///////////////////////////////////////////////////

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

CaConc::CaConc()
: CaConcBase(),
Ca_( 0.0 ),
CaBasal_( 0.0 ),
tau_( 1.0 ),
B_( 1.0 ),
c_( 0.0 ),
activation_( 0.0 ),
ceiling_( 1.0e9 ),
floor_( 0.0 )
: CaConcBase(),
Ca_( 0.0 ),
CaBasal_( 0.0 ),
tau_( 1.0 ),
B_( 1.0 ),
c_( 0.0 ),
activation_( 0.0 ),
ceiling_( 1.0e9 ),
floor_( 0.0 )
{;}

///////////////////////////////////////////////////
Expand All @@ -59,46 +59,46 @@ CaConc::CaConc()

void CaConc::vSetCa( const Eref& e, double Ca )
{
Ca_ = Ca;
Ca_ = Ca;
}
double CaConc::vGetCa( const Eref& e ) const
{
return Ca_;
return Ca_;
}

void CaConc::vSetCaBasal( const Eref& e, double CaBasal )
{
CaBasal_ = CaBasal;
CaBasal_ = CaBasal;
}
double CaConc::vGetCaBasal( const Eref& e ) const
{
return CaBasal_;
return CaBasal_;
}

void CaConc::vSetTau( const Eref& e, double tau )
{
tau_ = tau;
tau_ = tau;
}
double CaConc::vGetTau( const Eref& e ) const
{
return tau_;
return tau_;
}

void CaConc::vSetB( const Eref& e, double B )
{
B_ = B;
B_ = B;
}
double CaConc::vGetB( const Eref& e ) const
{
return B_;
return B_;
}
void CaConc::vSetCeiling( const Eref& e, double ceiling )
{
ceiling_ = ceiling;
}
double CaConc::vGetCeiling( const Eref& e ) const
{
return ceiling_;
return ceiling_;
}

void CaConc::vSetFloor( const Eref& e, double floor )
Expand All @@ -107,7 +107,7 @@ void CaConc::vSetFloor( const Eref& e, double floor )
}
double CaConc::vGetFloor( const Eref& e ) const
{
return floor_;
return floor_;
}

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

void CaConc::vReinit( const Eref& e, ProcPtr p )
{
activation_ = 0.0;
c_ = 0.0;
Ca_ = CaBasal_;
concOut()->send( e, Ca_ );
activation_ = 0.0;
c_ = 0.0;
Ca_ = CaBasal_;
concOut()->send( e, Ca_ );
}

void CaConc::vProcess( const Eref& e, ProcPtr p )
{
double x = exp( -p->dt / tau_ );
Ca_ = CaBasal_ + c_ * x + ( B_ * activation_ * tau_ ) * (1.0 - x);
if ( ceiling_ > 0.0 && Ca_ > ceiling_ ) {
Ca_ = ceiling_;
} else if ( Ca_ < floor_ ){
Ca_ = floor_;
}
c_ = Ca_ - CaBasal_;
concOut()->send( e, Ca_ );
activation_ = 0;
double x = exp( -p->dt / tau_ );
Ca_ = CaBasal_ + c_ * x + ( B_ * activation_ * tau_ ) * (1.0 - x);
if ( ceiling_ > 0.0 && Ca_ > ceiling_ )
{
Ca_ = ceiling_;
}
else if ( Ca_ < floor_ )
{
Ca_ = floor_;
}
c_ = Ca_ - CaBasal_;
concOut()->send( e, Ca_ );
activation_ = 0;
}


void CaConc::vCurrent( const Eref& e, double I )
{
activation_ += I;
activation_ += I;
}

void CaConc::vCurrentFraction( const Eref& e, double I, double fraction )
{
activation_ += I * fraction;
activation_ += I * fraction;
}

void CaConc::vIncrease( const Eref& e, double I )
{
activation_ += fabs( I );
activation_ += fabs( I );
}

void CaConc::vDecrease( const Eref& e, double I )
{
activation_ -= fabs( I );
activation_ -= fabs( I );
}

///////////////////////////////////////////////////
Expand All @@ -165,52 +168,52 @@ void CaConc::vDecrease( const Eref& e, double I )
void testCaConc()
{
/*
CaConc cc;
double tau = 0.10;
double basal = 0.0001;

cc.setCa( basal );
cc.setCaBasal( basal );
cc.setTau( tau );
// Here we use a volume of 1e-15 m^3, i.e., a 10 micron cube.
cc.setB( 5.2e-6 / 1e-15 );
// Faraday constant = 96485.3415 s A / mol
// Use a 1 pA input current. This should give (0.5e-12/F) moles/sec
// influx, because Ca has valence of 2.
// So we get 5.2e-18 moles/sec coming in.
// Our volume is 1e-15 m^3
// So our buildup should be at 5.2e-3 moles/m^3/sec = 5.2 uM/sec
double curr = 1e-12;
// This will settle when efflux = influx
// dC/dt = B*Ik - C/tau = 0.
// so Ca = CaBasal + tau * B * Ik =
// 0.0001 + 0.1 * 5.2e-6 * 1e3 = 0.000626

ProcInfo p;
p.dt = 0.001;
p.currTime = 0.0;
CaConc cc;
double tau = 0.10;
double basal = 0.0001;

cc.setCa( basal );
cc.setCaBasal( basal );
cc.setTau( tau );
// Here we use a volume of 1e-15 m^3, i.e., a 10 micron cube.
cc.setB( 5.2e-6 / 1e-15 );
// Faraday constant = 96485.3415 s A / mol
// Use a 1 pA input current. This should give (0.5e-12/F) moles/sec
// influx, because Ca has valence of 2.
// So we get 5.2e-18 moles/sec coming in.
// Our volume is 1e-15 m^3
// So our buildup should be at 5.2e-3 moles/m^3/sec = 5.2 uM/sec
double curr = 1e-12;
// This will settle when efflux = influx
// dC/dt = B*Ik - C/tau = 0.
// so Ca = CaBasal + tau * B * Ik =
// 0.0001 + 0.1 * 5.2e-6 * 1e3 = 0.000626

ProcInfo p;
p.dt = 0.001;
p.currTime = 0.0;
Eref sheller(Id().eref());
Shell * shell = reinterpret_cast<Shell*> (sheller.data());
Id temp = shell->doCreate("CaConc", Id(), "caconc", 1);
assert(temp.element()->getName() == "caconc");
// Id tempId = Id::nextId();
// Element temp( tempId, CaConc::initCinfo(), "temp", 0 );
Eref er( &temp, 0 );
cc.reinit( er, &p );

double y;
double conc;
double delta = 0.0;
for ( p.currTime = 0.0; p.currTime < 0.5; p.currTime += p.dt )
{
cc.current( curr );
cc.process( er, &p );
y = basal + 526.0e-6 * ( 1.0 - exp( -p.currTime / tau ) );
conc = cc.getCa();
delta += ( y - conc ) * ( y - conc );
}
assert( delta < 1e-6 );
cout << "." << flush;
// Id tempId = Id::nextId();
// Element temp( tempId, CaConc::initCinfo(), "temp", 0 );
Eref er( &temp, 0 );
cc.reinit( er, &p );

double y;
double conc;
double delta = 0.0;
for ( p.currTime = 0.0; p.currTime < 0.5; p.currTime += p.dt )
{
cc.current( curr );
cc.process( er, &p );
y = basal + 526.0e-6 * ( 1.0 - exp( -p.currTime / tau ) );
conc = cc.getCa();
delta += ( y - conc ) * ( y - conc );
}
assert( delta < 1e-6 );
cout << "." << flush;
*/
}
#endif
76 changes: 38 additions & 38 deletions biophysics/CaConc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* without diffusion. It uses a simple exponential return of Ca
* to baseline, with influxes from ion channels. It solves the
* equation:
* dC/dt = B*Ik - C/tau
* where Ca = Ca_base + C.
*
* dC/dt = B*Ik - C/tau, where Ca = Ca_base + C.
*
* From the GENESIS notes:
* In SI units, where concentration is moles/m^3
Expand All @@ -35,44 +35,44 @@

class CaConc: public CaConcBase
{
public:
CaConc();
///////////////////////////////////////////////////////////////
// Message handling functions
///////////////////////////////////////////////////////////////
void vReinit( const Eref&, ProcPtr info );
void vProcess( const Eref&, ProcPtr info );
public:
CaConc();
///////////////////////////////////////////////////////////////
// Message handling functions
///////////////////////////////////////////////////////////////
void vReinit( const Eref&, ProcPtr info );
void vProcess( const Eref&, ProcPtr info );

void vCurrent( const Eref& e, double I );
void vCurrentFraction( const Eref& e, double I, double fraction );
void vIncrease( const Eref& e, double I );
void vDecrease( const Eref& e, double I );
///////////////////////////////////////////////////////////////
// Field handling functions
///////////////////////////////////////////////////////////////
void vSetCa( const Eref& e, double val );
double vGetCa( const Eref& e ) const;
void vSetCaBasal( const Eref& e, double val );
double vGetCaBasal( const Eref& e ) const;
void vSetTau( const Eref& e, double val );
double vGetTau( const Eref& e ) const;
void vSetB( const Eref& e, double val );
double vGetB( const Eref& e ) const;
void vSetCeiling( const Eref& e, double val );
double vGetCeiling( const Eref& e ) const;
void vSetFloor( const Eref& e, double val );
double vGetFloor( const Eref& e ) const;
void vCurrent( const Eref& e, double I );
void vCurrentFraction( const Eref& e, double I, double fraction );
void vIncrease( const Eref& e, double I );
void vDecrease( const Eref& e, double I );
///////////////////////////////////////////////////////////////
// Field handling functions
///////////////////////////////////////////////////////////////
void vSetCa( const Eref& e, double val );
double vGetCa( const Eref& e ) const;
void vSetCaBasal( const Eref& e, double val );
double vGetCaBasal( const Eref& e ) const;
void vSetTau( const Eref& e, double val );
double vGetTau( const Eref& e ) const;
void vSetB( const Eref& e, double val );
double vGetB( const Eref& e ) const;
void vSetCeiling( const Eref& e, double val );
double vGetCeiling( const Eref& e ) const;
void vSetFloor( const Eref& e, double val );
double vGetFloor( const Eref& e ) const;

static const Cinfo* initCinfo();
private:
double Ca_;
double CaBasal_;
double tau_;
double B_;
double c_;
double activation_;
double ceiling_;
double floor_;
static const Cinfo* initCinfo();
private:
double Ca_;
double CaBasal_;
double tau_;
double B_;
double c_;
double activation_;
double ceiling_;
double floor_;
};


Expand Down
Loading