Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Finite Element Analysis of a plate with a hole usingConstant Strain triangle, four and eight noded
isoparametric quadrilateral elements
Sagar BhattPerson Number: 50170651
Department of Mechanical and Aerospace Engineering,
University at Buffalo
Contents
I Introduction 2I Problem Set Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
II Method of Solution 4I Governing Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
I.1 For Isoparametric Elements: . . . . . . . . . . . . . . . . . . . . . . . 8I.2 Stress Concentration Factor: . . . . . . . . . . . . . . . . . . . . . . . 9I.3 Energy Norm: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9I.4 Boundary Conditions: . . . . . . . . . . . . . . . . . . . . . . . . . . 9
IIIResults 9I Constant Strain Triangle Element . . . . . . . . . . . . . . . . . . . . . . . . 9II Four Noded Quadrilateral Isoparametric Element . . . . . . . . . . . . . . . 11III Eight Noded Quadrilateral Isoparametric Element . . . . . . . . . . . . . . . 12IV Results from ABAQUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
IV Summary: 13
V Appendix 14I Code to Plot Deformation: . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14II Code for CST Element: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15III Code for 4-noded quadrilateral isoparametric Element: . . . . . . . . . . . . 22IV Code for 4-noded quadrilateral isoparametric Element: . . . . . . . . . . . . 34
List of Figures
1 A constant strain triangle element . . . . . . . . . . . . . . . . . . . . . . . . 32 A 4-noded quadrilateral element . . . . . . . . . . . . . . . . . . . . . . . . . 3
1
3 An 8-noded quadrilateral element . . . . . . . . . . . . . . . . . . . . . . . . 34 The problem setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 The quadrant being used in this study considering symmetry . . . . . . . . . 46 Deformation of the plate due to the load for CST elements . . . . . . . . . . 107 Error in energy norm for CST elements . . . . . . . . . . . . . . . . . . . . . 108 Deformation of the plate due to the load for Q4 elements . . . . . . . . . . . 119 Error in energy norm for Q4 elements . . . . . . . . . . . . . . . . . . . . . . 1110 Deformation of the plate due to the loading for Q8 elements . . . . . . . . . 1211 Error in energy norm for Q8 elements . . . . . . . . . . . . . . . . . . . . . . 1212 Displacement plotted by ABAQUS . . . . . . . . . . . . . . . . . . . . . . . 13
Abstract
This project aims at studying the deformation of a thin plate with a central circularhole when the plate is loaded in tension with a constant load. Finite element codes weredeveloped in MATLAB using constant strain triangle elements, four- and eight-nodedisoparametric elements. A convergence study was performed based on the energy norm afor all three cases and the stress concentration factor around the circular whole was alsoinvestigated.The computed results were then compared with the results obtained usingcommercial code ABAQUS.
I. Introduction
A machine component is bound to have irregularities like a hole in its geometry for variousdesign reasons. These irregularities can contribute immensely to the strength of the part.Configuring the structures with discontinuities is one of the most important topics in theconstruction of ships, aero-planes, cars etc. Examples of problems in which discontinuitiesplay prominent role in the physical behavior of a system are numerous. From mathematicalpoint of view, analytical solutions are possible only for a limited class of such problems.Many times an accurate solution was not possible due to the complexity of the discontinuityconfiguration. However, with the advent of Finite element method (FEM), theses analysescan now be performed with a degree of accuracy.[3]
A Constant Strain Triangle element, also referred to as a CST element or a T3 element,has constant shape functions which when applied to plane stress or plane strain conditions,yield approximate solutions for stress and strain fields that are constant throughout the do-main of the element.
Introduction of isoparametric element formulation in 1968 by Bruce Irons was one of themost important contributions to the field of Finite Elements because it gave us the tools toovercome the complexity of dealing with the consistency requirements for higher order ele-ments with curved boundaries. The same shape functions are used to interpolate the nodal
2
coordinates and displacements. The whole element is transformed into an ideal element (e.g.a square element) by mapping it into a different coordinate system. The shape functions arethen defined for this idealized element. Here two quadrilateral isoparametric elements arebeing considered, 4-noded (also called Q4 element) and 8-noded (also called Q8 element).
Figure 1: A constant strain triangle element
Figure 2: A 4-noded quadrilateral element
Figure 3: An 8-noded quadrilateral element
3
I. Problem Set Up
The problem we are considering consists of a finite plate of length 2L and width 2H witha central hole of radius R, depicted in fig. 4. The relationship between these dimensionsis given by: L/H = α,R/H = β and these vales were determined from the my UB personnumber (50170651). Let abcd ijkl be the person number, the the pooisson’s ratio, ν = j/20.ans α = (k + 1)/2, β = 1/(l + 3). Young’s modulus was arbitrarily assumed to be 2.5.Hence, in this case, α = L/H = 3, β = R/H = 0.25 and ν = 0.3. Since the problem wassymmetrical, we broke the problem to a quarter plate and solved the problem for just onequadrant of the plate using these parameters.
Figure 4: The problem setup
Figure 5: The quadrant being used in this study considering symmetry
II. Method of Solution
I. Governing Equations
A general approach for a displacement based finite element formulation is given by the fol-lowing nine steps[1]. We will demonstrate this formulation for 2D CST. The iso parametricformulation follows the same basic guideline with additional steps involving coordinate trans-formation and Gauss Quadrature.
4
1. Choose the coordinate system and define the node numbering system, nodal displace-ments and body forces for the element.
~ue = u1 v1 u2 v2 u3 v3T
~f e = fx1 fy1 fx2 fy2 fx3 fy3T
2. Choose a displacement function that can represent the fundamental deformation of theelements. According to Principle of Virtual Work (PVW):∫
ΩσijdΩ =
∫ΓttiδuidΓ +
∫ΩfiδuidΩ
Here, if the highest order derivative is nth order, Cn−1 continuity is required. In case ofelastic bodies, the highest order derivative is 1st order, hence we require C0 continuity.So, Let:
u(x) = α1 + α2x+ α3y
v(x) = α4 + α5x+ α4y
Then,~u(~x) = Φ(~x)~α
i.e.
[u(x, y)v(x, y)
]=
[1 x y 0 0 00 0 0 1 x y
]α1
α2
α3
α4
α5
α6
or,
~ue = A~α
5
u1
v1
u2
v2
u3
v3
=
u(x1, y1)v(x1, y1)u(x1, y1)v(x1, y1)u(x2, y2)v(x3, y3)
=
1 x1 y1 0 0 00 0 0 1 x1 y1
1 x1 y1 0 0 00 0 0 1 x2 y2
1 x3 y3 0 0 00 0 0 1 x3 y3
α1
α2
α3
α4
α5
α6
or,
u1
v1
u2
v2
u3
v3
=
A 0
0 A
α1
α2
α3
α4
α5
α6
where,
A =
1 x1 y1
1 x2 y2
1 x3 y3
Then,
A−1 =
[A−1
0
0 A−1
]=⇒ ~u(~x) = Φ(~x)A−1~ue
3.
~ε(~x) =
εxxεyyγxy
=
0 1 0 0 0 00 0 0 0 0 10 0 1 0 1 0
α1
α2
α3
α4
α5
α6
εxx =
∂u
∂x
6
εyy =∂v
∂y
γxy =∂u
∂y+∂v
∂x
~ε(~x) = ∂ΦA−1~ue
=⇒ ~ε(~x) = B~ue
4.
~σ(~x) = C(~x)~ε(~x)
Where,
C(~x) =E(1− ν)
(1 + ν)(1− 2ν)
1
ν
1− ν0
ν
1− ν1 0
0 02ν
2(1− ν)
5.
δ~u(~x) = (N)(~x)δ~ue
∂~ε(~x) = B∂~ue
6. Invoke PVW and develop elemental stiffness matrix:Ke =
∫ΩBTCBdΩ
Now,Ke~ue = ~f e
7. Assemble and enforce boundary conditionsK~u = ~f
8. Solve for ~u
9. Post-Processing
7
For Isoparametric Elements:
Shape Functions:
4-noded element:
– N1(ζ, η) = 14(1− ζ)(1− η)
– N2(ζ, η) = 14(1 + ζ)(1− η)
– N3(ζ, η) = 14(1 + ζ)(1 + η)
– N4(ζ, η) = 14(1− ζ)(1 + η)
8-noded element:
– N1(ζ, η) = −14(1− ζ)(1− η)(ζ + η + 1)
– N1(ζ, η) = 14(1 + ζ)(1− η)(xi− η − 1)
– N1(ζ, η) = 14(1 + ζ)(1 + η)(ζ + η − 1)
– N1(ζ, η) = −14(1− ζ)(1 + η)(ζ − η + 1)
– N1(ζ, η) = 12(1− ζ2)(1− η)
– N1(ζ, η) = 12(1− η2)(1 + ζ)
– N1(ζ, η) = 12(1− ζ2)(1 + η)
– N1(ζ, η) = 12(1− η2)(1− ζ)
Also,x(ζ, η) =
∑iNi(ζ, η)xi
y(ζ, η) =∑
iNi(ζ, η)yi
u(ζ, η) =∑
iNi(ζ, η)ui
v(ζ, η) =∑
iNi(ζ, η)vi
Jacobian: J =
∂x
∂ζ
∂y
∂ζ∂x
∂η
∂y
∂η
=
[J11 J12
J21 J22
]Strain:
~ε(~x) =
εxxεyyγxy
8
εxx =∂u
∂x=∑i
(J11∂Ni
∂ζ+ J12
∂Ni
∂η)ui
εyy =∂v
∂y=∑i
(J21∂Ni
∂ζ+ J22
∂Ni
∂η)vi
γxy =∂u
∂y+∂v
∂x
Stress Concentration Factor:
The stress concentration factor was computed base on the following formula:
SCF =σmax
σnom, where,
σnom =load
minimum cross section
Energy Norm:
The energy norm was computed using:|UFE − UEX ||UEX |
Boundary Conditions:
Since we are considering only one quadrant of the plate, fig.5, the following boundary condi-tions were imposed on this geometry:
Left edge : No displacement in x-direction i.e. 1st degree of freedom set to 0.
Bottom edge : No displacement in y-direction i.e. 2nd degree of freedom set to 0.
III. Results
I. Constant Strain Triangle Element
Number of Elements Stress Concentration Factor Maximum Displacement
2190 1.3363 1.2619594 1.3580 1.2589394 1.1950 1.2567282 1.3594 1.2557156 1.0475 1.2531
9
Deformation:
Figure 6: Deformation of the plate due to the load for CST elements
Convergence Based on Energy Norm:
Figure 7: Error in energy norm for CST elements
10
II. Four Noded Quadrilateral Isoparametric Element
Number of Elements Stress Concentration Factor Maximum Displacement
1095 1.2679 1.2627300 1.7638 1.2616197 1.6378 1.2598137 1.5582 1.258878 1.4677 1.2582
Deformation:
Figure 8: Deformation of the plate due to the load for Q4 elements
Convergence Based on Energy Norm:
Figure 9: Error in energy norm for Q4 elements
11
III. Eight Noded Quadrilateral Isoparametric Element
Number of Elements Stress Concentration Factor Maximum Displacement
300 1.7540 1.3005297 1.7378 1.3005197 1.6175 1.3070137 1.5389 1.309378 1.4529 1.3224
Deformation:
Figure 10: Deformation of the plate due to the loading for Q8 elements
Convergence Based on Energy Norm:
Figure 11: Error in energy norm for Q8 elements
12
IV. Results from ABAQUS
The problem was solved using ABAQUS as well. The maximum displacement obtainedthrough the FE code was compared with the maximum displacement obtained throughABAQUS:
Umax, Abaqus: 1.26394Umax, CST: 1.2619Umax, Q4: 1.2627Umax, Q8: 1.3005
As we can see from the above comparison, the closest result to ABAQUS’s solution isthat of Q4 elements. This is because the mesh chosen for the study on ABAQUS wasequiped with Q4 elements. Hence, a comparative study between these two results is moresuitable. However, the results obtained through any other elements should not be verydifferent. The proximity of the results through all the methods corroborates the accuracy ofthe computation. Figure 12 demonstrates the deformation of a quadrant of the plate underthe load.
Figure 12: Displacement plotted by ABAQUS
IV. Summary:
Finite element codes were developed in MATLAB using constant strain triangle elements,four- and eight-noded isoparametric elements. A convergence study was performed basedon the energy norm a for all three cases and the stress concentration factor around thecircular whole was also investigated. The computed results were then compared with theresults obtained using commercial code ABAQUS. The computed maximum displacementwas ≈ 1.263 (for Q4 elements) where as the result from the result from ABAQUS showedthis to be = 1.264. The results are in very good agreement with each other. The stressconcentration factor was also computed. The deformation was plotted using the MATLABcode as well as ABAQUS. The convergence study based on the error in energy norm was also
13
computed and is presented here in graphical form. We can see that the this error increasesas ’h’ increases or as the number of elements decreases. The results of deformation show thatthe maximum displacement corresponds to the node at the center of each loaded side. Due tosymmetric loading, the central nodes do not move and the circle gets deformed to an ellipse.Another observation to be made here is as the number of nodes per element increases, we cansee the computed deformation increases and the minor axis of now deformed hole is muchsmaller resulting in a much sharper ellipse.
References
[1] Gary F. Dargush. Lecture notes in finite element analysis(mae529). Department ofMechanical and Aerospace Engineering, University at Buffalo, The State University ofNew York, Fall 2016.
[2] E Hart and V Hudramovich. Projection-iterative schemes for the realization of the finite-element method in problems of deformation of plates with holes and inclusions. Journalof Mathematical Sciences, 203(1), 2014.
[3] Sharaban Thohura and Md Shahidul Islam. Study of the effect of finite element meshquality on stress concentration factor of plates with holes. Proceedings of the 15th AnnualPaper Meet, 7:08, 2014.
V. Appendix
I. Code to Plot Deformation:
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 % %3 % PLOTTING THE DEFORMATION %4 % %5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
7
8 % PLotting the i n i t i a l p o s i t i o n nodes9
10 p lo t (Nodes ( : , 2 ) , Nodes ( : , 3 ) , ’ ob ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;11 p lo t (−Nodes ( : , 2 ) ,−Nodes ( : , 3 ) , ’ ob ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;12 p lo t (−Nodes ( : , 2 ) , Nodes ( : , 3 ) , ’ ob ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;13 p lo t (Nodes ( : , 2 ) ,−Nodes ( : , 3 ) , ’ ob ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;14
15 % Finding the f i n a l p o s i t i o n o f the nodes16 j =1;17 f o r i =1:2 : s i z e (U)18 n d i sp ( j , 1 )=U( i ) ;
14
19 n d i sp ( j , 2 )=U( i +1) ;20 j=j +1;21 end22 n f i n a l ( : , 1 )=Nodes ( : , 2 )+n d i sp ( : , 1 ) ;23 n f i n a l ( : , 2 )=Nodes ( : , 3 )+n d i sp ( : , 2 ) ;24
25
26 % Plo t t i ng the f i n a l p o s i t i o n s o f the nodes27
28 p lo t ( n f i n a l ( : , 1 ) , n f i n a l ( : , 2 ) , ’ * r ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;29 p lo t (− n f i n a l ( : , 1 ) , n f i n a l ( : , 2 ) , ’ * r ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;30 p lo t ( n f i n a l ( : , 1 ) ,− n f i n a l ( : , 2 ) , ’ * r ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ;31 p lo t (− n f i n a l ( : , 1 ) ,− n f i n a l ( : , 2 ) , ’ * r ’ ) ; ax i s equal ; ax i s t i g h t ; hold on ; s e t (
gca , ’ c o l o r ’ , ’ b lack ’ )
II. Code for CST Element:
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 % %3 % El a s t i c Constant St ra in Tr iangu lar Elements %4 % %5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
7 % Clear workspace8 c l c9 c l e a r a l l
10
11 nod1= csvread ( ’ Nodes 1 . csv ’ ) ;12 nod2= csvread ( ’ Nodes 2 . csv ’ ) ;13 nod3= csvread ( ’ Nodes 3 . csv ’ ) ;14 nod4= csvread ( ’ Nodes 4 . csv ’ ) ;15 nod5= csvread ( ’ Nodes 5 . csv ’ ) ;16
17 Elm1=csvread ( ’ Elements 1 . csv ’ ) ;18 Elm2=csvread ( ’ Elements 2 . csv ’ ) ;19 Elm3=csvread ( ’ Elements 3 . csv ’ ) ;20 Elm4=csvread ( ’ Elements 4 . csv ’ ) ;21 Elm5=csvread ( ’ Elements 5 . csv ’ ) ;22
23 f o r no=1:524
25 % Read nodes and coords26 i f no==127 Nodes = nod1 ;28 end29 i f no==230 Nodes = nod2 ;31 end32 i f no==3
15
33 Nodes = nod3 ;34 end35 i f no==436 Nodes = nod4 ;37 end38 i f no==539 Nodes = nod5 ;40 end41 [N, l ] = s i z e (Nodes ) ;42
43 % Read element mate r i a l id , t h i c kne s s and nodal c onne c t i v i t y44 i f no==145 Elems = Elm1 ;46 end47 i f no==248 Elems = Elm2 ;49 end50 i f no==351 Elems = Elm3 ;52 end53 i f no==454 Elems = Elm4 ;55 end56 i f no==557 Elems = Elm5 ;58 end59
60 [E, l ] = s i z e ( Elems ) ;61 j dbc =1;62 j nbc =1;63
64 % Read mate r i a l i n f o65 Mats = load ( ’ Mate r i a l s . txt ’ ) ;66 [M, l ] = s i z e (Mats ) ;67
68 %Determine De r i ch l e t BC69 f o r ( i =1:N)70 i f ( Nodes ( i , 2 )==0)71 DBC( j dbc , 1 )=Nodes ( i , 1 ) ;72 DBC( j dbc , 2 ) =1;73 DBC( j dbc , 3 ) =0;74 j dbc=j dbc +1;75 end76 i f ( Nodes ( i , 3 )==0)77 DBC( j dbc , 1 )=Nodes ( i , 1 ) ;78 DBC( j dbc , 2 ) =2;79 DBC( j dbc , 3 ) =0;80 j dbc=j dbc +1;81 end
16
82 end83 [P, l ] = s i z e (DBC) ;84 % Determine Neumann BC85 f o r ( i =1:N)86 i f ( Nodes ( i , 2 )==3)87 r i g h t ( j nbc , 1 )=Nodes ( i , 1 ) ;88 r i g h t ( j nbc , 2 ) =1;89 r i g h t ( j nbc , 3 ) =0;90 j nbc=j nbc +1;91 end92 end93 j nbc =1;94
95
96 comb=combnk( r i g h t ( : , 1 ) , 2 ) ;97
98 f o r i =1:E99 f o r j =1: s i z e (comb ( : , 1 ) )
100 i f comb( j , : ) == Elems ( i , 4 : 5 ) | comb( j , : ) == Elems ( i , 5 : 6 ) | comb( j, : ) == Elems ( i , [ 4 6 ] ) | comb( j , : ) == Elems ( i , [ 6 4 ] ) | comb( j , : ) == Elems ( i, [ 5 4 ] ) | comb( j , : ) == Elems ( i , [ 6 5 ] )
101 NBC( j nbc , 1 )=Elems ( i , 1 ) ;102 NBC( j nbc , 2 : 3 )=comb( j , : ) ;103 NBC( j nbc , 4 ) =1;104 NBC( j nbc , 5 ) =1;105 j nbc=j nbc +1;106 end107 end108 end109 [Q, l ] = s i z e (NBC) ;110
111 % Determining the ho le nodes112 i h o l =1;113 f o r i =1:N114 i f ( Nodes ( i , 2 )<=0.25 && Nodes ( i , 3 ) <=0.25)115 ho le ( i h o l )=Nodes ( i , 1 ) ;116 i h o l=i h o l +1;117 end118 end119
120 % Determining the ho le e lements121 i h o l =1;122 f o r i =1:E123 i f ( ho l e ( i h o l )==Elems ( i , 4 ) | | ho le ( i h o l )==Elems ( i , 5 ) | | ho le ( i h o l )==
Elems ( i , 6 ) )124 h o l e l ( i h o l )=Elems ( i , 1 ) ;125 i h o l=i h o l +1;126 end127 end
17
128 h o l e l=unique ( h o l e l ) ;129
130 % Id en t i f y out−of−plane cond i t i on s131 % ip s t r n = 1 Plane s t r a i n132 % ip s t r n = 2 Plane s t r e s s133 i p s t r n = 2 ;134
135 % Determine t o t a l number o f degrees−of−freedom136 udof = 2 ; % Degrees−of−freedom per node137 NDOF = N*udof ;138
139 % I n i t i a l i z e g l oba l matrix and vec to r s140 K = ze ro s (NDOF,NDOF) ; % S t i f f n e s s matrix141 U = ze ro s (NDOF, 1 ) ; % Displacement vec to r142 F = ze ro s (NDOF, 1 ) ; % Force vec to r143
144 % Set penal ty f o r d i sp lacement c on s t r a i n t s145 Klarge = 10ˆ10;146
147 % Loop over CST element148 f o r e = 1 :E149
150 % Estab l i sh element c onne c t i v i t y and coo rd ina t e s151 Nnums = Elems ( e , 4 : 6 ) ;152 xy = Nodes (Nnums ( : ) , 2 : 3 ) ;153
154 % Extract element th i c kne s s f o r plane s t r e s s155 h = Elems ( e , 3 ) ;156
157 % Extract element e l a s t i c Young ’ s modulus and Poisson ’ s r a t i o158 Y = Mats ( Elems ( e , 2 ) , 2 ) ;159 nu = Mats ( Elems ( e , 2 ) , 3 ) ;160
161 % Construct element s t i f f n e s s matrix162 [Ke ] = CST El St i f f ( ip s t rn , xy , h ,Y, nu) ;163
164 % Assemble element s t i f f n e s s matrix in to g l oba l s t i f f n e s s matrix165 i g = udof *(Nnums ( : ) −1) ;166 f o r n i = 1 :3167 i 0 = udof *( ni−1) ;168 f o r nj = 1 :3169 j 0 = udof *( nj−1) ;170 f o r i = 1 : udof171 f o r j = 1 : udof172 K( i g ( n i )+i , i g ( nj )+j ) = K( i g ( n i )+i , i g ( nj )+j ) + Ke( i 0+i ,
j 0+j ) ;173 end174 end175 end
18
176 end177 end178 % K179
180 % Construct g l oba l f o r c e vec to r181 f o r q = 1 :Q182
183 % Determine loaded edge184 e = NBC(q , 1 ) ;185 in1 = NBC(q , 2 ) ;186 in2 = NBC(q , 3 ) ;187 i d o f = NBC(q , 4 ) ;188 t va l = NBC(q , 5 ) ;189 h = Elems ( e , 3 ) ;190
191 % Estab l i sh edge l ength192 xlen2 = (Nodes ( in2 , 2 )−Nodes ( in1 , 2 ) ) ˆ2 ;193 ylen2 = (Nodes ( in2 , 3 )−Nodes ( in1 , 3 ) ) ˆ2 ;194 e l en = sq r t ( x len2+ylen2 ) ;195 f v a l = tva l * e l en *h/2 ;196 i l o c 1 = udof *( in1−1)+i d o f ;197 i l o c 2 = udof *( in2−1)+i d o f ;198 F( i l o c 1 ) = F( i l o c 1 ) + f v a l ;199 F( i l o c 2 ) = F( i l o c 2 ) + f v a l ;200 F;201
202 end203
204 f o r p = 1 :P205 inode = DBC(p , 1 ) ;206 i d o f = DBC(p , 2 ) ;207 i d i a g = udof *( inode−1) + i d o f ;208 K( id iag , i d i a g ) = Klarge ;209 F( i d i a g ) = Klarge *DBC(p , 3 ) ;210 end211 % K212 % F213
214 % Solve system to determine d i sp lacements215 U = K\F;216
217 % Recover i n t e r n a l element displacement , s t r a i n s and s t r e s s e s218 Disp = ze ro s (E, 6 ) ;219 Eps = ze ro s (E, 3 ) ;220 Sig = ze ro s (E, 3 ) ;221
222 f o r e = 1 :E223
224 % Estab l i sh element c onne c t i v i t y and coo rd ina t e s
19
225 Nnums = Elems ( e , 4 : 6 ) ;226 xy = Nodes (Nnums ( : ) , 2 : 3 ) ;227
228 % Extract element th i c kne s s f o r plane s t r e s s229 h = Elems ( e , 3 ) ;230
231 % Extract element e l a s t i c Young ’ s modulus and Poisson ’ s r a t i o232 Y = Mats ( Elems ( e , 2 ) , 2 ) ;233 nu = Mats ( Elems ( e , 2 ) , 3 ) ;234
235 % Extract element nodal d i sp lacements236 inode1 = Nnums(1) ;237 inode2 = Nnums(2) ;238 inode3 = Nnums(3) ;239 Disp ( e , 1 ) = U( udof *( inode1−1)+1) ;240 Disp ( e , 2 ) = U( udof* inode1 ) ;241 Disp ( e , 3 ) = U( udof *( inode2−1)+1) ;242 Disp ( e , 4 ) = U( udof* inode2 ) ;243 Disp ( e , 5 ) = U( udof *( inode3−1)+1) ;244 Disp ( e , 6 ) = U( udof* inode3 ) ;245
246 u = Disp ( e , : ) ’ ;247 [ eps , s i g ] = CST El Str ( ip s t rn , xy , u , h ,Y, nu) ;248
249 % Store element s t r a i n s250 Eps ( e , : ) = eps ;251
252 % Store element s t r e s s e s253 Sig ( e , : ) = s i g ;254
255 end256
257 % Computing St ra in concent ra t i on f a c t o r258
259 sig nom= 1/0 . 7 5 ;260
261 f o r i =1: s i z e ( h o l e l )262 s ig max=max( Sig ( h o l e l ( i ) , : , : ) ) ;263 end264 SCF(no )=mean( sig max ) / sig nom ;265
266
267 PE(no , 1 ) =0.5*U’*K*U;268
269 PE(no , 2 )=3/N;270 % i f ( no==1)271 % s t r=s p r i n t f ( ’ Or i g i na l p l a t e vs deformed p l a t e us ing constant s t r a i n
t r i a n g l e e lements f o r %d elements ’ ,E) ;272 % f i g u r e ;
20
273 % Plot de fo rmat ion ;274 % t i t l e ( s t r ) ;275 % x lab e l ( ’\ l e f t a r r ow 2L \ r ightarrow ’ ) ;276 % y lab e l ( ’\ l e f t a r r ow 2H \ r ightarrow ’ ) ;277 max(U)278 % end279 % E280 c l e a r v a r s −except nod1 nod2 nod3 nod4 nod5 Elm1 Elm2 Elm3 Elm4 Elm5 PE SCF
;281 end282
283 f o r i =1:5284 i f (PE( i , 2 )==min (PE( : , 2 ) ) )285 PE ex=PE( i , 1 ) ;286 end287 end288 PE( : , 1 )=abs (PE( : , 1 )−PE ex ) /abs (PE ex ) ;289
290 % f i g u r e ;291 % plo t ( l og (PE( : , 2 ) ) , l og (PE( : , 1 ) ) , ’−o ’ ) ;292 % t i t l e ( ’ Error in Energy norm ’ ) ;293 % x lab e l ( ’ $ l og (h)$ ’ , ’ I n t e rp r e t e r ’ , ’ l a tex ’ ) ;294 % y lab e l ( ’ $ l og (\ f r a c |U FE−U EX | |U EX | ) $ ’ , ’ I n t e rp r e t e r ’ , ’ l a tex ’ ) ;295 % ax i s square ;296 %297 % Disp298 % Eps299 % Sig
1 f unc t i on Ke = CST El St i f f ( ip s t rn , xy , h ,Y, nu)2
3 ndof = 6 ;4 Ke = ze ro s ( ndof , ndof ) ;5
6 Abar = [ 1 xy (1 , 1 ) xy (1 , 2 ) ; 1 xy (2 , 1 ) xy (2 , 2 ) ; 1 xy (3 , 1 ) xy (3 , 2 ) ] ;7 A = det (Abar ) /2 ;8
9 B = (1/A/2) * [ xy (2 , 2 )−xy (3 , 2 ) 0 xy (3 , 2 )−xy (1 , 2 ) 0 xy (1 , 2 )−xy (2 , 2 ) 0 ;10 0 xy (3 , 1 )−xy (2 , 1 ) 0 xy (1 , 1 )−xy (3 , 1 ) 0 xy (2 , 1 )−xy (1 , 1 ) ;11 xy (3 , 1 )−xy (2 , 1 ) xy (2 , 2 )−xy (3 , 2 ) xy (1 , 1 )−xy (3 , 1 ) . . .12 xy (3 , 2 )−xy (1 , 2 ) xy (2 , 1 )−xy (1 , 1 ) xy (1 , 2 )−xy (2 , 2 ) ] ;13
14 i f ( i p s t r n == 1)15 c = Y*(1−nu) /(1−2*nu) /(1+nu) ;16 C = c * [ 1 nu/(1−nu) 0 ; nu/(1−nu) 1 0 ; 0 0 (1−2*nu)/(1−nu) /2 ] ;17 e l s e18 c = Y/(1−nu) /(1+nu) ;19 C = c * [ 1 nu 0 ; nu 1 0 ; 0 0 (1−nu) /2 ] ;20 end21
21
22 Ke = h*A*B’*C*B;
1 f unc t i on [ eps , s t r ] = CST El Str ( ip s t rn , xy , u , h ,Y, nu)2
3 ndof = 6 ;4
5 Abar = [ 1 xy (1 , 1 ) xy (1 , 2 ) ; 1 xy (2 , 1 ) xy (2 , 2 ) ; 1 xy (3 , 1 ) xy (3 , 2 ) ] ;6 A = det (Abar ) /2 ;7
8 B = (1/A/2) * [ xy (2 , 2 )−xy (3 , 2 ) 0 xy (3 , 2 )−xy (1 , 2 ) 0 xy (1 , 2 )−xy (2 , 2 ) 0 ;9 0 xy (3 , 1 )−xy (2 , 1 ) 0 xy (1 , 1 )−xy (3 , 1 ) 0 xy (2 , 1 )−xy (1 , 1 ) ;
10 xy (3 , 1 )−xy (2 , 1 ) xy (2 , 2 )−xy (3 , 2 ) xy (1 , 1 )−xy (3 , 1 ) . . .11 xy (3 , 2 )−xy (1 , 2 ) xy (2 , 1 )−xy (1 , 1 ) xy (1 , 2 )−xy (2 , 2 ) ] ;12
13 i f ( i p s t r n == 1)14 c = Y*(1−nu) /(1−2*nu) /(1+nu) ;15 C = c * [ 1 nu/(1−nu) 0 ; nu/(1−nu) 1 0 ; 0 0 (1−2*nu)/(1−nu) /2 ] ;16 e l s e17 c = Y/(1−nu) /(1+nu) ;18 C = c * [ 1 nu 0 ; nu 1 0 ; 0 0 (1−nu) /2 ] ;19 end20
21 eps = B*u ;22 s t r = C* eps ;
III. Code for 4-noded quadrilateral isoparametric Element:
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 % %3 % El a s t i c 4−node Quadra late ra l Elements %4 % %5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
7 % Clear workspace8 c l c9 c l e a r
10
11 % Read nodes and coords12 nod1= csvread ( ’ Nodes 1 . csv ’ ) ;13 nod2= csvread ( ’ Nodes 2 . csv ’ ) ;14 nod3= csvread ( ’ Nodes 3 . csv ’ ) ;15 nod4= csvread ( ’ Nodes 4 . csv ’ ) ;16 nod5= csvread ( ’ Nodes 5 . csv ’ ) ;17
18 Elm1=csvread ( ’ Elements 1 . csv ’ ) ;19 Elm2=csvread ( ’ Elements 2 . csv ’ ) ;20 Elm3=csvread ( ’ Elements 3 . csv ’ ) ;21 Elm4=csvread ( ’ Elements 4 . csv ’ ) ;22 Elm5=csvread ( ’ Elements 5 . csv ’ ) ;23
22
24 f o r no=1:525
26 % Read nodes and coords27 i f no==128 Nodes = nod1 ;29 end30 i f no==231 Nodes = nod2 ;32 end33 i f no==334 Nodes = nod3 ;35 end36 i f no==437 Nodes = nod4 ;38 end39 i f no==540 Nodes = nod5 ;41 end42 [N, l ] = s i z e (Nodes ) ;43
44 % Read element mate r i a l id , t h i c kne s s and nodal c onne c t i v i t y45 i f no==146 Elems = Elm1 ;47 end48 i f no==249 Elems = Elm2 ;50 end51 i f no==352 Elems = Elm3 ;53 end54 i f no==455 Elems = Elm4 ;56 end57 i f no==558 Elems = Elm5 ;59 end60
61 [E, l ] = s i z e ( Elems ) ;62 j dbc =1;63 j nbc =1;64 % Number o f nodes per element65 NE = l −3;66
67 % Read mate r i a l i n f o68 Mats = load ( ’ Mate r i a l s . txt ’ ) ;69 [M, l ] = s i z e (Mats ) ;70
71 % Id en t i f y out−of−plane cond i t i on s72 % ip s t r n = 1 Plane s t r a i n
23
73 % ip s t r n = 2 Plane s t r e s s74 i p s t r n = 2 ;75 nstrn = 3 ;76
77 %Determine De r i ch l e t BC78 f o r ( i =1:N)79 i f ( Nodes ( i , 2 )==0)80 DBC( j dbc , 1 )=Nodes ( i , 1 ) ;81 DBC( j dbc , 2 ) =1;82 DBC( j dbc , 3 ) =0;83 j dbc=j dbc +1;84 end85 i f ( Nodes ( i , 3 )==0)86 DBC( j dbc , 1 )=Nodes ( i , 1 ) ;87 DBC( j dbc , 2 ) =2;88 DBC( j dbc , 3 ) =0;89 j dbc=j dbc +1;90 end91 end92 [P, l ] = s i z e (DBC) ;93
94 % Determine Neumann BC95 f o r ( i =1:N)96 i f ( Nodes ( i , 2 )==3)97 r i g h t ( j nbc , 1 )=Nodes ( i , 1 ) ;98 r i g h t ( j nbc , 2 ) =1;99 r i g h t ( j nbc , 3 ) =0;
100 j nbc=j nbc +1;101 end102 end103 j nbc =1;104
105
106 f o r i =1:E107 f o r j =1: s i z e ( r i g h t ( : , 1 ) )108 f o r k=4:7109
110 i f Elems ( i , k )==r i gh t ( j , 1 )111
112 e l l i s t ( j nbc , 1 )=Elems ( i , 1 ) ;113 e l l i s t ( j nbc , 2 )=r i gh t ( j , 1 ) ;114 j nbc=j nbc +1;115 break116 end117 end118
119 end120 end121 NBC( : , 1 )=unique ( e l l i s t ( : , 1 ) ) ;
24
122 f o r i =1:2 : s i z e ( e l l i s t ( : , 1 ) )123 f o r j =1: s i z e (NBC( : , 1 ) )124
125 k=0;126 i f (NBC( j , 1 )==e l l i s t ( i , 1 ) )127 NBC( j , 2 : 3 ) =[ e l l i s t ( i , 2 ) e l l i s t ( i +1 ,2) ] ;128 end129 end130 end131 NBC( : , 4 ) =1;132 NBC( : , 5 ) =1;133 [Q, l ] = s i z e (NBC) ;134
135 % Determining the ho le nodes136 i h o l =1;137 f o r i =1:N138 i f ( Nodes ( i , 2 )<=0.25 && Nodes ( i , 3 ) <=0.25)139 ho le ( i h o l )=Nodes ( i , 1 ) ;140 i h o l=i h o l +1;141 end142 end143
144 % Determining the ho le e lements145 i h o l =1;146 f o r i =1:E147 i f ( ho l e ( i h o l )==Elems ( i , 4 ) | | ho le ( i h o l )==Elems ( i , 5 ) | | ho le ( i h o l )==
Elems ( i , 6 ) | | ho le ( i h o l )==Elems ( i , 7 ) )148 h o l e l ( i h o l )=Elems ( i , 1 ) ;149 i h o l=i h o l +1;150 end151 end152 h o l e l=unique ( h o l e l ) ;153 % Determine t o t a l number o f degrees−of−freedom154 udof = 2 ; % Degrees−of−freedom per node155 NDOF = N*udof ;156
157 % I n i t i a l i z e g l oba l matrix and vec to r s158 K = ze ro s (NDOF,NDOF) ; % S t i f f n e s s matrix159 U = ze ro s (NDOF, 1 ) ; % Displacement vec to r160 F = ze ro s (NDOF, 1 ) ; % Force vec to r161
162 % Set penal ty f o r d i sp lacement c on s t r a i n t s163 Klarge = 10ˆ8 ;164
165
166 % Set Gauss po int l o c a t i o n s and weights167 NG = 4 ;168 [XG,WG] = Q4 El Gauss Points (NG) ;169
25
170 % Loop over Q4 elements171 f o r e = 1 :E172
173 % Estab l i sh element c onne c t i v i t y and coo rd ina t e s174 Nnums = Elems ( e ,4 :3+NE) ;175 xy = Nodes (Nnums ( : ) , 2 : 3 ) ;176
177 % Extract element th i c kne s s f o r plane s t r e s s178 h = Elems ( e , 3 ) ;179
180 % Extract element e l a s t i c Young ’ s modulus and Poisson ’ s r a t i o181 Y = Mats ( Elems ( e , 2 ) , 2 ) ;182 nu = Mats ( Elems ( e , 2 ) , 3 ) ;183
184 % Construct element s t i f f n e s s matrix185 [Ke ] = Q4 E l S t i f f ( ip s t rn , xy , h ,Y, nu , udof ,NE,NG,XG,WG) ;186
187 % Assemble element s t i f f n e s s matrix in to g l oba l s t i f f n e s s matrix188 i g = udof *(Nnums ( : ) −1) ;189 f o r n i = 1 :NE190 i 0 = udof *( ni−1) ;191 f o r nj = 1 :NE192 j 0 = udof *( nj−1) ;193 f o r i = 1 : udof194 f o r j = 1 : udof195 K( i g ( n i )+i , i g ( nj )+j ) = K( i g ( n i )+i , i g ( nj )+j ) + Ke( i 0+i ,
j 0+j ) ;196 end197 end198 end199 end200 end201 %K202
203 % Construct g l oba l f o r c e vec to r f o r loaded edges with constant t r a c t i o n204 NES = 2 ;205 % Set Gauss po int l o c a t i o n s and weights f o r t r a c t i o n i n t e g r a t i o n206 NGS = 2 ;207 [XGS,WGS] = Q4 El Gauss Points Sur f (NGS) ;208
209 f o r q = 1 :Q210
211 in = ze ro s (NES) ;212 t va l = ze ro s (NES, 1 ) ;213 f v a l = ze ro s (NES, 1 ) ;214
215 % Determine loaded edge216 e = NBC(q , 1 ) ;217 in1 = NBC(q , 2 ) ;
26
218 in2 = NBC(q , 3 ) ;219 i d o f = NBC(q , 4 ) ;220 t va l ( : , 1 ) = NBC(q , 4 : 5 ) ;221 h = Elems ( e , 3 ) ;222
223 f o r i =1:NGS224
225 % Evaluate f o r c e c on t r i bu t i on s at Gauss po in t s226 x i = XGS( i ) ;227 wgt = WGS( i ) ;228
229 [ NshapeS ] = Q4 El Shape Surf (NES, x i ) ;230 [ DNshapeS ] = Q4 El DShape Surf (NES, x i ) ;231
232 xyS (1 , 1 ) = Nodes ( in1 , 2 ) ;233 xyS (1 , 2 ) = Nodes ( in1 , 3 ) ;234 xyS (2 , 1 ) = Nodes ( in2 , 2 ) ;235 xyS (2 , 2 ) = Nodes ( in2 , 3 ) ;236 [ detJS ] = Q4 El Jacob ian Sur f (NES, xi , xyS , DNshapeS) ;237
238 f v a l = f v a l + h*wgt*NshapeS ’*NshapeS* t va l *detJS ;239
240 end241 %fv a l242
243 i l o c 1 = udof *( in1−1)+i d o f ;244 i l o c 2 = udof *( in2−1)+i d o f ;245 F( i l o c 1 ) = F( i l o c 1 ) + f v a l (1 ) ;246 F( i l o c 2 ) = F( i l o c 2 ) + f v a l (2 ) ;247 %F248
249 end250
251 % Impose D i r i c h l e t boundary cond i t i on s252 f o r p = 1 :P253 inode = DBC(p , 1 ) ;254 i d o f = DBC(p , 2 ) ;255 i d i a g = udof *( inode−1) + i d o f ;256 K( id iag , i d i a g ) = Klarge ;257 F( i d i a g ) = Klarge *DBC(p , 3 ) ;258 end259 %K260 %F261
262 % Solve system to determine d i sp lacements263 U = K\F;264
265 % Recover i n t e r n a l element displacement , s t r a i n s and s t r e s s e s266 nedof = udof*NE;
27
267 Disp = ze ro s (E, nedof ) ;268 Eps = ze ro s (E, nstrn ,NG) ;269 Sig = ze ro s (E, nstrn ,NG) ;270
271 f o r e = 1 :E272
273 % Estab l i sh element c onne c t i v i t y and coo rd ina t e s274 Nnums = Elems ( e ,4 :3+NE) ;275 xy = Nodes (Nnums ( : ) , 2 : 3 ) ;276
277 % Extract element th i c kne s s f o r plane s t r e s s278 h = Elems ( e , 3 ) ;279
280 % Extract element e l a s t i c Young ’ s modulus and Poisson ’ s r a t i o281 Y = Mats ( Elems ( e , 2 ) , 2 ) ;282 nu = Mats ( Elems ( e , 2 ) , 3 ) ;283
284 % Extract element nodal d i sp lacements285 f o r i =1:NE286 inode = Nnums( i ) ;287 i g l b 1 = udof *( inode−1)+1;288 i g l b 2 = udof* inode ;289 i l o c 1 = udof *( i −1)+1;290 i l o c 2 = udof* i ;291 Disp ( e , i l o c 1 ) = U( i g l b 1 ) ;292 Disp ( e , i l o c 2 ) = U( i g l b 2 ) ;293 end294 %Disp295
296 u = Disp ( e , : ) ’ ;297 [ eps , s i g ] = Q4 El Str ( ip s t rn , xy , u , h ,Y, nu , udof ,NE,NG,XG) ;298 %eps299 %s i g300
301 % Store element s t r a i n s302 Eps ( e , : , : ) = eps ( : , : ) ;303
304 % Store element s t r e s s e s305 Sig ( e , : , : ) = s i g ( : , : ) ;306
307 end308
309 % Computing St ra in concent ra t i on f a c t o r310
311 sig nom= 1/0 . 7 5 ;312
313 f o r i =1: s i z e ( h o l e l )314 s ig max=max( Sig ( h o l e l ( i ) , : , : ) ) ;315 end
28
316 SCF(no )=mean( sig max ) / sig nom ;317
318 PE(no , 1 ) =0.5*U’*K*U;319
320 PE(no , 2 )=3/N;321 % i f ( no==1)322 % s t r=s p r i n t f ( ’ Or i g i na l p l a t e vs deformed p l a t e us ing 4 Noded Quad
elements f o r %d elements ’ ,E) ;323 % f i g u r e ;324 % Plot de fo rmat ion ;325 % t i t l e ( s t r ) ;326 % x lab e l ( ’\ l e f t a r r ow 2L \ r ightarrow ’ ) ;327 % y lab e l ( ’\ l e f t a r r ow 2H \ r ightarrow ’ ) ;328 max(U)329 % end330 E331 c l e a r v a r s −except nod1 nod2 nod3 nod4 nod5 Elm1 Elm2 Elm3 Elm4 Elm5 PE SCF
;332 end333
334 f o r i =1:5335 i f (PE( i , 2 )==min (PE( : , 2 ) ) )336 PE ex=PE( i , 1 ) ;337 end338 end339 PE( : , 1 )=abs (PE( : , 1 )−PE ex ) /abs (PE ex ) ;340
341 % f i g u r e ;342 % plo t ( l og (PE( : , 2 ) ) , l og (PE( : , 1 ) ) , ’−o ’ ) ;343 % t i t l e ( ’ Error in Energy norm ’ ) ;344 % x lab e l ( ’ $ l og (h)$ ’ , ’ I n t e rp r e t e r ’ , ’ l a tex ’ ) ;345 % y lab e l ( ’ $ l og (\ f r a c |U FE−U EX | |U EX | ) $ ’ , ’ I n t e rp r e t e r ’ , ’ l a tex ’ ) ;346 % ax i s square ;347 % Disp ;348 % Eps ;349 % Sig ;
1 f unc t i on [ DNshape ] = Q4 El DShape (NE, xi , e ta )2
3 DNshape (1 , 1 ) = −(1−eta ) /4 ;4 DNshape (2 , 1 ) = +(1−eta ) /4 ;5 DNshape (3 , 1 ) = +(1+eta ) /4 ;6 DNshape (4 , 1 ) = −(1+eta ) /4 ;7
8 DNshape (1 , 2 ) = −(1−x i ) /4 ;9 DNshape (2 , 2 ) = −(1+x i ) /4 ;
10 DNshape (3 , 2 ) = +(1+x i ) /4 ;11 DNshape (4 , 2 ) = +(1−x i ) /4 ;
1 f unc t i on [ DNshapeS ] = Q4 El DShape Surf (NES, x i )
29
2
3 DNshapeS (1 ) = −1/2;4 DNshapeS (2 ) = +1/2;
1 f unc t i on [XG,WG] = Q4 El Gauss Points (NG)2
3 i f (NG == 4)4
5 a l f = sq r t (1/3) ;6
7 XG(1 ,1 ) = −a l f ;8 XG(2 ,1 ) = +a l f ;9 XG(3 ,1 ) = +a l f ;
10 XG(4 ,1 ) = −a l f ;11
12 XG(1 ,2 ) = −a l f ;13 XG(2 ,2 ) = −a l f ;14 XG(3 ,2 ) = +a l f ;15 XG(4 ,2 ) = +a l f ;16
17 f o r i =1:NG18 WG( i ) = 1 ;19 end20
21 e l s e22
23 a l f = sq r t (3/5) ;24
25 XG(1 ,1 ) = −a l f ;26 XG(2 ,1 ) = 0 ;27 XG(3 ,1 ) = +a l f ;28 XG(4 ,1 ) = −a l f ;29 XG(5 ,1 ) = 0 ;30 XG(6 ,1 ) = +a l f ;31 XG(7 ,1 ) = −a l f ;32 XG(8 ,1 ) = 0 ;33 XG(9 ,1 ) = +a l f ;34
35 XG(1 ,2 ) = −a l f ;36 XG(2 ,2 ) = −a l f ;37 XG(3 ,2 ) = −a l f ;38 XG(4 ,2 ) = 0 ;39 XG(5 ,2 ) = 0 ;40 XG(6 ,2 ) = 0 ;41 XG(7 ,2 ) = +a l f ;42 XG(8 ,2 ) = +a l f ;43 XG(9 ,2 ) = +a l f ;44
45 WG(1) = 25/81 ;46 WG(2) = 40/81 ;
30
47 WG(3) = 25/81 ;48 WG(4) = 40/81 ;49 WG(5) = 64/81 ;50 WG(6) = 40/81 ;51 WG(7) = 25/81 ;52 WG(8) = 40/81 ;53 WG(9) = 25/81 ;54
55 end
1 f unc t i on [XGS,WGS] = Q4 El Gauss Points Sur f (NGS)2
3 i f (NGS == 2)4
5 a l f = sq r t (1/3) ;6
7 XGS(1 , 1 ) = −a l f ;8 XGS(2 , 1 ) = +a l f ;9
10 WGS(1) = 1 ;11 WGS(2) = 1 ;12
13 e l s e14
15 a l f = sq r t (3/5) ;16
17 XGS(1 , 1 ) = −a l f ;18 XGS(2 , 1 ) = 0 ;19 XGS(3 , 1 ) = +a l f ;20
21 WGS(1) = 5/9 ;22 WGS(2) = 8/9 ;23 WGS(3) = 5/9 ;24
25 end
1 f unc t i on [ Jac , detJ , Jhat ] = Q4 El Jacobian (NE, xi , eta , xy , DNshape )2
3 Jac = ze ro s (2 , 2 ) ;4
5 f o r i =1:NE6 Jac (1 , 1 ) = Jac (1 , 1 ) + DNshape ( i , 1 ) *xy ( i , 1 ) ;7 Jac (1 , 2 ) = Jac (1 , 2 ) + DNshape ( i , 1 ) *xy ( i , 2 ) ;8 Jac (2 , 1 ) = Jac (2 , 1 ) + DNshape ( i , 2 ) *xy ( i , 1 ) ;9 Jac (2 , 2 ) = Jac (2 , 2 ) + DNshape ( i , 2 ) *xy ( i , 2 ) ;
10 end11
12 detJ = det ( Jac ) ;13 Jhat = inv ( Jac ) ;
31
1 f unc t i on [ detJS ] = Q4 El Jacob ian Sur f (NES, xi , xyS , DNshapeS)2
3 dxdxi = 0 ;4 dydxi = 0 ;5
6 f o r i =1:NES7 dxdxi = dxdxi + DNshapeS ( i ) *xyS ( i , 1 ) ;8 dydxi = dydxi + DNshapeS ( i ) *xyS ( i , 2 ) ;9 end
10
11 detJS = sq r t ( dxdxi*dxdxi + dydxi*dydxi ) ;
1 f unc t i on [ Nshape ] = Q4 El Shape (NE, xi , e ta )2
3 Nshape (1 ) = (1−x i )*(1− eta ) /4 ;4 Nshape (2 ) = (1+x i )*(1− eta ) /4 ;5 Nshape (3 ) = (1+x i ) *(1+ eta ) /4 ;6 Nshape (4 ) = (1−x i ) *(1+ eta ) /4 ;
1 f unc t i on [ NshapeS ] = Q4 El Shape Surf (NES, x i )2
3 NshapeS (1 ) = (1−x i ) /2 ;4 NshapeS (2 ) = (1+x i ) /2 ;5
6 %NshapeS = NshapeS ’ ;
1 f unc t i on Ke = CST El St i f f ( ip s t rn , xy , h ,Y, nu , udof ,NE,NG,XG,WG)2
3 ndof = NE*udof ;4 nstrn = 3 ;5 Ke = ze ro s ( ndof , ndof ) ;6
7 f o r i =1:NG8
9 x i = XG( i , 1 ) ;10 eta = XG( i , 2 ) ;11 wgt = WG( i ) ;12
13 %[ Nshape ] = Q4 El Shape (NE, xi , e ta ) ;14 [ DNshape ] = Q4 El DShape (NE, xi , e ta ) ;15 [ Jac , detJ , Jhat ] = Q4 El Jacobian (NE, xi , eta , xy , DNshape ) ;16
17 B = ze ro s ( nstrn , ndof ) ;18 f o r j =1:NE19 j l o c 1 = 2*( j−1)+1;20 j l o c 2 = j l o c 1 + 1 ;21 B(1 , j l o c 1 ) = B(1 , j l o c 1 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .22 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;23 B(2 , j l o c 2 ) = B(2 , j l o c 2 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .24 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;
32
25 B(3 , j l o c 1 ) = B(3 , j l o c 1 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .26 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;27 B(3 , j l o c 2 ) = B(3 , j l o c 2 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .28 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;29 end30
31 i f ( i p s t r n == 1)32 c = Y*(1−nu) /(1−2*nu) /(1+nu) ;33 C = c * [ 1 nu/(1−nu) 0 ; nu/(1−nu) 1 0 ; 0 0 (1−2*nu)/(1−nu) /2 ] ;34 e l s e35 c = Y/(1−nu) /(1+nu) ;36 C = c * [ 1 nu 0 ; nu 1 0 ; 0 0 (1−nu) /2 ] ;37 end38
39 Ke = Ke + h*wgt*B’*C*B*detJ ;40
41 end
1 f unc t i on [ eps , s i g ] = Q4 El Str ( ip s t rn , xy , u , h ,Y, nu , udof ,NE,NG,XG) ;2
3 ndof = NE*udof ;4 nstrn = 3 ;5 eps = ze ro s ( nstrn ,NG) ;6 s i g = ze ro s ( nstrn ,NG) ;7
8 f o r i =1:NG9
10 x i = XG( i , 1 ) ;11 eta = XG( i , 2 ) ;12
13 [ DNshape ] = Q4 El DShape (NE, xi , e ta ) ;14 [ Jac , detJ , Jhat ] = Q4 El Jacobian (NE, xi , eta , xy , DNshape ) ;15
16 B = ze ro s ( nstrn , ndof ) ;17 f o r j =1:NE18 j l o c 1 = 2*( j−1)+1;19 j l o c 2 = j l o c 1 + 1 ;20 B(1 , j l o c 1 ) = B(1 , j l o c 1 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .21 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;22 B(2 , j l o c 2 ) = B(2 , j l o c 2 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .23 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;24 B(3 , j l o c 1 ) = B(3 , j l o c 1 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .25 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;26 B(3 , j l o c 2 ) = B(3 , j l o c 2 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .27 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;28 end29
30 i f ( i p s t r n == 1)31 c = Y*(1−nu) /(1−2*nu) /(1+nu) ;32 C = c * [ 1 nu/(1−nu) 0 ; nu/(1−nu) 1 0 ; 0 0 (1−2*nu)/(1−nu) /2 ] ;
33
33 e l s e34 c = Y/(1−nu) /(1+nu) ;35 C = c * [ 1 nu 0 ; nu 1 0 ; 0 0 (1−nu) /2 ] ;36 end37
38 eps ( : , i ) = B*u ;39 s i g ( : , i ) = C* eps ( : , i ) ;40
41 end
IV. Code for 4-noded quadrilateral isoparametric Element:
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 % %3 % El a s t i c 8−node Quadra late ra l Elements %4 % %5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%6
7 % Clear workspace8 c l c9 c l e a r
10 c l o s e a l l11 % Read nodes and coords12 nod1= csvread ( ’ Nodes 1 . csv ’ ) ;13 nod2= csvread ( ’ Nodes 2 . csv ’ ) ;14 nod3= csvread ( ’ Nodes 3 . csv ’ ) ;15 nod4= csvread ( ’ Nodes 4 . csv ’ ) ;16 nod5= csvread ( ’ Nodes 5 . csv ’ ) ;17
18 Elm1=csvread ( ’ Elements 1 . csv ’ ) ;19 Elm2=csvread ( ’ Elements 2 . csv ’ ) ;20 Elm3=csvread ( ’ Elements 3 . csv ’ ) ;21 Elm4=csvread ( ’ Elements 4 . csv ’ ) ;22 Elm5=csvread ( ’ Elements 5 . csv ’ ) ;23
24 f o r no=1:525
26 % Read nodes and coords27 i f no==128 Nodes = nod1 ;29 end30 i f no==231 Nodes = nod2 ;32 end33 i f no==334 Nodes = nod3 ;35 end36 i f no==437 Nodes = nod4 ;
34
38 end39 i f no==540 Nodes = nod5 ;41 end42 [N, l ] = s i z e (Nodes ) ;43
44 % Read element mate r i a l id , t h i c kne s s and nodal c onne c t i v i t y45 i f no==146 Elems = Elm1 ;47 end48 i f no==249 Elems = Elm2 ;50 end51 i f no==352 Elems = Elm3 ;53 end54 i f no==455 Elems = Elm4 ;56 end57 i f no==558 Elems = Elm5 ;59 end60 [E, l ] = s i z e ( Elems ) ;61 j dbc =1;62 j nbc =1;63 % Number o f nodes per element64 NE = l −3;65
66 % Read mate r i a l i n f o67 Mats = load ( ’ Mate r i a l s . txt ’ ) ;68 [M, l ] = s i z e (Mats ) ;69
70 % Id en t i f y out−of−plane cond i t i on s71 % ip s t r n = 1 Plane s t r a i n72 % ip s t r n = 2 Plane s t r e s s73 i p s t r n = 2 ;74 nstrn = 3 ;75
76 %Determine De r i ch l e t BC77 f o r ( i =1:N)78 i f ( Nodes ( i , 2 )==0)79 DBC( j dbc , 1 )=Nodes ( i , 1 ) ;80 DBC( j dbc , 2 ) =1;81 DBC( j dbc , 3 ) =0;82 j dbc=j dbc +1;83 end84 i f ( Nodes ( i , 3 )==0)85 DBC( j dbc , 1 )=Nodes ( i , 1 ) ;86 DBC( j dbc , 2 ) =2;
35
87 DBC( j dbc , 3 ) =0;88 j dbc=j dbc +1;89 end90 end91 [P, l ] = s i z e (DBC) ;92 % Determine Neumann BC93 f o r ( i =1:N)94 i f ( Nodes ( i , 2 )==3)95 r i g h t ( j nbc , 1 )=Nodes ( i , 1 ) ;96 r i g h t ( j nbc , 2 ) =1;97 r i g h t ( j nbc , 3 ) =0;98 j nbc=j nbc +1;99 end
100 end101 j nbc =1;102 f o r i =1:E103 f o r j =1: s i z e ( r i g h t ( : , 1 ) )104 f o r k=4:11105 i f Elems ( i , k )==r i gh t ( j , 1 )106 e l l i s t ( j nbc , 1 )=Elems ( i , 1 ) ;107 e l l i s t ( j nbc , 2 )=r i gh t ( j , 1 ) ;108 j nbc=j nbc +1;109 break110 end111 end112 end113 end114 NBC( : , 1 )=unique ( e l l i s t ( : , 1 ) ) ;115 j nbc =1;116 f o r i =1:3 : s i z e ( e l l i s t ( : , 1 ) )117 f o r j =4:7118 i f ( e l l i s t ( i , 2 )==Elems ( e l l i s t ( i , 1 ) , j ) | | e l l i s t ( i +1 ,2)==Elems (
e l l i s t ( i , 1 ) , j ) )119 i f ( e l l i s t ( i , 2 )==Elems ( e l l i s t ( i , 1 ) , j ) )120 NBC( j nbc , 2 )=e l l i s t ( i , 2 ) ;121 NBC( j nbc , 4 )=e l l i s t ( i +1 ,2) ;122 NBC( j nbc , 3 )=e l l i s t ( i +2 ,2) ;123 j nbc=j nbc +1;124 break ;125 e l s e126 NBC( j nbc , 2 )=e l l i s t ( i +1 ,2) ;127 NBC( j nbc , 4 )=e l l i s t ( i , 2 ) ;128 NBC( j nbc , 3 )=e l l i s t ( i +2 ,2) ;129 j nbc=j nbc +1;130 break ;131 end132 end133 end134 end
36
135
136 NBC( : , 5 ) =1;137 NBC( : , 6 ) =1;138 [Q, l ] = s i z e (NBC) ;139
140
141 % Determining the ho le nodes142 i h o l =1;143 f o r i =1:N144 i f ( Nodes ( i , 2 )<=0.25 && Nodes ( i , 3 ) <=0.25)145 ho le ( i h o l )=Nodes ( i , 1 ) ;146 i h o l=i h o l +1;147 end148 end149
150 % Determining the ho le e lements151 i h o l =1;152 f o r i =1:E153 i f ( ho l e ( i h o l )==Elems ( i , 4 ) | | ho le ( i h o l )==Elems ( i , 5 ) | | ho le ( i h o l )==
Elems ( i , 6 ) | | ho le ( i h o l )==Elems ( i , 7 ) | | ho le ( i h o l )==Elems ( i , 8 ) | | ho le ( i h o l )==Elems ( i , 9 ) | | ho le ( i h o l )==Elems ( i , 1 0 ) | | ho le ( i h o l )==Elems ( i , 1 1 ) )
154 h o l e l ( i h o l )=Elems ( i , 1 ) ;155 i h o l=i h o l +1;156 end157 end158 h o l e l=unique ( h o l e l ) ;159
160
161 % Determine t o t a l number o f degrees−of−freedom162 udof = 2 ; % Degrees−of−freedom per node163 NDOF = N*udof ;164
165 % I n i t i a l i z e g l oba l matrix and vec to r s166 K = ze ro s (NDOF,NDOF) ; % S t i f f n e s s matrix167 U = ze ro s (NDOF, 1 ) ; % Displacement vec to r168 F = ze ro s (NDOF, 1 ) ; % Force vec to r169
170 % Set penal ty f o r d i sp lacement c on s t r a i n t s171 Klarge = 10ˆ8 ;172
173
174 % Set Gauss po int l o c a t i o n s and weights175 NG = 4 ;176 [XG,WG] = Q8 El Gauss Points (NG) ;177
178 % Loop over Q8 elements179 f o r e = 1 :E180
181 % Estab l i sh element c onne c t i v i t y and coo rd ina t e s
37
182 Nnums = Elems ( e ,4 :3+NE) ;183 xy = Nodes (Nnums ( : ) , 2 : 3 ) ;184
185 % Extract element th i c kne s s f o r plane s t r e s s186 h = Elems ( e , 3 ) ;187
188 % Extract element e l a s t i c Young ’ s modulus and Poisson ’ s r a t i o189 Y = Mats ( Elems ( e , 2 ) , 2 ) ;190 nu = Mats ( Elems ( e , 2 ) , 3 ) ;191
192 % Construct element s t i f f n e s s matrix193 [Ke ] = Q8 E l S t i f f ( ip s t rn , xy , h ,Y, nu , udof ,NE,NG,XG,WG) ;194
195 % Assemble element s t i f f n e s s matrix in to g l oba l s t i f f n e s s matrix196 i g = udof *(Nnums ( : ) −1) ;197 f o r n i = 1 :NE198 i 0 = udof *( ni−1) ;199 f o r nj = 1 :NE200 j 0 = udof *( nj−1) ;201 f o r i = 1 : udof202 f o r j = 1 : udof203 K( i g ( n i )+i , i g ( nj )+j ) = K( i g ( n i )+i , i g ( nj )+j ) + Ke( i 0+i ,
j 0+j ) ;204 end205 end206 end207 end208 end209 %K210
211 % Construct g l oba l f o r c e vec to r f o r loaded edges with constant t r a c t i o n212 NES = 3 ;213 % Set Gauss p int l o c a t i o n s and weights f o r t r a c t i o n i n t e g r a t i o n214 NGS = 3 ;215 [XGS,WGS] = Q8 El Gauss Points Sur f (NGS) ;216
217 f o r q = 1 :Q218
219 in = ze ro s (NES) ;220 t va l = ze ro s (NES, 1 ) ;221 f v a l = ze ro s (NES, 1 ) ;222
223 % Determine loaded edge224 e = NBC(q , 1 ) ;225 in1 = NBC(q , 2 ) ;226 in2 = NBC(q , 3 ) ;227 in3 = NBC(q , 4 ) ;228 i d o f = NBC(q , 5 ) ;229 t va l ( : , 1 ) = NBC(q , 6 ) ;
38
230 h = Elems ( e , 3 ) ;231
232 f o r i =1:NGS233
234 % Evaluate f o r c e c on t r i bu t i on s at Gauss po in t s235 x i = XGS( i ) ;236 wgt = WGS( i ) ;237
238 [ NshapeS ] = Q8 El Shape Surf (NES, x i ) ;239 [ DNshapeS ] = Q8 El DShape Surf (NES, x i ) ;240
241 xyS (1 , 1 ) = Nodes ( in1 , 2 ) ;242 xyS (1 , 2 ) = Nodes ( in1 , 3 ) ;243 xyS (2 , 1 ) = Nodes ( in2 , 2 ) ;244 xyS (2 , 2 ) = Nodes ( in2 , 3 ) ;245 xyS (3 , 1 ) = Nodes ( in3 , 2 ) ;246 xyS (3 , 2 ) = Nodes ( in3 , 3 ) ;247 [ detJS ] = Q8 El Jacob ian Sur f (NES, xi , xyS , DNshapeS) ;248
249 f v a l = f v a l + h*wgt*NshapeS ’*NshapeS* t va l *detJS ;250
251 end252 % fv a l253
254 i l o c 1 = udof *( in1−1)+i d o f ;255 i l o c 2 = udof *( in2−1)+i d o f ;256 i l o c 3 = udof *( in3−1)+i d o f ;257 F( i l o c 1 ) = F( i l o c 1 ) + f v a l (1 ) ;258 F( i l o c 2 ) = F( i l o c 2 ) + f v a l (2 ) ;259 F( i l o c 3 ) = F( i l o c 3 ) + f v a l (3 ) ;260 %F261
262 end263
264 % Impose D i r i c h l e t boundary cond i t i on s265 f o r p = 1 :P266 inode = DBC(p , 1 ) ;267 i d o f = DBC(p , 2 ) ;268 i d i a g = udof *( inode−1) + i d o f ;269 K( id iag , i d i a g ) = Klarge ;270 F( i d i a g ) = Klarge *DBC(p , 3 ) ;271 end272 %K273 %F274
275 % Solve system to determine d i sp lacements276 U = K\F;277
278 % Recover i n t e r n a l element displacement , s t r a i n s and s t r e s s e s
39
279 nedof = udof*NE;280 Disp = ze ro s (E, nedof ) ;281 Eps = ze ro s (E, nstrn ,NG) ;282 Sig = ze ro s (E, nstrn ,NG) ;283
284 f o r e = 1 :E285
286 % Estab l i sh element c onne c t i v i t y and coo rd ina t e s287 Nnums = Elems ( e ,4 :3+NE) ;288 xy = Nodes (Nnums ( : ) , 2 : 3 ) ;289
290 % Extract element th i c kne s s f o r plane s t r e s s291 h = Elems ( e , 3 ) ;292
293 % Extract element e l a s t i c Young ’ s modulus and Poisson ’ s r a t i o294 Y = Mats ( Elems ( e , 2 ) , 2 ) ;295 nu = Mats ( Elems ( e , 2 ) , 3 ) ;296
297 % Extract element nodal d i sp lacements298 f o r i =1:NE299 inode = Nnums( i ) ;300 i g l b 1 = udof *( inode−1)+1;301 i g l b 2 = udof* inode ;302 i l o c 1 = udof *( i −1)+1;303 i l o c 2 = udof* i ;304 Disp ( e , i l o c 1 ) = U( i g l b 1 ) ;305 Disp ( e , i l o c 2 ) = U( i g l b 2 ) ;306 end307 %Disp308
309 u = Disp ( e , : ) ’ ;310 [ eps , s i g ] = Q8 El Str ( ip s t rn , xy , u , h ,Y, nu , udof ,NE,NG,XG) ;311 %eps312 %s i g313
314 % Store element s t r a i n s315 Eps ( e , : , : ) = eps ( : , : ) ;316
317 % Store element s t r e s s e s318 Sig ( e , : , : ) = s i g ( : , : ) ;319
320 end321
322 % Computing St ra in concent ra t i on f a c t o r323
324 sig nom= 1/0 . 7 5 ;325
326 f o r i =1: s i z e ( h o l e l )327 s ig max=max( Sig ( h o l e l ( i ) , : , : ) ) ;
40
328 end329 SCF(no )=mean( sig max ) / sig nom ;330
331 PE(no , 1 ) =0.5*U’*K*U;332
333 PE(no , 2 )=3/N;334 % i f ( no==1)335 % s t r=s p r i n t f ( ’ Or i g i na l p l a t e vs deformed p l a t e us ing 8 Noded Quad
elements f o r %d elements ’ ,E) ;336 % f i g u r e ;337 % Plot de fo rmat ion ;338 % t i t l e ( s t r ) ;339 % x lab e l ( ’\ l e f t a r r ow 2L \ r ightarrow ’ ) ;340 % y lab e l ( ’\ l e f t a r r ow 2H \ r ightarrow ’ ) ;341 max(U)342 % end343 E344 c l e a r v a r s −except nod1 nod2 nod3 nod4 nod5 Elm1 Elm2 Elm3 Elm4 Elm5 PE SCF
;345 end346
347 f o r i =1:5348 i f (PE( i , 2 )==min (PE( : , 2 ) ) )349 PE ex=PE( i , 1 ) ;350 end351 end352 PE( : , 1 )=abs (PE( : , 1 )−PE ex ) /abs (PE ex ) ;353
354 % f i g u r e ;355 p lo t ( l og (PE( : , 2 ) ) , l og (PE( : , 1 ) ) , ’−o ’ ) ;356 t i t l e ( ’ Error in Energy norm ’ ) ;357 x l ab e l ( ’ $ l og (h) $ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ ) ;358 y l ab e l ( ’ $ l og (\ f r a c |U FE−U EX | |U EX | ) $ ’ , ’ I n t e r p r e t e r ’ , ’ l a t e x ’ ) ; ax i s
square ;359 % Disp360 % Eps361 % Sig
1 f unc t i on [ DNshape ] = Q8 El DShape (NE, xi , e ta )2
3
4 DNshape ( : , 1 )=[− ( x i /4 − 1/4) *( eta − 1) − ( ( eta − 1) *( eta + x i + 1) ) /4 ;5 ( ( eta − 1) *( eta − x i + 1) ) /4 − ( x i /4 + 1/4) *( eta − 1) ;6 ( x i /4 + 1/4) *( eta + 1) + ( ( eta + 1) *( eta + x i − 1) ) /4 ;7 ( x i /4 − 1/4) *( eta + 1) + ( ( eta + 1) *( x i − eta + 1) ) /4 ;8 x i *( eta − 1) ;9 1/2 − eta ˆ2/2 ;
10 −x i *( eta + 1) ;11 eta ˆ2/2 − 1 / 2 ] ’ ;12
41
13
14 DNshape ( : , 2 )=[− ( x i /4 − 1/4) *( eta − 1) − ( x i /4 − 1/4) *( eta + x i + 1) ;15 ( x i /4 + 1/4) *( eta − x i + 1) + ( x i /4 + 1/4) *( eta − 1) ;16 ( x i /4 + 1/4) *( eta + 1) + ( x i /4 + 1/4) *( eta + x i − 1) ;17 ( x i /4 − 1/4) *( x i − eta + 1) − ( x i /4 − 1/4) *( eta + 1) ;18 x i ˆ2/2 − 1/2 ;19 −eta *( x i + 1) ;20 1/2 − x i ˆ2/2 ;21 eta *( x i − 1) ] ’ ;
1 f unc t i on [ DNshapeS ] = Q8 El DShape Surf (NES, x i )2
3 DNshapeS (1 ) = x i − 1/2 ;4 DNshapeS (2 ) = −2*x i ;5 DNshapeS (3 ) = −x i − 1/2 ;
1 f unc t i on [XG,WG] = Q8 El Gauss Points (NG)2
3 i f (NG == 4)4
5 a l f = sq r t (1/3) ;6
7 XG(1 ,1 ) = −a l f ;8 XG(2 ,1 ) = +a l f ;9 XG(3 ,1 ) = +a l f ;
10 XG(4 ,1 ) = −a l f ;11
12 XG(1 ,2 ) = −a l f ;13 XG(2 ,2 ) = −a l f ;14 XG(3 ,2 ) = +a l f ;15 XG(4 ,2 ) = +a l f ;16
17 f o r i =1:NG18 WG( i ) = 1 ;19 end20
21 e l s e22
23 a l f = sq r t (3/5) ;24
25 XG(1 ,1 ) = −a l f ;26 XG(2 ,1 ) = 0 ;27 XG(3 ,1 ) = +a l f ;28 XG(4 ,1 ) = −a l f ;29 XG(5 ,1 ) = 0 ;30 XG(6 ,1 ) = +a l f ;31 XG(7 ,1 ) = −a l f ;32 XG(8 ,1 ) = 0 ;33 XG(9 ,1 ) = +a l f ;34
42
35 XG(1 ,2 ) = −a l f ;36 XG(2 ,2 ) = −a l f ;37 XG(3 ,2 ) = −a l f ;38 XG(4 ,2 ) = 0 ;39 XG(5 ,2 ) = 0 ;40 XG(6 ,2 ) = 0 ;41 XG(7 ,2 ) = +a l f ;42 XG(8 ,2 ) = +a l f ;43 XG(9 ,2 ) = +a l f ;44
45 WG(1) = 25/81 ;46 WG(2) = 40/81 ;47 WG(3) = 25/81 ;48 WG(4) = 40/81 ;49 WG(5) = 64/81 ;50 WG(6) = 40/81 ;51 WG(7) = 25/81 ;52 WG(8) = 40/81 ;53 WG(9) = 25/81 ;54
55 end
1 f unc t i on [XGS,WGS] = Q8 El Gauss Points Sur f (NGS)2
3 i f (NGS == 2)4
5 a l f = sq r t (1/3) ;6
7 XGS(1 , 1 ) = −a l f ;8 XGS(2 , 1 ) = +a l f ;9
10 WGS(1) = 1 ;11 WGS(2) = 1 ;12
13 e l s e14
15 a l f = sq r t (3/5) ;16
17 XGS(1 , 1 ) = −a l f ;18 XGS(2 , 1 ) = 0 ;19 XGS(3 , 1 ) = +a l f ;20
21 WGS(1) = 5/9 ;22 WGS(2) = 8/9 ;23 WGS(3) = 5/9 ;24
25 end
1 f unc t i on [ Jac , detJ , Jhat ] = Q8 El Jacobian (NE, xi , eta , xy , DNshape )2
43
3 Jac = ze ro s (2 , 2 ) ;4
5 f o r i =1:NE6 Jac (1 , 1 ) = Jac (1 , 1 ) + DNshape ( i , 1 ) *xy ( i , 1 ) ;7 Jac (1 , 2 ) = Jac (1 , 2 ) + DNshape ( i , 1 ) *xy ( i , 2 ) ;8 Jac (2 , 1 ) = Jac (2 , 1 ) + DNshape ( i , 2 ) *xy ( i , 1 ) ;9 Jac (2 , 2 ) = Jac (2 , 2 ) + DNshape ( i , 2 ) *xy ( i , 2 ) ;
10 end11
12 detJ = det ( Jac ) ;13 Jhat = inv ( Jac ) ;
1 f unc t i on [ detJS ] = Q8 El Jacob ian Sur f (NES, xi , xyS , DNshapeS)2
3 dxdxi = 0 ;4 dydxi = 0 ;5
6 f o r i =1:NES7 dxdxi = dxdxi + DNshapeS ( i ) *xyS ( i , 1 ) ;8 dydxi = dydxi + DNshapeS ( i ) *xyS ( i , 2 ) ;9 end
10
11 detJS = sq r t ( dxdxi*dxdxi + dydxi*dydxi ) ;
1 f unc t i on [ Nshape ] = Q8 El Shape (NE, xi , e ta )2
3
4 Nshape = [−1/4*(1− x i )*(1− eta ) *( x i+eta+1) ;5 1/4*(1+ x i )*(1− eta ) *( xi−eta−1) ;6 1/4*(1+ x i ) *(1+ eta ) *( x i+eta−1) ;7 −1/4*(1− x i ) *(1+ eta ) *( xi−eta+1) ;8 1/2*(1− x i ˆ2)*(1− eta ) ;9 1/2*(1− eta ˆ2)*(1+ x i ) ;
10 1/2*(1− x i ˆ2)*(1+ eta ) ;11 1/2*(1− eta ˆ2)*(1− x i ) ] ’ ;
1 f unc t i on [ NshapeS ] = Q8 El Shape Surf (NES, x i )2
3 NshapeS (1 ) = ( ( xi−0)*( xi−1) ) /((−1−0)*(−1−1) ) ;4 NshapeS (2 ) = ( ( x i+1)*( xi−1) ) /((0+1) *(0−1) ) ;5 NshapeS (3 ) = ( ( x i+1)*( xi−0) ) /((1+1) *(0−1) ) ;6
7 %NshapeS = NshapeS ’ ;
1 f unc t i on [Ke ] = CST El St i f f ( ip s t rn , xy , h ,Y, nu , udof ,NE,NG,XG,WG)2
3 ndof = NE*udof ;4 nstrn = 3 ;5 Ke = ze ro s ( ndof , ndof ) ;6
44
7 f o r i =1:NG8
9 x i = XG( i , 1 ) ;10 eta = XG( i , 2 ) ;11 wgt = WG( i ) ;12
13 %[ Nshape ] = Q8 El Shape (NE, xi , e ta ) ;14 [ DNshape ] = Q8 El DShape (NE, xi , e ta ) ;15 [ Jac , detJ , Jhat ] = Q8 El Jacobian (NE, xi , eta , xy , DNshape ) ;16
17 B = ze ro s ( nstrn , ndof ) ;18 f o r j =1:NE19 j l o c 1 = 2*( j−1)+1;20 j l o c 2 = j l o c 1 + 1 ;21 B(1 , j l o c 1 ) = B(1 , j l o c 1 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .22 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;23 B(2 , j l o c 2 ) = B(2 , j l o c 2 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .24 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;25 B(3 , j l o c 1 ) = B(3 , j l o c 1 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .26 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;27 B(3 , j l o c 2 ) = B(3 , j l o c 2 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .28 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;29 end30
31 i f ( i p s t r n == 1)32 c = Y*(1−nu) /(1−2*nu) /(1+nu) ;33 C = c * [ 1 nu/(1−nu) 0 ; nu/(1−nu) 1 0 ; 0 0 (1−2*nu)/(1−nu) /2 ] ;34 e l s e35 c = Y/(1−nu) /(1+nu) ;36 C = c * [ 1 nu 0 ; nu 1 0 ; 0 0 (1−nu) /2 ] ;37 end38
39 Ke = Ke + h*wgt*B’*C*B*detJ ;40
41 end
1 f unc t i on [ eps , s i g ] = Q8 El Str ( ip s t rn , xy , u , h ,Y, nu , udof ,NE,NG,XG) ;2
3 ndof = NE*udof ;4 nstrn = 3 ;5 eps = ze ro s ( nstrn ,NG) ;6 s i g = ze ro s ( nstrn ,NG) ;7
8 f o r i =1:NG9
10 x i = XG( i , 1 ) ;11 eta = XG( i , 2 ) ;12
13 [ DNshape ] = Q8 El DShape (NE, xi , e ta ) ;14 [ Jac , detJ , Jhat ] = Q8 El Jacobian (NE, xi , eta , xy , DNshape ) ;
45
15
16 B = ze ro s ( nstrn , ndof ) ;17 f o r j =1:NE18 j l o c 1 = 2*( j−1)+1;19 j l o c 2 = j l o c 1 + 1 ;20 B(1 , j l o c 1 ) = B(1 , j l o c 1 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .21 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;22 B(2 , j l o c 2 ) = B(2 , j l o c 2 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .23 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;24 B(3 , j l o c 1 ) = B(3 , j l o c 1 ) + Jhat (2 , 1 ) *DNshape ( j , 1 ) . . .25 + Jhat (2 , 2 ) *DNshape ( j , 2 ) ;26 B(3 , j l o c 2 ) = B(3 , j l o c 2 ) + Jhat (1 , 1 ) *DNshape ( j , 1 ) . . .27 + Jhat (1 , 2 ) *DNshape ( j , 2 ) ;28 end29
30 i f ( i p s t r n == 1)31 c = Y*(1−nu) /(1−2*nu) /(1+nu) ;32 C = c * [ 1 nu/(1−nu) 0 ; nu/(1−nu) 1 0 ; 0 0 (1−2*nu)/(1−nu) /2 ] ;33 e l s e34 c = Y/(1−nu) /(1+nu) ;35 C = c * [ 1 nu 0 ; nu 1 0 ; 0 0 (1−nu) /2 ] ;36 end37
38 eps ( : , i ) = B*u ;39 s i g ( : , i ) = C* eps ( : , i ) ;40
41 end
46