NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Examples for beginner who want to learn EJS => Topic started by: Fu-Kwun Hwang on January 30, 2012, 09:20:58 am



Title: Simple Harmonic Motion (SHM)
Post by: Fu-Kwun Hwang on January 30, 2012, 09:20:58 am
This is a simulation for simple harmonic motion:
$F=m \frac{dv}{dt}=-k*x$;

For the purpose numerical calculation, the above second order differential equation is transformer into two equations (first order differential equation):
$\frac{dx}{dt}=v_x$ // use this equation to calculate $x(t+dt)$ from $x(t)$ and $v_x(t)$
$\frac{dv_x}{dt}=-k*x/m$ // use this equation to calculate $v_x(t+dt)$ from $v_x(t)$ and $x(t), k, m$

With two initial conditions: $x(0)$ and $v_x(0)$, the rest of $x(t)$ and $v_x(t)$ can be calculated.