• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python moose.setClock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中moose.setClock函数的典型用法代码示例。如果您正苦于以下问题:Python setClock函数的具体用法?Python setClock怎么用?Python setClock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setClock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setupSolver

 def setupSolver(self, path = '/hsolve'):
     """Setting up HSolver """
     hsolve = moose.HSolve( path )
     hsolve.dt = self.simDt
     moose.setClock(1, self.simDt)
     moose.useClock(1, hsolve.path, 'process')
     hsolve.target = self.cablePath
开发者ID:asiaszmek,项目名称:moose-core,代码行数:7,代码来源:rallpacks_tree_cable.py


示例2: simulate

    def simulate(self,simtime=simtime,dt=dt,plotif=False,**kwargs):
        
        self.dt = dt
        self.simtime = simtime
        self.T = np.ceil(simtime/dt)
        self.trange = np.arange(0,self.simtime+dt,dt)   
        
        self._init_network(**kwargs)
        if plotif:
            self._init_plots()
        
        # moose simulation
        moose.useClock( 0, '/network/syns', 'process' )
        moose.useClock( 1, '/network', 'process' )
        moose.useClock( 2, '/plotSpikes', 'process' )
        moose.useClock( 3, '/plotVms', 'process' )
        moose.useClock( 3, '/plotWeights', 'process' )
        moose.setClock( 0, dt )
        moose.setClock( 1, dt )
        moose.setClock( 2, dt )
        moose.setClock( 3, dt )
        moose.setClock( 9, dt )
        t1 = time.time()
        print 'reinit MOOSE -- takes a while ~20s.'
        moose.reinit()
        print 'reinit time t = ', time.time() - t1
        t1 = time.time()
        print 'starting'
        moose.start(self.simtime)
        print 'runtime, t = ', time.time() - t1

        if plotif:
            self._plot()
开发者ID:csiki,项目名称:moose-1,代码行数:33,代码来源:ExcInhNet_Ostojic2014_Brunel2000.py


示例3: main

def main( runTime ):
    try:
        moose.delete('/acc92')
        print("Deleted old model")
    except Exception as  e:
        print("Could not clean. model not loaded yet")

    moose.loadModel('acc92_caBuff.g',loadpath,'gsl')  
    ca = moose.element(loadpath+'/kinetics/Ca')
    pr = moose.element(loadpath+'/kinetics/protein')
    clockdt = moose.Clock('/clock').dts 
    moose.setClock(8, 0.1)#simdt
    moose.setClock(18, 0.1)#plotdt
    print clockdt
    print " \t \t simdt ", moose.Clock('/clock').dts[8],"plotdt ",moose.Clock('/clock').dts[18]
    ori =  ca.concInit
    tablepath = loadpath+'/kinetics/Ca'
    tableele = moose.element(tablepath)
    table = moose.Table2(tablepath+'.con')
    x = moose.connect(table, 'requestOut', tablepath, 'getConc')
    tablepath1 = loadpath+'/kinetics/protein'
    tableele1 = moose.element(tablepath1)
    table1 = moose.Table2(tablepath1+'.con')
    x1 = moose.connect(table1, 'requestOut', tablepath1, 'getConc')

    ca.concInit = ori
    print("[INFO] Running for 4000 with Ca.conc %s " % ca.conc)
    moose.start(4000)

    ca.concInit = 5e-03
    print("[INFO] Running for 20 with Ca.conc %s " % ca.conc)
    moose.start(20)

    ca.concInit = ori
    moose.start( runTime ) #here give the interval time 

    ca.concInit = 5e-03
    print("[INFO] Running for 20 with Ca.conc %s " % ca.conc)
    moose.start(20)

    ca.concInit = ori
    print("[INFO] Running for 2000 with Ca.conc %s " % ca.conc)
    moose.start(2000)

    pylab.figure()
    pylab.subplot(2, 1, 1)
    t = numpy.linspace(0.0, moose.element("/clock").runTime, len(table.vector)) # sec
    pylab.plot( t, table.vector, label="Ca Conc (interval- 8000s)" )
    pylab.legend()
    pylab.subplot(2, 1, 2)
    t1 = numpy.linspace(0.0, moose.element("/clock").runTime, len(table1.vector)) # sec
    pylab.plot( t1, table1.vector, label="Protein Conc (interval- 8000s)" )
    pylab.legend()
    pylab.savefig( os.path.join( dataDir, '%s_%s.png' % (table1.name, runTime) ) )

    print('[INFO] Saving data to csv files in %s' % dataDir)
    tabPath1 = os.path.join( dataDir, '%s_%s.csv' % (table.name, runTime))
    numpy.savetxt(tabPath1, numpy.matrix([t, table.vector]).T, newline='\n')
    tabPath2 = os.path.join( dataDir, '%s_%s.csv' % (table1.name, runTime) )
    numpy.savetxt(tabPath2, numpy.matrix([t1, table1.vector]).T, newline='\n')
