SlideShare a Scribd company logo
Finite Element Techniques I: FINAL PROJECT
Due on Wednesday, December 14, 2016
Report and Manual for code
Ebenesh Rabiraj
1
Finite Element Techniques I (Report and Manual for code)
Contents
Problem statement 3
Questions to answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Ansys Implementation 4
General procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Extract files required for MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Sample input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Matlab Implementation 8
T3 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Q4 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Results 11
T3 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Coarse mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Medium mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Very fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Q4 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Coarse mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Medium mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Very fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Discussion 21
Convergence Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Error Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Code 23
How to run it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Page 2 of 29
Finite Element Techniques I (Report and Manual for code)
Problem statement
The figure above represents a simply supported beam with the following given conditions,
l = 20m
h = 2m
w = 2000N/m
ν = 0.3
E = 2e11 Pa
Questions to answer
• Use Ansys Q4 element to analyze a plane-stress beam.
• In the second part of this project, you will use the matlab program based on linear triangular element
(T3 element) solve the same problem. You need to modify the code so that it can input the triangular
mesh generated from ANSYS. The best way is to create an input file that contains all the nodal and
connectivity information and let you code read it.
• In this part of the project, you will develop a matlab program using Q4 element for solving the same
problem. To implement this, you will need to modify the code on T3 to implement the formulation
discussed in class for Q4. To apply it to the problem above, you can generate the mesh using ANSYS
and then input them to your own code. Use 2 by 2 Gauss quadrature for evaluating the stiffness
matrix.
1) A short write-up on implementation (similar to the Ansys assignments)
2) The FEM model (mesh), and deformed shape and stress.
3) For each types of element, prescribe three types of mesh (coarse, fine and very fine) densities. Compare
maximum deflection with the analytical solution and compute the error as a function of the mesh spacing
on a log-log scale plot.
4) Similar to 3), but compare the stress value σ xx at x= 0, y =h / 2 .
Page 3 of 29
Finite Element Techniques I (Report and Manual for code)
Ansys Implementation
General procedure
In the ansys implementation we follow the procedure given below keeping in mind that the version of Ansys
may be different from the ine I have used and there may be minor variations.
• Perferences
→ Structural
• Preprocessor
→ Element Type→ Add/Edit/Delete→ Add→ Solid→ Quad 4 node 182
→ Material Properties→ material models → Structural→ Linear→ Elastic→ Isotropic
→ EX=2e11
→ PRXY=0.3
→ Modelling→ Create→ Areas→ Rectangle → By 2 Corners
→ WP X→ -20
→ WP Y→ -1
→ Width→ 40
→ Height→ 2
→ Meshing→ MeshTool
→ Check the smart size button
→ Set the slider to,
→ 9→ coarse
→ 6→ medium
→ 4→ fine
→ 2→ very fine
→ Set Mesh to Area
→ Select the shape as tri
→ Click Mesh
• Solution
→ Define Loads→ → Apply→ Structural
→ Displacement
→ Select node(-20,-1)→ UX,UY
→ Select node(20,-1)→ UY
→ Pressure→ Select the upper nodes along y=1→ Constant value=2000
→ Solve→ Current LS→ OK
• General Postproc→ Plot Results (as and what is displayed)
Page 4 of 29
Finite Element Techniques I (Report and Manual for code)
Extract files required for MATLAB
The meshing of the given beam is done in Ansys and imported into MATLAB. For a sucessfull run, Ansys
will have to output 4 files
• NLIST.lis (Provides the Nodal coordinates)
• MAIN MENU⇒ List→ Nodes
• ELIST.lis (Provides the elements and the nodes in them)
• MAIN MENU⇒ List→ Elements→ on all nodes
• DLIST.lis (Provides the Nodal DOF)
• MAIN MENU⇒ List→ Loads→ DOF constraints → On all nodes
• SFLIS.lis (Provides the pressure applied on a surface with the constant load value across the nodes on
the surface)
• MAIN MENU⇒ List→ Loads→ Surfaces→ On all nodes
Sample input
The following input is generated by ansys for a T3 element with a coarse mesh. These files are imported
into the MATLAB main program through the code attached in an upcoming section.
INPUT to MATLAB
LIST ALL SELECTED NODES. DSYS= 0
SORT TABLE ON NODE NODE NODE
NODE X Y Z
1 -20.0000000000 -1.00000000000 0.00000000000
2 20.0000000000 -1.00000000000 0.00000000000
3 20.0000000000 1.00000000000 0.00000000000
4 -20.0000000000 1.00000000000 0.00000000000
5 -18.0000000000 -1.00000000000 0.00000000000
6 -14.2000000000 -1.00000000000 0.00000000000
7 -10.4000000000 -1.00000000000 0.00000000000
8 -6.60000000000 -1.00000000000 0.00000000000
9 -1.00000000000 -1.00000000000 0.00000000000
10 2.80000000000 -1.00000000000 0.00000000000
11 6.60000000000 -1.00000000000 0.00000000000
12 10.4000000000 -1.00000000000 0.00000000000
13 14.2000000000 -1.00000000000 0.00000000000
14 18.0000000000 -1.00000000000 0.00000000000
15 18.0000000000 1.00000000000 0.00000000000
16 14.2000000000 1.00000000000 0.00000000000
17 10.4000000000 1.00000000000 0.00000000000
18 6.60000000000 1.00000000000 0.00000000000
19 1.00000000000 1.00000000000 0.00000000000
20 -2.80000000000 1.00000000000 0.00000000000
NODE X Y Z
21 -6.60000000000 1.00000000000 0.00000000000
22 -10.4000000000 1.00000000000 0.00000000000
23 -14.2000000000 1.00000000000 0.00000000000
24 -18.0000000000 1.00000000000 0.00000000000
Page 5 of 29
Finite Element Techniques I (Report and Manual for code)
25 19.0000000000 0.00000000000 0.00000000000
26 -19.0000000000 0.00000000000 0.00000000000
INPUT to MATLAB
LIST ALL SELECTED ELEMENTS. LIST NODES
ELEM MAT TYP REL ESY SEC NODES
1 1 1 1 0 1 15 13 14 14
2 1 1 1 0 1 15 16 13 13
3 1 1 1 0 1 24 26 5 5
4 1 1 1 0 1 5 26 1 1
5 1 1 1 0 1 26 4 1 1
6 1 1 1 0 1 24 4 26 26
7 1 1 1 0 1 2 25 14 14
8 1 1 1 0 1 14 25 15 15
9 1 1 1 0 1 25 3 15 15
10 1 1 1 0 1 2 3 25 25
11 1 1 1 0 1 13 16 12 12
12 1 1 1 0 1 12 17 11 11
13 1 1 1 0 1 16 17 12 12
14 1 1 1 0 1 11 18 10 10
15 1 1 1 0 1 17 18 11 11
16 1 1 1 0 1 19 10 18 18
17 1 1 1 0 1 19 9 10 10
18 1 1 1 0 1 9 20 8 8
19 1 1 1 0 1 19 20 9 9
20 1 1 1 0 1 8 21 7 7
ELEM MAT TYP REL ESY SEC NODES
21 1 1 1 0 1 20 21 8 8
22 1 1 1 0 1 7 22 6 6
23 1 1 1 0 1 21 22 7 7
24 1 1 1 0 1 6 23 5 5
25 1 1 1 0 1 22 23 6 6
26 1 1 1 0 1 24 5 23 23
INPUT to MATLAB
LIST CONSTRAINTS FOR SELECTED NODES 1 TO 26 BY 1
CURRENTLY SELECTED DOF SET= UX UY
NODE LABEL REAL IMAG
1 UX 0.00000000 0.00000000
1 UY 0.00000000 0.00000000
2 UY 0.00000000 0.00000000
INPUT to MATLAB
Page 6 of 29
Finite Element Techniques I (Report and Manual for code)
The surface loads listed are the current database values and are not
necessarily the values corresponding to the current results data set.
Tabular boundary conditions, however, do list values corresponding to
the current results set.
LIST NODAL SURFACE LOAD PRES FOR ALL SELECTED NODES
ELEMENT LKEY FACE NODES REAL IMAGINARY
2 1 16 2000.00000 0.00000000
15 2000.00000 0.00000000
6 1 4 2000.00000 0.00000000
24 2000.00000 0.00000000
9 2 15 2000.00000 0.00000000
3 2000.00000 0.00000000
13 1 17 2000.00000 0.00000000
16 2000.00000 0.00000000
15 1 18 2000.00000 0.00000000
17 2000.00000 0.00000000
16 4 19 2000.00000 0.00000000
18 2000.00000 0.00000000
19 1 20 2000.00000 0.00000000
19 2000.00000 0.00000000
21 1 21 2000.00000 0.00000000
20 2000.00000 0.00000000
23 1 22 2000.00000 0.00000000
21 2000.00000 0.00000000
25 1 23 2000.00000 0.00000000
22 2000.00000 0.00000000
ELEMENT LKEY FACE NODES REAL IMAGINARY
26 4 24 2000.00000 0.00000000
23 2000.00000 0.00000000
Page 7 of 29
Finite Element Techniques I (Report and Manual for code)
Matlab Implementation
T3 element
From the implementation in the previous assignment, developed from the code provided, we have a working
code that helps us solve the problem by utilizing a T3 mesh element.
Figure 1: T3 element representing 3 nodes at the vertices of a triangle numbered in a clockwise direction.
Courtesy of University of Rome class notes
The T3 element is made up of 3 nodes at the vertices of a triangle numbered in a clockwise direction. Each
vertex has 2 degrees of freedom, a displacement in the the x and y direction [3]. This displacement can be
expressed as,
u
v
=
N1 0 N2 0 N3 0
0 N1 0 N2 0 N3



