Line2.mws

Here I give an example of how Maple can help you to visualise a physical problem. We look at the problem of two parallel uniform line of charges. The examples below are taken and collected from "Introduction to Maple," by A. Heck (2nd Ed).

> phi := ln(sqrt( (x+1)^2+y^2 ))-ln( sqrt( (x-1)^2+y^2 )) ; This is a potential of two line charges located at (-1,0) and (1,0). They are inifinitely long in the z-direction.

phi := ln(sqrt(x^2+2*x+1+y^2))-ln(sqrt(x^2-2*x+1+y^...

> with(plots):

Warning, the name changecoords has been redefined

> gradplot(-phi,x=-2..2, y=-1..1, arrows=THICK, grid=[11,11], axes=box); This is the electric field distribution.

[Maple Plot]

> contourplot( phi, x=-2..2,y=-1..1, color=black,numpoints=500, axes=box, contours=10);

This is a contour plot of the potential, which gives equipotential surfaces.

[Maple Plot]

> contourplot( phi, x=-2..2,y=-1..1, numpoints=500, axes=box, filled=true, contours=10,coloring=[white,black]); The higher the darker.

[Maple Plot]

Now we will plot the electric field lines utilising the differential equation tool.

> with(DEtools):

> with( linalg):

Warning, the name adjoint has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

> E := map( normal, linalg[grad](-phi, [x,y]) ); The electric vector field.

E := vector([2*(x^2-1-y^2)/((x^2+2*x+1+y^2)*(x^2-2*...
E := vector([2*(x^2-1-y^2)/((x^2+2*x+1+y^2)*(x^2-2*...

> alias( x=x(t), y=y(t) ):

> ODEs := diff(x,t) = E[1], diff(y,t) = E[2]; I am paramterising x(t) and y(t) as the field line. In other words, ( (x(t), y(t)) is a trajectory that traces a given electric field line.

ODEs := diff(x,t) = 2*(x^2-1-y^2)/((x^2+2*x+1+y^2)*...
ODEs := diff(x,t) = 2*(x^2-1-y^2)/((x^2+2*x+1+y^2)*...

> initvals := subs( t=0, [seq( [x=1+0.05*cos(Pi/20*s), y=0.05*sin(Pi/20*s)], s=5..19) ] ):

> initvals := evalf(initvals):

> DEplot( {ODEs}, [x,y], t=0..20, initvals, x=-1.5..1.5, y=0..2.5, stepsize=0.001);

[Maple Plot]

The above plot takes a long time. This is the price you pay for generating a graph with a fine resolution.