开发者ID:Ainurrohmah,项目名称:Scripts,代码行数:60,代码来源:run92_simple.py


示例4: example

def example():
    """In this example we create a square-pulse generator object and
    record the output using a table.

    The steps are:

    1. Create a PulseGen element `pulse`.

    2. Set `delay[0]=1.0`, `width[0]=0.2`, `level[0]=0.5`, so it
       generates 0.2 s wide square pulses with 0.5 amplitude every 1 s.

    3. Create a Table element `tab`.

    4. Connect the `outputValue` field of `pulse` to `tab`.

    5. We set tick-interval of ticks 0 and 1 to 0.01 and schedule
       `pulse` on tick 0 and `tab` on tick 1.

    5. Run the simulation for 5 s and save data to the ascii file
       `output_tabledemo.csv`.

    """
    pg = moose.PulseGen('pulse')
    pg.delay[0] = 1.0
    pg.width[0] = 0.2
    pg.level[0] = 0.5
    tab = moose.Table('tab')
    moose.connect(tab, 'requestOut', pg, 'getOutputValue')
    moose.setClock(0, 0.01)
    moose.setClock(1, 0.01)
    moose.useClock(0, pg.path, 'process')
    moose.useClock(1, tab.path, 'process')
    moose.reinit()
    moose.start(5.0)
    tab.plainPlot('output_tabledemo.csv')
开发者ID:2pysarthak,项目名称:moose-examples,代码行数:35,代码来源:tabledemo.py


示例5: main

def main():
    """
    This example illustrates how to define a kinetic model embedded in
    a NeuroMesh, and undergoing cross-compartment reactions. It is 
    completely self-contained and does not use any external model definition
    files.  Normally one uses standard model formats like
    SBML or kkit to concisely define kinetic and neuronal models.
    This example creates a simple reaction::
        a <==> b <==> c 
    in which 
    **a, b**, and **c** are in the dendrite, spine head, and PSD 
    respectively.
    The model is set up to run using the Ksolve for integration. Although
    a diffusion solver is set up, the diff consts here are set to zero.
    The display has two parts: 
    Above is a line plot of concentration against compartment#. 
    Below is a time-series plot that appears after # the simulation has 
    ended. The plot is for the last (rightmost) compartment.
    Concs of **a**, **b**, **c** are plotted for both graphs.
    """
    simdt = 0.01
    plotdt = 0.01

    makeModel()

    # Schedule the whole lot
    for i in range( 10, 19):
        moose.setClock( i, simdt ) # for the compute objects
    moose.reinit()
    display()
    quit()
开发者ID:NeuroArchive,项目名称:moose,代码行数:31,代码来源:crossComptNeuroMesh.py


示例6: run

def run(nogui):
    
    reader = NML2Reader(verbose=True)

    filename = 'test_files/NML2_SingleCompHHCell.nml'
    print('Loading: %s'%filename)
    reader.read(filename, symmetric=True)
    
    
    msoma = reader.getComp(reader.doc.networks[0].populations[0].id,0,0)
    print(msoma)
    
    
    data = moose.Neutral('/data')
    
    pg = reader.getInput('pulseGen1')
    
    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')
    
    
    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', msoma, 'getVm')
    
    simdt = 1e-6
    plotdt = 1e-4
    simtime = 300e-3
    #moose.showmsg( '/clock' )
    for i in range(8):
        moose.setClock( i, simdt )
    moose.setClock( 8, plotdt )
    moose.reinit()
    moose.start(simtime)
    
    print("Finished simulation!")
    
    t = np.linspace(0, simtime, len(vm.vector))
    
    if not nogui:
        import matplotlib.pyplot as plt

        vfile = open('moose_v_hh.dat','w')

        for i in range(len(t)):
            vfile.write('%s\t%s\n'%(t[i],vm.vector[i]))
        vfile.close()
        plt.subplot(211)
        plt.plot(t, vm.vector * 1e3, label='Vm (mV)')
        plt.legend()
        plt.title('Vm')
        plt.subplot(212)
        plt.title('Input')
        plt.plot(t, inj.vector * 1e9, label='injected (nA)')
        #plt.plot(t, gK.vector * 1e6, label='K')
        #plt.plot(t, gNa.vector * 1e6, label='Na')
        plt.legend()
        plt.figure()
        test_channel_gates()
        plt.show()
        plt.close()