u1
v1
u2
v2
u3
v3



where N1, N2 and N3 are the shape functions. The stiffness matrix can be written as,
k = V
BT
EBdV
where,
B =


y23 0 y31 0 y12 0
0 x32 0 x13 0 x21
x32 y23 x13 y31 x21 y12


and,
xij = xi − xj; yij = yi − yj;
Keeping this in mind an algorithm can be developed where the stiffness matrix for the entire element
is calculated as a superpositioning of the elemental stiffness matrix. The integration is carried out in a
numerical fashion.
Page 8 of 29
Finite Element Techniques I (Report and Manual for code)
Q4 element
Figure 2: Q4 element representing 4 nodes at the vertices of a isoparametric quadrilateral. Courtesy of
University of colorado class notes.
The Q4 element is a 4 node isoparametric element. In the case of the Q4 element we need to use a different
strategy for numerical integration of the quadrature points. Gauss integration method is the most standard
practice followed [5]. The stiffness matrix is represented as,
k = A
BT
EBtdxdy
The stiffness matrix in this case is an 8x8 matrix. It is similar to that of the T3 element, however, the B
martix is modified as,
B =


1 0 0 0
0 0 0 1
0 1 1 0

 τ
τ




N1,ξ 0 N2,ξ 0 N3,ξ 0 N4,ξ 0
N1,η 0 N2,η 0 N3,η 0 N4,η 0
0 N1,ξ 0 N2,ξ 0 N3,ξ 0 N4,ξ
0 N1,η 0 N2,η 0 N3,η 0 N4,η




where τ = J−1
. J is the jacobian matrix that is represented as,
J =
N1,ξ N2,ξ N3,ξ N4,ξ
N1,η N2,η N3,η N4,η




x1 y1
x2 y2
x3 y3
x4 y4




