This example illustrates loading, running and plotting a kinetic model defined in kkit format

In [1]:
import moose
import pylab
import numpy
import sys
%matplotlib inline

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 ``python filename runtime solver``. We use the gsl solver here. The model already defines a couple of plots and sets the runtime to 20 seconds.
	"""
	solver = "gsl"  # Pick any of gsl, gssa, ee..
	mfile = '../genesis/kkit_objects_example.g'
	runtime = 20.0
	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()