开发者ID:hrani,项目名称:moose-core,代码行数:60,代码来源:run_hhcell.py


示例7: main

def main():
    """
    Example of Interpol object.
    """
    simtime = 1.0
    simdt = 0.001
    model = moose.Neutral('/model')
    data = moose.Neutral('/data')
    interpol = moose.Interpol('/model/sin')
    vec = np.sin(np.linspace(-3.14, 3.14, 100))
    interpol.vector = vec
    interpol.xmax = 3.14
    interpol.xmin = -3.14
    recorded = moose.Table('/data/output')
    moose.connect(recorded, 'requestOut', interpol, 'getY')

    stimtab = moose.StimulusTable('/model/x')
    stimtab.stepSize = 0.0
    # stimtab.startTime = 0.0
    # stimtab.stopTime = simtime
    stimtab.vector = np.linspace(-4, 4, 1000)
    print((stimtab.vector))
    print((interpol.vector))
    moose.connect(stimtab, 'output', interpol, 'input')


    moose.setClock(0, simdt)
    moose.useClock(0, '/data/##,/model/##', 'process')
    moose.reinit()
    moose.start(simtime)
    plt.plot(np.linspace(0, simtime, len(recorded.vector)), recorded.vector, 'b-+', label='interpolated')
    plt.plot(np.linspace(0, simtime, len(vec)), vec, 'r-+', label='original')
    plt.show()
开发者ID:dilawar,项目名称:moose-examples,代码行数:33,代码来源:interpol.py


示例8: current_step_test

def current_step_test(simtime, simdt, plotdt):
    """
    Create a single compartment and set it up for applying a step
    current injection.

    We use a PulseGen object to generate a 40 ms wide 1 nA current
    pulse that starts 20 ms after start of simulation.

    """
    model = moose.Neutral('/model')
    comp = create_1comp_neuron('/model/neuron')
    stim = moose.PulseGen('/model/stimulus')
    stim.delay[0] = 20e-3
    stim.level[0] = 1e-9
    stim.width[0] = 40e-3
    stim.delay[1] = 1e9
    moose.connect(stim, 'output', comp, 'injectMsg')
    data = moose.Neutral('/data')
    current_tab = moose.Table('/data/current')
    moose.connect(current_tab, 'requestOut', stim, 'getOutputValue')
    vm_tab = moose.Table('/data/Vm')
    moose.connect(vm_tab, 'requestOut', comp, 'getVm')
    for i in range(10):
        moose.setClock(i, simdt)
    moose.setClock(8, plotdt)
    moose.reinit()
    moose.start(simtime)
    ts = np.linspace(0, simtime, len(vm_tab.vector))
    return ts, current_tab.vector, vm_tab.vector,
开发者ID:asiaszmek,项目名称:moose,代码行数:29,代码来源:ionchannel.py


示例9: simulate

    def simulate(self, simtime=simtime, dt=dt, plotif=False, **kwargs):

        self.dt = dt
        self.simtime = simtime
        self.T = np.ceil(simtime / dt)
        self.trange = np.arange(0, self.simtime + dt, dt)

        self._init_network(**kwargs)
        if plotif:
            self._init_plots()

        # moose simulation
        moose.useClock(0, "/network/syns", "process")
        moose.useClock(1, "/network", "process")
        moose.useClock(2, "/plotSpikes", "process")
        moose.useClock(3, "/plotVms", "process")
        moose.useClock(3, "/plotWeights", "process")
        moose.setClock(0, dt)
        moose.setClock(1, dt)
        moose.setClock(2, dt)
        moose.setClock(3, dt)
        moose.setClock(9, dt)
        t1 = time.time()
        print "reinit MOOSE"
        moose.reinit()
        print "reinit time t = ", time.time() - t1
        t1 = time.time()
        print "starting"
        moose.start(self.simtime)
        print "runtime, t = ", time.time() - t1

        if plotif:
            self._plot()
