Anda di halaman 1dari 13

10/31/14 4:12 PM

U:\FE.m

function varargout = FE(varargin)


% FE MATLAB code for FE.fig
%
FE, by itself, creates a new FE or raises the existing
%
singleton*.
%
%
H = FE returns the handle to a new FE or the handle to
%
the existing singleton*.
%
%
FE('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in FE.M with the given input arguments.
%
%
FE('Property','Value',...) creates a new FE or raises the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before FE_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to FE_OpeningFcn via varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help FE
% Last Modified by GUIDE v2.5 30-Oct-2014 09:52:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @FE_OpeningFcn, ...
'gui_OutputFcn', @FE_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before FE is made visible.


function FE_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB

1 of 13

10/31/14 4:12 PM
% handles
% varargin

U:\FE.m

structure with handles and user data (see GUIDATA)


command line arguments to FE (see VARARGIN)

% Choose default command line output for FE


handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes FE wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = FE_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in triangular.


function triangular_Callback(hObject, eventdata, handles)
% hObject
handle to triangular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of triangular

% --- Executes on button press in quadrilateral.


function quadrilateral_Callback(hObject, eventdata, handles)
% hObject
handle to quadrilateral (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of quadrilateral

% --- Executes on button press in brick.


function brick_Callback(hObject, eventdata, handles)
% hObject
handle to brick (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of brick

2 of 13

10/31/14 4:12 PM

U:\FE.m

% --- Executes on button press in ok.


function ok_Callback(hObject, eventdata, handles)
% hObject
handle to ok (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
status_1 = get(handles.triangular,'value');
status_2 = get(handles.quadrilateral,'value');
status_3 = get(handles.brick,'value');
if (status_1==1 & status_2==0 & status_3==0)
clear all
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Traingular Element Selected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
filename_1 = 'arbitary_coordinates.dat';
arb_cor=csvread(filename_1);
disp('Arbitary coordinates')
arb_cor_t=zeros(2,3);
for i=1:2
for j=1:3
arb_cor_t(i,j)=arb_cor(i,j);
end
end
arb_cor_t
filename_2 = 'arbitary_velocities.dat';
arb_velo=csvread(filename_2);
disp('Arbitary velocities')
arb_velo_t=zeros(2,3);
for i=1:2
for j=1:3
arb_velo_t(i,j)=arb_velo(i,j);
end
end
arb_velo_t
filename_3 = 'arbitary_stresses.dat';
arb_stress=csvread(filename_3);
disp('Arbitary stresses')
arb_streses_t=zeros(2,2);
for i=1:2
for j=1:2
arb_streses_t(i,j)=arb_stress(i,j);
end
end
arb_streses_t
X1=arb_cor_t(1,1);

3 of 13

10/31/14 4:12 PM

U:\FE.m

Y1=arb_cor_t(2,1);
X2=arb_cor_t(1,2);
Y2=arb_cor_t(2,2);
X3=arb_cor_t(1,3);
Y3=arb_cor_t(2,3);
Ma=zeros(3,3);
Ma(1,1)=Y2-Y3;
Ma(1,2)=X3-X2;
Ma(1,3)=X2*Y3-X3*Y2;
Ma(2,1)=Y3-Y1;
Ma(2,2)=X1-X3;
Ma(2,3)=X3*Y1-X1*Y3;
Ma(3,1)=Y1-Y2;
Ma(3,2)=X2-X1;
Ma(3,3)=X1*Y2-X2*Y1;

%Define A0 for triangular element


A0=(X3-X2)*(Y1-Y2)-(X1-X2)*(Y3-Y2);
C=zeros(3,1);
syms X Y
C=[X;Y;1];
%Define mapping to zeta
% Zeta=zeros(3,1);
NI=(1/2*A0)*Ma*C;
N_1= NI(1,1);
N_2= NI(2,1);
N_3= NI(3,1);
%Calculating B matrix
B_Matrix=zeros(3,2);
B_Matrix(1,1)=(Y2-Y3)/(2*A0);
B_Matrix(1,2)=(X3-X2)/(2*A0);
B_Matrix(2,1)=(Y3-Y1)/(2*A0);
B_Matrix(2,2)=(X1-X3)/(2*A0);
B_Matrix(3,1)=(Y1-Y2)/(2*A0);
B_Matrix(3,2)=(X2-X1)/(2*A0);
disp('B matrix in matrix notation')
B_Matrix
%B matrix in Voigt notation
B_Voigt=zeros(3,6);
B_Voigt(1,1)=(Y2-Y3)/(2*A0);
B_Voigt(1,2)=0;
B_Voigt(1,3)=(Y3-Y1)/(2*A0);

4 of 13

10/31/14 4:12 PM

U:\FE.m

B_Voigt(1,4)=0;
B_Voigt(1,5)=(Y1-Y2)/(2*A0);
B_Voigt(1,6)=0;
B_Voigt(2,1)=0;
B_Voigt(2,2)=(X3-X2)/(2*A0);
B_Voigt(2,3)=0;
B_Voigt(2,4)=(X1-X3)/(2*A0);
B_Voigt(2,5)=0;
B_Voigt(2,6)=(X2-X1)/(2*A0);
B_Voigt(3,1)=(X3-X2)/(2*A0);
B_Voigt(3,2)=(Y2-Y3)/(2*A0);
B_Voigt(3,3)=(X1-X3)/(2*A0);
B_Voigt(3,4)=(Y3-Y1)/(2*A0);
B_Voigt(3,5)=(X2-X1)/(2*A0);
B_Voigt(3,6)=(Y1-Y2)/(2*A0);
disp('B matrix in voigt notation')
B_Voigt

%Velocity gradient in matrix notation


Lij=zeros(2,2);
disp('Rate of deformation in matrix in notation')
Lij=arb_velo_t*B_Matrix

%Velocity gradients in voigt notation


v_Ii_voigt=zeros(6,1);
v_Ii_voigt(1,1)=arb_velo_t(1,1);
v_Ii_voigt(2,1)=arb_velo_t(2,1);
v_Ii_voigt(3,1)=arb_velo_t(1,2);
v_Ii_voigt(4,1)=arb_velo_t(2,2);
v_Ii_voigt(5,1)=arb_velo_t(1,3);
v_Ii_voigt(6,1)=arb_velo_t(2,3);

disp('Rate of deformation matrix in voigt notation')


Li_voigt=zeros(3,1);
Li_voigt=B_Voigt*v_Ii_voigt

disp('Nodal forces in matrix notation')


Nodal_m=B_Matrix*arb_streses_t

%Nodal forces in voigt notation


disp('Nodal forces in voigt notation')

5 of 13

10/31/14 4:12 PM

U:\FE.m

6 of 13

nodal_v=zeros(6,1);
arb_stress_v= zeros(3,1);
arb_stress_v(1,1)=arb_streses_t(1,1);
arb_stress_v(2,1)=arb_streses_t(2,2);
arb_stress_v(3,1)=arb_streses_t(1,2);
arb_stress_v;
nodal_v= transpose(B_Voigt)*arb_stress_v

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of Triangular Element calculation


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif (status_1==0 & status_2==1 & status_3==0)
clear all
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Quadrilateral Element Selected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('Arbitary coordinates')
filename_1 = 'arbitary_coordinates.dat';
arb_cor=csvread(filename_1);
disp('Arbitary coordinates')
arb_cor_t=zeros(2,4);
for i=1:2
for j=1:4
arb_cor_t(i,j)=arb_cor(i,j);
end
end
arb_cor_t
filename_2 = 'arbitary_velocities.dat';
arb_velo=csvread(filename_2);
disp('Arbitary velocities')
arb_velo_t=zeros(2,4);
for i=1:2
for j=1:4
arb_velo_t(i,j)=arb_velo(i,j);
end
end
arb_velo_t
filename_3 = 'arbitary_stresses.dat';
arb_stress=csvread(filename_3);
disp('Arbitary stresses')

10/31/14 4:12 PM

U:\FE.m

arb_streses_t=zeros(2,2);
for i=1:2
for j=1:2
arb_streses_t(i,j)=arb_stress(i,j);
end
end
arb_streses_t

X1=arb_cor_t(1,1);
Y1=arb_cor_t(2,1);
X2=arb_cor_t(1,2);
Y2=arb_cor_t(2,2);
X3=arb_cor_t(1,3);
Y3=arb_cor_t(2,3);
X4=arb_cor_t(1,4);
Y4=arb_cor_t(2,4);
syms z n X Y ;
N1=(1-z)*(1-n)/4;
dN1z= diff(N1, z, 1);
dN1n= diff(N1, n, 1);
N2=(1+z)*(1-n)/4;
dN2z= diff(N2, z, 1);
dN2n= diff(N2, n, 1);
N3=(1+z)*(1+n)/4;
dN3z= diff(N3, z, 1);
dN3n= diff(N3, n, 1);
N4=(1-z)*(1+n)/4;
dN4z= diff(N4, z, 1);
dN4n= diff(N4, n, 1);
%zeta and eta in local coordinates
X=N1*X1+N2*X2+N3*X3+N4*X4;
Y=N1*Y1+N2*Y2+N3*Y3+N4*Y4;

J=zeros(2,2);
J=[diff(X, z, 1),diff(X, n, 1);diff(Y, z, 1),diff(Y, n, 1)];
J_inv=inv(J);
detJ=det(J);
syms z n
B_Matrix = J_inv*[dN1z,dN2z,dN3z,dN4z;dN1n,dN2n,dN3n,dN4n];
Lij= B_Matrix*transpose(arb_velo_t);

7 of 13

10/31/14 4:12 PM

U:\FE.m

%B and Lij values at center of the parant element


z=0;
n=0;
B_matrix_at_center=eval(B_Matrix)
Rate_of_deformation_matrix_at_center=eval(Lij)
%nodal force calculation
B_Matrix_T=transpose(B_Matrix);
Int_B=zeros(4,2);
for k=1:4
for l=1:2
z=-1/sqrt(3);
n=-1/sqrt(3);
Int_B(k,l)=Int_B(k,l)+(eval((detJ)*B_Matrix_T(k,l)));
z=1/sqrt(3);
n=-1/sqrt(3);
Int_B(k,l)=Int_B(k,l)+eval((detJ)*B_Matrix_T(k,l));
z=-1/sqrt(3);
n=1/sqrt(3);
Int_B(k,l)=Int_B(k,l)+eval((detJ)*B_Matrix_T(k,l));
z=1/sqrt(3);
n=1/sqrt(3);
Int_B(k,l)=Int_B(k,l)+eval((detJ)*B_Matrix_T(k,l));
end
end
Nodal_forces_m=zeros(4,2);
Nodal_forces_m=Int_B*arb_streses_t;
Nodal_forces_in_Quadilateral_element_in_matrix_form=Nodal_forces_m

%vogit notation
%arbitary velocity
arb_velo_v=zeros(8,1);
for i=1:4
arb_velo_v(2*i-1,1)=arb_velo_t(1,i);
arb_velo_v(2*i,1)=arb_velo_t(2,i);
end
for i=1:4
B_Voigt(1,2*i-1)=B_Matrix(1,i);
B_Voigt(1,2*i)= 0;
B_Voigt(2,2*i)=B_Matrix(2,i);
B_Voigt(2,2*i-1)= 0;
B_Voigt(3,2*i-1)=B_Matrix(2,i);
B_Voigt(3,2*i)= 0;
end
B_Voigt;

8 of 13

10/31/14 4:12 PM

U:\FE.m

9 of 13

z=0;
n=0;
B_matrix_in_Voigt_notation_at_center_of_element=eval(B_Voigt)

Li_voigt=B_Voigt*arb_velo_v;
z=0;
n=0;
Rate_of_deformation_matrix_at_center_voigt_form=eval(Li_voigt)
%nodal forces in voigt form
Nodal_forces_v=zeros(8,1);
for i=1:4
Nodal_forces_v(2*i-1,1)=Nodal_forces_m(i,1);
Nodal_forces_v(2*i,1)=Nodal_forces_m(i,2);
end
Nodal_forces_in_Quadilateral_element_in_voigt_form=Nodal_forces_v
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of Quadrilateral Element calculation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif (status_1==0 & status_2==0 & status_3==1)
clear all
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 Nodal Brick Element Selected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('Arbitary coordinates')
filename_1 = 'arbitary_coordinates.dat';
arb_cor=csvread(filename_1)
disp('Arbitary velocities')
filename_2 = 'arbitary_velocities.dat';
arb_velo=csvread(filename_2);
disp('Arbitary stresses')
filename_3 = 'arbitary_stresses.dat';
arb_stress=csvread(filename_3);
X1=arb_cor(1,1);
Y1=arb_cor(2,1);
Z1=arb_cor(3,1);
X2=arb_cor(1,2);
Y2=arb_cor(2,2);
Z2=arb_cor(3,2);

10/31/14 4:12 PM

U:\FE.m

X3=arb_cor(1,3);
Y3=arb_cor(2,3);
Z3=arb_cor(3,3);
X4=arb_cor(1,4);
Y4=arb_cor(2,4);
Z4=arb_cor(3,4);
X5=arb_cor(1,5);
Y5=arb_cor(2,5);
Z5=arb_cor(3,5);
X6=arb_cor(1,6);
Y6=arb_cor(2,6);
Z6=arb_cor(3,6);
X7=arb_cor(1,7);
Y7=arb_cor(2,7);
Z7=arb_cor(3,7);
X8=arb_cor(1,8);
Y8=arb_cor(2,8);
Z8=arb_cor(3,8);
arb_velo=zeros(3,8);
arb_velo = [1,2,3,6,8,12,16,5;5,6,8,10,5,6,7,8;14,12,26,19,18,36,14,10];
arb_stress=zeros(3,3);
arb_stress = [1000,5000,2500;5000,4500,6000;2500,6000,7000];
syms z n s X Y Z;
N1=(1-z)*(1-n)*(1-s)/8;
dN1z= diff(N1, z, 1)/8;
dN1n= diff(N1, n, 1)/8;
dN1s= diff(N1, s, 1)/8;
N2=(1+z)*(1-n)*(1-s)/8;
dN2z= diff(N2, z, 1)/8;
dN2n= diff(N2, n, 1)/8;
dN2s= diff(N2, s, 1)/8;
N3=(1+z)*(1+n)*(1-s)/8;
dN3z= diff(N3, z, 1)/8;
dN3n= diff(N3, n, 1)/8;
dN3s= diff(N3, s, 1)/8;
N4=(1-z)*(1+n)*(1-s)/8;
dN4z= diff(N4, z, 1)/8;
dN4n= diff(N4, n, 1)/8;
dN4s= diff(N4, s, 1)/8;

10 of 13

10/31/14 4:12 PM

U:\FE.m

11 of 13

N5=(1-z)*(1-n)*(1+s)/8;
dN5z= diff(N5, z, 1)/8;
dN5n= diff(N5, n, 1)/8;
dN5s= diff(N5, s, 1)/8;
N6=(1+z)*(1-n)*(1+s)/8;
dN6z= diff(N6, z, 1)/8;
dN6n= diff(N6, n, 1)/8;
dN6s= diff(N6, s, 1)/8;
N7=(1+z)*(1+n)*(1+s)/8;
dN7z= diff(N7, z, 1)/8;
dN7n= diff(N7, n, 1)/8;
dN7s= diff(N7, s, 1)/8;
N8=(1-z)*(1+n)*(1+s)/8;
dN8z= diff(N8, z, 1)/8;
dN8n= diff(N8, n, 1)/8;
dN8s= diff(N8, s, 1)/8;

%zeta and eta in local coordinates


X=N1*X1+N2*X2+N3*X3+N4*X4+N5*X5+N6*X6+N7*X7+N8*X8;
Y=N1*Y1+N2*Y2+N3*Y3+N4*Y4+N5*Y5+N6*Y6+N7*Y7+N8*Y8;
Z=N1*Z1+N2*Z2+N3*Z3+N4*Z4+N5*Z5+N6*Z6+N7*Z7+N8*Z8;
J=zeros(2,2);
J=[diff(X, z, 1),diff(X, n, 1),diff(X, s, 1);diff(Y, z, 1),diff(Y, n, 1),diff(Y, s, 1);
diff(Z, z, 1),diff(Z, n, 1),diff(Z, s, 1)];
J_inv=inv(J);
B_Matrix = J_inv*[dN1z,dN2z,dN3z,dN4z,dN5z,dN6z,dN7z,dN8z;dN1n,dN2n,dN3n,dN4n,dN5n,dN6n,
dN7s,dN8s;dN1s,dN2s,dN3s,dN4s,dN5s,dN6s,dN7s,dN8s];
Lij= B_Matrix*transpose(arb_velo);
%B and Lij values at center of the parant element
z=0;
n=0;
s=0;
B_matrix_at_center=eval(B_Matrix)
Rate_of_deformation_matrix_at_center=eval(Lij)
% intergration for nodal force calculation
B_Matrix_T=transpose(B_Matrix);
for k=1:8
for l=1:3
Int_B(k,l)=det(J)*B_Matrix_T(k,l);
end

10/31/14 4:12 PM

U:\FE.m

end
nodalf=Int_B*arb_stress;
z=0;
n=0;
s=0;
Nodal_forces_in_brick_element_in_matrix_form=eval(nodalf)

%Voigt form
arb_velo_v=zeros(24,1);
for i=1:8
arb_velo_v(3*i-2,1)=arb_velo(1,i);
arb_velo_v(3*i-1,1)=arb_velo(2,i);
arb_velo_v(3*i,1)=arb_velo(3,i);
end
for i=1:8
B_Voigt(1,3*i-2)=B_Matrix(1,i);
B_Voigt(1,3*i-1)= 0;
B_Voigt(1,3*i)= 0;
B_Voigt(2,3*i-1)=B_Matrix(2,i);
B_Voigt(2,3*i-2)= 0;
B_Voigt(2,3*i)= 0;
B_Voigt(3,3*i)=B_Matrix(3,i);
B_Voigt(2,3*i-2)= 0;
B_Voigt(1,3*i-1)= 0;
B_Voigt(4,3*i)=B_Matrix(2,i);
B_Voigt(4,3*i-2)= 0;
B_Voigt(4,3*i-1)= 0;
B_Voigt(5,3*i-1)=B_Matrix(1,i);
B_Voigt(5,3*i-2)= 0;
B_Voigt(5,3*i)= 0;
B_Voigt(6,3*i-1)=B_Matrix(1,i);
B_Voigt(6,3*i-2)= 0;
B_Voigt(6,3*i)= 0;
end
B_Voigt;
Li_voigt=B_Voigt*arb_velo_v;
z=0;
n=0;
s=0;
B_voigt_form_at_center_of_parent_element=eval(B_Voigt)
Rate_of_deformation_matrix_at_center_voigt_form=eval(Li_voigt)

12 of 13

10/31/14 4:12 PM

U:\FE.m

%nodel forces in voigt form


for i=1:8
Nodal_forces_v(3*i-2,1)=nodalf(i,1);
Nodal_forces_v(3*i-1,1)=nodalf(i,2);
Nodal_forces_v(3*i,1)=nodalf(i,3);
end
z=0;
n=0;
s=0;
Nodal_forces_in_brick_element_in_voigt_form=eval(Nodal_forces_v)
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of 8 nodal brick Element calculation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
else
set(handles.text1,'string','Select one Element at a time')
end

13 of 13

Anda mungkin juga menyukai