You are on page 1of 6

6/24/2014

bem_problem

Contents
*********************************
*********************************
% Homework Project Heat equation
%Pratik Upadhyay(2869825)
% Evaluates the static heat flux on a given domain
% Postprocessing is done for quadrangular area
%
% Uses m-files domainplot, HG_generator, solver, interior
%
% coord_nodes node coordinates
% n_el
number of nodes
% elem
element table
% dirichlet
dirichlet boundary conditions (temperature)
% neumann
neumann boundary conditions (flux)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
% Quadrature points & Weights for Numeric Integration of Non Singular terms
GP4_xi=[-0.8611,-0.3399,0.3399,0.8611];
GP4_w =[0.3479,0.6521,0.6521,0.3479];
% Quadrature points & Weights for Numeric Integration of Singular terms
WS_GP3_xi=[0.0639,0.3690,0.7669];
WS_GP3_w =[0.5134,0.3920,0.0946];
% Nodal coordinates
%---------------------------------------------%
x,y
coord_nodes = [0,0;
1,0;
2,0;
2,1;
2,2;
1,2;
0,2;
0,1];
%----------------------------------------------

% Generation of the element table


n_el = length(coord_nodes(:,1))
for i=1:n_el
elem(i,1)=i;
elem(i,2)=index_n([i+1 n_el]);
end
% show matrix
elem
% plot of elements and points
domainplot;
% T=50x+50y, 8 elements
%--------------------------------------dirichlet = [1,2,3,4,5,6,7,8;
1,1,1,-1,1,1,1,-1;
0,50,150,0,0,50,150,0];

neumann = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16;
-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,1,1,1;
file:///G:/sem2/BEM_PRJPT1/Pratik/html/bem_problem.html

1/6

6/24/2014

bem_problem

0,0,0,0,50,50,50,50,0,0,0,0,50,50,50,50];
%---------------------------------------% Element Normals
n_x = [0,0,1,1,0,0,-1,-1];
n_y = [-1,-1,0,0,1,1,0,0];
syms eta;
H= zeros(8,8);
G= zeros(8,16);

n_el =
8

elem =
1
2
3
4
5
6
7
8

2
3
4
5
6
7
8
1

*********************************
CALCULATION OF H MATRIX
for n = 1:8
for e= 1:8
if (n~=e && e~=8)
file:///G:/sem2/BEM_PRJPT1/Pratik/html/bem_problem.html

2/6

6/24/2014

bem_problem

% First part of the Integral over all elements except element 8


% e=8 dealt separatetly because e+1 should be 1 and not 9
x_x = coord_nodes(e,1)*(1-eta)*0.5 + coord_nodes(e+1,1)*(1+eta)*0.5*1;
x_y = coord_nodes(e,2)*(1-eta)*0.5 + coord_nodes(e+1,2)*(1+eta)*0.5*1;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
feta1 = ((x_x - xi_x)*n_x(e) + (x_y - xi_y)*n_y(e))/(2*pi*((x_x - xi_x)^2+(x_y
- xi_y)^2))*-0.25*(1-eta);
I1=0;
for i =1:4
I1 = I1 + subs(feta1,eta,GP4_xi(i))* GP4_w(i);
end

if (e~=1)
% Second part of the Integral for all elements except element 1
% e=1 dealt separatetly because e-1 should be 8 and not 9
x_x = coord_nodes(e-1,1)*(1-eta)*0.5 + coord_nodes(e,1)*(1+eta)*0.5*1;
x_y = coord_nodes(e-1,2)*(1-eta)*0.5 + coord_nodes(e,2)*(1+eta)*0.5*1;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
feta2 = ((x_x - xi_x)*n_x(e-1) + (x_y - xi_y)*n_y(e-1))/(2*pi*((x_x - xi_x
)^2+(x_y - xi_y)^2))*-0.25*(1+eta);
I2=0;
for i =1:4
I2 = I2 + subs(feta2,eta,GP4_xi(i))* GP4_w(i);
end
else
% Second part of the Integral for element 1
x_x = coord_nodes(8,1)*(1-eta)*0.5 + coord_nodes(e,1)*(1+eta)*0.5*1;
x_y = coord_nodes(8,2)*(1-eta)*0.5 + coord_nodes(e,2)*(1+eta)*0.5*1;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
feta2 = ((x_x - xi_x)*n_x(8) + (x_y - xi_y)*n_y(8))/(2*pi*((x_x - xi_x)^2+
(x_y - xi_y)^2))*-0.25*(1+eta);
I2=0;
for i =1:4
I2 = I2 + subs(feta2,eta,GP4_xi(i))* GP4_w(i);
end
end
H(n,e)=I1+I2;

