コード例 #1
0
ファイル: utils.py プロジェクト: csiki/moose-csiki
def updateTicks(tickDtMap):
    """Try to assign dt values to ticks.

    Parameters
    ----------
    tickDtMap: dict
    map from tick-no. to dt value. if it is empty, then default dt
    values are assigned to the ticks.

    """
    for tickNo, dt in tickDtMap.items():
        if tickNo >= 0 and dt > 0.0:
            _moose.setClock(tickNo, dt)
    if all([(v == 0) for v in tickDtMap.values()]):
        setDefaultDt()
コード例 #2
0
def updateTicks(tickDtMap):
    """Try to assign dt values to ticks.

    Parameters
    ----------
    tickDtMap: dict
    map from tick-no. to dt value. if it is empty, then default dt
    values are assigned to the ticks.

    """
    for tickNo, dt in tickDtMap.items():
        if tickNo >= 0 and dt > 0.0:
            _moose.setClock(tickNo, dt)
    if all([(v == 0) for v in tickDtMap.values()]):
        setDefaultDt()
コード例 #3
0
ファイル: utils.py プロジェクト: csiki/moose-csiki
def resetSim(simpaths, simdt, plotdt, simmethod='hsolve'):
    """ For each of the MOOSE paths in simpaths, this sets the clocks and finally resets MOOSE.
    If simmethod=='hsolve', it sets up hsolve-s for each Neuron under simpaths, and clocks for hsolve-s too. """
    print 'Solver:', simmethod
    _moose.setClock(INITCLOCK, simdt)
    _moose.setClock(ELECCLOCK, simdt) # The hsolve and ee methods use clock 1
    _moose.setClock(CHANCLOCK, simdt) # hsolve uses clock 2 for mg_block, nmdachan and others.
    _moose.setClock(POOLCLOCK, simdt) # Ca/ion pools & funcs use clock 3
    _moose.setClock(STIMCLOCK, simdt) # Ca/ion pools & funcs use clock 3
    _moose.setClock(PLOTCLOCK, plotdt) # for tables
    for simpath in simpaths:
        ## User can connect [qty]Out of an element to input of Table or
        ## requestOut of Table to get[qty] of the element.
        ## Scheduling the Table to a clock tick, will call process() of the Table
        ## which will send a requestOut and overwrite any value set by input(),
        ## thus adding garbage value to the vector. Hence schedule only if
        ## input message is not connected to the Table.
        for table in _moose.wildcardFind(simpath+'/##[TYPE=Table]'):
            if len(table.neighbors['input']) == 0:
                _moose.useClock(PLOTCLOCK, table.path, 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=PulseGen]', 'process')
        _moose.useClock(STIMCLOCK, simpath+'/##[TYPE=DiffAmp]', 'process')
        _moose.useClock(STIMCLOCK, simpath+'/##[TYPE=VClamp]', 'process')
        _moose.useClock(STIMCLOCK, simpath+'/##[TYPE=PIDController]', 'process')
        _moose.useClock(STIMCLOCK, simpath+'/##[TYPE=RC]', 'process')
        _moose.useClock(STIMCLOCK, simpath+'/##[TYPE=TimeTable]', 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=LeakyIaF]', 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=IntFire]', 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=IzhikevichNrn]', 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=SpikeGen]', 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=Interpol]', 'process')
        _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=Interpol2D]', 'process')
        _moose.useClock(CHANCLOCK, simpath+'/##[TYPE=HHChannel2D]', 'process')
        _moose.useClock(CHANCLOCK, simpath+'/##[TYPE=SynChan]', 'process')
        ## If simmethod is not hsolve, set clocks for the biophysics,
        ## else just put a clock on the hsolve:
        ## hsolve takes care of the clocks for the biophysics
        if 'hsolve' not in simmethod.lower():
            print 'Using exp euler'
            _moose.useClock(INITCLOCK, simpath+'/##[TYPE=Compartment]', 'init')
            _moose.useClock(ELECCLOCK, simpath+'/##[TYPE=Compartment]', 'process')
            _moose.useClock(CHANCLOCK, simpath+'/##[TYPE=HHChannel]', 'process')
            _moose.useClock(POOLCLOCK, simpath+'/##[TYPE=CaConc]', 'process')
            _moose.useClock(POOLCLOCK, simpath+'/##[TYPE=Func]', 'process')
        else: # use hsolve, one hsolve for each Neuron
            print 'Using hsolve'
            element = _moose.Neutral(simpath)
            for childid in element.children: 
                childobj = _moose.Neutral(childid)
                classname = childobj.className
                if classname in ['Neuron']:
                    neuronpath = childobj.path
                    h = _moose.HSolve( neuronpath+'/solve' )
                    h.dt = simdt
                    h.target = neuronpath
                    _moose.useClock(INITCLOCK, h.path, 'process')
    _moose.reinit()