Gauss quadrature based integration is used to integrate the stiffness equation. The 1D form of the gauss
quadrature is represented as,
k =
1
−1
F(ξ)dξ ≈
p
i=1 ωiF(ξi)
Page 9 of 29
Finite Element Techniques I (Report and Manual for code)
Here we can understand that p represents the sample points for integration, ωi represents the weights for
integration and ξ is the sample point within the interval [-1,1].
To extend this to the 2D formulation we reduce the integration to it’s canonical form to better show the
process. The integration is thus represented as,
k =
1
−1
1
−1
F(ξ, η)dξdη ≈
p1
i=1
p2
i=1 ωiωjF(ξi, ηj)
According to our question we intend to use the 2x2 gauss quadrature to evaluate the stiffness matrix.
Figure 3: 2D gauss product rule implementation where p=2 depicted over a straight-sided quadrilateral
region. The sample points are represented as black dots. Courtesy of University of colorado class notes.
The sample points as see in Figure 3 are taken in the counter clockwise direction from the segment in the 1st
quadrature as, [ 1√
3
, 1√
3
], [− 1√
3
, 1√
3
], [− 1√
3
, − 1√
3
], [ 1√
3
, − 1√
3
]. These values are plugged into the weight terms
ωi and ωj
The matlab code that has been developed does the calculations based on the nodal and elemental information
provided by the Ansys export as discussed earlier. The matlab script imports the desired nodal and elemental
information from the .lis files mentioned and arranges them in the required form.
NOTE: The code remains unchanged even if the mesh of the beam is changed. However, if the inputs such
as young’s modulus and poisson’s ratio need to be updated in the code if changed.
Page 10 of 29
Finite Element Techniques I (Report and Manual for code)
Results
This section shows teh results obtained from Matlab and Ansys. Every coarse mesh shows the deflection and
the stress induced on the beam. The deflection is exagerated such that the beam passes the bottom length
of the beam. The nodes of beam are represented as scatter points. The element data is not shown. The
stress plots are not separately shown, however the points where the stress is maximum and minimum are
plotted. The red node shows a point of maximum stress and the green shows the point of minimum stress.
Since the stress in the x direction is uniform and a much lower value, it is neglected. The stress in the y
direction is only depicted. The ansys plot shows the deflection and sheer stress or σxy.
T3 element
Coarse mesh
Page 11 of 29
Finite Element Techniques I (Report and Manual for code)
Page 12 of 29
Finite Element Techniques I (Report and Manual for code)
Medium mesh
Page 13 of 29
Finite Element Techniques I (Report and Manual for code)
Fine mesh
Page 14 of 29
Finite Element Techniques I (Report and Manual for code)
Very fine mesh
Page 15 of 29
Finite Element Techniques I (Report and Manual for code)
Q4 element
The Q4 plots are also similare to the T3. It is important to note that the in the Q4 analysis each quadrilateral
has a node of minimum stress and a node of maximum stress. Only the node that has the least stress in
depicted in the diagram. The coarse mesh, as will be seen in a later section is innacurate or shows that the
node of maximum stress and minimum stress to be the same. This point then spreads to more reasonable
points as the mesh densities increase.
Coarse mesh
Page 16 of 29
Finite Element Techniques I (Report and Manual for code)
Page 17 of 29
Finite Element Techniques I (Report and Manual for code)
Medium mesh
Page 18 of 29
Finite Element Techniques I (Report and Manual for code)
Fine mesh
Page 19 of 29
Finite Element Techniques I (Report and Manual for code)
Very fine mesh
Page 20 of 29
Finite Element Techniques I (Report and Manual for code)
Discussion
Convergence Study
There are many ways to conduct convergence analysis [1] [2]. In essence we need to show how the solution,
whether it be displacement or stress approaches the analytical solution. We have been provided the solution
for the displacements and the stresses in the question. First we will look at the convergence of the maximum
displacement of the beam using a coarsely meshed beam. This solution is plotted as a function of increasing
refinement in the mesh. In the figure below we analyse the mesh at 4 points. The curve is interpolated
between the 4 points for clarity. The bold dots show the actual measurements from the matlab code or
Ansys result.
As seen above the x axis represents the density of the mesh across the beam. The graph shows that over
the given range of meshes ranging from 26 nodes to 635 nodes the obtained results quickly move toward the
analytical solution. In the case of the displacement graph we can also see how well the Ansys and Matlab
simulations agree with each other at the different mesh points. Seeing how well the results match we can
move to the stress plot without checking the similarities between the Ansys and Matlab plots. Instead we
will focus on the change in accuracy over the mesh density range.
The stresses in these kind of beams are also an important factor to look at. A clear explanation of the
stresses in a beam is provided by David Roylance in his notes [4]. The stresses are calculated using the
analytical solution provided in the question and then the code is run to calculate the principal stress. The
output is then plotted as shown below.
Page 21 of 29
Finite Element Techniques I (Report and Manual for code)
The plots also shows an important trait of the T3 and Q4 elements. Both the T3 and the Q4 elements
converge at different rates. The T3 element as expected is more stiff. The stiffness causes a less accurate
deflection but is closer in terms of stress.
It is important to note that for both the stress and displacement convergence studies, the curve is a contin-
uous, interpolated curve drawn over the points derived from those in the Matlab/Ansys simulations.
Error Study
The error is nothing but a difference in the actual solution and the solution obtained using the finite element
techniques. The error plotted in a log log scale to enhance the nuances in the curve. The change in density
shows a steep decline in the error in the Q4 element although the T3 element remains a little stiffer as it
approaches the 0 error point.
Page 22 of 29
Finite Element Techniques I (Report and Manual for code)
Code
How to run it
• The first step is to determine the mesh density.
• The mesh density ranges from 1-4 which points the code to different directories to grab the input files.
• There are separate scripts that import the nodes, Elements, DOF and Nodal force information
mesh=4;
if mesh==1
5 mesh=’Q4coarse’;
end
if mesh==2
mesh=’Q4medium’;
end
10 if mesh==3
mesh=’Q4fine’;
end
if mesh==4
mesh=’Q4very fine’;
15 end
%------------------------------------
% raw data
%------------------------------------
20 fprintf(’Importing nodes’);
ImportQ4nodes;
fprintf(’Done n’);
fprintf(’Importing Elements’);
ImportQ4ele;
25 fprintf(’Done n’);
fprintf(’Importing DOF Information’);
ImportQ4DOF;
fprintf(’Done n’);
fprintf(’Importing Nodal Force Information’);
30 ImportQ4Lnode;
fprintf(’Done n’);
• The code then fixes errors in the nodes
fix1=Quad1;
fix2=Quad2;
fix3=Quad3;
fix4=Quad4;
5 fix5=LISTCONS;
fix6=LNode;
for ifixNoN=1:length(Node)
10 actualnode=Node(ifixNoN);
Page 23 of 29
Finite Element Techniques I (Report and Manual for code)
flag=1;
if actualnode˜=ifixNoN
if flag==1
fprintf(’Nodal numbering error found’);
15 flag=flag+1;
end
fprintf(’.’);
loc=find(fix1==actualnode);
loclength=length(loc);
20 for replace=1:loclength
fix1(loc(replace))=ifixNoN;
end
loc=find(fix2==actualnode);
loclength=length(loc);
25 for replace=1:loclength
fix2(loc(replace))=ifixNoN;
end
loc=find(fix3==actualnode);
loclength=length(loc);
30 for replace=1:loclength
fix3(loc(replace))=ifixNoN;
end
loc=find(fix4==actualnode);
loclength=length(loc);
35 for replace=1:loclength
fix4(loc(replace))=ifixNoN;
end
loc=find(fix5==actualnode);
loclength=length(loc);
40 for replace=1:loclength
fix5(loc(replace))=ifixNoN;
end
loc=find(fix5==actualnode);
loclength=length(loc);
45 for replace=1:loclength
fix6(loc(replace))=ifixNoN;
end
end
if flag==2
50 fprintf(’nNodal numbering error fixedn’);
flag=flag+1;
end
end
55 quad1=fix1;
quad2=fix2;
quad3=fix3;
quad4=fix4;
LISTCONS=fix5;
60 LNode=fix6;
if flag==1
fprintf(’nNo nodal numbering issues foundn’);
flag=flag+1;
Page 24 of 29
Finite Element Techniques I (Report and Manual for code)
end
• This part is important.
• The inputs of the beam are provided here.
• These are used in subsequent calculations.
%------------------------------------
% input data for control parameters
%------------------------------------
fprintf(’nInput data for control parametersn’);
5 nel=length(quad1); % number of elements
nnel=4; % number of nodes per element
ndof=2; % number of dofs per node
nnode=length(Node); % total number of nodes in system
sdof=nnode*ndof; % total system dofs
10 edof=nnel*ndof; % degrees of freedom per element
emodule=2e11; % elastic modulus
poisson=0.3; % Poisson’s ratio
fprintf(’n================================================’);
fprintf(’n Number of elements are %g’,nel);
15 fprintf(’n Number of nodes per element are %g’,nnel);
fprintf(’n Number of dofs per node are %g’,ndof);
fprintf(’n Number of of nodes in system are %g’,nnode);
fprintf(’n Number of system dofs are %g’,sdof);
fprintf(’n Number of degrees of freedom per element are %g’,edof);
20 fprintf(’n Elastic modulus is %g N/mmˆ2’,emodule);
fprintf(’n Poissons ratio is %g’,poisson);
fprintf(’n================================================nn’);
%---------------------------------------------
% input data for nodal coordinate values
25 % gcoord(i,j) where i->node no. and j->x or y
%---------------------------------------------
fprintf(’n Mapping nodal coordinates’);
gcoord=[X,Y];
30 %---------------------------------------------------------
% input data for nodal connectivity for each element
% nodes(i,j) where i-> element no. and j-> connected nodes
%---------------------------------------------------------
fprintf(’n Connecting nodes’);
35 nodes=[quad1,quad2,quad3,quad4];
• The next thing to look at is the force matrix.
• Here were need to understand that Ansys provides only the nodes on which the pressure is applied and
the force per unit area.
%----------------------------
% force vector
%----------------------------
5
Page 25 of 29
Finite Element Techniques I (Report and Manual for code)
fprintf(’n Force vector’);
for i=1:2:length(LNode)
distxyloc=[gcoord((LNode(i+1)),1),gcoord((LNode(i+1)),2);gcoord((LNode(i)),1),
gcoord((LNode(i)),2)];
distxy=pdist(distxyloc);
10 ff((LNode(i)*2))=ff((LNode(i)*2))+(LNodeVal(i)*(distxy)/2);
%ff((LNode(i)*2))=LNodeVal(i)*(distxy)/2;
ff((LNode(i+1)*2))=ff((LNode(i+1)*2))+(LNodeVal(i+1)*(distxy)/2);
end
sum(ff)
• For the Q4 variation is mostly centered about the next piece of code.
• As mentioned in a previous section we use 2x2 gauss integration to solve the problem.
• This is done in this code.
for ielp=1:nel % loop for the total number of elements
nd(1)=nodes(ielp,1); % 1st connected node for (iel)-th element
5 nd(2)=nodes(ielp,2); % 2nd connected node for (iel)-th element
nd(3)=nodes(ielp,3); % 3rd connected node for (iel)-th element
nd(4)=nodes(ielp,4); % 4th connected node for (iel)-th element
x1=gcoord(nd(1),1); y1=gcoord(nd(1),2);% coord values of 1st node
10 x2=gcoord(nd(2),1); y2=gcoord(nd(2),2);% coord values of 2nd node
x3=gcoord(nd(3),1); y3=gcoord(nd(3),2);% coord values of 3rd node
x4=gcoord(nd(4),1); y4=gcoord(nd(4),2);% coord values of 3rd node
15 index=feeldof(nd,nnel,ndof);% extract system dofs associated with element
% Put the nodes’ coordinates in a matrix
ncoord = [x1 y1;
x2 y2;
20 x3 y3;
x4 y4];
% matrix related to shape function
A = [1 0 0 0;
25 0 0 0 1;
0 1 1 0];
% Gauss Quadrature Matrix
gmtrx = [-1/sqrt(3) -1/sqrt(3);
30 1/sqrt(3) -1/sqrt(3);
1/sqrt(3) 1/sqrt(3);
-1/sqrt(3) 1/sqrt(3)];
% Initialization
35 % Jacobian Matrix
J = zeros(2,2);
% Derivative of the
Page 26 of 29
Finite Element Techniques I (Report and Manual for code)
drvtN = zeros(2,4);
% Gamma matrix
40 Gamma2 = zeros(4,4);
% element stiffness matrix
k = zeros(8,8);
%-----------------------------------
% Compute Element Stress and Strain
45 %-----------------------------------
Nu = 0; eta = 0;
drvtN = 0.25*[ eta-1 1-eta 1+eta -1-eta;
Nu-1 -1-Nu 1+Nu 1-Nu];
J = drvtN * ncoord;
50 valueJ = norm(J);
Gamma = Jˆ-1;
Gamma2(1,1) = Gamma(1,1); Gamma2(1,2) = Gamma(1,2);
Gamma2(2,1) = Gamma(2,1); Gamma2(2,2) = Gamma(2,2);
Gamma2(3,3) = Gamma(1,1); Gamma2(3,4) = Gamma(1,2);
55 Gamma2(4,3) = Gamma(2,1); Gamma2(4,4) = Gamma(2,2);
DrvtN = 0.25*[eta-1 0 1-eta 0 1+eta 0 -1-eta 0;
Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu 0;
0 eta-1 0 1-eta 0 1+eta 0 -1-eta;
0 Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu];
60 B = A * Gamma2 * DrvtN;
for i=1:edof
eldisp(i)=Displacement(index(i));
end
estrain=B*eldisp; % compute element strains
65 estress=matmtx*estrain; % compute element stresses
for i=1:3
strain(iel,i)=estrain(i); % store for each element
stress(iel,i)=estress(i); % store for each element
end
70 %-----------------------------------
% Compute Nodal Stress and Strain
%-----------------------------------
for j = 1:4
Nu = gmtrx(j,1); eta = gmtrx(j,2);
75 drvtN = 0.25*[ eta-1 1-eta 1+eta -1-eta;
Nu-1 -1-Nu 1+Nu 1-Nu];
J = drvtN * ncoord;
valueJ = det(J);
Gamma = Jˆ-1;
80 Gamma2(1,1) = Gamma(1,1); Gamma2(1,2) = Gamma(1,2);
Gamma2(2,1) = Gamma(2,1); Gamma2(2,2) = Gamma(2,2);
Gamma2(3,3) = Gamma(1,1); Gamma2(3,4) = Gamma(1,2);
Gamma2(4,3) = Gamma(2,1); Gamma2(4,4) = Gamma(2,2);
DrvtN = 0.25*[eta-1 0 1-eta 0 1+eta 0 -1-eta 0;
85 Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu 0;
0 eta-1 0 1-eta 0 1+eta 0 -1-eta;
0 Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu];
B = A * Gamma2 * DrvtN;
ndisp = eldisp;
90 nstrain=B*ndisp; % compute nodal strains
Page 27 of 29
Finite Element Techniques I (Report and Manual for code)
nstress=matmtx*nstrain; % compute nodal stresses
for i=1:3
nodalstrain(nd(j),i)=nstrain(i); % store for each node
nodalstress(nd(j),i)=nstress(i); % store for each node
95
end
end
end
• Finally we get the maximum values, actual values and final results.
scalex=10000;
scaley=4/max(Displacement);
for i=2:2:length(Displacement)
5 NewX(i/2)=X(i/2)-(scalex*Displacement(i-1));
NewY(i/2)=Y(i/2)-(scaley*Displacement(i));
end
Maxdisp=max(Displacement);
Maxdisp=max(Displacement);
10 SMX=max(nodalstress);
SMX=max(SMX);
SMXnd=find(nodalstress==SMX);
SMXndno=nodes(SMXnd);
SMXndloc=gcoord(SMXndno,:);
15 SMN=min(nodalstress);
SMN=min(SMN);
SMNnd=find(nodalstress==SMN);
SMNndno=nodes(SMNnd);
SMNndloc=gcoord(SMNndno,:);
20 figure()
scatter(X,Y,’b’);
axis equal ;
grid on;
title(’Deformed + Undeformed nodes’)
25 hold on
scatter(NewX,NewY,’filled’,’k’)
scatter(SMXndloc(1),SMXndloc(2),’filled’,’r’,’d’)
scatter(SMNndloc(1),SMNndloc(2),’filled’,’g’,’d’)
legend(’Undeformed’,’Deformed’,’Maxstress’,’MinStress’)
30 %Text on plot
txt1=sprintf(’Total number of nodes = %g’,nnode);
txt2=sprintf(’Total number of elements = %g’,nel);
txt4=sprintf(’Maximum Displacement = %g’,Maxdisp);
txt3=sprintf(’%s mesh’,mesh(5:end));
35 txt5=sprintf(’Maximum Stress is %g’,SMX);
txt6=sprintf(’Minimum Stress is %g’,SMN);
text(-2,-7,txt1)
text(-2,-9,txt2)
text(-20,12,txt3)
40 text(-2,-11,txt4)
text(-2,-13,txt5)
text(-2,-15,txt6)
Page 28 of 29
Finite Element Techniques I (Report and Manual for code)
45
fprintf(’nn================================================’);
fprintf(’nMaximum deformation is %g’,Maxdisp)
fprintf(’n================================================n’);
50 %% ACTUAL SOLUTION
%[U,V,sigx,sigy,tauxy]=actualsol(0,0)
scalex=10000;
scaley=4/5e-4;
for i=1:length(Node)
55 [actU(i),actV(i),actSigx(i),actSigy(i),actTauxy(i)]=actualsol(gcoord(i,1),
gcoord(i,2));
actX(i)=X(i)-(scalex*actU(i));
actY(i)=Y(i)-(scaley*actV(i));
end
60 %scatter(actX,actY);
axis equal ;
grid on;
max(actV);
max(NewX);
65 max(actSigx)
max(actSigy)
max(actTauxy)
hold off
References
[1] Autodesk. How to Perform a Mesh Convergence Study. https://knowledge.autodesk.
com/support/simulation-mechanical/troubleshooting/caas/sfdcarticles/
sfdcarticles/How-to-Perform-a-Mesh-Convergence-Study.html, 2015. [Online; ac-
cessed 11-December-2016].
[2] Bethany Nine. How to Implement a Mesh Refinement Study. https://www.comsol.com/blogs/
how-to-implement-mesh-refinement-study/, 2013. [Online; accessed 11-December-2016].
[3] University of Rome. Finite Elements for 2-D Problems-General Formula for the Stiffness Matrix. http:
//www.uniroma2.it/didattica/TCM/deposito/2-D_elements.pdf, 2016. [Online; accessed
10-December-2016].
[4] David Roylance. How to Perform a Mesh Convergence Study. http://web.mit.edu/course/3/3.
11/www/modules/bstress.pdf, 2000. [Online; accessed 11-December-2016].
[5] Boulder University of Colorado. FEM - Chapter 17 Isoparametric Quadrilaterals. http://www.
colorado.edu/engineering/CAS/courses.d/IFEM.d/IFEM.Ch17.d/IFEM.Ch17.pdf, 2016.
[Online; accessed 10-December-2016].
Page 29 of 29

