Skip to content

Commit 12cf83e

Browse files
committed
Updates to Hsolve to be able to delete and recreate it. Still problematic for HHChannels. Also added Vclamp to the rdesigneurProtos.
1 parent 3ec52cd commit 12cf83e

File tree

5 files changed

+113
-7
lines changed

5 files changed

+113
-7
lines changed

hsolve/HSolve.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "../biophysics/ChanBase.h"
2424
#include "../biophysics/ChanCommon.h"
2525
#include "../biophysics/HHChannel.h"
26+
#include "../biophysics/CaConc.h"
2627
#include "ZombieHHChannel.h"
2728
#include "../shell/Shell.h"
2829

@@ -192,6 +193,11 @@ HSolve::HSolve()
192193
;
193194
}
194195

196+
HSolve::~HSolve()
197+
{
198+
unzombify();
199+
}
200+
195201

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

216222
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
217223
temp.push_back( ObjId( *i, 0 ) );
218-
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
224+
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i ) {
219225
CompartmentBase::zombify( i->eref().element(),
220226
ZombieCompartment::initCinfo(), hsolve.id() );
227+
}
221228

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

229237
temp.clear();
230238
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
231239
temp.push_back( ObjId( *i, 0 ) );
232-
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
240+
for ( i = channelId_.begin(); i != channelId_.end(); ++i ) {
233241
HHChannelBase::zombify( i->eref().element(),
234242
ZombieHHChannel::initCinfo(), hsolve.id() );
243+
}
244+
}
245+
246+
void HSolve::unzombify() const
247+
{
248+
vector< Id >::const_iterator i;
249+
250+
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
251+
CompartmentBase::zombify( i->eref().element(),
252+
Compartment::initCinfo(), Id() );
253+
254+
for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
255+
CaConcBase::zombify( i->eref().element(), CaConc::initCinfo(), Id() );
256+
257+
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
258+
HHChannelBase::zombify( i->eref().element(),
259+
HHChannel::initCinfo(), Id() );
235260
}
236261

237262
void HSolve::setup( Eref hsolve )

