if var in options: options[var] = float(val) else: print 'Unknown argument: ', a use() sys.exit() # Get the values for the initial conditions and parameters from the options dict. y_ = [] for i in range(N_): y_ = y_ + [options[varnames_[i]]] p_ = [] for i in range(P_): p_ = p_ + [options[parnames_[i]]] # Create the time samples for the output of the ODE solver. tfinal = options['stoptime'] N = int(options['numpoints']) if N < 2: print 'The number of points must be at least 2.' sys.exit() t = [tfinal*float(i)/(N-1) for i in range(N)] # Call the ODE solver. ysol = odeint(pendulum.vectorfield,y_,t,args=(p_,),Dfun=pendulum.jacobian,atol=options['abserr'],rtol=options['relerr']) # Print the solution. for t1,y1 in zip(t,ysol): print t1,y1[0],y1[1], print pendulum.energy(y1,t1,p_)