More Related Content

PDF
Lee_Seunghee
Stephanie Lee
 
TXT
Nuevo documento de texto
Luis Charley Cabrera Ramirez
 
PDF
Partial differential equations, graduate level problems and solutions by igor...
Julio Banks
 
PDF
Notes for GNU Octave - Numerical Programming - for Students 01 of 02 by Arun ...
ssuserd6b1fd
 
PDF
Java Programming Notes for Beginners by Arun Umrao
ssuserd6b1fd
 
PDF
2013 Specialized bikes catalogue
Donald Dumas
 
DOCX
StrucA final report
Graeme Ramsey
 
PDF
Finite_Element_Analysis_with_MATLAB_GUI
Colby White
 
Lee_Seunghee
Stephanie Lee
 
Nuevo documento de texto
Luis Charley Cabrera Ramirez
 
Partial differential equations, graduate level problems and solutions by igor...
Julio Banks
 
Notes for GNU Octave - Numerical Programming - for Students 01 of 02 by Arun ...
ssuserd6b1fd
 
Java Programming Notes for Beginners by Arun Umrao
ssuserd6b1fd
 
2013 Specialized bikes catalogue
Donald Dumas
 
StrucA final report
Graeme Ramsey
 
Finite_Element_Analysis_with_MATLAB_GUI
Colby White
 

Viewers also liked (10)

DOCX
Matlab code of chapter 4
Abdo Khalaf
 
PPT
international business management
Sumit Suman
 
PDF
CEE 235B Final Project_John_Wick
John (JC) Wick, P.E.
 
PPTX
International Business And Management
Hassan Gardezi
 
PDF
Mustafa Hussain Bohra BBA 3rd Year
Dezyneecole
 
DOC
International Business -notes-complete
Syed Valiullah Bakhtiyari
 
PDF
Summer internship project report
Manish Singh
 
PDF
Summer internship report L&T
Umed Paliwal
 
PPTX
International Business Environment
Visakhapatnam
 
PPT
Automobiles
ashishmakhija86
 
Matlab code of chapter 4
Abdo Khalaf
 
international business management
Sumit Suman
 
CEE 235B Final Project_John_Wick
John (JC) Wick, P.E.
 
International Business And Management
Hassan Gardezi
 
Mustafa Hussain Bohra BBA 3rd Year
Dezyneecole
 
International Business -notes-complete
Syed Valiullah Bakhtiyari
 
Summer internship project report
Manish Singh
 
Summer internship report L&T
Umed Paliwal
 
International Business Environment
Visakhapatnam
 
Automobiles
ashishmakhija86
 
Ad

