the Technlgy Interface/Fall 007 Direct Mnte Carl Simulatin f Time- Depent Prblems by Matthew. N. O. Sadiku, Cajetan M. Akujubi, Sarhan M. Musa, and Sudarshan R. Nelatury Center f Excellence fr Cmmunicatin Systems Technlgy Research (CECSTR) Cllege f Engineering Prairie View A&M University, Prairie View, TX 77446 Email: mnsadiku, cmakujubi, smmusa @pvamu.edu Schl f Engineering and Engineering Technlgy Pennsylvania State University Erie, PA 6563-70 Email: srn3@psu.edu Abstract: Mnte Carl methd is well knwn fr slving static prblems such as Laplace s r Pissn s equatin. In this paper, we ext the applicability f the cnventinal Mnte Carl methd t slve time-depent (heat) prblems. We illustrate this with sme examples and present results in ne-dimensin (-D) and tw-dimensin (-D) that agree with the exact slutins. I. Intrductin Mnte Carl methds are nndeterministic mdeling appraches fr slving physical and engineering prblems. They have been applied successfully fr slving differential and integral equatins, fr finding eigenvalues, fr inverting matrices, and fr evaluating multiple integrals [-5]. Mnte Carl methds are well knwn fr slving static prblems such as Laplace s r Pissn s equatin. They are hardly applied in slving parablic and hyperblic partial differential equatins. The s-called Mnte Carl simulatin f Maxwell s equatin [6-9] gives the impressin that Mnte Carl methd is being applied t time-depent prblems. This is nt a direct r explicit slutin f Maxwell equatins like the finite-difference time-dmain (FDTD) scheme [0-]. In this paper, we ext the applicability f the cnventinal Mnte Carl methd t slve directly time-depent (heat) prblems. We deal with the case f rectangular slutin regins. We cmpare Mnte Carl slutins with the finite difference and exact slutins. Our results fr ne-dimensin (-D) and tw-dimensin (-D) prblems agree
the Technlgy Interface/Fall 007 with the exact slutins. The Mnte Carl treatment is s straightfrward that it can be presented t undergraduate students withut difficulties. II. Diffusin Equatin Cnsider the skin effect n a slid cylindrical cnductr. The current density distributin within a gd cnducting wire ( σ / ω >> ) beys the diffusin equatin J J () =μσ We may derive the diffusin equatin directly frm Maxwell s equatins. We recall that H = J+ J () d D where J = σ E is the cnductin current density and J d = is the displacement current t density. Fr σ / ω >>, J d is negligibly small cmpared with J. Hence Als, H J (3) H E =μ E= E E=μ H (4) Since E = 0, intrducing eq. (3), we btain Replacing E with J/σ, eq. (5) becmes which is the diffusin (r heat) equatin. J E (5) = μ J J =μσ We nw cnsider the Mnte Carl slutin f the diffusin (r heat) equatin in nedimensinal (-D) and tw-dimensinal (-D) frms in rectangular crdinate system.
the Technlgy Interface/Fall 007 III. One-Dimensinal Heat Equatin T be cncrete, cnsider the ne-dimensinal heat equatin: Uxx = U, 0< x <, t > 0 (6) Bundary cnditins: U(0, t) = 0 = U(, t), t > 0 (7a) Initial cnditin: U( x,0) = 00, 0< x < (7b) In eq. (6), U xx indicates secnd partial derivative with respect t x, while Ut indicates partial derivative with respect tt. The prblem mdels temperature distributin in a rd r eddy current in a cnducting medium [3]. In rder t slve this prblem using the Mnte Carl methd, we first need t btain the finite difference equivalent f the partial differential equatin in eq.(6). Using the central-space and backward-time scheme, we btain Ui ( +, n) ( Uin (, ) + Ui (, n) Uin (, ) Uin (, ) = (8) ( Δx) Δt where x = iδ x and t = nδ t. If we let ( Δx) α = (9) Δ t eq.(8) becmes Uin (, ) = PUi ( +, n) + PUi (, n) + PUin (, ) (0) x+ x t where P = Px =, + α x+ P t = α +α () Ntice that Px+ + Px + Pt =. Equatin (0) can be given a prbabilistic interpretatin. If a randm-walking particle is instantaneusly at the pint ( x, y ), it has prbabilities P x +, Px, and P t f mving frm ( x, t ) t ( x + Δ xt, ), ( x Δ xt, ), and ( x, t Δ t) respectively. The particle can nly mve tward the past, but never tward the future. A means f determining which way the particle shuld mve is t generate a randm number r, 0< r <, and instruct the particle t walk as fllws: ( x, t) ( x+δ x, t) if (0 < r < 0.5) ( x, t) ( xδ x, t) if (0.5 < r < 0.5) ( x, t) ( x, tδ t) if ( (0.5 < r < ) ) () where it is assumed that α =. Mst mdern sftware such as MATLAB have a randm number generatr t btain r. T calculate U at pint ( x, t ), we fllw the fllwing randm walk algrithm:. Begin a randm walk at ( x, t) = ( x, t ). 3
the Technlgy Interface/Fall 007. Generate a randm number 0< r <, and mve t the next pint using eq. (). 3(a). If the next pint is nt n the bundary, repeat step. 3(b). If the randm walk hits the bundary, terminate the randm walk. Recrd U b at the bundary and g t step and begin anther randm walk. 4. After N randm walks, determine N U( x, t ) = U ( K) (3) b N K = where N, the number f randm walks is assumed large. A typical randm walk is illustrated in Fig.. Example As a numerical example, cnsider the slutin f the prblem in eqs. (6) and (7). We selectα =, Δ x = 0., s that Δ t = 0.005 and Px+ = Px =, Pt =. 4 We calculate U at x 0 = 0.4, t = 0.0, 0.0, 0.03, 0.04, 0.0. The MATLAB cde fr the prblem is shwn in Fig.. As evident in the prgram, N = 000. As shwn in Table, we cmpare the results with the finite different slutin and exact slutin [4]: 400 ( n π t) U( x, t) = sin( nπ x) e, n= K + (4) π n K = 0 Fr the exact slutin in eq. (4), the infinite series was truncated at K = 0. U(0, t ) = 0 U(, t ) = 0 x = 0 U( x,0) = 00 x = Fig. A typical randm walk in rectangular dmain. 4
the Technlgy Interface/Fall 007 Table Cmparing Mnte Carl (MCM) slutin with finite difference (FD) and exact slutin ( x = 0.4) t Exact MCM FD 0.0 99.53 94.4 00 0.0 95.8 93.96 96.87 0.03 83. 87.6 89.84 0.04 80.88 8.54 8.03 0.0 45.3 46.36 45.8 % This prgram slves ne-dimensinal diffusin (r heat) equatin % using Mnte Carl methd nrun = 000; delta = 0.; % deltat=*delta^; deltat = 0.005; A=.0; x=0.4; t=0.; i=x/delta; j=t/deltat; n=t/deltat; imax=a/delta; sum=0; fr k=:nrun i=i; n=n; while i<=imax & n<=n r=rand; %randm number between 0 and if (r >= 0.0 & r <= 0.5) i=i+; if (r >= 0.5 & r <= 0.5) i=i-; if (r >= 0.5 & r <=.0) n=n-; if (n < 0) break; % check if (i,n) is n the bundary if(i == 0.0) 5
the Technlgy Interface/Fall 007 sum=sum+ 0.0; break; if(i == imax) sum=sum+ 0.0; break; if(n == 0.0) sum=sum+ 00; break; % while u=sum/nrun Fig. MATLAB prgram fr Example. IV. Tw-Dimensinal Heat Equatin Suppse we are interested in the slutin f the tw-dimensinal heat equatin: Uxx + Uyy = Ut, 0< x <, 0 < y <, t > 0 (5) Bundary cnditins: U(0, y, t) = 0 = U(, y, t), 0 < y <, t > 0 (6a) Initial cnditin: U( x,0, t) = 0 = U( x,, t), 0< x <, t > 0 (6b) U( x, y,0) = 0xy, 0< x <, 0 < y < (6c) Using the central-space and backward-time scheme, we btain the finite difference equivalent as ( i+, j, n) U( i, j, n) + U( i, j, n) ( i, j+, n) U( i, j, n) + U( i, j, n) ( i, j, n) U( i, j, n) + = ( Δx) ( Δy) ( Δt) (7) Let Δ x=δ y =Δ and α = Δ (8) Δ t eq. (7) becmes Ui (, jn, ) = PUi x+ ( +, jn, ) + PUi x (, jn, ) + PUi y+ (, j+, n) + PUi y (, j, n) + PUi t (, jn, ) where Px+ = Px = Py+ = Py = (0a) 4 + α (9) 6
the Technlgy Interface/Fall 007 P = α t (0b) 4 +α Nte that Px+ + Px + Py+ + Py + Pt = s that a prbabilistic interpretatin can be given t eq. (9). A randm walking particle at pint ( x, yt, ) mves t ( x +Δ, yt, ), ( x Δ, yt, ), ( x, y+δ, t), ( x, yδ, t), ( x, yt, Δ t) with prbabilities, P x +, Px, P y +, Py, and Pt respectively. By generating a randm number 0< r <, we instruct the particle t mve as fllws: (, x yt,) ( x+δ, yt,) if (0 < r < 0.) (, x yt,) ( xδ, yt,) if (0. < r < 0.4) ( x, yt, ) ( xy, +Δ, t) if (0.4 < r < 0.6) () ( x, yt, ) ( xy, Δ, t) if (0.6 < r < 0.8) ( x, yt, ) ( xyt,, Δ t) if ( (0.8 < r < ) ) assuming thatα =. Therefre, we take the fllwing steps t calculate U at pint ( x, y, t ) :. Begin each randm walk at ( x, yt, ) = ( x, y, t).. Generate a randm number 0< r <, and mve the next pint accrding t eq. (). 3(a). If the next pint is nt n the bundary, repeat step. 3(b). If the randm walk hits the bundary, terminate the randm walk. Recrd at the bundary and g t step and begin anther randm walk. 3. After N randm walks, determine N U( x, y, t ) = U ( K) () b N K = U b The nly difference between -D and -D is that there are three kinds f displacements in -D while there are five displacements (fur spatial nes and ne tempral ne) in -D. Example As a numerical example, cnsider the slutin f the prblem in eqs. (5) and (6). We selectα =, Δ= 0., s that Δ t = 0.0 and we calculate U at x = 0.5, y = 0.5, t = 0.05, 0., 0.5, 0., 0.5, 0.3. In Mnte Carl simulatins, we used N = 000. As shwn in Table, we cmpare the results frm the Mnte Carl methd (MCM) with the finite difference (FD) slutin and exact slutin [5]: 40 cs( mπ)cs( nπ) mn U( x, y, t) = sin( m x) sin( n y) e t π ( λ ) π π, (3) m= n= mn where λ ( ) ( ) mn = mπ + nπ. In the exact slutin in eq. (3), the infinite series was truncated at m = 0 and n = 0. Due t the randmness f the Mnte Carl slutin, each MCM result in Tables and was btained by running the simulatin five times and taking the average. 7
the Technlgy Interface/Fall 007 Table Cmparing Mnte Carl slutin with finite difference and exact slutin t Exact MCM FD 0.05.49.534.58 0.0 0.563 0.667 0.567 0.5 0.6 0.67 0.063 0.0 0.078 0.06 0.0756 0.5 0.09 0.049 0.077 0.30 0.05 0.09 0.00 V. Cnclusin In this paper, we have demnstrated hw the cnventinal Mnte Carl methd (the fixed randm walk) can be applied t time-depent prblems such as the heat equatin in bth rectangular and cylindrical crdinates. Fr -D and -D cases, we ntice that the Mnte Carl slutins agree well with the finite difference slutin and the exact analytical slutins and it is easier t understand and prgram than the finite difference methd. The methd des nt require the need fr slving large matrices and is trivially easy t prgram s that even undergraduates can understand it. The randmness f the MCM results can be eliminated if we apply the Exdus methd, anther Mnte Carl technique [6, 7]. The idea can be exted t ther time-depent prblems such as Maxwell s equatins r the wave equatin. VI. References [] T. E. Price and D. P. Stry, Mnte Carl simulatin f numerical integratin, J. Statistical Cmputatin and Simulatin, vl. 3, 985, pp. 97-. [] J. Padvan, Slutin f anistrpic heat cnductin prblems by Mnte Carl prcedures, Trans. ASME, August 974, pp. 48-430. [3] K. K. Sabelfeld, Mnte Carl Methds in Bundary Value Prblems. Berlin/New Yrk: Springer-Verlag, 99, p.. [4] N. Metrplis and S. Ulam, "The Mnte Carl Methd," Jur. Amer. Stat. Assc. vl. 44, n. 47, 949, pp. 335-34. [5] I. M. Sbl, A Primer fr the Mnte Carl Methd. Bca Ratn: CRC Press, 994. [6] J. Gu et al., Frequency depence f scattering by dense media f small particles based n Mnte Carl simulatin f Maxwell equatins, IEEE Trans. Gescience & Remte Sensing, vl. 40, n., Jan. 00, pp. 53-6. [7] L. Tsang, C. E. Mandt, and K. H. Ding, Mnte Carl simulatins f the extinctin rate f dense media with randmly distributed dielectric spheres based n slutin f Maxwell s equatins, Optical Letters, vl. 7, n. 5, 99, pp. 34-36. 8
the Technlgy Interface/Fall 007 [8] R. L. Wagner et al., Mnte Carl simulatin f electrmagnetic scattering frm twdimensinal randm rugh surfaces, IEEE Trans. Antennas and Prpagatin, vl. 45, n., Feb. 997, pp.35-45. [9] K. W. Lam et al., On the analysis f statistical distributins f UWB signal scattering by randm rugh surfaces based n Mnte Carl simulatins f Maxwell equatins, IEEE Trans. Antennas and Prpagatin, vl. 5, n., Dec. 004, pp.35-45. [0] K. S. Yee, Numerical slutin f initial bundary-value prblems invlving Maxwell s equatins in istrpic media, IEEE Trans. Antennas and Prpagatin, vl. 4, May. 966, pp.30-307. [] A. Taflve and M. E. Brdwin, Numerical slutin f steady-state electrmagnetic scattering prblems using the time-depent Maxwell s equatins, IEEE Micrwave Thery & Techniques, vl. 3, n.8, Aug. 975, pp. 63-630. [] M. Okniewski, Vectr wave equatin D-FDTD methd fr guided wave equatin, IEEE Micrwave Guided Wave Letters, vl. 3, n. 9, Sept. 993, pp. 307-309. [3] D. Netter, J. Levenque, P. Massn and A. Rezzug, Mnte Carl methd fr transient eddy-current calculatins, IEEE Trans. Magnetics, vl.40, n.5, Sept. 004, pp.3450-3456. [4] M. N. O. Sadiku, Numerical Techniques in Electrmagnetics. Bca Ratn, FL: CRC Press, nd editin, 00, pp. 5-30. [5] D. L. Pwers, Bundary Value Prblems. New Yrk: Academic Press, 97, pp. 35-39. [6] M. N. O. Sadiku. and D. Hunt, "Slutin f Dirichlet prblems by the Exdus Methd," IEEE Transactins f Micrwave Thery & Techniques, vl. 40, n., Jan. 99, pp. 89-95. [7] M. N. O. Sadiku, S. O. Ajse, and F. Zhiba, "Applying the Exdus Methd t slve Pissn's Equatin," IEEE Transactins f Micrwave Thery & Techniques, V. 4, N. 4, April 994, pp. 66-666. 9