diff --git a/moose-examples/snippets/RandSpikeStats.py b/moose-examples/snippets/RandSpikeStats.py index 725ae5d0ac9cc29af6fff70178ae2d747d7e4198..5bc14ae0517b873447cd93083510a7cf380e1b50 100644 --- a/moose-examples/snippets/RandSpikeStats.py +++ b/moose-examples/snippets/RandSpikeStats.py @@ -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' ) diff --git a/moose-examples/snippets/analogStimTable.py b/moose-examples/snippets/analogStimTable.py index 941de47ec9cf8bb309eee68a50e5cefa2d35dfc1..9b29b6f77ee92b59e66a1fabe9400c2c101d0a94 100644 --- a/moose-examples/snippets/analogStimTable.py +++ b/moose-examples/snippets/analogStimTable.py @@ -96,5 +96,6 @@ if __name__ == '__main__': >>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b + # # stimtable.py ends here diff --git a/moose-examples/snippets/funcInputToPools.py b/moose-examples/snippets/funcInputToPools.py index 45f5c1da9d4f826fe92e3fc5207852e698fef3e7..6ab9b3e757fabfd345edd155cd68ef452a2750e8 100644 --- a/moose-examples/snippets/funcInputToPools.py +++ b/moose-examples/snippets/funcInputToPools.py @@ -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() diff --git a/moose-examples/snippets/intfire.py b/moose-examples/snippets/intfire.py index 7cd93d3c35a92d3f28a4640cdcf94dc05367fe2e..8426052e245176f27458852cda4bc68bfcfa8e24 100644 --- a/moose-examples/snippets/intfire.py +++ b/moose-examples/snippets/intfire.py @@ -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() diff --git a/moose-examples/snippets/loadKineticModel.py b/moose-examples/snippets/loadKineticModel.py index ad71c67a94451d6276dfbab3efd49bf947467e8b..25c3f69e5144bc7419ca827e16314e41d1b4c0cb 100644 --- a/moose-examples/snippets/loadKineticModel.py +++ b/moose-examples/snippets/loadKineticModel.py @@ -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. diff --git a/moose-examples/snippets/loadSbmlmodel.py b/moose-examples/snippets/loadSbmlmodel.py index 6288215d586b0767d17e8157d737dc31e569869e..744c723933686e32c5c095de1949cfacd10a3483 100644 --- a/moose-examples/snippets/loadSbmlmodel.py +++ b/moose-examples/snippets/loadSbmlmodel.py @@ -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(): """ diff --git a/moose-examples/snippets/multiComptSigNeur.py b/moose-examples/snippets/multiComptSigNeur.py index bb964baf2e27fc021677298e6147ad1df665f66e..613249cbda288e14f3572b6a151f6b7c76e4af72 100644 --- a/moose-examples/snippets/multiComptSigNeur.py +++ b/moose-examples/snippets/multiComptSigNeur.py @@ -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 diff --git a/moose-examples/snippets/scaleVolumes.py b/moose-examples/snippets/scaleVolumes.py index 965a8562f28d6b0c2b01825a2977df5064a854b5..02fec606d38dc27207785b1a75752740c30d244e 100644 --- a/moose-examples/snippets/scaleVolumes.py +++ b/moose-examples/snippets/scaleVolumes.py @@ -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.