From 349abe7e0132111737153bf2d4b1692d091b5ea8 Mon Sep 17 00:00:00 2001 From: Dilawar Singh <dilawars@ncbs.res.in> Date: Sat, 15 Apr 2017 12:38:26 +0530 Subject: [PATCH] Squashed 'moose-examples/' changes from 69062d9..7054325 7054325 mooseaddChemSolver is needed in loadSbmlModel file 6116c7e Indentation cleanup 9fd501a conflict cleanups fe297f6 indentation correction 2b24c64 indentation correction 0e329d5 Merge branch 'master' of http://github.com/BhallaLab/moose-examples 7ce262e corrected indentation 0f1e722 Resolved merge conflict 0ff3b05 temp deletion git-subtree-dir: moose-examples git-subtree-split: 705432541ca38b6bd082bec1b1fc3e7809b4b32a --- snippets/RandSpikeStats.py | 14 ++++++++------ snippets/analogStimTable.py | 1 + snippets/cspaceSteadyState.py | 20 ++++++++++++++++++++ snippets/funcInputToPools.py | 12 ++++++++---- snippets/intfire.py | 22 +++++++++++++--------- snippets/loadKineticModel.py | 6 ++++++ snippets/loadSbmlmodel.py | 2 +- snippets/multiComptSigNeur.py | 6 +++--- snippets/scaleVolumes.py | 7 +------ 9 files changed, 61 insertions(+), 29 deletions(-) diff --git a/snippets/RandSpikeStats.py b/snippets/RandSpikeStats.py index dfe288f9..1b494da4 100644 --- a/snippets/RandSpikeStats.py +++ b/snippets/RandSpikeStats.py @@ -67,13 +67,14 @@ def make_model(): moose.connect( plotf, 'requestOut', fire, 'getVm' ) def main(): + """ - 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() @@ -91,6 +92,7 @@ def main(): pylab.legend() pylab.show() + ''' moose.useClock( 0, '/stim', 'process' ) moose.useClock( 1, '/spike', 'process' ) diff --git a/snippets/analogStimTable.py b/snippets/analogStimTable.py index 006f47f8..e6b7602c 100644 --- a/snippets/analogStimTable.py +++ b/snippets/analogStimTable.py @@ -92,5 +92,6 @@ if __name__ == '__main__': main() + # # stimtable.py ends here diff --git a/snippets/cspaceSteadyState.py b/snippets/cspaceSteadyState.py index 713e157b..7cd2f012 100644 --- a/snippets/cspaceSteadyState.py +++ b/snippets/cspaceSteadyState.py @@ -40,6 +40,15 @@ def main(): It looks for the fixed points 100 times, as follows: - Set up the random initial condition that fits the conservation laws - Run for 2 seconds. This should not be mathematically necessary, but +<<<<<<< HEAD + for obscure numerical reasons it makes it much more likely that the + steady state solver will succeed in finding a state. + - Find the fixed point + - Print out the fixed point vector and various diagnostics. + - Run for 10 seconds. This is completely unnecessary, and is done here + just so that the resultant graph will show what kind of state has been + found. +======= for obscure numerical reasons it makes it much more likely that the steady state solver will succeed in finding a state. - Find the fixed point @@ -47,6 +56,7 @@ def main(): - Run for 10 seconds. This is completely unnecessary, and is done here just so that the resultant graph will show what kind of state has been found. +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b After it does all this, the program runs for 100 more seconds on the last found fixed point (which turns out to be a saddle node), then is hard-switched in the script to the first attractor basin from which @@ -55,6 +65,15 @@ def main(): seconds. Looking at the output you will see many features of note: - the first attractor (stable point) and the saddle point +<<<<<<< HEAD + (unstable fixed point) are both found quite often. But the second + attractor is found just once. Has a very small basin of attraction. + - The values found for each of the fixed points match well with the + values found by running the system to steady-state at the end. + - There are a large number of failures to find a fixed point. These are + found and reported in the diagnostics. They show up on the plot + as cases where the 10-second runs are not flat. +======= (unstable fixed point) are both found quite often. But the second attractor is found just once. Has a very small basin of attraction. - The values found for each of the fixed points match well with the @@ -62,6 +81,7 @@ def main(): - There are a large number of failures to find a fixed point. These are found and reported in the diagnostics. They show up on the plot as cases where the 10-second runs are not flat. +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b If you wanted to find fixed points in a production model, you would not need to do the 10-second runs, and you would need to eliminate the diff --git a/snippets/funcInputToPools.py b/snippets/funcInputToPools.py index b6f8f0b3..52978b4c 100644 --- a/snippets/funcInputToPools.py +++ b/snippets/funcInputToPools.py @@ -13,6 +13,7 @@ import numpy import moose import sys + def makeModel(): if len( sys.argv ) == 1: useGsolve = True @@ -65,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 ): @@ -88,11 +92,11 @@ 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'' """ @@ -100,6 +104,7 @@ To run in deterministic mode:: moose.seed() moose.reinit() + moose.start( 50.0 ) # Run the model for 100 seconds. a = moose.element( '/model/compartment/a' ) @@ -107,12 +112,11 @@ To run in deterministic mode:: # Iterate through all plots, dump their contents to data.plot. for x in moose.wildcardFind( '/model/graphs/n#' ): - #x.xplot( 'scriptKineticModel.plot', x.name ) + #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() - quit() # Run the 'main' if this script is executed standalone. diff --git a/snippets/intfire.py b/snippets/intfire.py index 7cd93d3c..8426052e 100644 --- a/snippets/intfire.py +++ b/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/snippets/loadKineticModel.py b/snippets/loadKineticModel.py index ad71c67a..25c3f69e 100644 --- a/snippets/loadKineticModel.py +++ b/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/snippets/loadSbmlmodel.py b/snippets/loadSbmlmodel.py index 6288215d..744c7239 100644 --- a/snippets/loadSbmlmodel.py +++ b/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/snippets/multiComptSigNeur.py b/snippets/multiComptSigNeur.py index bb964baf..613249cb 100644 --- a/snippets/multiComptSigNeur.py +++ b/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/snippets/scaleVolumes.py b/snippets/scaleVolumes.py index 965a8562..02fec606 100644 --- a/snippets/scaleVolumes.py +++ b/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. -- GitLab