Skip to content

Commit

Permalink
Updates to Hsolve to be able to delete and recreate it. Still problem…
Browse files Browse the repository at this point in the history
…atic for HHChannels. Also added Vclamp to the rdesigneurProtos.
  • Loading branch information
upibhalla committed May 10, 2018
1 parent 3ec52cd commit 12cf83e
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 7 deletions.
31 changes: 28 additions & 3 deletions hsolve/HSolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "../biophysics/ChanBase.h"
#include "../biophysics/ChanCommon.h"
#include "../biophysics/HHChannel.h"
#include "../biophysics/CaConc.h"
#include "ZombieHHChannel.h"
#include "../shell/Shell.h"

Expand Down Expand Up @@ -192,6 +193,11 @@ HSolve::HSolve()
;
}

HSolve::~HSolve()
{
unzombify();
}


///////////////////////////////////////////////////
// Dest function definitions
Expand All @@ -215,23 +221,42 @@ void HSolve::zombify( Eref hsolve ) const

for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
temp.push_back( ObjId( *i, 0 ) );
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i ) {
CompartmentBase::zombify( i->eref().element(),
ZombieCompartment::initCinfo(), hsolve.id() );
}

temp.clear();
for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
temp.push_back( ObjId( *i, 0 ) );
// Shell::dropClockMsgs( temp, "process" );
for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
for ( i = caConcId_.begin(); i != caConcId_.end(); ++i ) {
CaConcBase::zombify( i->eref().element(), ZombieCaConc::initCinfo(), hsolve.id() );
}

temp.clear();
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
temp.push_back( ObjId( *i, 0 ) );
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
for ( i = channelId_.begin(); i != channelId_.end(); ++i ) {
HHChannelBase::zombify( i->eref().element(),
ZombieHHChannel::initCinfo(), hsolve.id() );
}
}

void HSolve::unzombify() const
{
vector< Id >::const_iterator i;

for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
CompartmentBase::zombify( i->eref().element(),
Compartment::initCinfo(), Id() );

for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
CaConcBase::zombify( i->eref().element(), CaConc::initCinfo(), Id() );

for ( i = channelId_.begin(); i != channelId_.end(); ++i )
HHChannelBase::zombify( i->eref().element(),
HHChannel::initCinfo(), Id() );
}

void HSolve::setup( Eref hsolve )
Expand Down
2 changes: 2 additions & 0 deletions hsolve/HSolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class HSolve: public HSolveActive
{
public:
HSolve();
~HSolve();

void process( const Eref& hsolve, ProcPtr p );
void reinit( const Eref& hsolve, ProcPtr p );
Expand Down Expand Up @@ -157,6 +158,7 @@ class HSolve: public HSolveActive

void setup( Eref hsolve );
void zombify( Eref hsolve ) const;
void unzombify() const;

// Mapping global Id to local index. Defined in HSolveInterface.cpp.
void mapIds();
Expand Down
4 changes: 2 additions & 2 deletions hsolve/HSolveActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ void HSolveActive::sendValues( ProcPtr info )
{
vector< unsigned int >::iterator i;

for ( i = outVm_.begin(); i != outVm_.end(); ++i )
for ( i = outVm_.begin(); i != outVm_.end(); ++i ) {
Compartment::VmOut()->send(
//~ ZombieCompartment::VmOut()->send(
compartmentId_[ *i ].eref(),
V_[ *i ]
);

}

for ( i = outIk_.begin(); i != outIk_.end(); ++i ){

Expand Down
5 changes: 3 additions & 2 deletions hsolve/HSolveUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ int HSolveUtils::targets(
e->getNeighbors( all, f );

vector< Id >::iterator ia;
if ( filter.empty() )
if ( filter.empty() ) {
target.insert( target.end(), all.begin(), all.end() );
else
} else {
for ( ia = all.begin(); ia != all.end(); ++ia ) {
string className = (*ia).element()->cinfo()->name();
bool hit =
Expand All @@ -335,6 +335,7 @@ int HSolveUtils::targets(
if ( ( hit && include ) || ( !hit && !include ) )
target.push_back( *ia );
}
}

return target.size() - oldSize;
}
Expand Down
78 changes: 78 additions & 0 deletions python/rdesigneur/rdesigneurProtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,84 @@ def make_LCa( name = 'LCa', parent = '/library' ):
ygate.tableA = yA
ygate.tableB = yB
return Ca
######################################################################

# Derived from : squid/electronics.py
# Description:
# Author: Subhasis Ray
# Maintainer:
# Created: Wed Feb 22 00:53:38 2012 (+0530)
# Version:
# Last-Updated: Fri May 04 16:35:40 2018 (+0530)
# By: Upi
# Update #: 221

# Change log:
#
# 2012-02-22 23:22:30 (+0530) Subha - the circuitry put in a class.
# 2018-05-04 23:22:30 (+0530) Upi - Adapted for Rdesigneur
#

# Code:

class ClampCircuit(moose.Neutral):
"""Container for a Voltage-Clamp/Current clamp circuit."""
defaults = {
'level1': 25.0e-3,
'width1': 50.0e-3,
'delay1': 2.0e-3,
'delay2': 1e3,
'trigMode': 0,
'delay3': 1e6
}
def __init__(self, path ):
moose.Neutral.__init__(self, path)
'''
self.pulsegen = moose.PulseGen(path+"/pulse") # holding voltage/current generator
self.pulsegen.count = 2
self.pulsegen.baseLevel = -65.0e-3
self.pulsegen.firstLevel = -40.0e-3
self.pulsegen.firstWidth = 50.0e-3
self.pulsegen.firstDelay = 2.0e-3
self.pulsegen.secondDelay = 0.0
self.pulsegen.trigMode = 2
self.gate = moose.PulseGen(path+"/gate") # holding voltage/current generator
self.gate.level[0] = 1.0
self.gate.delay[0] = 0.0
self.gate.width[0] = 1e3
moose.connect(self.gate, 'output', self.pulsegen, 'input')
'''
self.lowpass = moose.RC(path+"/lowpass") # lowpass filter
self.lowpass.R = 1.0
self.lowpass.C = 0.03
self.vclamp = moose.DiffAmp(path+"/vclamp")
self.vclamp.gain = 1.0
self.vclamp.saturation = 1e10
self.iclamp = moose.DiffAmp(path+"/iclamp")
self.iclamp.gain = 0.0
self.iclamp.saturation = 1e10
self.pid = moose.PIDController(path+"/pid")
self.pid.gain = 0.5
self.pid.tauI = 0.02e-3
self.pid.tauD = 0.005e-3
self.pid.saturation = 1e7
# Connect voltage clamp circuitry
#moose.connect(self.pulsegen, "output", self.lowpass, "injectIn")
moose.connect(self.lowpass, "output", self.vclamp, "plusIn")
moose.connect(self.vclamp, "output", self.pid, "commandIn")
#moose.connect(compartment, "VmOut", self.pid, "sensedIn")
#moose.connect(self.pid, "output", compartment, "injectMsg")
addmsg1 = moose.Mstring( path + '/addmsg1' )
addmsg1.value = './pid output .. injectMsg'
addmsg2 = moose.Mstring( path + '/addmsg2' )
addmsg2.value = '.. VmOut ./pid sensedIn'

def make_vclamp( name = 'Vclamp', parent = '/library' ):
if moose.exists( '/library/' + name ):
return
vclamp = ClampCircuit( parent + '/' + name )

######################################################################

################################################################
# API function for building spine prototypes. Here we put in the
Expand Down

0 comments on commit 12cf83e

Please sign in to comment.