12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

pdes for electrostatics & heat flow 475first equation,⎛c11⎞d 10 0 ··· ··· ··· 0 ⎛ ⎞ ⎛ b 1⎞x 1d 10 d 2 − a2c1d 1c 2 0 ··· ··· ··· 0x 2b 2 − a2b1d 10 a 3 d 3 c 3 ··· ··· ··· 0x 3b 3··· ··· ··· ··· ··· ··· ··· ···. =... ..,⎜ ⎟⎜⎝ 0 0 0 0 ··· a N−1 d N−1 c N−1⎟ ⎝ · ⎠ ⎜ ⎟⎠ ⎝ · ⎠0 0 0 0 ··· 0 a N dx N N b Nand then dividing the second equation by the second diagonal element,⎛ c1 1⎞ ⎛d 10 0 ··· ··· ··· 0 ⎛ ⎞x 1c 0 12cd 2−a 1 0 ··· ··· 02 a 1 x 20 a 3 d 3 c 3 ··· ··· ··· 0x 3··· ··· ··· ··· ··· ··· ··· ···. =..⎜ ⎟⎜⎝ 0 0 0 0 a N−1 d N−1 c N−1⎟ ⎝ · ⎠⎜⎠ ⎝x N0 0 0 0 ··· 0 a N d Nb 1d 1b 2−a 2b 1d 1d 2−a 2c 1d 1b 3Assuming that we can repeat these steps without ever dividing by zero, the systemof equations will be reduced to upper triangular form,. ..·b N⎞.⎟⎠⎛1 h 1 0 0 ··· 00 1 h 2 0 ··· 00 0 1 h 3 ··· 0. 0 ··· ··· .. . .. ···⎜⎝0 0 0 0 ··· ···0 0 0 ··· 0 1⎞ ⎛ ⎞ ⎛ ⎞x 1 p 1x 2p 2x 3p 3. =... , ..⎟ ⎜ ⎟ ⎜ ⎟⎠ ⎝ · ⎠ ⎝ · ⎠x N p Nwhere h 1 = c 1 /d 1 and p 1 = b 1 /d 1 . We then recur for the others elements:h i =c id i − a i h i−1,p i = b i − a i p i−1d i − a i h i−1. (17.85)Finally, back substitution leads to the explicit solution for the unknowns:x i = p i − h i x i−1 ; i = n − 1,n− 2,...,1, x N = p N . (17.86)In Listing 17.4 we give the program HeatCNTridiag.java that solves the heatequation using the Crank–Nicolson algorithm via a triadiagonal reduction.−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 475

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

Saved successfully!

Ooh no, something went wrong!