def __init__(self, regions=None, d=0, name=None, charge=0, initial=None): """s = rxd.Species(regions, d = 0, name = None, charge = 0, initial = None) Declare a species. Parameters: regions -- a Region or list of Region objects containing the species d -- the diffusion constant of the species (optional; default is 0, i.e. non-diffusing) name -- the name of the Species; used for syncing with HOC (optional; default is none) charge -- the charge of the Species (optional; default is 0) initial -- the initial concentration or None (if None, then imports from HOC if the species is defined at finitialize, else 0) Note: charge must match the charges specified in NMODL files for the same ion, if any.""" import neuron import ctypes from . import rxd # if there is a species, then rxd is being used, so we should register # this function may be safely called many times rxd._do_nbs_register() # TODO: check if "name" already defined elsewhere (if non-None) # if so, make sure other fields consistent, expand regions as appropriate self._allow_setting = True self.regions = regions self.d = d self.name = name self.charge = charge self.initial = initial _all_species.append(weakref.ref(self)) # declare an update to the structure of the model (the number of differential equations has changed) neuron.nrn_dll_sym('structure_change_cnt', ctypes.c_int).value += 1 # initialize self if the rest of rxd is already initialized if initializer.is_initialized(): if _has_3d: if isinstance(regions, region.Region) and not regions._secs1d: pass elif hasattr(regions, '__len__') and all(not r._secs1d for r in regions): pass else: # TODO: remove this limitation # one strategy would be to just redo the whole thing; what are the implications of that? # (pointers would be invalid; anything else?) raise RxDException( 'Currently cannot add species containing 1D after 3D species defined and initialized. To work-around: reorder species definition.' ) self._do_init()
def __init__(self, secs=None, nrn_region=None, geometry=None, dimension=None, dx=None, name=None): """ In NEURON 7.4+, secs is optional at initial region declaration, but it must be specified before the reaction-diffusion model is instantiated. .. note:: dimension and dx will be deprecated in a future version """ self._allow_setting = True self.secs = secs self.nrn_region = nrn_region self.geometry = geometry if dimension is not None: warnings.warn( "dimension argument was a development feature only; use set_solve_type instead... the current version sets all the sections to your requested dimension, but this will override any previous settings" ) import neuron neuron.rxd.set_solve_type(secs, dimension=dimension) self._name = name self.dx = dx _all_regions.append(weakref.ref(self)) # initialize self if the rest of rxd is already initialized if initializer.is_initialized(): self._do_init()
def __init__(self, secs=None, nrn_region=None, geometry=None, dimension=None, dx=None, name=None): """ In NEURON 7.4+, secs is optional at initial region declaration, but it must be specified before the reaction-diffusion model is instantiated. .. note:: dimension and dx will be deprecated in a future version """ self._allow_setting = True self.secs = secs self.nrn_region = nrn_region self.geometry = geometry if dimension is not None: warnings.warn( 'dimension argument was a development feature only; use set_solve_type instead... the current version sets all the sections to your requested dimension, but this will override any previous settings' ) import neuron neuron.rxd.set_solve_type(secs, dimension=dimension) self._name = name self.dx = dx _all_regions.append(weakref.ref(self)) # initialize self if the rest of rxd is already initialized if initializer.is_initialized(): self._do_init()
def __init__(self, regions=None, d=0, name=None, charge=0, initial=None): """s = rxd.Species(regions, d = 0, name = None, charge = 0, initial = None) Declare a species. Parameters: regions -- a Region or list of Region objects containing the species d -- the diffusion constant of the species (optional; default is 0, i.e. non-diffusing) name -- the name of the Species; used for syncing with HOC (optional; default is none) charge -- the charge of the Species (optional; default is 0) initial -- the initial concentration or None (if None, then imports from HOC if the species is defined at finitialize, else 0) Note: charge must match the charges specified in NMODL files for the same ion, if any.""" import neuron import ctypes from . import rxd # if there is a species, then rxd is being used, so we should register # this function may be safely called many times rxd._do_nbs_register() # TODO: check if "name" already defined elsewhere (if non-None) # if so, make sure other fields consistent, expand regions as appropriate self._allow_setting = True self.regions = regions self.d = d self.name = name self.charge = charge self.initial = initial _all_species.append(weakref.ref(self)) # declare an update to the structure of the model (the number of differential equations has changed) neuron.nrn_dll_sym('structure_change_cnt', ctypes.c_int).value += 1 # initialize self if the rest of rxd is already initialized if initializer.is_initialized(): if _has_3d: if isinstance(regions, region.Region) and not regions._secs1d: pass elif hasattr(regions, '__len__') and all(not r._secs1d for r in regions): pass else: # TODO: remove this limitation # one strategy would be to just redo the whole thing; what are the implications of that? # (pointers would be invalid; anything else?) raise RxDException('Currently cannot add species containing 1D after 3D species defined and initialized. To work-around: reorder species definition.') self._do_init()