Laplace Eqn

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Laplace Eqn as PDF for free.

More details

  • Words: 790
  • Pages: 9
Assignment 3 Rajarshi Guha, Vishal Dalvi and Rahul Kumar M.Tech. 2nd year, 07302009, 07302005 and 07302006 Modeling & Simulation, CL676 Monte Carlo Simulation of 2 dimensional Laplace Equation: 10 x 10 Temperature Grid: 400 300 300 300 300 300 300 300 300 400

500 330 310 310 330 440 420 410 360 500

500 340 300 450 360 350 340 400 350 500

500 420 480 310 400 360 460 480 380 500

500 440 300 310 470 350 410 340 400 500

500 500 400 300 410 420 300 370 410 500

500 420 500 380 380 320 310 320 440 500

500 440 420 410 360 320 310 440 440 500

500 500 300 340 430 300 470 450 380 500

400 300 300 300 300 300 300 300 300 400

500 480 460 440 420 400 380 360 340 10 320 300 10

8 6 9

8

4 7

6

5

4

2 3

2

1

0

Fig.1. 3-dimensional plot of grid point temperatures using MC simulation in MATLAB. Walls are at temperatures 300 & 500 K with the corner points having 400K.

Finite Difference Simulation of 2 dimensional Laplace Equation: 10 x 10 Temperature Grid:

500 480 460 440 420 400 380 360 340 320 300 10

9

8

7

6

5

4

3

2

1

1

2

3

4

5

6

7

8

9

10

Fig.2. 3-dimensional plot of grid point temperatures using FD simulation in MATLAB. Walls are at temperatures 300 & 500 K with the corner points having 400K.

Monte Carlo Simulation of 2 dimensional Laplace Equation: 10 x 10 Temperature Grid: 500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

500 500 500 500 500 500 500 500 500 500

501 5 0 0 .8 5 0 0 .6 5 0 0 .4 5 0 0 .2 500 4 9 9 .8 4 9 9 .6 4 9 9 .4 10 4 9 9 .2 8 499 10

9

6 8

7

4 6

5

4

2 3

2

1

0

Fig.3. 3-dimensional plot of grid point temperatures using MC simulation in MATLAB. Wall temperatures are at 500K throughout.

Finite Difference Simulation of 2 dimensional Laplace Equation: 10 x 10 Temperature Grid:

6 00 5 50 5 00 4 50 4 00 35 0 30 0 10 9 8 7 6 5

10 9 4

8 6

3

7

5 4

2

3 1

2 1

Fig.4. 3-dimensional plot of grid point temperatures using MC simulation in MATLAB. Wall temperatures are at 500K throughout.

Simulation with MC and FD with different Boundary Temperatures: The below figures are for Boundary Temperatures of 500 & 800 K with corners are at 500, 600, 650 & 700K.

800

750

700

650

600 10

550 8 500 10

6 9

8

4

7

6

5

2

4

3

2

1

0

800

750

700

650

600

550

500 10

9

8

7

6

5

4

3

2

1

10

9

8

7

6

5

4

3

2

1

Appendix: Coding: 1. Monte Carlo Simulation: % Defining the boundary points for i=1:10 for j=1:10 if(i==1||i==10||j==1||j==10) C(1,:)=500; C(10,:)=500; C(:,1)=300; C(:,10)=300; C(1,1)=400; C(1,10)=400; C(10,1)=400; C(10,10)=400; else C(i,j)=0; end end end %C; % Taking intermediate grid points and iterating for i=2:9 for j=2:9 x=i; y=j; avgT=0; for m=1:10000 conv=1; while(conv>0) % 2-dimensional Random Walk r = rand(1,1); if(r < 0.25) x=x-1;

elseif (r < 0.50) x=x+1; elseif (r < 0.75) y=y+1; else y=y-1; end if(x<1 || x>10 || y<1 || y>10) if(x<=1) x=x+1; end if(y<=1) y=y+1; end if(x>=10) x=x-1; end if(y>=1) y=y-1; end continue; end % Whether boundary is reached if(C(x,y)==300 || C(x,y)==400|| C(x,y)==500) d(m)=C(x,y); break; else continue; end end avgT=avgT+d(m); if(m==10) C(i,j)=avgT/m; end end end end

% Plotting the Mesh for i=1:10 for j=1:10 Px(i)=i; Py(j)=j; Temp(i,j)=C(i,j); end end Temp mesh(Px,Py,Temp)

2. Finite Difference Simulation: a. Function File: function f = laplace_eqn(Tn) v=Tn; for i=2:9 for j=2:9 v(i,j)=0.25*(v(i-1,j)+v(i+1,j)+v(i,j+1)+v(i,j-1)); end end f=v; b. Main file: for i=1:10 for j=1:10 if(i==1||i==10||j==1||j==10) C(1,:)=500; C(10,:)=500; C(:,1)=300; C(:,10)=300; C(1,1)=400; C(1,10)=400; C(10,1)=400; C(10,10)=400; else

C(i,j)=450; end end end % Running the iterations until consecutive matrix difference norm becomes less than tolerance for i=1:50000 Co=C; soln=feval('laplace_eqn',C); Cn=soln; C=soln; if(norm(Cn-Co)<.01) break; end end norm(Cn-Co) Temp=C; for i=1:10 for j=1:10 Px(i)=i; Py(j)=j; Temp(i,j)=C(i,j); end end Temp mesh(Px,Py,Temp)

Related Documents

Laplace Eqn
July 2020 2
Laplace
November 2019 27
Laplace
November 2019 17
Laplace
December 2019 21
Laplace
May 2020 14
Laplace
July 2020 5