[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Additional outputs when solving an ODE

From: Luke
Subject: [Help-gsl] Additional outputs when solving an ODE
Date: Wed, 16 Sep 2009 12:07:03 -0700

I integrating some first order equations that describe the equations of
motion for various mechanical systems.  In addition to the trajectory of the
states, I am interested in several quantities which depend upon the state,
such as (but not limited to):
1)  position of various points of the system (depend on the state)
2)  potential energy
3)  kinetic energy
4)  momentum
5)  equations of constraint (holonomic and nonholonomic)

The right hand side of the ODE's for my system are automatically generated
in such a way that there are a number of intermediate variables introduced
as a means to save repetitive computations, and I would like to take
advantage of this when computing the output quantities in the above list.
The approach I am using right now to generate those above quantities is to
first integrate the equations of motion to determine the state trajectory,
then passing the state trajectory to a function which computes them in a
separate step.  It seems like to me that this isn't a very efficient way to
do it because lots of calculations are being repeated.

Is there a way I could include the calculation of the extra quantities into
the definition of the ode function?  I was thinking that maybe the params
pointer could point to a structure which could be used for the system
parameters *AND* to store the quantities in the above list, at each time
step, but I'm not sure how I would do this exactly.  Or can the ode func be
written with an extra parameter in the function definition so that the user
can pass an extra argument?  Alternatively, I guess global variables could
be used within the ode func, but I was hoping for a cleaner way to do it.

Has anybody encountered the need for this or know a good way to go about it?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]