Beispiel #1
0
 def __init__(self, seg):
   self.seg = seg #dangerous as contents can disappear when nseg changes
   self.call = [self.setup, self.initialize,
     self.current, self.conductance, self.fixed_step_solve,
     self.ode_count, self.ode_reinit, self.ode_fun, self.ode_solve, None,
     None
   ]
   self.gkbar = .036
   nbs.register(self.call)
Beispiel #2
0
 def __init__(self, sectionlist=None):
   if sectionlist:
     self.sl = sectionlist
   else:
     self.sl = h.SectionList()
     for sec in h.allsec():
       self.sl.append()
   self.call = [self.setup, self.initialize,
     self.current, self.conductance, self.fixed_step_solve,
     self.ode_count, self.ode_reinit, self.ode_fun, self.ode_solve, None,
     None, self.statename
   ]
   self.gkbar = .036
   nbs.register(self.call)
Beispiel #3
0
def test_nonvint_block_supervisor():
    # making sure we can import
    from neuron import nonvint_block_supervisor
    # and can still use threads (no registered callbacks)
    pc = h.ParallelContext()
    pc.nthread(2)
    h.finitialize()
    # but if there is a callback it will fail with threads
    nonvint_block_supervisor.register([None for _ in range(11)])
    expect_hocerr(h.finitialize, (-65, ))
    # but can be cleared
    nonvint_block_supervisor.clear()
    h.finitialize()
    pc.nthread(1)
Beispiel #4
0
def _do_nbs_register():
    global _has_nbs_registered, _nbs, _fih, _fih2
    
    if not _has_nbs_registered:
        from neuron import nonvint_block_supervisor as _nbs

        _has_nbs_registered = True
        _nbs.register(_callbacks)
    
        #
        # register the initialization handler and the ion register handler
        #
        _fih = h.FInitializeHandler(_init)
        _fih2 = h.FInitializeHandler(3, initializer._do_ion_register)

        #
        # register scatter/gather mechanisms
        #
        _cvode_object.extra_scatter_gather(0, _after_advance)
Beispiel #5
0
def _do_nbs_register():
    global _has_nbs_registered, _nbs, _fih, _fih2

    if not _has_nbs_registered:
        from neuron import nonvint_block_supervisor as _nbs

        _has_nbs_registered = True
        _nbs.register(_callbacks)

        #
        # register the initialization handler and the ion register handler
        #
        _fih = h.FInitializeHandler(_init)
        _fih2 = h.FInitializeHandler(3, initializer._do_ion_register)

        #
        # register scatter/gather mechanisms
        #
        _cvode_object.extra_scatter_gather(0, _after_advance)
Beispiel #6
0
def _conductance(d):
    pass


def _ode_jacobian(dt, t, ypred, fpred):
    #print '_ode_jacobian: dt = %g, last_dt = %r' % (dt, _last_dt)
    lo = _rxd_offset
    hi = lo + len(_nonzero_volume_indices)
    _reaction_matrix_setup(dt, ypred[lo:hi])


_callbacks = [
    _setup, None, _fixed_step_currents, _conductance, _fixed_step_solve,
    _ode_count, _ode_reinit, _ode_fun, _ode_solve, _ode_jacobian, None
]
nbs.register(_callbacks)

_curr_ptr_vector = None
_curr_ptr_storage = None
_curr_ptr_storage_nrn = None


def _update_node_data(force=False):
    global last_diam_change_cnt, last_structure_change_cnt, _curr_indices, _curr_scales, _curr_ptrs
    global _curr_ptr_vector, _curr_ptr_storage, _curr_ptr_storage_nrn
    if last_diam_change_cnt != _cvode_object.diam_change_count(
    ) or _cvode_object.structure_change_count(
    ) != last_structure_change_cnt or force:
        last_diam_change_cnt = _cvode_object.diam_change_count()
        last_structure_change_cnt = _cvode_object.structure_change_count()
        for sr in species._get_all_species().values():
Beispiel #7
0
    print(h.f())
    h.x = 4
    print(h.x)
    h.y[2] = 6
    print(h.y[2])


a = h.A()
a.call(callback)

from neuron import h, nonvint_block_supervisor
h.load_file('stdrun.hoc')

_callbacks = [None] * 11
_callbacks[1] = callback
nonvint_block_supervisor.register(_callbacks)

#h.cvode_active(0)
h('''
begintemplate B
proc call() {
  // anything that ends up calling a nonvint_block_supervisor callback
  // that calls 'def callback' within this context
  finitialize()
}

endtemplate B
''')

h.finitialize()
print('ok so far')
Beispiel #8
0
        _react_matrix_solver = lambda x: x

def _setup():
    # TODO: this is when I should resetup matrices (structure changed event)
    pass

def _conductance(d):
    pass
    
def _ode_jacobian(dt, t, ypred, fpred):
    #print '_ode_jacobian: dt = %g, last_dt = %r' % (dt, _last_dt)
    _reaction_matrix_setup(dt, fpred)

_callbacks = [_setup, None, _fixed_step_currents, _conductance, _fixed_step_solve,
              _ode_count, _ode_reinit, _ode_fun, _ode_solve, _ode_jacobian, None]
nbs.register(_callbacks)

_curr_ptr_vector = None
_curr_ptr_storage = None
_curr_ptr_storage_nrn = None

def _update_node_data(force=False):
    global last_diam_change_cnt, last_structure_change_cnt, _curr_indices, _curr_scales, _curr_ptrs
    global _curr_ptr_vector, _curr_ptr_storage, _curr_ptr_storage_nrn
    if last_diam_change_cnt != _cvode_object.diam_change_count() or _cvode_object.structure_change_count() != last_structure_change_cnt or force:
        last_diam_change_cnt = _cvode_object.diam_change_count()
        last_structure_change_cnt = _cvode_object.structure_change_count()
        for sr in species._get_all_species().values():
            s = sr()
            if s is not None: s._update_node_data()
        for sr in species._get_all_species().values():