Protected names in auxiliary functions

  • Daniel Damineli

    Daniel Damineli - 2013-02-18

    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{'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

    # Initialize dictionaries

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

    for i in xrange(
        # Assign angular velocities

        # 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

    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.

  • Daniel Damineli

    Daniel Damineli - 2013-02-19

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


Log in to post a comment.