Similar to FINAL PROJECT (20)

PPTX
tuttuturtCH 1 and 2 FEM ppt finite el.pptx
ozelalemshiferaw
 
PDF
L3-1 Introduction to Analysis tools.pdf
Khums Musopa
 
PPT
Intro to fea software
kubigs
 
PPTX
Fem utkarsh
UTKARSH DWIVEDI
 
PPTX
Introduction to FEA
Kishan Sharma
 
PDF
Fem in matlab
Shince Joseph
 
PDF
IRJET- Stress – Strain Field Analysis of Mild Steel Component using Finite El...
IRJET Journal
 
PDF
01-Chapter 01 Moaveni.pdf
hamza218909
 
PDF
CAE_notes.pdf all notes for computer aided eng
jacoblabelle2004
 
PDF
fea_analysis book................................
ssuseree6cfa
 
PDF
Product failure analysis using Explicit dynamic
naga ram
 
PDF
FEA Basic Introduction Training By Praveen
praveenpat
 
PDF
Finite Element Modeling On Behaviour Of Reinforced Concrete Beam Column Joint...
IJERA Editor
 
PDF
Part 1_Methods for mechanically analysing a solid structure(1).pdf
SajawalNawaz5
 
PDF
A Comprehensive Introduction of the Finite Element Method for Undergraduate C...
IJERA Editor
 
PDF
ConSteel_14_User_Manual-251-300.pdf
JuanUnafVargas
 
PPTX
Lec9 finite element_beam_structures 1
Mahdi Damghani
 
PPTX
Introduction to CFd analysis.FEM4CFD-Week1.pptx
siranjeevi56
 
PPTX
chapter 1- introduction to finite element method
AberaAbebe14
 
PPT
FEA intro patran_nastran
nmahi96
 
tuttuturtCH 1 and 2 FEM ppt finite el.pptx
ozelalemshiferaw
 
L3-1 Introduction to Analysis tools.pdf
Khums Musopa
 
Intro to fea software
kubigs
 
Fem utkarsh
UTKARSH DWIVEDI
 
Introduction to FEA
Kishan Sharma
 
Fem in matlab
Shince Joseph
 
IRJET- Stress – Strain Field Analysis of Mild Steel Component using Finite El...
IRJET Journal
 
01-Chapter 01 Moaveni.pdf
hamza218909
 
CAE_notes.pdf all notes for computer aided eng
jacoblabelle2004
 
fea_analysis book................................
ssuseree6cfa
 
Product failure analysis using Explicit dynamic
naga ram
 
FEA Basic Introduction Training By Praveen
praveenpat
 
Finite Element Modeling On Behaviour Of Reinforced Concrete Beam Column Joint...
IJERA Editor
 
Part 1_Methods for mechanically analysing a solid structure(1).pdf
SajawalNawaz5
 
A Comprehensive Introduction of the Finite Element Method for Undergraduate C...
IJERA Editor
 
ConSteel_14_User_Manual-251-300.pdf
JuanUnafVargas
 
Lec9 finite element_beam_structures 1
Mahdi Damghani
 
Introduction to CFd analysis.FEM4CFD-Week1.pptx
siranjeevi56
 
chapter 1- introduction to finite element method
AberaAbebe14
 
FEA intro patran_nastran
nmahi96
 
Ad