hsolve/HSolve.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class HSolve: public HSolveActive
1717
{
1818
public:
1919
HSolve();
20+
~HSolve();
2021

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

158159
void setup( Eref hsolve );
159160
void zombify( Eref hsolve ) const;
161+
void unzombify() const;
160162

161163
// Mapping global Id to local index. Defined in HSolveInterface.cpp.
162164
void mapIds();

hsolve/HSolveActive.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ void HSolveActive::sendValues( ProcPtr info )
356356
{
357357
vector< unsigned int >::iterator i;
358358

359-
for ( i = outVm_.begin(); i != outVm_.end(); ++i )
359+
for ( i = outVm_.begin(); i != outVm_.end(); ++i ) {
360360
Compartment::VmOut()->send(
361361
//~ ZombieCompartment::VmOut()->send(
362362
compartmentId_[ *i ].eref(),
363363
V_[ *i ]
364364
);
365-
365+
}
366366

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

hsolve/HSolveUtils.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ int HSolveUtils::targets(
320320
e->getNeighbors( all, f );
321321

322322
vector< Id >::iterator ia;
323-
if ( filter.empty() )
323+
if ( filter.empty() ) {
324324
target.insert( target.end(), all.begin(), all.end() );
325-
else
325+
} else {
326326
for ( ia = all.begin(); ia != all.end(); ++ia ) {
327327
string className = (*ia).element()->cinfo()->name();
328328
bool hit =
@@ -335,6 +335,7 @@ int HSolveUtils::targets(
335335
if ( ( hit && include ) || ( !hit && !include ) )
336336
target.push_back( *ia );
337337
}
338+
}
338339

339340
return target.size() - oldSize;
340341
}

python/rdesigneur/rdesigneurProtos.py

+78
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,84 @@ def make_LCa( name = 'LCa', parent = '/library' ):
325325
ygate.tableA = yA
326326
ygate.tableB = yB
327327
return Ca
328+
######################################################################
329+
330+
# Derived from : squid/electronics.py
331+
# Description:
332+
# Author: Subhasis Ray
333+
# Maintainer:
334+
# Created: Wed Feb 22 00:53:38 2012 (+0530)
335+
# Version:
336+
# Last-Updated: Fri May 04 16:35:40 2018 (+0530)
337+
# By: Upi
338+
# Update #: 221
339+
340+
# Change log:
341+
#
342+
# 2012-02-22 23:22:30 (+0530) Subha - the circuitry put in a class.
343+
# 2018-05-04 23:22:30 (+0530) Upi - Adapted for Rdesigneur
344+
#
345+
346+
# Code:
347+
348+
class ClampCircuit(moose.Neutral):
349+
"""Container for a Voltage-Clamp/Current clamp circuit."""
350+
defaults = {
351+
'level1': 25.0e-3,
352+
'width1': 50.0e-3,
353+
'delay1': 2.0e-3,
354+
'delay2': 1e3,
355+
'trigMode': 0,
356+
'delay3': 1e6
357+
}
358+
def __init__(self, path ):
359+
moose.Neutral.__init__(self, path)
360+
'''
361+
self.pulsegen = moose.PulseGen(path+"/pulse") # holding voltage/current generator
362+
self.pulsegen.count = 2
363+
self.pulsegen.baseLevel = -65.0e-3
364+
self.pulsegen.firstLevel = -40.0e-3
365+
self.pulsegen.firstWidth = 50.0e-3
366+
self.pulsegen.firstDelay = 2.0e-3
367+
self.pulsegen.secondDelay = 0.0
368+
self.pulsegen.trigMode = 2
369+
self.gate = moose.PulseGen(path+"/gate") # holding voltage/current generator
370+
self.gate.level[0] = 1.0
371+
self.gate.delay[0] = 0.0
372+
self.gate.width[0] = 1e3
373+
moose.connect(self.gate, 'output', self.pulsegen, 'input')
374+
'''
375+
self.lowpass = moose.RC(path+"/lowpass") # lowpass filter
376+
self.lowpass.R = 1.0
377+
self.lowpass.C = 0.03
378+
self.vclamp = moose.DiffAmp(path+"/vclamp")
379+
self.vclamp.gain = 1.0
380+
self.vclamp.saturation = 1e10
381+
self.iclamp = moose.DiffAmp(path+"/iclamp")
382+
self.iclamp.gain = 0.0
383+
self.iclamp.saturation = 1e10
384+
self.pid = moose.PIDController(path+"/pid")
385+
self.pid.gain = 0.5
386+
self.pid.tauI = 0.02e-3
387+
self.pid.tauD = 0.005e-3
388+
self.pid.saturation = 1e7
389+
# Connect voltage clamp circuitry
390+
#moose.connect(self.pulsegen, "output", self.lowpass, "injectIn")
391+
moose.connect(self.lowpass, "output", self.vclamp, "plusIn")
392+
moose.connect(self.vclamp, "output", self.pid, "commandIn")
393+
#moose.connect(compartment, "VmOut", self.pid, "sensedIn")
394+
#moose.connect(self.pid, "output", compartment, "injectMsg")
395+
addmsg1 = moose.Mstring( path + '/addmsg1' )
396+
addmsg1.value = './pid output .. injectMsg'
397+
addmsg2 = moose.Mstring( path + '/addmsg2' )
398+
addmsg2.value = '.. VmOut ./pid sensedIn'
399+
400+
def make_vclamp( name = 'Vclamp', parent = '/library' ):
401+
if moose.exists( '/library/' + name ):
402+
return
403+
vclamp = ClampCircuit( parent + '/' + name )
404+
405+
######################################################################
328406

329407
################################################################
330408
# API function for building spine prototypes. Here we put in the

0 commit comments

Comments
 (0)