Name: derivs.pro
Description:
derivs extracts second order differential equations
(of the form d^2Q/dt^2=...) from the string array equ_string and
returns the derivative of the input array y.
Syntax:
derivs(t,y)
Input:t:
t is an IDL double.
t corresponds to the time of the individual time step.
y:
y is an IDL dblarr with an even number of elements.
The first half of y's elements are the variables of the function.
The rest are the derivatives of the variables with respect to t
evaluated at t.
SHARE.equ_string:
equ_string is an IDL string variable that contains the acceleration
equations.
The variables must be entered as elements of the y array.
The string must be of the format:
'dvdt = [equ1, equ2, ...]'.
The string saved to equ_string must be in appropriate IDL format such
that execute may be called to create the variable dvdt.
Output:dydt:
dydt is an idl dblarr.
The first half of the elements are the equal to the latter half of y's.
The rest are the second derivatives with respect to t at t.
Example:
This example uses the acceleration equation for a simple pendulum
where the pendulum length is free to change.
The initial conditions are such that the pendulum is held
about 90 degrees above verticle and released.
Here the derivatives of the angle and the angular velocity are
calculated and printed for the first time step.
;define inital y's. radius=3, theta=1.57, dr/dt=0, dtheta/dt=0
y=[3.d0,1.7d0,0.d0,0.d0]
;define equ_string
equ_string='dvdt=[9.8d0*COS(y[1])+y[0]*y[3]^2,-9.8d0*SIN(y[1])/y[0]]
;call derivs
dydt=derivs(0.d0,y)
print, dydt
|