16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.2. DIFFUSION AND LAPLACE'S EQUATION MODELS 233<br />

> phi:=collect(phi,[cos(theta),sin(theta),r]);<br />

μ<br />

μ<br />

<br />

C4 C2<br />

C3 C2<br />

Á := C4 C1 r + cos(μ)+ C3 C1 r + sin(μ)<br />

r<br />

r<br />

To simplify the coe±cients in Á, Benny makes the following substitutions.<br />

> phi:=subs(_C3=a/_C1,_C2=b*_C1/a,_C4=c/_C1,phi);<br />

μ<br />

Á := cr+ cb<br />

μ<br />

cos(μ)+ ar+<br />

ar<br />

b<br />

<br />

sin(μ)<br />

r<br />

> phi:=algsubs(c*b=a*d,phi);<br />

μ<br />

Á := cos(μ) cr+ d<br />

μ<br />

+ ar+<br />

r<br />

b<br />

<br />

sin(μ)<br />

r<br />

To determine the four unknown coe±cients a, b, c, andd, four boundary conditions<br />

are required. On the inner boundary, r = 10 cm, the coe±cient of the<br />

cos μ term must equal 15, while the coe±cient of the sin μ term must equal zero.<br />

This yields two boundary conditions, labeled bc1 and bc2 .<br />

> bc1:=eval(coeff(phi,cos(theta)),r=10)=15;<br />

bc1 := 10 c + d<br />

10 =15<br />

> bc2:=eval(coeff(phi,sin(theta)),r=10)=0;<br />

bc2 := 10 a + b<br />

10 =0<br />

On the outer boundary, r =20cm,thecoe±cientofthesinμterm must equal<br />

30, while the coe±cient of the cos μ term is equal to zero. This yields two more<br />

boundary conditions, bc3 and bc4 .<br />

> bc3:=eval(coeff(phi,sin(theta)),r=20)=30;<br />

bc3 := 20 a + b<br />

20 =30<br />

> bc4:=eval(coeff(phi,cos(theta)),r=20)=0;;<br />

bc4 := 20 c + d<br />

20 =0<br />

The four boundary condition equations are solved for a, b, c, andd,<br />

> coefficients:=solve(fbc1,bc2,bc3,bc4g,fa,b,c,dg);<br />

½<br />

coe±cients := d =200;a=2;c= ¡1<br />

¾<br />

;b= ¡200<br />

2<br />

which are assigned to produce the ¯nal solution Á to the potential problem.<br />

> assign(coefficients): phi:=phi;<br />

μ<br />

Á := cos(μ) ¡ r<br />

μ<br />

200<br />

+ + 2 r ¡<br />

2 r<br />

200<br />

<br />

sin(μ)<br />

r<br />

As requested by Professor Nerd, Benny will now use Á to plot the equipotentials<br />

in the annular region between r = 10 and 20. He ¯rst converts the potential<br />

into Cartesian coordinates by substituting r = p x2 + y2 ,cosμ = x= p x2 + y2 ,<br />

and sin μ = y= p x2 + y2 ,intoÁ.

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

Saved successfully!

Ooh no, something went wrong!