class Simulation implements Runnable{ private DrawSim plot; private Earthquake earth; private double x[],v[]; private double TIMESTEP1=0.005,TIMESTEP2=0.2,t=0.0,time; private int N=100; private double energy=0.0; Simulation(DrawSim plotting, Earthquake e){ earth=e; plot=plotting; x = new double[N]; v = new double[N]; time=TIMESTEP2; } public void run(){ int i,j; double total_energy=0.0,old_energy=0.0; double localt=0.0; for(i=0;i0.0){ if(old_energy==0.0){ plot.clearScreen(); total_energy=0.0; localt=0.0;} total_energy+=energy; plot.addToScreen(localt,energy); earth.usercontrols.addToBox(total_energy); localt+=time;} if((energy==0.0) && (old_energy!=0.0)) earth.runner.suspend(); old_energy=energy; t+=time; // wait a bit before moving on try{Thread.sleep(10);} catch(InterruptedException e){} } } private double update(){ double felastic,vnew[],xnew[]; int i,iplus,iminus; boolean loop_again=false; double KC=250.0,KP=40.0,F=50.0,v0=0.01; vnew = new double[N]; xnew = new double[N]; do{ for(i=0;i