开发者ID:NeuroArchive,项目名称:moose,代码行数:33,代码来源:ExcInhNet_Ostojic2014_Brunel2000.py


示例10: main

def main():
    makeModel()
    solver = moose.GslStoich("/model/compartment/solver")
    solver.path = "/model/compartment/##"
    solver.method = "rk5"
    mesh = moose.element("/model/compartment/mesh")
    moose.connect(mesh, "remesh", solver, "remesh")
    moose.setClock(5, 1.0)  # clock for the solver
    moose.useClock(5, "/model/compartment/solver", "process")

    moose.reinit()
    moose.start(100.0)  # Run the model for 100 seconds.

    a = moose.element("/model/compartment/a")
    b = moose.element("/model/compartment/b")

    # move most molecules over to b
    b.conc = b.conc + a.conc * 0.9
    a.conc = a.conc * 0.1
    moose.start(100.0)  # Run the model for 100 seconds.

    # move most molecules back to a
    a.conc = a.conc + b.conc * 0.99
    b.conc = b.conc * 0.01
    moose.start(100.0)  # Run the model for 100 seconds.

    # Iterate through all plots, dump their contents to data.plot.
    for x in moose.wildcardFind("/model/graphs/conc#"):
        moose.element(x[0]).xplot("scriptKineticSolver.plot", x[0].name)

    quit()
开发者ID:praveenv253,项目名称:moose,代码行数:31,代码来源:scriptKineticSolver.py


示例11: test_crossing_single

def test_crossing_single():
    """This function creates an ematrix of two PulseGen elements and
    another ematrix of two Table elements.

    The two pulsegen elements have same amplitude but opposite phase.

    Table[0] is connected to PulseGen[1] and Table[1] to Pulsegen[0].

    In the plot you should see two square pulses of opposite phase.

    """
    size = 2
    pg = moose.PulseGen('pulsegen', size)
    for ix, ii in enumerate(pg.vec):
        pulse = moose.element(ii)
        pulse.delay[0] = 1.0
        pulse.width[0] = 2.0
        pulse.level[0] = (-1)**ix
    tab = moose.Table('table', size)
    moose.connect(tab.vec[0], 'requestOut', pg.vec[1], 'getOutputValue', 'Single')
    moose.connect(tab.vec[1], 'requestOut', pg.vec[0], 'getOutputValue', 'Single')
    print 'Neighbors:'
    for t in tab.vec:
        print t.path
        for n in moose.element(t).neighbors['requestOut']:
            print 'requestOut <-', n.path
    moose.setClock(0, 0.1)
    moose.useClock(0, '/##', 'process')
    moose.start(5)
    for ii in tab.vec:
        t = moose.Table(ii).vector
        print len(t)
        pylab.plot(t)
    pylab.show()
开发者ID:csiki,项目名称:MOOSE,代码行数:34,代码来源:singlemsgcross.py


示例12: main

def main():
    makeModel()
    gsolve = moose.Gsolve("/model/compartment/gsolve")
    stoich = moose.Stoich("/model/compartment/stoich")
    stoich.compartment = moose.element("/model/compartment")
    stoich.ksolve = gsolve
    stoich.path = "/model/compartment/##"
    # solver.method = "rk5"
    # mesh = moose.element( "/model/compartment/mesh" )
    # moose.connect( mesh, "remesh", solver, "remesh" )
    moose.setClock(5, 1.0)  # clock for the solver
    moose.useClock(5, "/model/compartment/gsolve", "process")

    moose.reinit()
    moose.start(100.0)  # Run the model for 100 seconds.

    a = moose.element("/model/compartment/a")
    b = moose.element("/model/compartment/b")

    # move most molecules over to bgsolve
    b.conc = b.conc + a.conc * 0.9
    a.conc = a.conc * 0.1
    moose.start(100.0)  # Run the model for 100 seconds.

    # move most molecules back to a
    a.conc = a.conc + b.conc * 0.99
    b.conc = b.conc * 0.01
    moose.start(100.0)  # Run the model for 100 seconds.

    # Iterate through all plots, dump their contents to data.plot.
    displayPlots()

    quit()
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:33,代码来源:scriptGssaSolver.py


