// 22 fev 2004 // mars //v2 juillet 04 // pyl@ccr.jussieu.fr // www.lmm.jussieu.fr/~lagree/lagree.html // libre de copie // //javac AppletMascaret.java;open HelloMascaret.html import java.awt.event.*; import java.awt.*; import java.applet.*; import java.io.*; // Import input-output Library public class AppletMascaret extends java.applet.Applet implements Runnable { Thread runstring; private Image offScreenImage; int appWidth, appHeight ; int tt; double Lx=50,dx,dt,nu,mu,eps,t=0; double h[]; double ho[]; int n=500; //333 static PrintWriter q; public static void main(String[] argv) throws IOException, FileNotFoundException { q = new PrintWriter( new FileOutputStream("h.dat"), true); } public void init() { int i; appWidth = getSize().width; appHeight = getSize().height; offScreenImage=createImage(appWidth,appHeight); tt=1; h =new double[n+1]; ho=new double[n+1]; dx=Lx/n; // dt=.000001; dt=Double.parseDouble(getParameter ("dt")); // nu = .000001*dx*dx; nu=Double.parseDouble(getParameter ("nu")); eps=Double.parseDouble(getParameter ("eps")); mu=Double.parseDouble(getParameter ("mu")); System.out.println("pyl@ccr.jussieu.fr "); System.out.println("www.lmm.jussieu.fr/~lagree"); System.out.println(" mars 2004 "); System.out.println(" dt =" + dt); System.out.println(" dx =" + dx); System.out.println(" nu =" + nu); System.out.println(" mu =" + mu); System.out.println(" eps=" + eps); //pour faire un autre cas changer le commentaire for(i=0;i<=n;i++) h[i] = 0.5*(1.-(2./Math.PI)*(Math.atan(0.3*(i-(2/2*n)/5.)*dx))); //h[i] = 0.1+ 0.5* Math.exp( -(0.3*(i-(2*n)/5.)*dx)*(0.3*(i-(2*n)/5.)*dx)); // h[i] = 1 - i*1./n; //for(i=0;i<(2*n)/3;i++) h[i] = 1; //for(i=(2*n)/3;i.0000001); // System.out.println(" e =" + Math.sqrt(e) + "ic = " + ic); for ( i = 1 ; i < n ; i++) { h[i] = ho[i]; } } public void dro(Graphics g, double x1,double y1,double x2,double y2){ int i1,i2,j1,j2; int rr,gg,bb; i1 = (int)(appWidth*x1/Lx); i2 = (int)(appWidth*x2/Lx); j1 = (int)(appHeight/2 - (appHeight/4.)*y1); j2 = (int)(appHeight/2 - (appHeight/4.)*y2); rr=Math.min((128*(int)(100*(y2)))/100,128); rr =0; gg=0; bb=250;//Math.max(0,255-rr); g.setColor(new Color(rr,gg, bb)); g.drawLine(i1,j1,i2,j2); } public void nextpaint(Graphics g, int tt) { int i,jj; double x,y,xm1,ym1; for ( jj = 0 ; jj < 1000 ; jj++) { t=t+dt; nouvel(); } xm1=0; ym1=h[0]; for ( i = 1 ; i < n ; i++) { x=i*dx; y= h[i]; dro(g,xm1, ym1, x,y); xm1=x; ym1=y; // q.println(x+" "+y); } //dro(g,n*dx/2, -.95, n*dx/2,h[n/2]-.05); dro(g,1, -.95,1,1-.1); dro(g,0, -1,n*dx,-1); g.setColor(new Color(255,0,0)); g.drawString("h(x,t="+(((int)(t*100))/100.)+")",20,30); g.drawString("--->",20,50); g.drawString("--->",20,110); g.drawString("--->",20,70); g.drawString("--->",20,90); g.drawString("Mascaret! " ,100,10); } public void paint(Graphics g){ nextpaint(g,tt); tt=tt+1; // System.out.println(" tt =" + tt); } } // javac AppletMascaret.java // // // //pour memoire: fichier HelloWorldApp.java //class HelloWorldApp { // public static void main (String args[]) { // System.out.println("Hello World!"); // } //} // // ////Fp = F0 + h F1 + h^2 F2/2 + h^3 F3/6 + h^4 F4 ; // Fpp = Fp /. (h -> 2h); // Fppp = Fp /. (h -> 3h); // Fm = Fp /. (h -> -h); // Fmm = Fp /. (h -> -2h); // Fmmm = Fp /. (h -> -3h); // {Simplify[Fpp - 2 Fp + 2 Fm - Fmm]/2/h^3, // Simplify[Fppp - 3 Fp + 3 Fm - Fmmm]/8/h^3}