(*A code to simulat the propagation of 1D monochromatic wave *) (*Input parameter*) A=1.0;lambda=1.0;f=0.1;xini=0;xlast=50lambda; Deltat=0.01;tlast=10T;sigma=10.0;mu=10.0; (*End of Input parameter*) (*Calculation*) ilast=IntegerPart[tlast/Deltat]; t:=i*Deltat; k=(2Pi)/lambda;omega=2Pi*f;T=1/f; phi[x_,t_]:=k*x-omega*t; (*y[x_,t_]:=A*Sin[k*x+omega*t];*) y[x_,t_]:=A*Exp[-(phi[x,t]-mu)^2/(2*sigma^2)]; (*End of Calculation*) (* output / visualisation *) Manipulate[ t=i*Deltat; Plot[y[x,t],{x,xini,xlast},PlotRange->{0,A}],{i,0,ilast,1} ](*end of Manipulate*) (* end of output / visualisation *) (Debug) In[23]:= (*Simulate of a 1D wave by solving the wave equaion *) (*Set Parameters*) xini=0;xlast=1;NN=100;Deltat=0.1; k=1000;x0=0.3(*(1/2)(xlast-xini)*); r=1.0;nlast=1000; (*End of Set Parameters*) ilast=NN;iini=0; Deltax=(xlast-xini)/NN; c=r*Deltax/Deltat; (* Initialisation *) For[ i=iini,i<=ilast,i++, x[i]=xini+i*Deltax; y[i,0]=Exp[-k*(x[i]-x0)^2]; y[i,-1]=Exp[-k*(x[i]-x0)^2]; ]; txy[0]=Table[{x[i],y[i,0]},{i,iini,ilast}]; Amp=Max[Table[{y[i,0]},{i,iini,ilast}]]; ListPlot[txy[0],Joined->True,Mesh->All,PlotRange->{-Amp,Amp},PlotLabel->"Initial Profile"]; (* End of Initialisation *) (* Calculation *) For[n=0,n<=nlast,n++, For[i=iini+1,i<=ilast-1,i++, y[i,n+1]=2(1-r^2)*y[i,n]-y[i,n-1]+(r^2)(y[i+1,n]+y[i-1,n]) ];(*end for i*) (* impose BC *) y[iini,n]=0;y[ilast,n]=0; (* end of impose BC *) txy[n+1]=Table[{x[i],y[i,n]},{i,iini,ilast}]; ];(*end for n*) (* Calculation *) (* visualisation *) Print[Manipulate[ Show[ListPlot[txy[n],Joined->True,Mesh->All,PlotRange->{-Amp,Amp},PlotLabel->{"t =",n*Deltat}]] ,{n,0,nlast,1}]]; (Debug) During evaluation of In[23]:= Manipulate[Show[ListPlot[ txy[n], Joined -> True, Mesh -> All, PlotRange -> {-Amp, Amp}, PlotLabel -> {"t =", n*Deltat}]], {{n, 705}, 0, 1000, 1}]