diff --git a/moose-examples/snippets/intfire.py b/moose-examples/snippets/intfire.py new file mode 100644 index 0000000000000000000000000000000000000000..35f8fcb9ea245df9b65b40afe7e5ee96ccb5115c --- /dev/null +++ b/moose-examples/snippets/intfire.py @@ -0,0 +1,128 @@ +<<<<<<< HEAD + +======= +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b +# intfire.py --- +# +# Filename: intfire.py +# Description: +# Author:Subhasis Ray +# Maintainer: +# Created: Thu Jun 21 16:40:25 2012 (+0530) +# Version: +# Last-Updated: Sat Jun 23 13:44:10 2012 (+0530) +# By: subha +# Update #: 35 +# URL: +# Keywords: +# Compatibility: +# +# + +# Commentary: +# +# Code snippet to show some operations on IntFire. +# +# + +# Change log: +# +# +# +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth +# Floor, Boston, MA 02110-1301, USA. +# +# + +# Code: + +import moose + +def connect_two_intfires(): + """ +Connect two IntFire neurons so that spike events in one gets +transmitted to synapse of the other. +<<<<<<< HEAD +======= + +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b + """ + if1 = moose.IntFire('if1') + if2 = moose.IntFire('if2') + sf1 = moose.SimpleSynHandler( 'if1/sh' ) + moose.connect( sf1, 'activationOut', if1, 'activation' ) + sf1.synapse.num = 1 + syn1 = moose.element(sf1.synapse) + # Connect the spike message of if2 to the first synapse on if1 + moose.connect(if2, 'spikeOut', syn1, 'addSpike') + +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. + +<<<<<<< HEAD + """ + if3 = moose.IntFire('if3') +======= +if3 = moose.IntFire('if3') + """ +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b + sf3 = moose.SimpleSynHandler( 'if3/sh' ) + moose.connect( sf3, 'activationOut', if3, 'activation' ) + sf3.synapse.num = 1 + sg = moose.SpikeGen('sg') + syn = moose.element(sf3.synapse) + moose.connect(sg, 'spikeOut', syn, 'addSpike') + +def setup_synapse(): + """ +Create an intfire object and create two synapses on it. +<<<<<<< HEAD +======= + +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b + """ + if4 = moose.IntFire('if4') + sf4 = moose.SimpleSynHandler( 'if4/sh' ) + sg1 = moose.SpikeGen('sg1') + sg2 = moose.SpikeGen('sg2') + sf4.synapse.num = 2 # set synapse count to 2 + sf4.synapse[0].weight = 0.5 + sf4.synapse[0].delay = 1e-3 + sf4.synapse[1].weight = 2.0 + sf4.synapse[1].delay = 2e-3 + moose.connect(sg1, 'spikeOut', sf4.synapse[0], 'addSpike') + moose.connect(sg2, 'spikeOut', sf4.synapse[1], 'addSpike') + +def main(): + """ +Demonstrates connection between 2 IntFire neurons to observe +spike generation. +<<<<<<< HEAD +======= + +>>>>>>> 0e491aa41584cf7a66c0e242374d8ee61660eb7b + """ + connect_two_intfires() + connect_spikegen() + setup_synapse() + +if __name__ == '__main__': + main() +# +# intfire.py ends here diff --git a/moose-examples/snippets/loadKineticModel.py b/moose-examples/snippets/loadKineticModel.py new file mode 100644 index 0000000000000000000000000000000000000000..25c3f69e5144bc7419ca827e16314e41d1b4c0cb --- /dev/null +++ b/moose-examples/snippets/loadKineticModel.py @@ -0,0 +1,100 @@ +# loadKineticModel.py --- +# +# Filename: loadKineticModel.py +# Description: +# Author: Upi Bhalla +# Maintainer: +# Created: Sat Oct 04 12:14:15 2014 (+0530) +# Version: +# Last-Updated: +# By: +# Update #: 0 +# URL: +# Keywords: +# Compatibility: +# +# + +# Commentary: +# +# +# +# + +# Change log: +# +# +# +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth +# Floor, Boston, MA 02110-1301, USA. +# +# +# Code: + +import moose +import pylab +import numpy +import sys + +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. + + """ + solver = "gsl" # Pick any of gsl, gssa, ee.. + mfile = '../genesis/kkit_objects_example.g' + runtime = 20.0 + if ( len( sys.argv ) >= 3 ): + if sys.argv[1][0] == '/': + mfile = sys.argv[1] + else: + mfile = '../genesis/' + sys.argv[1] + runtime = float( sys.argv[2] ) + if ( len( sys.argv ) == 4 ): + solver = sys.argv[3] + modelId = moose.loadModel( mfile, 'model', solver ) + # Increase volume so that the stochastic solver gssa + # gives an interesting output + #compt = moose.element( '/model/kinetics' ) + #compt.volume = 1e-19 + + moose.reinit() + moose.start( runtime ) + + + # Display all plots. + for x in moose.wildcardFind( '/model/#graphs/conc#/#' ): + t = numpy.arange( 0, x.vector.size, 1 ) * x.dt + pylab.plot( t, x.vector, label=x.name ) + pylab.legend() + pylab.show() + + quit() + +# Run the 'main' if this script is executed standalone. +if __name__ == '__main__': + main()