elseif (e==8)
% First part of the Integral for element 8
x_x = coord_nodes(e,1)*(1-eta)*0.5 + coord_nodes(1,1)*(1+eta)*0.5;
x_y = coord_nodes(e,2)*(1-eta)*0.5 + coord_nodes(1,2)*(1+eta)*0.5;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
feta1 = ((x_x - xi_x)*n_x(e) + (x_y - xi_y)*n_y(e))/(2*pi*((x_x - xi_x)^2+ (x_
y - xi_y)^2))*-0.25*(1-eta);
I1=0;
for i =1:4
I1 = I1 + subs(feta1,eta,GP4_xi(i))* GP4_w(i);
end
% Second part of the Integral for element 8
x_x = coord_nodes(e-1,1)*(1-eta)*0.5 + coord_nodes(8,1)*(1+eta)*0.5*1;
x_y = coord_nodes(e-1,2)*(1-eta)*0.5 + coord_nodes(8,2)*(1+eta)*0.5*1;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
feta2 = ((x_x - xi_x)*n_x(e-1) + (x_y - xi_y)*n_y(e-1))/(2*pi*((x_x - xi_x)^2+
(x_y - xi_y)^2))*-0.25*(1+eta);
I2=0;
for i =1:4
I2 = I2 + subs(feta2,eta,GP4_xi(i))* GP4_w(i);
end
H(n,e)=I1+I2;
file:///G:/sem2/BEM_PRJPT1/Pratik/html/bem_problem.html

3/6

6/24/2014

bem_problem

end
end
end
% Calculation of Diagonal Entries of H by negative sum Method
for n = 1:8
for e= 1:8
if (n~=e)
H(n,n)=H(n,n)+H(n,e)*-1;
end
end
end
H

H=
0.2500
-0.0698
-0.0383
-0.0572
-0.0472
-0.0572
-0.0383
-0.0698

0
0.5000
0
-0.0847
-0.0631
-0.0766
-0.0631
-0.0847

-0.0383
-0.0698
0.2500
-0.0698
-0.0383
-0.0572
-0.0472
-0.0572

-0.0631
-0.0847
0
0.5000
0
-0.0847
-0.0631
-0.0766

-0.0472
-0.0572
-0.0383
-0.0698
0.2500
-0.0698
-0.0383
-0.0572

-0.0631
-0.0766
-0.0631
-0.0847
0
0.5000
0
-0.0847

-0.0383
-0.0572
-0.0472
-0.0572
-0.0383
-0.0698
0.2500
-0.0698

0
-0.0847
-0.0631
-0.0766
-0.0631
-0.0847
0
0.5000

