Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
numpy.ctypeslib.ndpointer(dtype=int),
numpy.ctypeslib.ndpointer(dtype=int),
numpy.ctypeslib.ndpointer(dtype=int),
ctypes.c_long,
numpy.ctypeslib.ndpointer(dtype=int),
ctypes.c_long,
numpy.ctypeslib.ndpointer(dtype=int),
ctypes.c_long,
ctypes.c_double,
ctypes.c_double,
ctypes.c_bool,
ctypes.c_double,
numpy.ctypeslib.ndpointer(dtype=float),]
#function to change extracellular diffusion
set_diffusion = nrn_dll_sym('set_diffusion')
set_diffusion.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_double]
set_diffusion.restype = ctypes.c_int
ICS_insert.restype = ctypes.c_int
species_atolscale = nrn_dll_sym('species_atolscale')
species_atolscale.argtypes = [ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
_set_grid_concentrations = nrn_dll_sym('set_grid_concentrations')
_set_grid_concentrations.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.py_object, ctypes.py_object]
_ics_set_grid_concentrations = nrn_dll_sym('ics_set_grid_concentrations')
_ics_set_grid_concentrations.argtypes = [ctypes.c_int, ctypes.c_int, numpy.ctypeslib.ndpointer(dtype=numpy.int64), numpy.ctypeslib.ndpointer(dtype=numpy.int64), ctypes.py_object]
_set_grid_currents = nrn_dll_sym('set_grid_currents')
_set_grid_currents.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.py_object, ctypes.py_object, ctypes.py_object]
_windows_dll_files = []
_windows_dll = []
make_time_ptr = nrn_dll_sym('make_time_ptr')
make_time_ptr.argtypes = [ctypes.py_object, ctypes.py_object]
make_time_ptr(h._ref_dt, h._ref_t)
_double_ptr = ctypes.POINTER(ctypes.c_double)
_int_ptr = ctypes.POINTER(_ctypes_c_int)
_long_ptr = ctypes.POINTER(ctypes.c_long)
fptr_prototype = ctypes.CFUNCTYPE(None)
set_nonvint_block = nrn_dll_sym('set_nonvint_block')
set_nonvint_block(nrn_dll_sym('rxd_nonvint_block'))
set_setup = nrn_dll_sym('set_setup')
set_setup.argtypes = [fptr_prototype]
set_initialize = nrn_dll_sym('set_initialize')
set_initialize.argtypes = [fptr_prototype]
scatter_concentrations = nrn_dll_sym('scatter_concentrations')
# Transfer extracellular concentrations to NEURON
_fih_transfer_ecs = h.FInitializeHandler(1, scatter_concentrations)
rxd_set_no_diffusion = nrn_dll_sym('rxd_set_no_diffusion')
setup_solver = nrn_dll_sym('setup_solver')
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])
_curr_ptr_vector = None
_curr_ptr_storage = None
_curr_ptr_storage_nrn = None
pinverse = None
_cur_map = None
_h_ptrvector = h.PtrVector
_h_vector = h.Vector
_structure_change_count = nrn_dll_sym('structure_change_cnt', _ctypes_c_int)
_diam_change_count = nrn_dll_sym('diam_change_cnt', _ctypes_c_int)
def _donothing(): pass
def _update_node_data(force=False, newspecies=False):
global last_diam_change_cnt, last_structure_change_cnt, _curr_indices, _cur_node_indices, _curr_scales, _curr_ptrs, _cur_map
global _curr_ptr_vector, _curr_ptr_storage, _curr_ptr_storage_nrn
if last_diam_change_cnt != _diam_change_count.value or _structure_change_count.value != last_structure_change_cnt or force:
_cur_map = {}
last_diam_change_cnt = _diam_change_count.value
last_structure_change_cnt = _structure_change_count.value
#if not species._has_3d:
# TODO: merge this with the 3d/hybrid case?
if initializer.is_initialized():
nsegs_changed = 0
for sr in _species_get_all_species():
s = sr()
ICS_insert.restype = ctypes.c_int
species_atolscale = nrn_dll_sym('species_atolscale')
species_atolscale.argtypes = [ctypes.c_int, ctypes.c_double, ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
_set_grid_concentrations = nrn_dll_sym('set_grid_concentrations')
_set_grid_concentrations.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.py_object, ctypes.py_object]
_ics_set_grid_concentrations = nrn_dll_sym('ics_set_grid_concentrations')
_ics_set_grid_concentrations.argtypes = [ctypes.c_int, ctypes.c_int, numpy.ctypeslib.ndpointer(dtype=numpy.int64), numpy.ctypeslib.ndpointer(dtype=numpy.int64), ctypes.py_object]
_set_grid_currents = nrn_dll_sym('set_grid_currents')
_set_grid_currents.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.py_object, ctypes.py_object, ctypes.py_object]
_ics_set_grid_currents = nrn_dll_sym('ics_set_grid_currents')
_ics_set_grid_currents.argtypes = [ctypes.c_int, ctypes.c_int, numpy.ctypeslib.ndpointer(dtype=numpy.int64), numpy.ctypeslib.ndpointer(dtype=numpy.int64), ctypes.py_object, numpy.ctypeslib.ndpointer(dtype=numpy.float_)]
_delete_by_id = nrn_dll_sym('delete_by_id')
_delete_by_id.argtypes = [ctypes.c_int]
# The difference here is that defined species only exists after rxd initialization
_all_species = []
_defined_species = {}
def _get_all_species():
return _defined_species
_extracellular_diffusion_objects = weakref.WeakKeyDictionary()
_intracellular_diffusion_objects = weakref.WeakKeyDictionary()
fptr_prototype = ctypes.CFUNCTYPE(None)
set_nonvint_block = nrn_dll_sym('set_nonvint_block')
set_nonvint_block(nrn_dll_sym('rxd_nonvint_block'))
set_setup = nrn_dll_sym('set_setup')
set_setup.argtypes = [fptr_prototype]
set_initialize = nrn_dll_sym('set_initialize')
set_initialize.argtypes = [fptr_prototype]
scatter_concentrations = nrn_dll_sym('scatter_concentrations')
# Transfer extracellular concentrations to NEURON
_fih_transfer_ecs = h.FInitializeHandler(1, scatter_concentrations)
rxd_set_no_diffusion = nrn_dll_sym('rxd_set_no_diffusion')
setup_solver = nrn_dll_sym('setup_solver')
setup_solver.argtypes = [ndpointer(ctypes.c_double), ctypes.c_int, numpy.ctypeslib.ndpointer(numpy.int_, flags='contiguous'), ctypes.c_int, ctypes.py_object, ctypes.py_object]
#states = None
_set_num_threads = nrn_dll_sym('set_num_threads')
_set_num_threads.argtypes = [ctypes.c_int]
_get_num_threads = nrn_dll_sym('get_num_threads')
_get_num_threads.restype = ctypes.c_int
clear_rates = nrn_dll_sym('clear_rates')
register_rate = nrn_dll_sym('register_rate')
register_rate.argtypes = [
ctypes.c_int, #num species
ctypes.c_int, #num regions
set_nonvint_block(nrn_dll_sym('rxd_nonvint_block'))
set_setup = nrn_dll_sym('set_setup')
set_setup.argtypes = [fptr_prototype]
set_initialize = nrn_dll_sym('set_initialize')
set_initialize.argtypes = [fptr_prototype]
scatter_concentrations = nrn_dll_sym('scatter_concentrations')
# Transfer extracellular concentrations to NEURON
_fih_transfer_ecs = h.FInitializeHandler(1, scatter_concentrations)
rxd_set_no_diffusion = nrn_dll_sym('rxd_set_no_diffusion')
setup_solver = nrn_dll_sym('setup_solver')
setup_solver.argtypes = [ndpointer(ctypes.c_double), ctypes.c_int, numpy.ctypeslib.ndpointer(numpy.int_, flags='contiguous'), ctypes.c_int, ctypes.py_object, ctypes.py_object]
#states = None
_set_num_threads = nrn_dll_sym('set_num_threads')
_set_num_threads.argtypes = [ctypes.c_int]
_get_num_threads = nrn_dll_sym('get_num_threads')
_get_num_threads.restype = ctypes.c_int
clear_rates = nrn_dll_sym('clear_rates')
register_rate = nrn_dll_sym('register_rate')
register_rate.argtypes = [
ctypes.c_int, #num species
ctypes.c_int, #num regions
ctypes.c_int, #num seg
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #species ids
_fih_transfer_ecs = h.FInitializeHandler(1, scatter_concentrations)
rxd_set_no_diffusion = nrn_dll_sym('rxd_set_no_diffusion')
setup_solver = nrn_dll_sym('setup_solver')
setup_solver.argtypes = [ndpointer(ctypes.c_double), ctypes.c_int, numpy.ctypeslib.ndpointer(numpy.int_, flags='contiguous'), ctypes.c_int, ctypes.py_object, ctypes.py_object]
#states = None
_set_num_threads = nrn_dll_sym('set_num_threads')
_set_num_threads.argtypes = [ctypes.c_int]
_get_num_threads = nrn_dll_sym('get_num_threads')
_get_num_threads.restype = ctypes.c_int
clear_rates = nrn_dll_sym('clear_rates')
register_rate = nrn_dll_sym('register_rate')
register_rate.argtypes = [
ctypes.c_int, #num species
ctypes.c_int, #num parameters
ctypes.c_int, #num regions
ctypes.c_int, #num seg
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #species ids
ctypes.c_int, #num ecs species
ctypes.c_int, #num ecs parameters
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #ecs species ids
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #ecs indices
ctypes.c_int, #num multicompartment reactions
numpy.ctypeslib.ndpointer(ctypes.c_double, flags='contiguous'), #multicompartment multipliers
ctypes.POINTER(ctypes.py_object), #voltage pointers
] #Reaction rate function
set_initialize = nrn_dll_sym('set_initialize')
set_initialize.argtypes = [fptr_prototype]
scatter_concentrations = nrn_dll_sym('scatter_concentrations')
# Transfer extracellular concentrations to NEURON
_fih_transfer_ecs = h.FInitializeHandler(1, scatter_concentrations)
rxd_set_no_diffusion = nrn_dll_sym('rxd_set_no_diffusion')
setup_solver = nrn_dll_sym('setup_solver')
setup_solver.argtypes = [ndpointer(ctypes.c_double), ctypes.c_int, numpy.ctypeslib.ndpointer(numpy.int_, flags='contiguous'), ctypes.c_int, ctypes.py_object, ctypes.py_object]
#states = None
_set_num_threads = nrn_dll_sym('set_num_threads')
_set_num_threads.argtypes = [ctypes.c_int]
_get_num_threads = nrn_dll_sym('get_num_threads')
_get_num_threads.restype = ctypes.c_int
clear_rates = nrn_dll_sym('clear_rates')
register_rate = nrn_dll_sym('register_rate')
register_rate.argtypes = [
ctypes.c_int, #num species
ctypes.c_int, #num regions
ctypes.c_int, #num seg
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #species ids
ctypes.c_int, numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #num ecs species
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #ecs species ids
ctypes.c_int, #num multicompartment reactions
numpy.ctypeslib.ndpointer(ctypes.c_double, flags='contiguous'), #multicompartment multipliers
clear_rates = nrn_dll_sym('clear_rates')
register_rate = nrn_dll_sym('register_rate')
register_rate.argtypes = [
ctypes.c_int, #num species
ctypes.c_int, #num regions
ctypes.c_int, #num seg
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #species ids
ctypes.c_int, numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #num ecs species
numpy.ctypeslib.ndpointer(ctypes.c_int, flags='contiguous'), #ecs species ids
ctypes.c_int, #num multicompartment reactions
numpy.ctypeslib.ndpointer(ctypes.c_double, flags='contiguous'), #multicompartment multipliers
ctypes.POINTER(ctypes.py_object), #voltage pointers
] #Reaction rate function
setup_currents = nrn_dll_sym('setup_currents')
setup_currents.argtypes = [
ctypes.c_int, #number of membrane currents
ctypes.c_int, #number induced currents
ctypes.c_int, #number of nodes with membrane currents
_int_ptr, #number of species involved in each membrane current
_int_ptr, #charges of the species involved in each membrane current
_int_ptr, #node indices
_int_ptr, #node indices
_double_ptr, #scaling (areas) of the fluxes
_int_ptr, #charges for each species in each reation
ctypes.POINTER(ctypes.py_object), #hoc pointers
_int_ptr, #maps for membrane fluxes
_int_ptr #maps for ecs fluxes
]
def _do_nbs_register():
global _has_nbs_registered, _nbs, _fih, _fih2, _fih3, do_setup_matrices_fptr
if not _has_nbs_registered:
#from neuron import nonvint_block_supervisor as _nbs
_has_nbs_registered = True
#_nbs.register(_callbacks) not used by crxd
#
# register the initialization handler and the ion register handler
#
_fih = h.FInitializeHandler(_init_concentration)
_fih3 = h.FInitializeHandler(3, _init)
set_setup_matrices = nrn_dll_sym('set_setup_matrices')
set_setup_matrices.argtypes = [fptr_prototype]
do_setup_matrices_fptr = fptr_prototype(_setup_matrices)
set_setup_matrices(do_setup_matrices_fptr)
_fih2 = h.FInitializeHandler(3, initializer._do_ion_register)
#
# register scatter/gather mechanisms
#
_cvode_object.extra_scatter_gather(0, _after_advance)