16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7.3. SIMULATING SOLITON COLLISIONS 315<br />

The spatial range is taken from xmin =3x1 = ¡15 to xmax =3x2 = 15, and<br />

the step size h =(xmax ¡ xmin)=M calculated.<br />

> xmin:=3*x[1]: xmax:=3*x[2]: h:=evalf((xmax-xmin)/M);<br />

h := 0:1500000000<br />

The kink{antikink pro¯le at time t is entered.<br />

> U:=4*arctan(exp((x-x[1]-c[1]*t)/a))<br />

+4*arctan(exp(-(x-x[2]-c[2]*t)/b));<br />

³<br />

U := 4 arctan e (1:666666667 x +8:333333335 ¡ 1:333333334 t)´<br />

³<br />

+ 4 arctan e (¡1:666666667 x +8:333333335 ¡ 1:333333334 t)´<br />

The values of p(x; 0) ´ (@U=@x)jt=0 and q(x; 0) ´ (@U=@t)jt=0 are needed, so<br />

the relevant spatial and time derivatives are calculated and labeled P and Q.<br />

> P:=diff(U,x): Q:=diff(U,t): t:=0:<br />

Setting t = 0, the following loop evaluates U, p, andq at each spatial grid point<br />

on the zeroth time step. Note that the numerical value of U at the ith spatial<br />

grid point is labeled ui;0 and i is incremented in steps of 2 from 0 to M.<br />

> for i from 0 to M by 2 do #initial conditions<br />

> x:=xmin + i*h;<br />

> u[i,0]:=evalf(U); p[i,0]:=evalf(P); q[i,0]:=evalf(Q);<br />

> end do:<br />

The input pro¯le is now plotted and displayed in Figure 7.10.<br />

> plot([seq([xmin+2*i*h,u[2*i,0]],i=0..M/2)],view=<br />

[xmin..xmax,-1..15],tickmarks=[3,3],labels=["x","U"]);<br />

15<br />

10<br />

U<br />

5<br />

–10 0<br />

x 10<br />

Figure 7.10: Input pro¯le for the kink{antikink soliton collision simulation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!