Name: newton_nd.pro
Description:
IDL function to propagate a system of second order differential
equation using a 4th order runge-kutta routine.
Syntax:
result = newton_nd( equ_array, y, tfinal, hint )
Input:equ_array: (required)
equ_array is an string array.
It consits of n second order differential euations.
Each equation must use y[i]'s as the variables.
y: (required)
y is an IDL dblarr.
y[0:n_elements(y)/2-1)] are the values of the variables(coords).
y[n_elements(y)/2:n_elements(y)] are the first derivatives of
the varibles with respect to t.
tfinal: (optional)
tfinal is an IDL double.
It represents the time (in the units of the given diffeq.s for the
iterating to stop.
If tfinal is not specified it'll be given the value 2000*hint.
hint: (optional)
hint is an idl double.
This represents the desired change in coordinate for a time step h.
If hint is not specified it'll be given the value 0.02.
Output:step:
Step is an idl structure.
Common calls include step.t, step.h, step.dof[n].q, and step.dof[n].v.
These calls will yield all of the times, stepsizes,
q's of the nth degree of freedom, and v's of the nth
degree of freedom respectively.
Example:
This example runs newton_nd to simulate two simple harmonic
oscillators for 30 seconds.
and then plots the motion of each with time.
result = newton_nd( $
['-3.*y[0]','-5.*y[1]'],[5.d0, 3.d0, 0.d0, 0.8d0], 30.d0, 0.02d0 $
)
;this will plot y[0] vs t
plot, result.t, result.dof[0].q
oplot, result.t, result.dof[1].q
|