Re: [pydstool-users] simulation with many auxiliary equations
Status: Beta
Brought to you by:
robclewley
From: Ludo V. <l.c...@sc...> - 2012-05-24 18:17:00
|
> 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? You can use the fnspec attribute for that. Building from your example, let's consider: dx/dt = c1*z, with c1 = k/m and z = y/k dy/dt = ... Your varspec would look like: varspec = {'x': 'c1(k,m)*z(y,k)', 'y': ...} Then, your fnspec would be: fnspec = {'c1': (['a', 'b'], 'a/b'), 'z': (['a', 'b'], 'a/b')} This defines the functions 'c1' and 'z', both taking 2 arguments. The keys of the fnspec dictionary defines the function name, the values are tuples of function arguments and function implementations. (Note that in this trivial example you could be done with defining only one function, since they both do the same.) Hope this helps, Ludo -- Ludo C. Visser, M.Sc. Science Applied phone: +31 6 1066 3076 e-mail: l.c...@sc... |