Re: [pydstool-users] simulation with many auxiliary equations
Status: Beta
Brought to you by:
robclewley
From: gyro f. <gyr...@gm...> - 2012-05-24 14:57:02
|
On 5/24/2012 8:39 AM, Ludo Visser wrote: >> >> The problem is one of ignorance. I am accustomed to ODE integrators >> like scipy.odeint or MATLAB's ode45, where one writes a function >> that returns the numerical rhs of the ODE system at a given time >> point and the ODE solver takes this function as an argument. >> >> Although I am a decent Python programmer, the object oriented >> structure of the PyDSTool framework and the idea of specifying >> equations and parameters using strings and dictionaries is foreign >> to me. > > Hi Gyro, > > I see what you mean now. I found this tutorial very useful in understanding the basics: > http://www.ni.gsu.edu/~rclewley/PyDSTool/Tutorial/Tutorial_linear.html > > Essentially, you need to define: > * a dictionary of parameters, with parameter names as keys and parameter values as values > * a dictionary of initial conditions, with variable names as keys and initial values as values > * a dictionary of ODEs, with variables names as keys and string-expressions for the ODE, in terms of other variables and parameters > > Then you can use the args-object to create a generator to compute the trajectories. > > I'm currently working on some examples myself, while learning how to work with PyDSTool. Maybe, once these examples can also be useful to you or others, but the fact that they may not be related to your field of research can be distracting rather than clarifying. My examples are in the field of mechanics; if you're interested, I can document them some more and post them here. > > Kind regards, > Ludo > Hi Ludo, Thank you. That example is very clear. The construction of the parameter, initial condition, and ODE dictionaries is straightforward. However, I am still not sure how one adds additional equations that are not ODEs. Although not realistic and consistent in units, suppose that for this oscillations example (Tutorial_linear.html) there are a number of derived quantities: c1 = k/m c2 = k*m^2 z = y/k and that the differential equations are dx/dt = c1*z dy/dt = -k*x/m + c2*(dx/dt) For this simple example, we can do some trivial substitutions. However, in general, how does one add additional auxiliary equations that are then used in the simulation system? Thanks. Kind regards, gyro |