MATLAB Answers

How to turn potential functions into a graph in FEM fluid question ?

2 views (last 30 days)
Anilcan Taner
Anilcan Taner on 24 Dec 2019
I have a problem about confined flow around cylinder. I have to solve them using finite element method and represent graphical result with that.
My question seems like ;
and the code i wrote for it looks like this;
clear
clc
%Ak��kanlar Mekani�inde Sonlu Elemanlar Metodu
%[K][q]=[P]
%[K]:characteristic matrix
%[q]:potential function
%[P]:characteristic vector
%Sonlu Elemanlar ve Koordinatlar�n Girilmesi
elementNodes=[5 1 6;6 1 2;6 2 7;7 2 3;7 3 4;7 4 8;5 6 9;9 6 10;10 6 11;11 6 12;6 7 12;7 12 13;7 8 13]
nodeCoordinates=[0 8;5 8;9.17 8;12 8;0 4;5 4;9.17 5.5;12 5.5;0 0;5 0;8 0;9.17 2.83;12 4]
numberElements=size(elementNodes,1)
numberNodes=size(nodeCoordinates,1)
%Her Bir Element Ait Alan�n Hesaplanmas�%
for i=1:numberElements
xi= nodeCoordinates((elementNodes(i,1)),1);
xj= nodeCoordinates((elementNodes(i,2)),1);
xk= nodeCoordinates((elementNodes(i,3)),1);
yi= nodeCoordinates((elementNodes(i,1)),2);
yj= nodeCoordinates((elementNodes(i,2)),2);
yk= nodeCoordinates((elementNodes(i,3)),2);
ck(i) = xj - xi;
ci(i) = xk - xj;
cj(i) = xi - xk;
bi(i) = yj - yk;
bj(i) = yk - yi;
bk(i) = yi - yj;
Ae(i) = abs(0.5 * (xi * yj + xj * yk + xk * yi - xi * yk - xj * yi - xk * yj));
end
%Characteristic Matrix (Stiffness Matrix) Olu�turulmas�
ch_matrix=zeros(numberElements)
x=zeros(3)
for k=1:numberElements
x1=(1/(4*Ae(k)))*((bi(k)^2)+(ci(k)^2))
x2=(1/(4*Ae(k)))*((bi(k)*bj(k))+(ci(k)*cj(k)))
x3=(1/(4*Ae(k)))*((bi(k)*bk(k))+(ci(k)*ck(k)))
x4=x2
x5=(1/(4*Ae(k)))*((bj(k)^2)+(cj(k)^2))
x6=(1/(4*Ae(k)))*((bj(k)*bk(k))+(cj(k)*ck(k)))
x7=x3
x8=x6
x9=(1/(4*Ae(k)))*((bk(k)^2)+(ck(k)^2))
a=elementNodes(k,:)
for i=1:3
for j=1:3
x=[x1 x2 x3;x4 x5 x6;x7 x8 x9]
ch_matrix(a(i),a(j))=ch_matrix(a(i),a(j))+x(i,j)
end
end
end
%Characteristic Vector [P] i�in s�n�r ko�ullar�
P=zeros(numberElements,1)
P(1)=2
P(5)=4
P(9)=2
%Potential Function [q], s�n�r ko�ullar�na g�re node 4,8 ve 13 de s�f�r
%de�eri alacakt�r.Bu nedenle characteris matrix ve characteristic vectorden
%4.,8. ve 13. sat�r ve s�t�nlar silinerek ��z�m ger�ekle�tirilmelidir.
K=ch_matrix
b=P
K(13,:)=[]
K(8,:)=[]
K(4,:)=[]
K(:,13)=[]
K(:,8)=[]
K(:,4)=[]
b(13,:)=[]
b(8,:)=[]
b(4,:)=[]
%Ters Matris metodu ile ��z�m ger�ekle�tirilmi�tir.
z=inv(K)*b
%potential function[q] 4., 8. ve 13. de�erlerine 0 atanmas�
for i=1:numberElements
if i<=3
q(i,1)=z(i)
elseif i==4
q(i,1)=0
elseif i>4 && i<=7
q(i,1)=z(i-1)
elseif i==8
q(i,1)=0
elseif i>8 && i<=12
q(i,1)=z(i-2)
else
q(i,1)=0
end
end
Result of potential function is;
q =
14.9004
9.6754
4.4818
0
15.0443
10.0107
4.7838
0
15.2314
10.5237
8.4687
6.2288
0
for points 1,2,3...,13
I need to represent graphic like the code in the attachment.(Give input V_i=1 and G=0)
I'm asking for opinions or ideas, I know that it would be too much to ask a direct solution.

  0 Comments

Sign in to comment.

Answers (0)


Translated by