示例13: loadAndRun

def loadAndRun(solver=True):
    simtime = 500e-3
    model = moose.loadModel('../data/h10.CNG.swc', '/cell')
    comp = moose.element('/cell/apical_e_177_0')
    soma = moose.element('/cell/soma')
    for i in range(10):
        moose.setClock(i, dt)
    if solver:
        solver = moose.HSolve('/cell/solver')
        solver.target = soma.path
        solver.dt = dt
    stim = moose.PulseGen('/cell/stim')
    stim.delay[0] = 50e-3
    stim.delay[1] = 1e9
    stim.level[0] = 1e-9
    stim.width[0] = 2e-3    
    moose.connect(stim, 'output', comp, 'injectMsg')
    tab = moose.Table('/cell/Vm')
    moose.connect(tab, 'requestOut', comp, 'getVm')
    tab_soma = moose.Table('/cell/Vm_soma')
    moose.connect(tab_soma, 'requestOut', soma, 'getVm')
    moose.reinit()
    print('[INFO] Running for %s' % simtime)
    moose.start(simtime )
    vec = tab_soma.vector 
    moose.delete( '/cell' )
    return vec
开发者ID:rahulgayatri23,项目名称:moose-core,代码行数:27,代码来源:issue_93.py


示例14: main

def main():
    """
A demo to create a network of single compartmental neurons connected
via alpha synapses. Here SynChan class is used to setup synaptic
connection between two single-compartmental Hodgkin-Huxley type
neurons.

    """
    simtime = 0.1
    simdt = 0.25e-5
    plotdt = 0.25e-3
    netinfo = create_model()
    expinfo = setup_experiment(netinfo['presynaptic'],
                               netinfo['postsynaptic'],
                               netinfo['synchan'])
    vm_a = expinfo['Vm_pre']
    vm_b = expinfo['Vm_post']
    gksyn_b = expinfo['Gk_syn']
    for ii in range(10):
        moose.setClock(ii, simdt)
    moose.setClock(18, plotdt)
    moose.reinit()
    moose.start(simtime)
    plt.subplot(211)
    plt.plot(vm_a.vector*1e3, color='b', label='presynaptic Vm (mV)')
    plt.plot(vm_b.vector*1e3, color='g', label='postsynaptic Vm (mV)')
    plt.plot(expinfo['stimulus'].vector * 1e9, color='r', label='injected current (nA)')
    plt.legend()
    plt.subplot(212)
    plt.plot(expinfo['Gk_syn'].vector*1e9, color='orange', label='Gk_synapse (nS)')
    plt.legend()
    plt.tight_layout()
    plt.show()
开发者ID:asiaszmek,项目名称:moose,代码行数:33,代码来源:twocells.py


示例15: main

def main():
    """
    This example illustrates how to create a network of single compartmental neurons
    connected via alpha synapses. It also shows the use of SynChan class to create a
    network of single-compartment neurons connected by synapse.
    """
    simtime = 0.1
    simdt = 0.25e-5
    plotdt = 0.25e-3
    netinfo = create_network(size=2)
    vm_a = netinfo['Vm_A']
    vm_b = netinfo['Vm_B']
    gksyn_b = netinfo['Gsyn_B']
    for ii in range(10):
        moose.setClock(ii, simdt)
    moose.setClock(18, plotdt)
    moose.reinit()
    moose.start(simtime)
    plt.subplot(221)
    for oid in vm_a.vec:
        print((oid, oid.vector.shape))
        plt.plot(oid.vector, label=oid.path)
    plt.legend()
    plt.subplot(223)
    for oid in vm_b.vec:
        plt.plot(oid.vector, label=oid.path)
    plt.legend()
    plt.subplot(224)
    for oid in gksyn_b.vec:
        plt.plot(oid.vector, label=oid.path)
    plt.legend()
    plt.show()
开发者ID:asiaszmek,项目名称:moose,代码行数:32,代码来源:compartment_net.py