コード例 #4
0
ファイル: utils.py プロジェクト: csiki/moose-csiki
def setDefaultDt(elecdt=1e-5, chemdt=0.01, tabdt=1e-5, plotdt1=1.0, plotdt2=0.25e-3):
    """Setup the ticks with dt values.

    Parameters
    ----------

    elecdt: dt for ticks used in computing electrical biophysics, like
    neuronal compartments, ion channels, synapses, etc.

    chemdt: dt for chemical computations like enzymatic reactions.

    tabdt: dt for lookup tables

    plotdt1: dt for chemical kinetics plotting

    plotdt2: dt for electrical simulations

    """
    _moose.setClock(0, elecdt)
    _moose.setClock(1, elecdt)
    _moose.setClock(2, elecdt)
    _moose.setClock(3, elecdt)
    _moose.setClock(4, chemdt)
    _moose.setClock(5, chemdt)
    _moose.setClock(6, tabdt)
    _moose.setClock(7, tabdt)        
    _moose.setClock(8, plotdt1) # kinetics sim
    _moose.setClock(9, plotdt2) # electrical sim
コード例 #5
0
def resetSim(simpaths, simdt, plotdt, simmethod='hsolve'):
    """ For each of the MOOSE paths in simpaths, this sets the clocks and finally resets MOOSE.
    If simmethod=='hsolve', it sets up hsolve-s for each Neuron under simpaths, and clocks for hsolve-s too. """
    print 'Solver:', simmethod
    _moose.setClock(INITCLOCK, simdt)
    _moose.setClock(ELECCLOCK, simdt)  # The hsolve and ee methods use clock 1
    _moose.setClock(
        CHANCLOCK,
        simdt)  # hsolve uses clock 2 for mg_block, nmdachan and others.
    _moose.setClock(POOLCLOCK, simdt)  # Ca/ion pools & funcs use clock 3
    _moose.setClock(STIMCLOCK, simdt)  # Ca/ion pools & funcs use clock 3
    _moose.setClock(PLOTCLOCK, plotdt)  # for tables
    for simpath in simpaths:
        ## User can connect [qty]Out of an element to input of Table or
        ## requestOut of Table to get[qty] of the element.
        ## Scheduling the Table to a clock tick, will call process() of the Table
        ## which will send a requestOut and overwrite any value set by input(),
        ## thus adding garbage value to the vector. Hence schedule only if
        ## input message is not connected to the Table.
        for table in _moose.wildcardFind(simpath + '/##[TYPE=Table]'):
            if len(table.neighbors['input']) == 0:
                _moose.useClock(PLOTCLOCK, table.path, 'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=PulseGen]', 'process')
        _moose.useClock(STIMCLOCK, simpath + '/##[TYPE=DiffAmp]', 'process')
        _moose.useClock(STIMCLOCK, simpath + '/##[TYPE=VClamp]', 'process')
        _moose.useClock(STIMCLOCK, simpath + '/##[TYPE=PIDController]',
                        'process')
        _moose.useClock(STIMCLOCK, simpath + '/##[TYPE=RC]', 'process')
        _moose.useClock(STIMCLOCK, simpath + '/##[TYPE=TimeTable]', 'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=LeakyIaF]', 'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=IntFire]', 'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=IzhikevichNrn]',
                        'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=SpikeGen]', 'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=Interpol]', 'process')
        _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=Interpol2D]', 'process')
        _moose.useClock(CHANCLOCK, simpath + '/##[TYPE=HHChannel2D]',
                        'process')
        _moose.useClock(CHANCLOCK, simpath + '/##[TYPE=SynChan]', 'process')
        ## If simmethod is not hsolve, set clocks for the biophysics,
        ## else just put a clock on the hsolve:
        ## hsolve takes care of the clocks for the biophysics
        if 'hsolve' not in simmethod.lower():
            print 'Using exp euler'
            _moose.useClock(INITCLOCK, simpath + '/##[TYPE=Compartment]',
                            'init')
            _moose.useClock(ELECCLOCK, simpath + '/##[TYPE=Compartment]',
                            'process')
            _moose.useClock(CHANCLOCK, simpath + '/##[TYPE=HHChannel]',
                            'process')
            _moose.useClock(POOLCLOCK, simpath + '/##[TYPE=CaConc]', 'process')
            _moose.useClock(POOLCLOCK, simpath + '/##[TYPE=Func]', 'process')
        else:  # use hsolve, one hsolve for each Neuron
            print 'Using hsolve'
            element = _moose.Neutral(simpath)
            for childid in element.children:
                childobj = _moose.Neutral(childid)
                classname = childobj.className
                if classname in ['Neuron']:
                    neuronpath = childobj.path
                    h = _moose.HSolve(neuronpath + '/solve')
                    h.dt = simdt
                    h.target = neuronpath
                    _moose.useClock(INITCLOCK, h.path, 'process')
    _moose.reinit()
