/* vibrating string simulation by Mariusz H. Jakubowski (mj@cs.princeton.edu) started: 4/25/96 */ import java.awt.*; import java.applet.Applet; public class waveq extends java.applet.Applet implements Runnable { // solution of wave equation with damping and the FPU cubic nonlinearity static final double PI = 3.14159265358979323846264338327950; double Y[][] = new double[GRIDLENGTH][3]; // numerical grid int prevT = 0, curT = 1, nextT = 2; double dt = .1, dx = .02, c = .04, damp = 0., fpu = 0.; static final int GRIDLENGTH = 64; static final int WIDTH = 580, HEIGHT = 220; static final double xscale = WIDTH/GRIDLENGTH, yscale = HEIGHT/5.4, dampScale = 100., fpuScale = 100.; static final int xoffs = (int)(0.5 + xscale/2), yoffs = HEIGHT/2; static final double MAXDAMP = 1., MAXFPU = 1.; // interface Thread waveqThread = null; int status; static final int running = 0, editing = 1; String statusText[] = new String[2]; int delay = 10; Scrollbar dampingSlider, fpuSlider; // double buffering Dimension offDimension; Image offImage; Graphics offGraphics; // ** wave equation solution ** // initialize string shape protected double sech(double x) { return 2./(Math.exp(x) + Math.exp(-x)); } protected void initshape() { for (int m=0; m