## Protected names in auxiliary functions

Help
2013-02-18
2013-11-04
• Greetings!
I am trying to start using PyDSTool instead of my previous tools (XPP, R, Scipy and OpenOpt) but I've been stuck for days in a probably silly step: defining and using auxiliary functions.
I have simplified my script but could not find the issue - my initial suspects were using 't', 'beta' or 'exp' but it turns out even without those I can't get it right.
I would really appreciate some help. The code is pasted below - it is not the simplest form but with luck you can spot other traps ready to blow.
Thank you very much!
Daniel Damineli

import numpy as np
import PyDSTool as dst

# Name
DSargs = dst.args(name='Uncoupled phase oscillators')

# Auxiliary functions
DSargs.fnspecs  = {'prc': (, '-sin(x-phs_cte)'),
'pcp': (, 'exp(-beta*(1-cos(x-phs_cte)))'),
'gate': (, 'if(t<(stim_on+stim_dur),0,1)')}

# Model parameters
DSargs.pars={'N':10,'mu':1,'sigma':0.1,'eps':1000,'beta':10,'stim_on':10,'stim_dur':1,'phs_cte':np.pi/2}
# Array of angular velocities to be used in for loop
omega=np.random.normal(DSargs.pars, DSargs.pars, DSargs.pars)

# Initialize dictionaries
DSargs.varspecs={}
DSargs.ics={}

# array of ICs to be used in for loop
ics=np.random.uniform(0, 2*np.pi, DSargs.pars)

for i in xrange(DSargs.pars):

# Assign angular velocities
DSargs.pars=omega_

# rhs of the differential equation
DSargs.varspecs='om'+str(i)+'+ eps*prc('+'x'+str(i)+',phs_cte)*pcp('+'x'+str(i)+',beta,phs_cte)*gate(t,stim_on,stim_dur)'

# Assign ICs
DSargs.ics = ics

DSargs.tdomain =                          # set the range of integration.
ode  = dst.Generator.Vode_ODEsystem(DSargs)     # an instance of the 'Generator' class.

_

• Rob Clewley
2013-02-18

Thanks for asking this question. I have improved the error message in the code to make it clearer what the problem is. You can't use system parameter names as function argument names. The model's parameters are already globally visible so they don't have to be passed at all. In this case, remove all those the function argument lists leaving just 'x' and 't'. If you *really* want to pass those you'll have to rename them.

• Thank you very much!
In retrospect I could have inferred this from the examples, but I didn't.
I even tried tinkering with FuncSpec.py by forcing it to print badparnames, but that was still confusing.
An improved error message should do the job!
Once again thank you