示例16: simulate

    def simulate(self,simtime=simtime,dt=dt,plotif=False,**kwargs):
        
        self.dt = dt
        self.simtime = simtime
        self.T = np.ceil(simtime/dt)
        self.trange = np.arange(0,self.simtime+dt,dt)   
        
        self._init_network(**kwargs)
        if plotif:
            self._init_plots()
        
        # moose simulation
        # moose auto-schedules
        #moose.useClock( 0, '/network/syns', 'process' )
        #moose.useClock( 1, '/network', 'process' )
        #moose.useClock( 2, '/plotSpikes', 'process' )
        #moose.useClock( 3, '/plotVms', 'process' )
        #moose.useClock( 3, '/plotWeights', 'process' )
        for i in range(10):
            moose.setClock( i, dt )

        t1 = time.time()
        print('reinit MOOSE')
        moose.reinit()
        print(('reinit time t = ', time.time() - t1))
        t1 = time.time()
        print('starting')
        moose.start(self.simtime)
        print(('runtime, t = ', time.time() - t1))

        if plotif:
            self._plot()
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:32,代码来源:ExcInhNet_Ostojic2014_Brunel2000.py


示例17: main

def main():
    numpy.random.seed( 1234 )
    rdes = buildRdesigneur()
    rdes.buildModel( '/model' )
    assert( moose.exists( '/model' ) )
    moose.element( '/model/elec/hsolve' ).tick = -1
    for i in range( 10, 18 ):
        moose.setClock( i, dt )
    moose.setClock( 18, plotdt )
    moose.reinit()

    if do3D:
        app = QtGui.QApplication(sys.argv)
        compts = moose.wildcardFind( "/model/elec/#[ISA=CompartmentBase]" )
        print(("LEN = ", len( compts )))
        for i in compts:
            n = i.name[:4]
            if ( n == 'head' or n == 'shaf' ):
                i.diameter *= 1.0
                i.Vm = 0.02
            else:
                i.diameter *= 4.0
                i.Vm = -0.05
        vm_viewer = createVmViewer(rdes)
        vm_viewer.showMaximized()
        vm_viewer.start()
        app.exec_()
开发者ID:dilawar,项目名称:moose-examples,代码行数:27,代码来源:Fig4B.py


示例18: assign_clocks

def assign_clocks(model_container_list, simdt, plotdt):
    """
    Assign clocks to elements under the listed paths.

    This should be called only after all model components have been
    created. Anything created after this will not be scheduled.

    """
    global inited
    # `inited` is for avoiding double scheduling of the same object
    if not inited:
        print(('SimDt=%g, PlotDt=%g' % (simdt, plotdt)))
        moose.setClock(0, simdt)
        moose.setClock(1, simdt)
        moose.setClock(2, simdt)
        moose.setClock(3, simdt)
        moose.setClock(4, plotdt)
        for path in model_container_list:
            print(('Scheduling elements under:', path))
            moose.useClock(0, '%s/##[TYPE=Compartment]' % (path), 'init')
            moose.useClock(1, '%s/##[TYPE=Compartment]' % (path), 'process')
            moose.useClock(2, '%s/##[TYPE=SynChan],%s/##[TYPE=HHChannel]' % (path, path), 'process')
            moose.useClock(3, '%s/##[TYPE=SpikeGen],%s/##[TYPE=PulseGen]' % (path, path), 'process')
        moose.useClock(4, '/data/##[TYPE=Table]', 'process')
        inited = True
    moose.reinit()
开发者ID:dilawar,项目名称:moose-examples,代码行数:26,代码来源:compartment_net_no_array.py


示例19: makeModel

def makeModel():
                if len( sys.argv ) == 1:
                        useGsolve = True
                else:
                        useGsolve = ( sys.argv[1] == 'True' )
                # create container for model
                model = moose.Neutral( 'model' )
                compartment = moose.CubeMesh( '/model/compartment' )
                compartment.volume = 1e-22
                # the mesh is created automatically by the compartment
                moose.le( '/model/compartment' )
                mesh = moose.element( '/model/compartment/mesh' )

                # create molecules and reactions
                a = moose.Pool( '/model/compartment/a' )
                b = moose.Pool( '/model/compartment/b' )

                # create functions of time
                f1 = moose.Function( '/model/compartment/f1' )
                f2 = moose.Function( '/model/compartment/f2' )

                # connect them up for reactions
                moose.connect( f1, 'valueOut', a, 'setConc' )
                moose.connect( f2, 'valueOut', b, 'increment' )

                # Assign parameters
                a.concInit = 0
                b.concInit = 1
                #f1.numVars = 1
                #f2.numVars = 1
                f1.expr = '1 + sin(t)'
                f2.expr = '10 * cos(t)'

                # Create the output tables
                graphs = moose.Neutral( '/model/graphs' )
                outputA = moose.Table2 ( '/model/graphs/nA' )
                outputB = moose.Table2 ( '/model/graphs/nB' )

                # connect up the tables
                moose.connect( outputA, 'requestOut', a, 'getN' );
                moose.connect( outputB, 'requestOut', b, 'getN' );

                # Set up the solvers
                if useGsolve:
                    gsolve = moose.Gsolve( '/model/compartment/gsolve' )
                    gsolve.useClockedUpdate = True
                else:
                    gsolve = moose.Ksolve( '/model/compartment/gsolve' )
                stoich = moose.Stoich( '/model/compartment/stoich' )
                stoich.compartment = compartment
                stoich.ksolve = gsolve
                stoich.path = '/model/compartment/##'
                '''
                '''

                # We need a finer timestep than the default 0.1 seconds,
                # in order to get numerical accuracy.
                for i in range (10, 19 ):
                    moose.setClock( i, 0.1 ) # for computational objects
