Skip to content
Snippets Groups Projects
Commit de659651 authored by Dilawar Singh's avatar Dilawar Singh
Browse files

Merge commit '349abe7e'

parents 7088b0c5 349abe7e
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import moose
dt = 0.01
runtime = 100
def make_model():
sinePeriod = 50
maxFiringRate = 10
......@@ -67,51 +68,14 @@ def make_model():
moose.connect( plotf, 'requestOut', fire, 'getVm' )
def main():
<<<<<<< HEAD
"""
This snippet shows the use of several objects.
This snippet sets up a StimulusTable to control a RandSpike which
sends its outputs to two places: to a SimpleSynHandler on an IntFire,
which is used to monitor spike arrival, and to various Stats objects.
Each of these are recorded and plotted.
The StimulusTable has a sine-wave waveform.
"""
make_model()
moose.reinit()
moose.start( runtime )
plots = moose.element( '/plots' )
plot1 = moose.element( '/plot1' )
plot2 = moose.element( '/plot2' )
plotf = moose.element( '/plotf' )
t = [i * dt for i in range( plot1.vector.size )]
pylab.plot( t, plots.vector, label='stimulus' )
pylab.plot( t, plot1.vector, label='spike rate mean' )
pylab.plot( t, plot2.vector, label='Vm mean' )
pylab.plot( t, plotf.vector, label='Vm' )
pylab.legend()
pylab.show()
'''
moose.useClock( 0, '/stim', 'process' )
moose.useClock( 1, '/spike', 'process' )
moose.useClock( 2, '/syn', 'process' )
moose.useClock( 3, '/fire', 'process' )
moose.useClock( 4, '/stats#', 'process' )
moose.useClock( 8, '/plot#', 'process' )
for i in range (10):
moose.setClock( i, dt )
moose.useClock( 8, '/plot#', 'process' )
'''
=======
"""
This snippet shows the use of several objects.
This snippet sets up a StimulusTable to control a RandSpike which
sends its outputs to two places: to a SimpleSynHandler on an IntFire,
which is used to monitor spike arrival, and to various Stats objects.
Each of these are recorded and plotted.
The StimulusTable has a sine-wave waveform.
This snippet shows the use of several objects.
This snippet sets up a StimulusTable to control a RandSpike which
sends its outputs to two places: to a SimpleSynHandler on an IntFire,
which is used to monitor spike arrival, and to various Stats objects.
Each of these are recorded and plotted.
The StimulusTable has a sine-wave waveform.
"""
make_model()
......@@ -128,7 +92,7 @@ def main():
pylab.plot( t, plotf.vector, label='Vm' )
pylab.legend()
pylab.show()
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
'''
moose.useClock( 0, '/stim', 'process' )
......
......@@ -96,5 +96,6 @@ if __name__ == '__main__':
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
#
# stimtable.py ends here
......@@ -12,95 +12,7 @@ import pylab
import numpy
import moose
import sys
<<<<<<< HEAD
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
def main():
"""
This example describes the special (and discouraged) use case where
functions provide input to a reaction system. Here we have two functions of
time which control the pool # and pool rate of change, respectively::
number of molecules of a = 1 + sin(t)
rate of change of number of molecules of b = 10 * cos(t)
In the stochastic case one must set a special flag *useClockedUpdate*
in order to achieve clock-triggered updates from the functions. This is
needed because the functions do not have reaction events to trigger them,
and even if there were reaction events they might not be frequent enough to
track the periodic updates. The use of this flag slows down the calculations,
so try to use a table to control a pool instead.
To run in stochastic mode::
''python funcInputToPools''
To run in deterministic mode::
''python funcInputToPools false''
"""
=======
def makeModel():
if len( sys.argv ) == 1:
......@@ -154,6 +66,9 @@ def makeModel():
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 ):
......@@ -177,46 +92,32 @@ so try to use a table to control a pool instead.
To run in stochastic mode::
''python funcInputToPools''
''python funcInputToPools''
To run in deterministic mode::
''python funcInputToPools false''
''python funcInputToPools false''
"""
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
makeModel()
moose.seed()
moose.reinit()
<<<<<<< HEAD
moose.start( 50.0 ) # Run the model for 50 seconds.
=======
moose.start( 50.0 ) # Run the model for 100 seconds.
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
a = moose.element( '/model/compartment/a' )
b = moose.element( '/model/compartment/b' )
# Iterate through all plots, dump their contents to data.plot.
for x in moose.wildcardFind( '/model/graphs/n#' ):
<<<<<<< HEAD
#x.xplot( 'scriptKineticModel.plot', x.name )
t = numpy.arange( 0, x.vector.size, 1 ) * x.dt # sec
pylab.plot( t, x.vector, label=x.name )
pylab.legend()
pylab.show()
=======
#x.xplot( 'scriptKineticModel.plot', x.name )
t = numpy.arange( 0, x.vector.size, 1 ) * x.dt # sec
pylab.plot( t, x.vector, label=x.name )
pylab.legend()
pylab.show()
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
quit()
# Run the 'main' if this script is executed standalone.
if __name__ == '__main__':
main()
\ No newline at end of file
main()
......@@ -49,8 +49,8 @@ import moose
def connect_two_intfires():
"""
Connect two IntFire neurons so that spike events in one gets
transmitted to synapse of the other.
Connect two IntFire neurons so that spike events in one gets
transmitted to synapse of the other.
"""
if1 = moose.IntFire('if1')
if2 = moose.IntFire('if2')
......@@ -63,11 +63,13 @@ def connect_two_intfires():
def connect_spikegen():
"""
Connect a SpikeGen object to an IntFire neuron such that spike
events in spikegen get transmitted to the synapse of the IntFire
neuron.
"""
Connect a SpikeGen object to an IntFire neuron such that spike
events in spikegen get transmitted to the synapse of the IntFire
neuron.
"""
if3 = moose.IntFire('if3')
sf3 = moose.SimpleSynHandler( 'if3/sh' )
moose.connect( sf3, 'activationOut', if3, 'activation' )
sf3.synapse.num = 1
......@@ -77,7 +79,8 @@ def connect_spikegen():
def setup_synapse():
"""
Create an intfire object and create two synapses on it.
Create an intfire object and create two synapses on it.
"""
if4 = moose.IntFire('if4')
sf4 = moose.SimpleSynHandler( 'if4/sh' )
......@@ -93,8 +96,9 @@ def setup_synapse():
def main():
"""
Demonstrates connection between 2 IntFire neurons to observe
spike generation.
Demonstrates connection between 2 IntFire neurons to observe
spike generation.
"""
connect_two_intfires()
connect_spikegen()
......
......@@ -54,7 +54,13 @@ def main():
This example illustrates loading, running, and saving a kinetic
model defined in kkit format. It uses a default kkit model but
you can specify another using the command line
<<<<<<< HEAD
``python filename runtime solver``.
=======
``python filename runtime solver``.
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
We use the gsl solver here.
The model already defines a couple of plots and sets the runtime 20 secs.
......
......@@ -43,7 +43,7 @@ import pylab
import moose
from moose.SBML import *
#from moose.chemUtil.add_Delete_ChemicalSolver import *
from moose.chemUtil.add_Delete_ChemicalSolver import *
def main():
"""
......
......@@ -222,9 +222,9 @@ def dumpPlots( fname,runtime ):
for x in moose.wildcardFind( '/graphs/##[ISA=Table]' ):
x.xplot( fname, x.name )
t = numpy.linspace( 0, runtime, x.vector.size ) # sec
plt.plot( t, x.vector, label=x.name )
plt.legend()
plt.show()
plt.plot( t, x.vector, label=x.name )
plt.legend()
plt.show()
quit()
def makeSpinyCompt():
comptLength = 30e-6
......
......@@ -155,14 +155,9 @@ def main():
# Iterate through all plots, dump their contents to data.plot.
displayPlots()
pylab.show( block=False )
<<<<<<< HEAD
print(('vol = ', vol, 'hit 0 to go to next plot'))
eval(str(input()))
=======
print( 'vol = %f ' % vol )
response = input( "Press enter to go to next plot... " )
>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b
quit()
# Run the 'main' if this script is executed standalone.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment