0% found this document useful (0 votes)
20 views4 pages

Vadym - Kuleba2023.sce 2

The document contains MATLAB functions for finite element analysis, specifically for bar elements, including stiffness matrix calculation, strain extraction, and system solving. It defines element properties, constructs the global stiffness matrix, applies boundary conditions, and solves for displacements and internal forces. The code also includes an example with defined element connectivity and properties, demonstrating the assembly and solution process.

Uploaded by

fcnpdxzkdt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Vadym - Kuleba2023.sce 2

The document contains MATLAB functions for finite element analysis, specifically for bar elements, including stiffness matrix calculation, strain extraction, and system solving. It defines element properties, constructs the global stiffness matrix, applies boundary conditions, and solves for displacements and internal forces. The code also includes an example with defined element connectivity and properties, demonstrating the assembly and solution process.

Uploaded by

fcnpdxzkdt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

function [Ke]=bar2e(ex,ey,ep)

E=ep(1); A=ep(2);

b=[ ex(2)-ex(1); ey(2)-ey(1) ];


L=sqrt(b'*b);

Kle=E*A/L*[ 1 -1;
-1 1];

n=b'/L;
[t1,t2]=size(n)
G=[ n zeros(t1,t2);
zeros(t1,t2) n ];

Ke=G'*Kle*G;
endfunction

function [es]=bar2s(ex,ey,ep,ed)
E=ep(1); A=ep(2);

b=[ ex(2)-ex(1); ey(2)-ey(1) ];


L=sqrt(b'*b);

Kle=E*A/L*[1 -1 ;
-1 1 ];

n=b'/L; G=[ n zeros(size(n));


zeros(size(n)) n ];

u=ed';
N=E*A/L*[-1 1]*G*u;
es=N;
endfunction

function [ed]=extract(edof,a)
[nie,n]=size(edof);

t=edof(:,2:n);

for i = 1:nie
ed(i,1:(n-1))=a(t(i,:))';
end

endfunction

function [d,Q]=solveq(K,f,bc)
[nargout,nargin] = argn(0);
ieee(1)

if nargin==2 ;
d=K\f ;
elseif nargin==3;
[nd,nd]=size(K);
fdof=[1:nd]';

dd=size(fdof);
d=zeros(dd(1),dd(2))
Q=zeros(dd(1),dd(2));
pdof=bc(:,1);
dp=bc(:,2);
fdof(pdof)=[];

s=K(fdof,fdof)\(f(fdof)-K(fdof,pdof)*dp);

d(pdof)=dp;
d(fdof)=s;
end
Q=K*d-f;

endfunction

function [K,f] = assem(edof,K,Ke,f,fe)


[nargout,nargin] = argn(0)

ieee(1)

[nie,n] = size(edof);
t = edof(:,2:n);
for i = 1:nie;
K(t(i,:),t(i,:)) = K(t(i,:),t(i,:))+Ke;
if nargin==5 then
f(t(i,:))=f(t(i,:))+fe;
end;
end;

endfunction

Edof = [1 1 2 11 12;
2 11 12 9 10;
3 9 10 7 8;
4 7 8 5 6;
5 5 6 3 4;
6 3 4 1 2;
7 1 2 9 10;
8 11 12 3 4;
9 3 4 7 8;
10 9 10 5 6];

K = zeros (12,12)
f = zeros (12,1)

f(12,1) = -1e3
f(10,1)=-10e3
f(8,1)=-8e3

E=2.0e11;
A1=6.0e-4;
A2=3.0e-4;
A3=10.0e-4;
ep1=[E A1];
ep2=[E A2];
ep3=[E A3];
ep4=[E A3];
ep5=[E A3];
ep6=[E A3];
ep7=[E A3];
ep8=[E A3];
ep9=[E A3];
ep10=[E A3];

ex1=[0 0]; ex2=[0 5];


ex3=[5 10];ex4=[10 10];ex5=[5 10];ex6=[0 5];ex7=[0 5];ex8=[0 5];
ex9=[5 10]; ex10=[5 10]
ey1=[0 6.5]; ey2=[6.5 6.5];
ey3=[6.5 6.5];ey4=[0 6.5];ey5=[0 0];ey6=[0 0];ey7=[0 6.5];ey8=[0 6.5];
ey9=[0 6.5]; ey10=[0 6.5]

Ke1=bar2e(ex1, ey1, ep1);


Ke2=bar2e(ex2, ey2, ep2);
Ke3=bar2e(ex3, ey3, ep3);
Ke4=bar2e(ex4, ey4, ep4);
Ke5=bar2e(ex5, ey5, ep5);
Ke6=bar2e(ex6, ey6, ep6);
Ke7=bar2e(ex7, ey7, ep7);
Ke8=bar2e(ex8, ey8, ep8);
Ke9=bar2e(ex9, ey9, ep9);
Ke10=bar2e(ex10, ey10, ep10);

K=assem(Edof(1, : ), K, Ke1);
K=assem(Edof(2, : ), K, Ke2);
K=assem(Edof(3, : ), K, Ke3);
K=assem(Edof(4, : ), K, Ke4);
K=assem(Edof(5, : ), K, Ke5);
K=assem(Edof(6, : ), K, Ke6);
K=assem(Edof(7, : ), K, Ke7);
K=assem(Edof(8, : ), K, Ke8);
K=assem(Edof(9, : ), K, Ke9);
K=assem(Edof(10, : ), K, Ke10);

bc=[1 0 2 0 6 0 50 0];

[a, r]=solveq(K, f, bc)

ed1=extract(Edof(1, : ), a);
N1=bar2s(ex1, ey1, ep1, ed1)

ed2=extract(Edof(2, : ), a);
N2=bar2s(ex2, ey2, ep2, ed2)

ed3=extract(Edof(3, : ), a);
N3=bar2s(ex3, ey3, ep3, ed3)

ed4=extract(Edof(4, : ), a);
N4=bar2s(ex4, ey4, ep4, ed4)

ed5=extract(Edof(5, : ), a);
N5=bar2s(ex5, ey5, ep5, ed5)

ed6=extract(Edof(6, : ), a);
N6=bar2s(ex6, ey6, ep6, ed6)
ed7=extract(Edof(7, : ), a);
N7=bar2s(ex7, ey7, ep7, ed7)

ed8=extract(Edof(8, : ), a);
N8=bar2s(ex8, ey8, ep8, ed8)

ed9=extract(Edof(9, : ), a);
N9=bar2s(ex9, ey9, ep9, ed9)

ed10=extract(Edof(10, : ), a);
N10=bar2s(ex10, ey10, ep10, ed10)

You might also like