コード例 #6
0
def setDefaultDt(elecdt=1e-5,
                 chemdt=0.01,
                 tabdt=1e-5,
                 plotdt1=1.0,
                 plotdt2=0.25e-3):
    """Setup the ticks with dt values.

    Parameters
    ----------

    elecdt: dt for ticks used in computing electrical biophysics, like
    neuronal compartments, ion channels, synapses, etc.

    chemdt: dt for chemical computations like enzymatic reactions.

    tabdt: dt for lookup tables

    plotdt1: dt for chemical kinetics plotting

    plotdt2: dt for electrical simulations

    """
    _moose.setClock(0, elecdt)
    _moose.setClock(1, elecdt)
    _moose.setClock(2, elecdt)
    _moose.setClock(3, elecdt)
    _moose.setClock(4, chemdt)
    _moose.setClock(5, chemdt)
    _moose.setClock(6, tabdt)
    _moose.setClock(7, tabdt)
    _moose.setClock(8, plotdt1)  # kinetics sim
    _moose.setClock(9, plotdt2)  # electrical sim
コード例 #7
0
ファイル: utils.py プロジェクト: praveenv253/moose
def resetSim(simpaths, simdt, plotdt, simmethod="hsolve"):
    """ For each of the MOOSE paths in simpaths, this sets the clocks and finally resets MOOSE.
    If simmethod=='hsolve', it sets up hsolve-s for each Neuron under simpaths, and clocks for hsolve-s too. """
    print "Solver:", simmethod
    _moose.setClock(INITCLOCK, simdt)
    _moose.setClock(ELECCLOCK, simdt)  # The hsolve and ee methods use clock 1
    _moose.setClock(CHANCLOCK, simdt)  # hsolve uses clock 2 for mg_block, nmdachan and others.
    _moose.setClock(POOLCLOCK, simdt)  # Ca/ion pools use clock 3
    _moose.setClock(STIMCLOCK, simdt)  # Ca/ion pools use clock 3
    _moose.setClock(PLOTCLOCK, plotdt)  # for tables
    for simpath in simpaths:
        _moose.useClock(PLOTCLOCK, simpath + "/##[TYPE=Table]", "process")
        _moose.useClock(ELECCLOCK, simpath + "/##[TYPE=PulseGen]", "process")
        _moose.useClock(STIMCLOCK, simpath + "/##[TYPE=DiffAmp]", "process")
        _moose.useClock(STIMCLOCK, simpath + "/##[TYPE=VClamp]", "process")
        _moose.useClock(STIMCLOCK, simpath + "/##[TYPE=PIDController]", "process")
        _moose.useClock(STIMCLOCK, simpath + "/##[TYPE=RC]", "process")
        _moose.useClock(ELECCLOCK, simpath + "/##[TYPE=LeakyIaF]", "process")
        _moose.useClock(ELECCLOCK, simpath + "/##[TYPE=IntFire]", "process")
        _moose.useClock(CHANCLOCK, simpath + "/##[TYPE=HHChannel2D]", "process")
        _moose.useClock(CHANCLOCK, simpath + "/##[TYPE=SynChan]", "process")
        ## If simmethod is not hsolve, set clocks for the biophysics,
        ## else just put a clock on the hsolve:
        ## hsolve takes care of the clocks for the biophysics
        if "hsolve" not in simmethod.lower():
            print "Using exp euler"
            _moose.useClock(INITCLOCK, simpath + "/##[TYPE=Compartment]", "init")
            _moose.useClock(ELECCLOCK, simpath + "/##[TYPE=Compartment]", "process")
            _moose.useClock(CHANCLOCK, simpath + "/##[TYPE=HHChannel]", "process")
            _moose.useClock(POOLCLOCK, simpath + "/##[TYPE=CaConc]", "process")
        else:  # use hsolve, one hsolve for each Neuron
            print "Using hsolve"
            element = _moose.Neutral(simpath)
            for childid in element.children:
                childobj = _moose.Neutral(childid)
                classname = childobj.class_
                if classname in ["Neuron"]:
                    neuronpath = childobj.path
                    h = _moose.HSolve(neuronpath + "/solve")
                    h.dt = simdt
                    h.target = neuronpath
                    _moose.useClock(INITCLOCK, h.path, "process")
    _moose.reinit()