开发者ID:asiaszmek,项目名称:moose,代码行数:59,代码来源:funcInputToPools.py


示例20: setup_model

def setup_model():
    """Setup a dummy model with a pulsegen and a spikegen detecting the
    leading edges of the pulses. We record the pulse output as Uniform
    data and leading edge time as Event data."""
    simtime = 100.0
    dt = 1e-3
    model = moose.Neutral('/model')
    pulse = moose.PulseGen('/model/pulse')
    pulse.level[0] = 1.0
    pulse.delay[0] = 10
    pulse.width[0] = 20
    t_lead = moose.SpikeGen('/model/t_lead')
    t_lead.threshold = 0.5
    moose.connect(pulse, 'output', t_lead,'Vm');
    nsdf = moose.NSDFWriter('/model/writer')
    nsdf.filename = 'nsdf_demo.h5'
    nsdf.mode = 2 #overwrite existing file
    nsdf.flushLimit = 100
    moose.connect(nsdf, 'requestOut', pulse, 'getOutputValue')
    print 'event input', nsdf.eventInput, nsdf.eventInput.num
    print nsdf

    nsdf.eventInput.num = 1
    ei = nsdf.eventInput[0]
    print ei.path
    moose.connect(t_lead, 'spikeOut', nsdf.eventInput[0], 'input')
    tab = moose.Table('spiketab')
    tab.threshold = t_lead.threshold
    clock = moose.element('/clock')
    for ii in range(32):
        moose.setClock(ii, dt)
    moose.connect(pulse, 'output', tab, 'spike')
    print datetime.now().isoformat()
    moose.reinit()
    moose.start(simtime)
    print datetime.now().isoformat()
    np.savetxt('nsdf.txt', tab.vector)
    ###################################
    # Set the environment attributes
    ###################################
    nsdf.stringAttr['title'] = 'NSDF writing demo for moose'
    nsdf.stringAttr['description'] = '''An example of writing data to NSDF file from MOOSE simulation. In
this simulation we generate square pules from a PulseGen object and
use a SpikeGen to detect the threshold crossing events of rising
edges. We store the pulsegen output as Uniform data and the threshold
crossing times as Event data. '''    
    nsdf.stringAttr['creator'] = getpass.getuser()
    nsdf.stringVecAttr['software'] = ['python2.7', 'moose3' ]
    nsdf.stringVecAttr['method'] = ['']
    nsdf.stringAttr['rights'] = ''
    nsdf.stringAttr['license'] = 'CC-BY-NC'
    # Specify units. MOOSE is unit agnostic, so we explicitly set the
    # unit attibutes on individual datasets
    nsdf.stringAttr['/data/uniform/PulseGen/outputValue/tunit'] = 's'
    nsdf.stringAttr['/data/uniform/PulseGen/outputValue/unit'] = 'A'
    eventDataPath = '/data/event/SpikeGen/spikeOut/{}_{}_{}/unit'.format(t_lead.vec.value,
                                                                         t_lead.getDataIndex(), 
                                                                         t_lead.getFieldIndex())
    nsdf.stringAttr[eventDataPath] = 's'
开发者ID:NeuroArchive,项目名称:moose,代码行数:59,代码来源:nsdf.py



注:本文中的moose.setClock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python moose.start函数代码示例发布时间:2022-05-27
下一篇:
Python moose.reinit函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap