home *** CD-ROM | disk | FTP | other *** search
- # OSCILLAT.ODE
- # A driven, damped oscillator
- #
- # Select 5th order Runge-Kutta, fixed stepsize
- $m -5
- # Solve to time=100
- $t 100
- position = 1
-
- # Initial values
- velocity = 0
- time = 0
-
- # Try different amounts of damping
- damping = 0.5
-
- # Omega is the natural frequency
- omega = 1
- # Driving frequency
- drivefreq= 1
- # Drive amplitude
- amplitude= 1
-
- # Differential equations
- time' = 1
- position' = velocity
- velocity' = -omega*position - damping*velocity + amplitude*cos(drivefreq*time)