#include #include #include "math.h" #include // cc onde1.c ; ./a.out | gnuplot // OK MARCHE // // attention les differences finies c est pas bien // // // solution de du/dt = - deta/dx; deta/dt = -du/dx // cas instable; jouer avec dt pour stabiliser /* --------------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------------*/ int main (int argc, const char *argv[]) { int i,nx,it; char file; double*x=NULL,*u=NULL,*uo=NULL,*eta=NULL,*etao=NULL; double dt,dx,x0,L,t,tmax; FILE *g; nx = 800; L = 40; x0=-10; dx = L/nx; dt = 0.4; t = 0; tmax=3; x= (double*)calloc(nx+1,sizeof(double)); u= (double*)calloc(nx+1,sizeof(double)); eta=(double*)calloc(nx+1,sizeof(double)); uo= (double*)calloc(nx+1,sizeof(double)); etao=(double*)calloc(nx+1,sizeof(double)); fprintf(stderr," Coucou solution de du/dt = - deta/dx; deta/dt = -du/dx dx=%lf dt/dx=%lf\n",dx,dt/dx); // init for(i=0;i<=nx;i++) { u[i]=0; x[i]= x0 +i*dx; uo[i]=0;; etao[i]=.01*exp(-(x[i])*(x[i])); u[i]=uo[i]; eta[i]=etao[i]; } do{ t=t+dt; it++; // resolution simple for(i=1;i