*********************************
CALCULATION OF G MATRIX
for n = 1:8
for e= 1:8
if (e~=8)
x_x = coord_nodes(e,1)*(1-eta)*0.5 + coord_nodes(e+1,1)*(1+eta)*0.5*1;
x_y = coord_nodes(e,2)*(1-eta)*0.5 + coord_nodes(e+1,2)*(1+eta)*0.5*1;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
mag = ((x_x-xi_x)^2 + (x_y-xi_y)^2)^0.5;
if subs(mag,-1)==0
feta1 = (1-eta)/(2*pi);
for i =1:3
G(n,2*e-1) = G(n,2*e-1) + subs(feta1,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end
feta2 = (eta)/2/pi;
for i =1:3
G(n,2*e) = G(n,2*e) + subs(feta2,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end

elseif subs(mag,1)==0
feta1 = (eta)/(2*pi);
for i =1:3
G(n,2*e-1) = G(n,2*e-1) + subs(feta1,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end
feta2 = (1-eta)/(2*pi);
for i =1:3
G(n,2*e) = G(n,2*e) + subs(feta2,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end

else
feta1 = (-1/(8*pi))*(1-eta)*log(mag);
for i =1:4
file:///G:/sem2/BEM_PRJPT1/Pratik/html/bem_problem.html

4/6

6/24/2014

bem_problem

G(n,2*e-1) = G(n,2*e-1) + subs(feta1,eta,GP4_xi(i))* GP4_w(i);


end
feta2 = (-1/(8*pi))*(1+eta)*log(mag);
for i =1:4
G(n,2*e) = G(n,2*e) + subs(feta2,eta,GP4_xi(i))* GP4_w(i);
end
end
else
x_x = coord_nodes(e,1)*(1-eta)*0.5 + coord_nodes(1,1)*(1+eta)*0.5*1;
x_y = coord_nodes(e,2)*(1-eta)*0.5 + coord_nodes(1,2)*(1+eta)*0.5*1;
xi_x = coord_nodes(n,1);
xi_y = coord_nodes(n,2);
mag = ((x_x-xi_x)^2 + (x_y-xi_y)^2)^0.5;
if subs(mag,-1)==0
feta1 = (1-eta)/(2*pi);
for i =1:3
G(n,2*e-1) = G(n,2*e-1) + subs(feta1,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end
feta2 = (eta)/2/pi;
for i =1:3
G(n,2*e) = G(n,2*e) + subs(feta2,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end
% for loop for evaluating integral
elseif subs(mag,1)==0
feta1 = (eta)/(2*pi);
for i =1:3
G(n,2*e-1) = G(n,2*e-1) + subs(feta1,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end
feta2 = (eta)/2/pi;
for i =1:3
G(n,2*e) = G(n,2*e) + subs(feta2,eta,WS_GP3_xi(i))* WS_GP3_w(i);
end
% for loop for evaluating integral
else
feta1 = (-1/(8*pi))*(1-eta)*log(mag);
for i =1:4
G(n,2*e-1) = G(n,2*e-1) + subs(feta1,eta,GP4_xi(i))* GP4_w(i);
end
feta2 = (-1/(8*pi))*(1+eta)*log(mag);
for i =1:4
G(n,2*e) = G(n,2*e) + subs(feta2,eta,GP4_xi(i))* GP4_w(i);
end
end
end
end
end
G
figure(1)
hold off;

G=
Columns 1 through 9
0.1194
0.0398
-0.0398
-0.0526

0.0398
0.1194
-0.0217
-0.0404

-0.0217
0.1194
0.0398
-0.0154

file:///G:/sem2/BEM_PRJPT1/Pratik/html/bem_problem.html

-0.0398
0.0398
0.1194
-0.0056

-0.0567
-0.0056
0.1194
0.0398

-0.0598
-0.0154
0.0398
0.1194

-0.0699
-0.0404
-0.0217
0.1194

-0.0762
-0.0526
-0.0398
0.0398

-0.0762
-0.0598
-0.0567
-0.0056
5/6

6/24/2014

bem_problem

-0.0762
-0.0598
-0.0567
-0.0056

-0.0699
-0.0567
-0.0598
-0.0154

-0.0598
-0.0567
-0.0699
-0.0404

-0.0567
-0.0598
-0.0762
-0.0526

-0.0398
-0.0526
-0.0762
-0.0598

-0.0217
-0.0404
-0.0699
-0.0567

0.0398
-0.0154
-0.0598
-0.0567

-0.0398
-0.0526
-0.0762
-0.0598
-0.0567
-0.0056
0.1194
0.0398

-0.0217
-0.0404
-0.0699
-0.0567
-0.0598
-0.0154
0.0398
0.1194

0.0398
-0.0154
-0.0598
-0.0567
-0.0699
-0.0404
-0.0217
0.1194

0.0398
-0.0056
-0.0567
-0.0598
-0.0762
-0.0526
-0.0398
0.0398

0.1194
-0.0056
-0.0567
-0.0598

0.1194
0.0398
-0.0398
-0.0526

Columns 10 through 16
-0.0699
-0.0567
-0.0598
-0.0154
0.0398
0.1194
-0.0217
-0.0404

-0.0598
-0.0567
-0.0699
-0.0404
-0.0217
0.1194
0.0398
-0.0154

-0.0567
-0.0598
-0.0762
-0.0526
-0.0398
0.0398
0.1194
-0.0056

Published with MATLAB 7.8

file:///G:/sem2/BEM_PRJPT1/Pratik/html/bem_problem.html

6/6

You might also like