FINAL PROJECT

  • 1. Finite Element Techniques I: FINAL PROJECT Due on Wednesday, December 14, 2016 Report and Manual for code Ebenesh Rabiraj 1
  • 2. Finite Element Techniques I (Report and Manual for code) Contents Problem statement 3 Questions to answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Ansys Implementation 4 General procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Extract files required for MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Sample input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Matlab Implementation 8 T3 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Q4 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Results 11 T3 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Coarse mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Medium mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Very fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Q4 element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Coarse mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Medium mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Very fine mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Discussion 21 Convergence Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Error Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Code 23 How to run it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Page 2 of 29
  • 3. Finite Element Techniques I (Report and Manual for code) Problem statement The figure above represents a simply supported beam with the following given conditions, l = 20m h = 2m w = 2000N/m ν = 0.3 E = 2e11 Pa Questions to answer • Use Ansys Q4 element to analyze a plane-stress beam. • In the second part of this project, you will use the matlab program based on linear triangular element (T3 element) solve the same problem. You need to modify the code so that it can input the triangular mesh generated from ANSYS. The best way is to create an input file that contains all the nodal and connectivity information and let you code read it. • In this part of the project, you will develop a matlab program using Q4 element for solving the same problem. To implement this, you will need to modify the code on T3 to implement the formulation discussed in class for Q4. To apply it to the problem above, you can generate the mesh using ANSYS and then input them to your own code. Use 2 by 2 Gauss quadrature for evaluating the stiffness matrix. 1) A short write-up on implementation (similar to the Ansys assignments) 2) The FEM model (mesh), and deformed shape and stress. 3) For each types of element, prescribe three types of mesh (coarse, fine and very fine) densities. Compare maximum deflection with the analytical solution and compute the error as a function of the mesh spacing on a log-log scale plot. 4) Similar to 3), but compare the stress value σ xx at x= 0, y =h / 2 . Page 3 of 29
  • 4. Finite Element Techniques I (Report and Manual for code) Ansys Implementation General procedure In the ansys implementation we follow the procedure given below keeping in mind that the version of Ansys may be different from the ine I have used and there may be minor variations. • Perferences → Structural • Preprocessor → Element Type→ Add/Edit/Delete→ Add→ Solid→ Quad 4 node 182 → Material Properties→ material models → Structural→ Linear→ Elastic→ Isotropic → EX=2e11 → PRXY=0.3 → Modelling→ Create→ Areas→ Rectangle → By 2 Corners → WP X→ -20 → WP Y→ -1 → Width→ 40 → Height→ 2 → Meshing→ MeshTool → Check the smart size button → Set the slider to, → 9→ coarse → 6→ medium → 4→ fine → 2→ very fine → Set Mesh to Area → Select the shape as tri → Click Mesh • Solution → Define Loads→ → Apply→ Structural → Displacement → Select node(-20,-1)→ UX,UY → Select node(20,-1)→ UY → Pressure→ Select the upper nodes along y=1→ Constant value=2000 → Solve→ Current LS→ OK • General Postproc→ Plot Results (as and what is displayed) Page 4 of 29
  • 5. Finite Element Techniques I (Report and Manual for code) Extract files required for MATLAB The meshing of the given beam is done in Ansys and imported into MATLAB. For a sucessfull run, Ansys will have to output 4 files • NLIST.lis (Provides the Nodal coordinates) • MAIN MENU⇒ List→ Nodes • ELIST.lis (Provides the elements and the nodes in them) • MAIN MENU⇒ List→ Elements→ on all nodes • DLIST.lis (Provides the Nodal DOF) • MAIN MENU⇒ List→ Loads→ DOF constraints → On all nodes • SFLIS.lis (Provides the pressure applied on a surface with the constant load value across the nodes on the surface) • MAIN MENU⇒ List→ Loads→ Surfaces→ On all nodes Sample input The following input is generated by ansys for a T3 element with a coarse mesh. These files are imported into the MATLAB main program through the code attached in an upcoming section. INPUT to MATLAB LIST ALL SELECTED NODES. DSYS= 0 SORT TABLE ON NODE NODE NODE NODE X Y Z 1 -20.0000000000 -1.00000000000 0.00000000000 2 20.0000000000 -1.00000000000 0.00000000000 3 20.0000000000 1.00000000000 0.00000000000 4 -20.0000000000 1.00000000000 0.00000000000 5 -18.0000000000 -1.00000000000 0.00000000000 6 -14.2000000000 -1.00000000000 0.00000000000 7 -10.4000000000 -1.00000000000 0.00000000000 8 -6.60000000000 -1.00000000000 0.00000000000 9 -1.00000000000 -1.00000000000 0.00000000000 10 2.80000000000 -1.00000000000 0.00000000000 11 6.60000000000 -1.00000000000 0.00000000000 12 10.4000000000 -1.00000000000 0.00000000000 13 14.2000000000 -1.00000000000 0.00000000000 14 18.0000000000 -1.00000000000 0.00000000000 15 18.0000000000 1.00000000000 0.00000000000 16 14.2000000000 1.00000000000 0.00000000000 17 10.4000000000 1.00000000000 0.00000000000 18 6.60000000000 1.00000000000 0.00000000000 19 1.00000000000 1.00000000000 0.00000000000 20 -2.80000000000 1.00000000000 0.00000000000 NODE X Y Z 21 -6.60000000000 1.00000000000 0.00000000000 22 -10.4000000000 1.00000000000 0.00000000000 23 -14.2000000000 1.00000000000 0.00000000000 24 -18.0000000000 1.00000000000 0.00000000000 Page 5 of 29
  • 6. Finite Element Techniques I (Report and Manual for code) 25 19.0000000000 0.00000000000 0.00000000000 26 -19.0000000000 0.00000000000 0.00000000000 INPUT to MATLAB LIST ALL SELECTED ELEMENTS. LIST NODES ELEM MAT TYP REL ESY SEC NODES 1 1 1 1 0 1 15 13 14 14 2 1 1 1 0 1 15 16 13 13 3 1 1 1 0 1 24 26 5 5 4 1 1 1 0 1 5 26 1 1 5 1 1 1 0 1 26 4 1 1 6 1 1 1 0 1 24 4 26 26 7 1 1 1 0 1 2 25 14 14 8 1 1 1 0 1 14 25 15 15 9 1 1 1 0 1 25 3 15 15 10 1 1 1 0 1 2 3 25 25 11 1 1 1 0 1 13 16 12 12 12 1 1 1 0 1 12 17 11 11 13 1 1 1 0 1 16 17 12 12 14 1 1 1 0 1 11 18 10 10 15 1 1 1 0 1 17 18 11 11 16 1 1 1 0 1 19 10 18 18 17 1 1 1 0 1 19 9 10 10 18 1 1 1 0 1 9 20 8 8 19 1 1 1 0 1 19 20 9 9 20 1 1 1 0 1 8 21 7 7 ELEM MAT TYP REL ESY SEC NODES 21 1 1 1 0 1 20 21 8 8 22 1 1 1 0 1 7 22 6 6 23 1 1 1 0 1 21 22 7 7 24 1 1 1 0 1 6 23 5 5 25 1 1 1 0 1 22 23 6 6 26 1 1 1 0 1 24 5 23 23 INPUT to MATLAB LIST CONSTRAINTS FOR SELECTED NODES 1 TO 26 BY 1 CURRENTLY SELECTED DOF SET= UX UY NODE LABEL REAL IMAG 1 UX 0.00000000 0.00000000 1 UY 0.00000000 0.00000000 2 UY 0.00000000 0.00000000 INPUT to MATLAB Page 6 of 29
  • 7. Finite Element Techniques I (Report and Manual for code) The surface loads listed are the current database values and are not necessarily the values corresponding to the current results data set. Tabular boundary conditions, however, do list values corresponding to the current results set. LIST NODAL SURFACE LOAD PRES FOR ALL SELECTED NODES ELEMENT LKEY FACE NODES REAL IMAGINARY 2 1 16 2000.00000 0.00000000 15 2000.00000 0.00000000 6 1 4 2000.00000 0.00000000 24 2000.00000 0.00000000 9 2 15 2000.00000 0.00000000 3 2000.00000 0.00000000 13 1 17 2000.00000 0.00000000 16 2000.00000 0.00000000 15 1 18 2000.00000 0.00000000 17 2000.00000 0.00000000 16 4 19 2000.00000 0.00000000 18 2000.00000 0.00000000 19 1 20 2000.00000 0.00000000 19 2000.00000 0.00000000 21 1 21 2000.00000 0.00000000 20 2000.00000 0.00000000 23 1 22 2000.00000 0.00000000 21 2000.00000 0.00000000 25 1 23 2000.00000 0.00000000 22 2000.00000 0.00000000 ELEMENT LKEY FACE NODES REAL IMAGINARY 26 4 24 2000.00000 0.00000000 23 2000.00000 0.00000000 Page 7 of 29
  • 8. Finite Element Techniques I (Report and Manual for code) Matlab Implementation T3 element From the implementation in the previous assignment, developed from the code provided, we have a working code that helps us solve the problem by utilizing a T3 mesh element. Figure 1: T3 element representing 3 nodes at the vertices of a triangle numbered in a clockwise direction. Courtesy of University of Rome class notes The T3 element is made up of 3 nodes at the vertices of a triangle numbered in a clockwise direction. Each vertex has 2 degrees of freedom, a displacement in the the x and y direction [3]. This displacement can be expressed as, u v = N1 0 N2 0 N3 0 0 N1 0 N2 0 N3    u1 v1 u2 v2 u3 v3    where N1, N2 and N3 are the shape functions. The stiffness matrix can be written as, k = V BT EBdV where, B =   y23 0 y31 0 y12 0 0 x32 0 x13 0 x21 x32 y23 x13 y31 x21 y12   and, xij = xi − xj; yij = yi − yj; Keeping this in mind an algorithm can be developed where the stiffness matrix for the entire element is calculated as a superpositioning of the elemental stiffness matrix. The integration is carried out in a numerical fashion. Page 8 of 29
  • 9. Finite Element Techniques I (Report and Manual for code) Q4 element Figure 2: Q4 element representing 4 nodes at the vertices of a isoparametric quadrilateral. Courtesy of University of colorado class notes. The Q4 element is a 4 node isoparametric element. In the case of the Q4 element we need to use a different strategy for numerical integration of the quadrature points. Gauss integration method is the most standard practice followed [5]. The stiffness matrix is represented as, k = A BT EBtdxdy The stiffness matrix in this case is an 8x8 matrix. It is similar to that of the T3 element, however, the B martix is modified as, B =   1 0 0 0 0 0 0 1 0 1 1 0   τ τ     N1,ξ 0 N2,ξ 0 N3,ξ 0 N4,ξ 0 N1,η 0 N2,η 0 N3,η 0 N4,η 0 0 N1,ξ 0 N2,ξ 0 N3,ξ 0 N4,ξ 0 N1,η 0 N2,η 0 N3,η 0 N4,η     where τ = J−1 . J is the jacobian matrix that is represented as, J = N1,ξ N2,ξ N3,ξ N4,ξ N1,η N2,η N3,η N4,η     x1 y1 x2 y2 x3 y3 x4 y4     Gauss quadrature based integration is used to integrate the stiffness equation. The 1D form of the gauss quadrature is represented as, k = 1 −1 F(ξ)dξ ≈ p i=1 ωiF(ξi) Page 9 of 29
  • 10. Finite Element Techniques I (Report and Manual for code) Here we can understand that p represents the sample points for integration, ωi represents the weights for integration and ξ is the sample point within the interval [-1,1]. To extend this to the 2D formulation we reduce the integration to it’s canonical form to better show the process. The integration is thus represented as, k = 1 −1 1 −1 F(ξ, η)dξdη ≈ p1 i=1 p2 i=1 ωiωjF(ξi, ηj) According to our question we intend to use the 2x2 gauss quadrature to evaluate the stiffness matrix. Figure 3: 2D gauss product rule implementation where p=2 depicted over a straight-sided quadrilateral region. The sample points are represented as black dots. Courtesy of University of colorado class notes. The sample points as see in Figure 3 are taken in the counter clockwise direction from the segment in the 1st quadrature as, [ 1√ 3 , 1√ 3 ], [− 1√ 3 , 1√ 3 ], [− 1√ 3 , − 1√ 3 ], [ 1√ 3 , − 1√ 3 ]. These values are plugged into the weight terms ωi and ωj The matlab code that has been developed does the calculations based on the nodal and elemental information provided by the Ansys export as discussed earlier. The matlab script imports the desired nodal and elemental information from the .lis files mentioned and arranges them in the required form. NOTE: The code remains unchanged even if the mesh of the beam is changed. However, if the inputs such as young’s modulus and poisson’s ratio need to be updated in the code if changed. Page 10 of 29
  • 11. Finite Element Techniques I (Report and Manual for code) Results This section shows teh results obtained from Matlab and Ansys. Every coarse mesh shows the deflection and the stress induced on the beam. The deflection is exagerated such that the beam passes the bottom length of the beam. The nodes of beam are represented as scatter points. The element data is not shown. The stress plots are not separately shown, however the points where the stress is maximum and minimum are plotted. The red node shows a point of maximum stress and the green shows the point of minimum stress. Since the stress in the x direction is uniform and a much lower value, it is neglected. The stress in the y direction is only depicted. The ansys plot shows the deflection and sheer stress or σxy. T3 element Coarse mesh Page 11 of 29
  • 12. Finite Element Techniques I (Report and Manual for code) Page 12 of 29
  • 13. Finite Element Techniques I (Report and Manual for code) Medium mesh Page 13 of 29
  • 14. Finite Element Techniques I (Report and Manual for code) Fine mesh Page 14 of 29
  • 15. Finite Element Techniques I (Report and Manual for code) Very fine mesh Page 15 of 29
  • 16. Finite Element Techniques I (Report and Manual for code) Q4 element The Q4 plots are also similare to the T3. It is important to note that the in the Q4 analysis each quadrilateral has a node of minimum stress and a node of maximum stress. Only the node that has the least stress in depicted in the diagram. The coarse mesh, as will be seen in a later section is innacurate or shows that the node of maximum stress and minimum stress to be the same. This point then spreads to more reasonable points as the mesh densities increase. Coarse mesh Page 16 of 29
  • 17. Finite Element Techniques I (Report and Manual for code) Page 17 of 29
  • 18. Finite Element Techniques I (Report and Manual for code) Medium mesh Page 18 of 29
  • 19. Finite Element Techniques I (Report and Manual for code) Fine mesh Page 19 of 29
  • 20. Finite Element Techniques I (Report and Manual for code) Very fine mesh Page 20 of 29
  • 21. Finite Element Techniques I (Report and Manual for code) Discussion Convergence Study There are many ways to conduct convergence analysis [1] [2]. In essence we need to show how the solution, whether it be displacement or stress approaches the analytical solution. We have been provided the solution for the displacements and the stresses in the question. First we will look at the convergence of the maximum displacement of the beam using a coarsely meshed beam. This solution is plotted as a function of increasing refinement in the mesh. In the figure below we analyse the mesh at 4 points. The curve is interpolated between the 4 points for clarity. The bold dots show the actual measurements from the matlab code or Ansys result. As seen above the x axis represents the density of the mesh across the beam. The graph shows that over the given range of meshes ranging from 26 nodes to 635 nodes the obtained results quickly move toward the analytical solution. In the case of the displacement graph we can also see how well the Ansys and Matlab simulations agree with each other at the different mesh points. Seeing how well the results match we can move to the stress plot without checking the similarities between the Ansys and Matlab plots. Instead we will focus on the change in accuracy over the mesh density range. The stresses in these kind of beams are also an important factor to look at. A clear explanation of the stresses in a beam is provided by David Roylance in his notes [4]. The stresses are calculated using the analytical solution provided in the question and then the code is run to calculate the principal stress. The output is then plotted as shown below. Page 21 of 29
  • 22. Finite Element Techniques I (Report and Manual for code) The plots also shows an important trait of the T3 and Q4 elements. Both the T3 and the Q4 elements converge at different rates. The T3 element as expected is more stiff. The stiffness causes a less accurate deflection but is closer in terms of stress. It is important to note that for both the stress and displacement convergence studies, the curve is a contin- uous, interpolated curve drawn over the points derived from those in the Matlab/Ansys simulations. Error Study The error is nothing but a difference in the actual solution and the solution obtained using the finite element techniques. The error plotted in a log log scale to enhance the nuances in the curve. The change in density shows a steep decline in the error in the Q4 element although the T3 element remains a little stiffer as it approaches the 0 error point. Page 22 of 29
  • 23. Finite Element Techniques I (Report and Manual for code) Code How to run it • The first step is to determine the mesh density. • The mesh density ranges from 1-4 which points the code to different directories to grab the input files. • There are separate scripts that import the nodes, Elements, DOF and Nodal force information mesh=4; if mesh==1 5 mesh=’Q4coarse’; end if mesh==2 mesh=’Q4medium’; end 10 if mesh==3 mesh=’Q4fine’; end if mesh==4 mesh=’Q4very fine’; 15 end %------------------------------------ % raw data %------------------------------------ 20 fprintf(’Importing nodes’); ImportQ4nodes; fprintf(’Done n’); fprintf(’Importing Elements’); ImportQ4ele; 25 fprintf(’Done n’); fprintf(’Importing DOF Information’); ImportQ4DOF; fprintf(’Done n’); fprintf(’Importing Nodal Force Information’); 30 ImportQ4Lnode; fprintf(’Done n’); • The code then fixes errors in the nodes fix1=Quad1; fix2=Quad2; fix3=Quad3; fix4=Quad4; 5 fix5=LISTCONS; fix6=LNode; for ifixNoN=1:length(Node) 10 actualnode=Node(ifixNoN); Page 23 of 29
  • 24. Finite Element Techniques I (Report and Manual for code) flag=1; if actualnode˜=ifixNoN if flag==1 fprintf(’Nodal numbering error found’); 15 flag=flag+1; end fprintf(’.’); loc=find(fix1==actualnode); loclength=length(loc); 20 for replace=1:loclength fix1(loc(replace))=ifixNoN; end loc=find(fix2==actualnode); loclength=length(loc); 25 for replace=1:loclength fix2(loc(replace))=ifixNoN; end loc=find(fix3==actualnode); loclength=length(loc); 30 for replace=1:loclength fix3(loc(replace))=ifixNoN; end loc=find(fix4==actualnode); loclength=length(loc); 35 for replace=1:loclength fix4(loc(replace))=ifixNoN; end loc=find(fix5==actualnode); loclength=length(loc); 40 for replace=1:loclength fix5(loc(replace))=ifixNoN; end loc=find(fix5==actualnode); loclength=length(loc); 45 for replace=1:loclength fix6(loc(replace))=ifixNoN; end end if flag==2 50 fprintf(’nNodal numbering error fixedn’); flag=flag+1; end end 55 quad1=fix1; quad2=fix2; quad3=fix3; quad4=fix4; LISTCONS=fix5; 60 LNode=fix6; if flag==1 fprintf(’nNo nodal numbering issues foundn’); flag=flag+1; Page 24 of 29
  • 25. Finite Element Techniques I (Report and Manual for code) end • This part is important. • The inputs of the beam are provided here. • These are used in subsequent calculations. %------------------------------------ % input data for control parameters %------------------------------------ fprintf(’nInput data for control parametersn’); 5 nel=length(quad1); % number of elements nnel=4; % number of nodes per element ndof=2; % number of dofs per node nnode=length(Node); % total number of nodes in system sdof=nnode*ndof; % total system dofs 10 edof=nnel*ndof; % degrees of freedom per element emodule=2e11; % elastic modulus poisson=0.3; % Poisson’s ratio fprintf(’n================================================’); fprintf(’n Number of elements are %g’,nel); 15 fprintf(’n Number of nodes per element are %g’,nnel); fprintf(’n Number of dofs per node are %g’,ndof); fprintf(’n Number of of nodes in system are %g’,nnode); fprintf(’n Number of system dofs are %g’,sdof); fprintf(’n Number of degrees of freedom per element are %g’,edof); 20 fprintf(’n Elastic modulus is %g N/mmˆ2’,emodule); fprintf(’n Poissons ratio is %g’,poisson); fprintf(’n================================================nn’); %--------------------------------------------- % input data for nodal coordinate values 25 % gcoord(i,j) where i->node no. and j->x or y %--------------------------------------------- fprintf(’n Mapping nodal coordinates’); gcoord=[X,Y]; 30 %--------------------------------------------------------- % input data for nodal connectivity for each element % nodes(i,j) where i-> element no. and j-> connected nodes %--------------------------------------------------------- fprintf(’n Connecting nodes’); 35 nodes=[quad1,quad2,quad3,quad4]; • The next thing to look at is the force matrix. • Here were need to understand that Ansys provides only the nodes on which the pressure is applied and the force per unit area. %---------------------------- % force vector %---------------------------- 5 Page 25 of 29
  • 26. Finite Element Techniques I (Report and Manual for code) fprintf(’n Force vector’); for i=1:2:length(LNode) distxyloc=[gcoord((LNode(i+1)),1),gcoord((LNode(i+1)),2);gcoord((LNode(i)),1), gcoord((LNode(i)),2)]; distxy=pdist(distxyloc); 10 ff((LNode(i)*2))=ff((LNode(i)*2))+(LNodeVal(i)*(distxy)/2); %ff((LNode(i)*2))=LNodeVal(i)*(distxy)/2; ff((LNode(i+1)*2))=ff((LNode(i+1)*2))+(LNodeVal(i+1)*(distxy)/2); end sum(ff) • For the Q4 variation is mostly centered about the next piece of code. • As mentioned in a previous section we use 2x2 gauss integration to solve the problem. • This is done in this code. for ielp=1:nel % loop for the total number of elements nd(1)=nodes(ielp,1); % 1st connected node for (iel)-th element 5 nd(2)=nodes(ielp,2); % 2nd connected node for (iel)-th element nd(3)=nodes(ielp,3); % 3rd connected node for (iel)-th element nd(4)=nodes(ielp,4); % 4th connected node for (iel)-th element x1=gcoord(nd(1),1); y1=gcoord(nd(1),2);% coord values of 1st node 10 x2=gcoord(nd(2),1); y2=gcoord(nd(2),2);% coord values of 2nd node x3=gcoord(nd(3),1); y3=gcoord(nd(3),2);% coord values of 3rd node x4=gcoord(nd(4),1); y4=gcoord(nd(4),2);% coord values of 3rd node 15 index=feeldof(nd,nnel,ndof);% extract system dofs associated with element % Put the nodes’ coordinates in a matrix ncoord = [x1 y1; x2 y2; 20 x3 y3; x4 y4]; % matrix related to shape function A = [1 0 0 0; 25 0 0 0 1; 0 1 1 0]; % Gauss Quadrature Matrix gmtrx = [-1/sqrt(3) -1/sqrt(3); 30 1/sqrt(3) -1/sqrt(3); 1/sqrt(3) 1/sqrt(3); -1/sqrt(3) 1/sqrt(3)]; % Initialization 35 % Jacobian Matrix J = zeros(2,2); % Derivative of the Page 26 of 29
  • 27. Finite Element Techniques I (Report and Manual for code) drvtN = zeros(2,4); % Gamma matrix 40 Gamma2 = zeros(4,4); % element stiffness matrix k = zeros(8,8); %----------------------------------- % Compute Element Stress and Strain 45 %----------------------------------- Nu = 0; eta = 0; drvtN = 0.25*[ eta-1 1-eta 1+eta -1-eta; Nu-1 -1-Nu 1+Nu 1-Nu]; J = drvtN * ncoord; 50 valueJ = norm(J); Gamma = Jˆ-1; Gamma2(1,1) = Gamma(1,1); Gamma2(1,2) = Gamma(1,2); Gamma2(2,1) = Gamma(2,1); Gamma2(2,2) = Gamma(2,2); Gamma2(3,3) = Gamma(1,1); Gamma2(3,4) = Gamma(1,2); 55 Gamma2(4,3) = Gamma(2,1); Gamma2(4,4) = Gamma(2,2); DrvtN = 0.25*[eta-1 0 1-eta 0 1+eta 0 -1-eta 0; Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu 0; 0 eta-1 0 1-eta 0 1+eta 0 -1-eta; 0 Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu]; 60 B = A * Gamma2 * DrvtN; for i=1:edof eldisp(i)=Displacement(index(i)); end estrain=B*eldisp; % compute element strains 65 estress=matmtx*estrain; % compute element stresses for i=1:3 strain(iel,i)=estrain(i); % store for each element stress(iel,i)=estress(i); % store for each element end 70 %----------------------------------- % Compute Nodal Stress and Strain %----------------------------------- for j = 1:4 Nu = gmtrx(j,1); eta = gmtrx(j,2); 75 drvtN = 0.25*[ eta-1 1-eta 1+eta -1-eta; Nu-1 -1-Nu 1+Nu 1-Nu]; J = drvtN * ncoord; valueJ = det(J); Gamma = Jˆ-1; 80 Gamma2(1,1) = Gamma(1,1); Gamma2(1,2) = Gamma(1,2); Gamma2(2,1) = Gamma(2,1); Gamma2(2,2) = Gamma(2,2); Gamma2(3,3) = Gamma(1,1); Gamma2(3,4) = Gamma(1,2); Gamma2(4,3) = Gamma(2,1); Gamma2(4,4) = Gamma(2,2); DrvtN = 0.25*[eta-1 0 1-eta 0 1+eta 0 -1-eta 0; 85 Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu 0; 0 eta-1 0 1-eta 0 1+eta 0 -1-eta; 0 Nu-1 0 -1-Nu 0 1+Nu 0 1-Nu]; B = A * Gamma2 * DrvtN; ndisp = eldisp; 90 nstrain=B*ndisp; % compute nodal strains Page 27 of 29
  • 28. Finite Element Techniques I (Report and Manual for code) nstress=matmtx*nstrain; % compute nodal stresses for i=1:3 nodalstrain(nd(j),i)=nstrain(i); % store for each node nodalstress(nd(j),i)=nstress(i); % store for each node 95 end end end • Finally we get the maximum values, actual values and final results. scalex=10000; scaley=4/max(Displacement); for i=2:2:length(Displacement) 5 NewX(i/2)=X(i/2)-(scalex*Displacement(i-1)); NewY(i/2)=Y(i/2)-(scaley*Displacement(i)); end Maxdisp=max(Displacement); Maxdisp=max(Displacement); 10 SMX=max(nodalstress); SMX=max(SMX); SMXnd=find(nodalstress==SMX); SMXndno=nodes(SMXnd); SMXndloc=gcoord(SMXndno,:); 15 SMN=min(nodalstress); SMN=min(SMN); SMNnd=find(nodalstress==SMN); SMNndno=nodes(SMNnd); SMNndloc=gcoord(SMNndno,:); 20 figure() scatter(X,Y,’b’); axis equal ; grid on; title(’Deformed + Undeformed nodes’) 25 hold on scatter(NewX,NewY,’filled’,’k’) scatter(SMXndloc(1),SMXndloc(2),’filled’,’r’,’d’) scatter(SMNndloc(1),SMNndloc(2),’filled’,’g’,’d’) legend(’Undeformed’,’Deformed’,’Maxstress’,’MinStress’) 30 %Text on plot txt1=sprintf(’Total number of nodes = %g’,nnode); txt2=sprintf(’Total number of elements = %g’,nel); txt4=sprintf(’Maximum Displacement = %g’,Maxdisp); txt3=sprintf(’%s mesh’,mesh(5:end)); 35 txt5=sprintf(’Maximum Stress is %g’,SMX); txt6=sprintf(’Minimum Stress is %g’,SMN); text(-2,-7,txt1) text(-2,-9,txt2) text(-20,12,txt3) 40 text(-2,-11,txt4) text(-2,-13,txt5) text(-2,-15,txt6) Page 28 of 29
  • 29. Finite Element Techniques I (Report and Manual for code) 45 fprintf(’nn================================================’); fprintf(’nMaximum deformation is %g’,Maxdisp) fprintf(’n================================================n’); 50 %% ACTUAL SOLUTION %[U,V,sigx,sigy,tauxy]=actualsol(0,0) scalex=10000; scaley=4/5e-4; for i=1:length(Node) 55 [actU(i),actV(i),actSigx(i),actSigy(i),actTauxy(i)]=actualsol(gcoord(i,1), gcoord(i,2)); actX(i)=X(i)-(scalex*actU(i)); actY(i)=Y(i)-(scaley*actV(i)); end 60 %scatter(actX,actY); axis equal ; grid on; max(actV); max(NewX); 65 max(actSigx) max(actSigy) max(actTauxy) hold off References [1] Autodesk. How to Perform a Mesh Convergence Study. https://knowledge.autodesk. com/support/simulation-mechanical/troubleshooting/caas/sfdcarticles/ sfdcarticles/How-to-Perform-a-Mesh-Convergence-Study.html, 2015. [Online; ac- cessed 11-December-2016]. [2] Bethany Nine. How to Implement a Mesh Refinement Study. https://www.comsol.com/blogs/ how-to-implement-mesh-refinement-study/, 2013. [Online; accessed 11-December-2016]. [3] University of Rome. Finite Elements for 2-D Problems-General Formula for the Stiffness Matrix. http: //www.uniroma2.it/didattica/TCM/deposito/2-D_elements.pdf, 2016. [Online; accessed 10-December-2016]. [4] David Roylance. How to Perform a Mesh Convergence Study. http://web.mit.edu/course/3/3. 11/www/modules/bstress.pdf, 2000. [Online; accessed 11-December-2016]. [5] Boulder University of Colorado. FEM - Chapter 17 Isoparametric Quadrilaterals. http://www. colorado.edu/engineering/CAS/courses.d/IFEM.d/IFEM.Ch17.d/IFEM.Ch17.pdf, 2016. [Online; accessed 10-December-2016]. Page 29 of 29