SlideShare a Scribd company logo
ADVANCED MECHANICS OF MATERIALS
COURSE PROJECT
ON
FINITE ELEMENT METHOD STRUCTURAL ANALYSIS
OF BICYCLE (FRAME ELEMENT)
USING “C PROGRAMMING”
SUBMITTED BY:
AKASH KUMAR GUPTA
MDS17M004
PROBLEM STATEMENT:-
DETERMINE THE DISPLACEMENT AND ROTATIONS AT NODES FOR THE
FRAME SHOWN IN BELOW FIGURES:
CASE 1:- CYCLE (MEN)
Discretization along with the connectivity of elements
E=30e6 psi
I1=0.01in4
I2=I3=I4=I5=0.02in4
I6=I7= 0.1 in4
A1=0.1in2
A2=A3=A4=A5=0.15in2
A6=A7=0.3in2
FEM STEP FOLLOWED IN C CODE:
 DISCRETIZATION.
 SELECTION OF INTERPOLATION MODEL.
 EVALUATION OF ELEMENT STIFFNESS MATRIX AND FORCE VECTOR.
 ASSEMBLY OF ELEMENT STIFFNESS MATRIX.
 APPLY BOUNDARY CONDITION.
 NODAL DISPLACEMENT.
 EVALUATION OF SECONDARY VARIABLES.
Formulation of L matrix
Formulation of k matrix
Local stiffness matrix of each element:-
INPUT of the program :-
please enter number of elements 7
please enter number of nodes 6
enter the value of E30000000
enter AREA and INERTIA of 1th element respectively
0.1
0.01
enter AREA and INERTIA of 2th element respectively
0.15
0.02
enter AREA and INERTIA of 3th element respectively
0.15
0.02
enter AREA and INERTIA of 4th element respectively
0.15
0.02
enter AREA and INERTIA of 5th element respectively
0.15
0.02
enter AREA and INERTIA of 6th element respectively
0.3
0.1
enter AREA and INERTIA of 7th element respectively
0.3
0.1
enter X and Y co-ordinates of 1th node
0
0
enter X and Y co-ordinates of 2th node
10
15
enter X and Y co-ordinates of 3th node
20
0
enter X and Y co-ordinates of 4th node
30
15
enter X and Y co-ordinates of 5th node
32
11.25
enter X and Y co-ordinates of 6th node
38
0
enter ni and nj co-ordinates of 1th element
1
2
enter ni and nj co-ordinates of 2th element
2
3
enter ni and nj co-ordinates of 3th element
1
3
enter ni and nj co-ordinates of 4th element
2
4
enter ni and nj co-ordinates of 5th element
3
5
enter ni and nj co-ordinates of 6th element
4
5
enter ni and nj co-ordinates of 7th element
5
6
 Then after input
enter the nodes where you wants to put constraints please enter back wheel node first
1
6
 Then after input
please enter the forces on back seat and its notes respectively
-125
2
please enter the forces on front handle and its notes respectively
-25
4
OUTPUT of the program :-
<<<<<<<UX of each node>>>>>>
node 1 => 0.000000000
node 2 => 0.001919842
node 3 => 0.000291206
node 4 => 0.001703861
node 5 => 0.003210961
node 6 => 0.014042133
<<<<<<<UY of each node>>>>>>
node 1 => 0.000000000
node 2 => -0.002132138
node 3 => -0.003045308
node 4 => -0.006676688
node 5 => -0.005851189
node 6 => 0.000000000
<<<<<<<rotZ of each node>>>>>>
node 1 => -0.000092717
node 2 => -0.000229784
node 3 => -0.000297664
node 4 => 0.000323999
node 5 => 0.000518149
node 6 => 0.001189210
<<<<<<<Reaction force>>>>>>
node 1 => 97.368492126
node 6 => 52.632865906
COMPARISON OF RESULTS WITH ANSYS :
NODAL DISPALCEMENT:
REACTION AT SUPPORT:
 The same code gives the displacement & reaction of
cycle(women) .
CASE 2-
DETERMINE THE DISPLACEMENT AND ROTATIONS AT NODES FOR THE
FRAME SHOWN IN BELOW FIGURES:
CASE 2- CYCLE (WOMEN)
Discretization along with the connectivity of elements
E=10e6 psi
I1=0.01in4
I2=I3=I4=I5=0.02in4
I6=I7=I8= 0.1 in4
A1=0.1in2
A2=A3=A4=A5=0.15in2
A6=A7=A8=0.3in2
INPUT of the program :-
please enter number of elements 8
please enter number of nodes 7
enter the value of E10000000
enter AREA and INERTIA of 1th element respectively
0.1
0.01
enter AREA and INERTIA of 2th element respectively
0.15
0.02
enter AREA and INERTIA of 3th element respectively
0.15
0.02
enter AREA and INERTIA of 4th element respectively
0.15
0.02
enter AREA and INERTIA of 5th element respectively
0.15
0.02
enter AREA and INERTIA of 6th element respectively
0.3
0.1
enter AREA and INERTIA of 7th element respectively
0.3
0.1
enter AREA and INERTIA of 8th element respectively
0.3
0.1
enter X and Y co-ordinates of 1th node
0
0
enter X and Y co-ordinates of 2th node
10
15
enter X and Y co-ordinates of 3th node
18
3.75
enter X and Y co-ordinates of 4th node
20
0
enter X and Y co-ordinates of 5th node
30
15
enter X and Y co-ordinates of 6th node
32
11.25
enter X and Y co-ordinates of 7th node
38
0
enter ni and nj co-ordinates of 1th element
1
2
enter ni and nj co-ordinates of 2th element
2
3
enter ni and nj co-ordinates of 3th element
1
4
enter ni and nj co-ordinates of 4th element
3
5
enter ni and nj co-ordinates of 5th element
4
6
enter ni and nj co-ordinates of 6th element
5
6
enter ni and nj co-ordinates of 7th element
6
7
enter ni and nj co-ordinates of 8th element
3
4
 Then after input
enter the nodes where you wants to put constraints please enter back wheel
node first
1
7
 Then after input
please enter the forces on back seat and its notes respectively -125
2
please enter the forces on fronthandle and its notes respectively -25
5
OUTPUT of the program :-
<<<<<<<UX of each node>>>>>>
node 1 => 0.000000000
node 2 => 0.049084820
node 3 => -0.006489811
node 4 => 0.000885768
node 5 => -0.047025576
node 6 => -0.036962006
node 7 => 0.013382180
<<<<<<<UY of eachnode>>>>>>
node 1 => 0.000000000
node 2 => -0.035041552
node 3 => -0.073752053
node 4 => -0.069679081
node 5 => -0.032445088
node 6 => -0.027073935
node 7 => 0.000000000
<<<<<<<rotZ of eachnode>>>>>>
node 1 => -0.004590009
node 2 => -0.006706568
node 3 => 0.001747432
node 4 => 0.001976273
node 5 => 0.002551198
node 6 => 0.003141104
node 7 => 0.005154393
<<<<<<<Reaction force node>>>>>>
node 1 => 97.372192383
node 7 => 52.635559082
COMPARISON OF RESULTS WITH ANSYS :
NODAL DISPALCEMENT:
REACTION AT SUPPORT:
Conclusion:-
FEM Analysis of cycle structure (frame element) have conducted using
C programming code and its output results are same as result generated by
ANSYS.
Program:-
#include<stdio.h>
#include<conio.h>
#include <math.h>
int main()
{ int ele,nod;
printf("please enter number of elements "); /*total number of element of a structure */
scanf("%d",&ele);
printf("n");
printf("please enter number of nodes ");
scanf("%d",&nod);
float
X[100],Y[100],le[100],l[100],m[100],L[100][20][20],KL[100][20][20],KG[100][20][20],res[100][20][20],LT[100]
[20][20],KGL[100][100],keff[100][100],matrix[50][50],inv[100][100];
int ni[100],nj[100],N[100][100];
float A[20] ;
float I[20] ;
int E;
float F[50];
float Q[50];
printf("enter the value of E");
scanf("%d",&E);
for(int i=0;i<ele;i++)
{printf("enter AREA and INERTIA of %dth element respectively ",i+1);
scanf("%f%f",&A[i],&I[i]);
printf("n");
}
for(int i=0;i<nod;i++)
{printf("enter X and Y co-ordinates of %dth node ",i+1);
scanf("%f%f",&X[i],&Y[i]);
printf("n");
}
for(int i=0;i<ele;i++)
{printf("enter ni and nj co-ordinates of %dth element ",i+1); /*enter the connectivity of each element i.e.
connetivity
table which store in ni & nj seperately */
scanf("%d%d",&ni[i],&nj[i]); // ni and nj are 1D array
printf("n");
}
for(int i=0;i<ele;i++) /* the store value of ni and nj provide us the dof of each element*/
// here a 2D array name "N[][]" will store the dof of each elemnt at the respective row
// means dof of 1st element will store in 1st row of N[][] matrix and so on ....
{int k=2,p=2;
for(int j=0;j<6;j++)
{if(k>=0)
{N[i][j]=3*ni[i]-k;
k--;
}
else if(p>=0)
{N[i][j]=3*nj[i]-p;
p--;
}
}
}
for(int i=0;i<ele;i++)
{for(int j=0;j<6;j++)
{printf("%dt",N[i][j]);
}printf("n");
}
for(int i=0;i<ele;i++)
{le[i]=sqrt((pow((X[nj[i]-1]-X[ni[i]-1]),2)+(pow((Y[nj[i]-1]-Y[ni[i]-1]),2)))); // calculation of length , l and m
value of each element
l[i]=(X[nj[i]-1]-X[ni[i]-1])/le[i];
m[i]=(Y[nj[i]-1]-Y[ni[i]-1])/le[i];
}
printf("le matrix");
for(int i=0;i<ele;i++)
{ printf("%f",le[i]);
printf("t");
}
printf("n");
printf("l matrix");
for(int i=0;i<ele;i++)
{ printf("%f",l[i]);
printf("t");
}
printf("n");
printf("m matrix");
for(int i=0;i<ele;i++)
{ printf("%f",m[i]);
printf("t");
}
printf("n");
for(int k=0;k<ele;k++) // a 3 dimension array name "L[][][]" will store the value of L matrix of each element
{for(int i=0;i<6;i++) //means L[0][][] stores the value of L matrix of first element and so on .....
{for(int j=0;j<6;j++)
{
if(i==0&&j==0)
{L[k][i][j]=l[k];
}
else if(i==0&&j==1)
{L[k][i][j]=m[k];
}
else if(i==1&&j==0)
{L[k][i][j]=-1*m[k];
}
else if(i==1&&j==1)
{L[k][i][j]=l[k];
}
else if(i==2&&j==2)
{L[k][i][j]=1;
}
else if(i==3&&j==3)
{L[k][i][j]=l[k];
}
else if(i==4&&j==3)
{L[k][i][j]=-1*m[k];
}
else if(i==3&&j==4)
{L[k][i][j]=m[k];
}
else if(i==4&&j==4)
{L[k][i][j]=l[k];
}
else if(i==5&&j==5)
{L[k][i][j]=1;
}
else
{L[k][i][j]=0;
}
}
}
}
for(int k=0;k<ele;k++)
{for(int i=0;i<6;i++)
{for(int j=0;j<6;j++)
{printf("%f",L[k][i][j]);
}printf("n");
}printf("n");
}
for(int k=0;k<ele;k++)
{ float P[6][6]= {
{((E*A[k])/le[k]),0,0,(-1*(E*A[k])/le[k]),0,0},
{0,(12*E*I[k]/(pow(le[k],3))),(6*E*I[k]/(pow(le[k],2))),0,(-
12*E*I[k]/(pow(le[k],3))),(6*E*I[k]/(pow(le[k],2)))},
{0,(6*E*I[k]/(pow(le[k],2))),(4*E*I[k]/(pow(le[k],1))),0,(-
6*E*I[k]/(pow(le[k],2))),(2*E*I[k]/(pow(le[k],1)))},
{((-1*E*A[k])/le[k]),0,0,((E*A[k])/le[k]),0,0},
{0,(-12*E*I[k]/(pow(le[k],3))),(-6*E*I[k]/(pow(le[k],2))),0,(12*E*I[k]/(pow(le[k],3))),(-
6*E*I[k]/(pow(le[k],2)))},
{0,(6*E*I[k]/(pow(le[k],2))),(2*E*I[k]/(pow(le[k],1))),0,(-
6*E*I[k]/(pow(le[k],2))),(4*E*I[k]/(pow(le[k],1)))}
};
for(int i=0;i<6;i++)
{for(int j=0;j<6;j++)
{KL[k][i][j]=P[i][j];
}
}
}
for(int z=0;z<ele;z++)
{ for (int i = 0; i < 6; i++)
{ for (int j = 0; j < 6; j++)
{ res[z][i][j] = 0;
for (int k = 0; k< 6; k++)
{ res[z][i][j]= res[z][i][j] + KL[z][i][k]*L[z][k][j];
}
}
}
}
for(int k=0;k<ele;k++)
{for(int i=0;i<6;i++)
{for(int j=0;j<6;j++)
{LT[k][i][j]=L[k][j][i];
}
}
}
for(int z=0;z<ele;z++)
{ for (int i = 0; i < 6; i++)
{ for (int j = 0; j< 6; j++)
{ KG[z][i][j] = 0;
for (int k = 0; k < 6; k++)
{ KG[z][i][j] = KG[z][i][j]+LT[z][i][k]*res[z][k][j];
}
}
}
}
printf("n");
printf(" <<<<<<<<local stiffness matrix of each element>>>>>>>");
printf("n");
for(int k=0;k<ele;k++)
{for(int i=0;i<6;i++)
{for(int j=0;j<6;j++)
{printf("%f",KG[k][i][j]);
printf("t");
}
printf("n");
}
printf("n");
}
printf("n");
for(int i=0;i<18;i++)
{for(int j=0;j<18;j++)
{KGL[i][j]=0;
}
}
printf("<<<<<<<< GLOBAL stiffness matrix>>>>>>> ");
printf("n");
for(int k=0;k<ele;k++)
{for(int i=0;i<6;i++)
{for(int j=0;j<6;j++)
{KGL[N[k][i]-1][N[k][j]-1]=KGL[N[k][i]-1][N[k][j]-1]+KG[k][i][j];
}
}
}
printf("n");
for(int i=0;i<18;i++)
{for(int j=0;j<18;j++)
{printf("%.2f",KGL[i][j]);
printf("t");
}printf("n");
}
printf("n");
int p1,p2;
printf("enter the nodes where you wants to put constraints please enter back wheel node first");
scanf("%d%d",&p1,&p2);
int w1,w2,w3,w4,w5;
w1=3*p1-3;
w2=3*p1-2;
w3=3*p2-2;
w4=3*nod;
w5=w4-3;
int v=0;
for(int i=0;i<w4;i++)
{ int p=0;
for(int j=0;j<w4;j++)
{
if(i!=w1&&i!=w2&&j!=w1&&j!=w2&&i!=w3&&j!=w3)
{keff[v][p]=KGL[i][j];
p++;
}
if(p==w5)
{ v++;
}
}
}
printf("n");
for(int i=0;i<w5;i++)
{for(int j=0;j<w5;j++)
{printf("%.2f",keff[i][j]);
printf("t");
}printf("n");
}
for(int i=0;i<w5;i++)
{for(int j=0;j<w5;j++)
{ matrix[i][j]=keff[i][j];
}
}
printf("n");
int n=w5,i,j,k;
float a,ratio;
for(i = 0; i < n; i++){
for(j = n; j < 2*n; j++){
if(i==(j-n))
matrix[i][j] = 1.0;
else
matrix[i][j] = 0.0;
}
}
for(i = 0; i < n; i++){
for(j = 0; j < n; j++){
if(i!=j){
ratio = matrix[j][i]/matrix[i][i];
for(k = 0; k < 2*n; k++){
matrix[j][k] -= ratio * matrix[i][k];
}
}
}
}
for(i = 0; i < n; i++){
a = matrix[i][i];
for(j = 0; j < 2*n; j++){
matrix[i][j] /= a;
}
}
for(int i=0;i<w5;i++)
{for(int j=0;j<w5;j++)
{inv[i][j]=matrix[i][j+n];
}
}
printf("n");
printf("inverse of reduce stiffness matrix is: n");
for(int i = 0; i < w5; i++){
for(int j = 0; j < w5; j++){
printf("%.9f", inv[i][j]);
printf("t");
}
printf("n");
}
printf("n");
float load1,load2;
int l1,l2;
printf("please enter the forces on back seat and its notes respectively ");
scanf("%f%d",&load1,&l1);
printf("n");
printf("please enter the forces on front handle and its notes respectively ");
scanf("%f%d",&load2,&l2);
for(int i=0;i<w4;i++)
{F[i]=0;
}
F[(3*l1)-2]=load1;
F[(3*l2)-2]=load2;
int k1=0;
float F1[50];
for(int i=0;i<w4;i++)
{ if(i!=w1&&i!=w2&&i!=w3)
{F1[k1]=F[i];
k1++;
}
}
printf("n");
printf("force matrix");
printf("n");
for(int i=0;i<w5;i++)
{ printf("%f",F1[i]);
printf("n");
}
for(int i=0;i<w5;i++)
{ Q[i]=0;
for(int j=0;j<w5;j++)
{Q[i]=Q[i]+inv[i][j]*F1[j];
}
}
printf("n");
printf(" <<<<<<<<<<displacement matrix>>>>>>>");
printf("n");
for(int i=0;i<w5;i++)
{ printf("%.9f",Q[i]);
printf("n");
}
int kc=0;
float QG[50];
for(int i=0;i<w4;i++)
{ if(i==w1||i==w2||i==w3)
{QG[i]=0;
}
else
{QG[i]=Q[kc];
kc++;
}
}
printf("n");
for(int i=0;i<w4;i++)
{ printf("%.9f",QG[i]);
printf("n");
}
float Re[50];
for (int i = 0; i < w4; i++)
{
Re[i]=0;
for (int j = 0; j < w4; j++)
Re[i]= Re[i] + KGL[i][j]*QG[j];
}
printf("n");
printf("<<<<<<<UX of each node>>>>>>");
printf("n");
int koi=0;
for(int i=0;i<nod;i++)
{
printf("node %d => %.9f",i+1,QG[koi]);
koi=koi+3;
printf("n");
}
printf("n");
printf("<<<<<<<UY of each node>>>>>>");
printf("n");
int Toi=1;
for(int i=0;i<nod;i++)
{
printf("node %d => %.9f",i+1,QG[Toi]);
Toi=Toi+3;
printf("n");
}
printf("n");
printf("<<<<<<<rotZ of each node>>>>>>");
printf("n");
int aoi=2;
for(int i=0;i<nod;i++)
{
printf("node %d => %.9f",i+1,QG[aoi]);
aoi=aoi+3;
printf("n");
}
printf("n");
printf("<<<<<<<Reaction force node>>>>>>");
printf("n");
printf("node %d => %.9f",p1,Re[w2]);
printf("n");
printf("node %d => %.9f",p2,Re[w3]);
return 0;
}

More Related Content

PPTX
Kinetics of a Particle : Force and Acceleration
PDF
02 ec2 ws_biasiolimancini_durabilitymaterialsactionsconceptualdesign
PPT
Introduction to finite element method(fem)
PDF
Introduction to Theory of elasticity and plasticity Att 6521
PDF
Module1 1 introduction-tomatrixms - rajesh sir
PDF
Dynamic analysis and structural design of turbine generator foundations(1)
PPTX
Chapter 4: Torsion
PDF
Prestress loss due to friction & anchorage take up
Kinetics of a Particle : Force and Acceleration
02 ec2 ws_biasiolimancini_durabilitymaterialsactionsconceptualdesign
Introduction to finite element method(fem)
Introduction to Theory of elasticity and plasticity Att 6521
Module1 1 introduction-tomatrixms - rajesh sir
Dynamic analysis and structural design of turbine generator foundations(1)
Chapter 4: Torsion
Prestress loss due to friction & anchorage take up

What's hot (20)

PPT
9 shear strength of soil
PPTX
Simple stresses and strains
PDF
Analysis and Design of Rectangular and L-Shaped Columns Subjected to Axial Lo...
PPTX
Axial Stress-Strain Curve & Modulus of Elasticity
PPT
PDF
Design of machine elements - DESIGN FOR SIMPLE STRESSES
PPTX
Bending stresses in beams
PDF
CSI ETABS & SAFE MANUAL: Slab Analysis and Design to EC2
PPTX
Torsion
PPTX
Truss for indeterminacy Check
PDF
Mohr circle
PPT
Chapter 12 kinematics_of_a_particle
DOC
Examples on seepage
PDF
WIND LOAD ON BUILDING AND STR.pdf
PDF
Simple Stress and Strain
DOCX
Machine Foundation Design - An Introduction
PPT
Lecture 1 Introduction to Matrix Structural Analysis.ppt
PPTX
Theories of failure
PPTX
FLUID MECHANICS AND HYDRAULIC MACHINES
9 shear strength of soil
Simple stresses and strains
Analysis and Design of Rectangular and L-Shaped Columns Subjected to Axial Lo...
Axial Stress-Strain Curve & Modulus of Elasticity
Design of machine elements - DESIGN FOR SIMPLE STRESSES
Bending stresses in beams
CSI ETABS & SAFE MANUAL: Slab Analysis and Design to EC2
Torsion
Truss for indeterminacy Check
Mohr circle
Chapter 12 kinematics_of_a_particle
Examples on seepage
WIND LOAD ON BUILDING AND STR.pdf
Simple Stress and Strain
Machine Foundation Design - An Introduction
Lecture 1 Introduction to Matrix Structural Analysis.ppt
Theories of failure
FLUID MECHANICS AND HYDRAULIC MACHINES
Ad

Similar to FINITE ELEMENT METHOD (FEM) coding using C PROGRAMMING (20)

PDF
Comparative study of results obtained by analysis of structures using ANSYS, ...
PPT
generalformulation.ppt
PPT
generalformulationofFiniteelementofmodel
PDF
2d beam element with combined loading bending axial and torsion
PPT
lec3 Direct Stiffness Approach for Beams and Frames.ppt
PDF
solution for 2D truss1
PPTX
Introduction to FEA
PDF
IRJET- Stress – Strain Field Analysis of Mild Steel Component using Finite El...
PDF
A VBA Based Computer Program for Nonlinear FEA of Large Displacement 2D Beam ...
PPT
Fem l1(a)
PDF
BazzucchiCampolmi
PDF
CAE_notes.pdf all notes for computer aided eng
PDF
01-Chapter 01 Moaveni.pdf
PDF
Linear analysis of 2 d truss in c++
PPT
Finite_Element_Method analysis and theory of yeild line .ppt
PPTX
DSM.pptx
PDF
UNIT I_3.pdf
PDF
Introduction to FEM
Comparative study of results obtained by analysis of structures using ANSYS, ...
generalformulation.ppt
generalformulationofFiniteelementofmodel
2d beam element with combined loading bending axial and torsion
lec3 Direct Stiffness Approach for Beams and Frames.ppt
solution for 2D truss1
Introduction to FEA
IRJET- Stress – Strain Field Analysis of Mild Steel Component using Finite El...
A VBA Based Computer Program for Nonlinear FEA of Large Displacement 2D Beam ...
Fem l1(a)
BazzucchiCampolmi
CAE_notes.pdf all notes for computer aided eng
01-Chapter 01 Moaveni.pdf
Linear analysis of 2 d truss in c++
Finite_Element_Method analysis and theory of yeild line .ppt
DSM.pptx
UNIT I_3.pdf
Introduction to FEM
Ad

Recently uploaded (20)

PPTX
Geodesy 1.pptx...............................................
PPTX
Construction Project Organization Group 2.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Sustainable Sites - Green Building Construction
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
PPT on Performance Review to get promotions
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Well-logging-methods_new................
PPTX
Lecture Notes Electrical Wiring System Components
Geodesy 1.pptx...............................................
Construction Project Organization Group 2.pptx
OOP with Java - Java Introduction (Basics)
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Model Code of Practice - Construction Work - 21102022 .pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Sustainable Sites - Green Building Construction
Operating System & Kernel Study Guide-1 - converted.pdf
CH1 Production IntroductoryConcepts.pptx
bas. eng. economics group 4 presentation 1.pptx
Foundation to blockchain - A guide to Blockchain Tech
PPT on Performance Review to get promotions
UNIT 4 Total Quality Management .pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Well-logging-methods_new................
Lecture Notes Electrical Wiring System Components

FINITE ELEMENT METHOD (FEM) coding using C PROGRAMMING

  • 1. ADVANCED MECHANICS OF MATERIALS COURSE PROJECT ON FINITE ELEMENT METHOD STRUCTURAL ANALYSIS OF BICYCLE (FRAME ELEMENT) USING “C PROGRAMMING” SUBMITTED BY: AKASH KUMAR GUPTA MDS17M004
  • 2. PROBLEM STATEMENT:- DETERMINE THE DISPLACEMENT AND ROTATIONS AT NODES FOR THE FRAME SHOWN IN BELOW FIGURES: CASE 1:- CYCLE (MEN) Discretization along with the connectivity of elements E=30e6 psi I1=0.01in4 I2=I3=I4=I5=0.02in4 I6=I7= 0.1 in4 A1=0.1in2 A2=A3=A4=A5=0.15in2 A6=A7=0.3in2
  • 3. FEM STEP FOLLOWED IN C CODE:  DISCRETIZATION.  SELECTION OF INTERPOLATION MODEL.  EVALUATION OF ELEMENT STIFFNESS MATRIX AND FORCE VECTOR.  ASSEMBLY OF ELEMENT STIFFNESS MATRIX.  APPLY BOUNDARY CONDITION.  NODAL DISPLACEMENT.  EVALUATION OF SECONDARY VARIABLES. Formulation of L matrix
  • 4. Formulation of k matrix Local stiffness matrix of each element:- INPUT of the program :- please enter number of elements 7 please enter number of nodes 6 enter the value of E30000000 enter AREA and INERTIA of 1th element respectively 0.1 0.01 enter AREA and INERTIA of 2th element respectively 0.15 0.02 enter AREA and INERTIA of 3th element respectively 0.15 0.02 enter AREA and INERTIA of 4th element respectively 0.15
  • 5. 0.02 enter AREA and INERTIA of 5th element respectively 0.15 0.02 enter AREA and INERTIA of 6th element respectively 0.3 0.1 enter AREA and INERTIA of 7th element respectively 0.3 0.1 enter X and Y co-ordinates of 1th node 0 0 enter X and Y co-ordinates of 2th node 10 15 enter X and Y co-ordinates of 3th node 20 0 enter X and Y co-ordinates of 4th node 30 15 enter X and Y co-ordinates of 5th node 32 11.25 enter X and Y co-ordinates of 6th node 38 0 enter ni and nj co-ordinates of 1th element 1 2
  • 6. enter ni and nj co-ordinates of 2th element 2 3 enter ni and nj co-ordinates of 3th element 1 3 enter ni and nj co-ordinates of 4th element 2 4 enter ni and nj co-ordinates of 5th element 3 5 enter ni and nj co-ordinates of 6th element 4 5 enter ni and nj co-ordinates of 7th element 5 6  Then after input enter the nodes where you wants to put constraints please enter back wheel node first 1 6  Then after input please enter the forces on back seat and its notes respectively -125 2 please enter the forces on front handle and its notes respectively -25 4 OUTPUT of the program :- <<<<<<<UX of each node>>>>>> node 1 => 0.000000000
  • 7. node 2 => 0.001919842 node 3 => 0.000291206 node 4 => 0.001703861 node 5 => 0.003210961 node 6 => 0.014042133 <<<<<<<UY of each node>>>>>> node 1 => 0.000000000 node 2 => -0.002132138 node 3 => -0.003045308 node 4 => -0.006676688 node 5 => -0.005851189 node 6 => 0.000000000 <<<<<<<rotZ of each node>>>>>> node 1 => -0.000092717 node 2 => -0.000229784 node 3 => -0.000297664 node 4 => 0.000323999 node 5 => 0.000518149 node 6 => 0.001189210 <<<<<<<Reaction force>>>>>> node 1 => 97.368492126 node 6 => 52.632865906 COMPARISON OF RESULTS WITH ANSYS : NODAL DISPALCEMENT:
  • 9.  The same code gives the displacement & reaction of cycle(women) . CASE 2- DETERMINE THE DISPLACEMENT AND ROTATIONS AT NODES FOR THE FRAME SHOWN IN BELOW FIGURES: CASE 2- CYCLE (WOMEN)
  • 10. Discretization along with the connectivity of elements E=10e6 psi I1=0.01in4 I2=I3=I4=I5=0.02in4 I6=I7=I8= 0.1 in4 A1=0.1in2 A2=A3=A4=A5=0.15in2 A6=A7=A8=0.3in2 INPUT of the program :- please enter number of elements 8 please enter number of nodes 7 enter the value of E10000000 enter AREA and INERTIA of 1th element respectively 0.1 0.01 enter AREA and INERTIA of 2th element respectively 0.15 0.02
  • 11. enter AREA and INERTIA of 3th element respectively 0.15 0.02 enter AREA and INERTIA of 4th element respectively 0.15 0.02 enter AREA and INERTIA of 5th element respectively 0.15 0.02 enter AREA and INERTIA of 6th element respectively 0.3 0.1 enter AREA and INERTIA of 7th element respectively 0.3 0.1 enter AREA and INERTIA of 8th element respectively 0.3 0.1 enter X and Y co-ordinates of 1th node 0 0 enter X and Y co-ordinates of 2th node 10 15 enter X and Y co-ordinates of 3th node 18 3.75 enter X and Y co-ordinates of 4th node 20 0 enter X and Y co-ordinates of 5th node 30
  • 12. 15 enter X and Y co-ordinates of 6th node 32 11.25 enter X and Y co-ordinates of 7th node 38 0 enter ni and nj co-ordinates of 1th element 1 2 enter ni and nj co-ordinates of 2th element 2 3 enter ni and nj co-ordinates of 3th element 1 4 enter ni and nj co-ordinates of 4th element 3 5 enter ni and nj co-ordinates of 5th element 4 6 enter ni and nj co-ordinates of 6th element 5 6 enter ni and nj co-ordinates of 7th element 6 7 enter ni and nj co-ordinates of 8th element 3 4  Then after input
  • 13. enter the nodes where you wants to put constraints please enter back wheel node first 1 7  Then after input please enter the forces on back seat and its notes respectively -125 2 please enter the forces on fronthandle and its notes respectively -25 5 OUTPUT of the program :- <<<<<<<UX of each node>>>>>> node 1 => 0.000000000 node 2 => 0.049084820 node 3 => -0.006489811 node 4 => 0.000885768 node 5 => -0.047025576 node 6 => -0.036962006 node 7 => 0.013382180 <<<<<<<UY of eachnode>>>>>> node 1 => 0.000000000 node 2 => -0.035041552 node 3 => -0.073752053 node 4 => -0.069679081 node 5 => -0.032445088 node 6 => -0.027073935 node 7 => 0.000000000 <<<<<<<rotZ of eachnode>>>>>> node 1 => -0.004590009 node 2 => -0.006706568 node 3 => 0.001747432 node 4 => 0.001976273 node 5 => 0.002551198 node 6 => 0.003141104 node 7 => 0.005154393 <<<<<<<Reaction force node>>>>>> node 1 => 97.372192383 node 7 => 52.635559082
  • 14. COMPARISON OF RESULTS WITH ANSYS : NODAL DISPALCEMENT: REACTION AT SUPPORT:
  • 15. Conclusion:- FEM Analysis of cycle structure (frame element) have conducted using C programming code and its output results are same as result generated by ANSYS. Program:- #include<stdio.h> #include<conio.h> #include <math.h> int main() { int ele,nod; printf("please enter number of elements "); /*total number of element of a structure */ scanf("%d",&ele); printf("n"); printf("please enter number of nodes "); scanf("%d",&nod);
  • 16. float X[100],Y[100],le[100],l[100],m[100],L[100][20][20],KL[100][20][20],KG[100][20][20],res[100][20][20],LT[100] [20][20],KGL[100][100],keff[100][100],matrix[50][50],inv[100][100]; int ni[100],nj[100],N[100][100]; float A[20] ; float I[20] ; int E; float F[50]; float Q[50]; printf("enter the value of E"); scanf("%d",&E); for(int i=0;i<ele;i++) {printf("enter AREA and INERTIA of %dth element respectively ",i+1); scanf("%f%f",&A[i],&I[i]); printf("n"); } for(int i=0;i<nod;i++) {printf("enter X and Y co-ordinates of %dth node ",i+1); scanf("%f%f",&X[i],&Y[i]); printf("n"); } for(int i=0;i<ele;i++) {printf("enter ni and nj co-ordinates of %dth element ",i+1); /*enter the connectivity of each element i.e. connetivity table which store in ni & nj seperately */ scanf("%d%d",&ni[i],&nj[i]); // ni and nj are 1D array printf("n"); } for(int i=0;i<ele;i++) /* the store value of ni and nj provide us the dof of each element*/ // here a 2D array name "N[][]" will store the dof of each elemnt at the respective row // means dof of 1st element will store in 1st row of N[][] matrix and so on .... {int k=2,p=2;
  • 17. for(int j=0;j<6;j++) {if(k>=0) {N[i][j]=3*ni[i]-k; k--; } else if(p>=0) {N[i][j]=3*nj[i]-p; p--; } } } for(int i=0;i<ele;i++) {for(int j=0;j<6;j++) {printf("%dt",N[i][j]); }printf("n"); } for(int i=0;i<ele;i++) {le[i]=sqrt((pow((X[nj[i]-1]-X[ni[i]-1]),2)+(pow((Y[nj[i]-1]-Y[ni[i]-1]),2)))); // calculation of length , l and m value of each element l[i]=(X[nj[i]-1]-X[ni[i]-1])/le[i]; m[i]=(Y[nj[i]-1]-Y[ni[i]-1])/le[i]; } printf("le matrix"); for(int i=0;i<ele;i++) { printf("%f",le[i]); printf("t"); } printf("n"); printf("l matrix"); for(int i=0;i<ele;i++) { printf("%f",l[i]); printf("t"); }
  • 18. printf("n"); printf("m matrix"); for(int i=0;i<ele;i++) { printf("%f",m[i]); printf("t"); } printf("n"); for(int k=0;k<ele;k++) // a 3 dimension array name "L[][][]" will store the value of L matrix of each element {for(int i=0;i<6;i++) //means L[0][][] stores the value of L matrix of first element and so on ..... {for(int j=0;j<6;j++) { if(i==0&&j==0) {L[k][i][j]=l[k]; } else if(i==0&&j==1) {L[k][i][j]=m[k]; } else if(i==1&&j==0) {L[k][i][j]=-1*m[k]; } else if(i==1&&j==1) {L[k][i][j]=l[k]; } else if(i==2&&j==2) {L[k][i][j]=1; } else if(i==3&&j==3) {L[k][i][j]=l[k]; } else if(i==4&&j==3) {L[k][i][j]=-1*m[k]; } else if(i==3&&j==4) {L[k][i][j]=m[k];
  • 19. } else if(i==4&&j==4) {L[k][i][j]=l[k]; } else if(i==5&&j==5) {L[k][i][j]=1; } else {L[k][i][j]=0; } } } } for(int k=0;k<ele;k++) {for(int i=0;i<6;i++) {for(int j=0;j<6;j++) {printf("%f",L[k][i][j]); }printf("n"); }printf("n"); } for(int k=0;k<ele;k++) { float P[6][6]= { {((E*A[k])/le[k]),0,0,(-1*(E*A[k])/le[k]),0,0}, {0,(12*E*I[k]/(pow(le[k],3))),(6*E*I[k]/(pow(le[k],2))),0,(- 12*E*I[k]/(pow(le[k],3))),(6*E*I[k]/(pow(le[k],2)))}, {0,(6*E*I[k]/(pow(le[k],2))),(4*E*I[k]/(pow(le[k],1))),0,(- 6*E*I[k]/(pow(le[k],2))),(2*E*I[k]/(pow(le[k],1)))}, {((-1*E*A[k])/le[k]),0,0,((E*A[k])/le[k]),0,0}, {0,(-12*E*I[k]/(pow(le[k],3))),(-6*E*I[k]/(pow(le[k],2))),0,(12*E*I[k]/(pow(le[k],3))),(- 6*E*I[k]/(pow(le[k],2)))}, {0,(6*E*I[k]/(pow(le[k],2))),(2*E*I[k]/(pow(le[k],1))),0,(- 6*E*I[k]/(pow(le[k],2))),(4*E*I[k]/(pow(le[k],1)))} }; for(int i=0;i<6;i++) {for(int j=0;j<6;j++) {KL[k][i][j]=P[i][j];
  • 20. } } } for(int z=0;z<ele;z++) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { res[z][i][j] = 0; for (int k = 0; k< 6; k++) { res[z][i][j]= res[z][i][j] + KL[z][i][k]*L[z][k][j]; } } } } for(int k=0;k<ele;k++) {for(int i=0;i<6;i++) {for(int j=0;j<6;j++) {LT[k][i][j]=L[k][j][i]; } } } for(int z=0;z<ele;z++) { for (int i = 0; i < 6; i++) { for (int j = 0; j< 6; j++) { KG[z][i][j] = 0; for (int k = 0; k < 6; k++) { KG[z][i][j] = KG[z][i][j]+LT[z][i][k]*res[z][k][j]; } } } }
  • 21. printf("n"); printf(" <<<<<<<<local stiffness matrix of each element>>>>>>>"); printf("n"); for(int k=0;k<ele;k++) {for(int i=0;i<6;i++) {for(int j=0;j<6;j++) {printf("%f",KG[k][i][j]); printf("t"); } printf("n"); } printf("n"); } printf("n"); for(int i=0;i<18;i++) {for(int j=0;j<18;j++) {KGL[i][j]=0; } } printf("<<<<<<<< GLOBAL stiffness matrix>>>>>>> "); printf("n"); for(int k=0;k<ele;k++) {for(int i=0;i<6;i++) {for(int j=0;j<6;j++) {KGL[N[k][i]-1][N[k][j]-1]=KGL[N[k][i]-1][N[k][j]-1]+KG[k][i][j]; } } } printf("n"); for(int i=0;i<18;i++) {for(int j=0;j<18;j++) {printf("%.2f",KGL[i][j]);
  • 22. printf("t"); }printf("n"); } printf("n"); int p1,p2; printf("enter the nodes where you wants to put constraints please enter back wheel node first"); scanf("%d%d",&p1,&p2); int w1,w2,w3,w4,w5; w1=3*p1-3; w2=3*p1-2; w3=3*p2-2; w4=3*nod; w5=w4-3; int v=0; for(int i=0;i<w4;i++) { int p=0; for(int j=0;j<w4;j++) { if(i!=w1&&i!=w2&&j!=w1&&j!=w2&&i!=w3&&j!=w3) {keff[v][p]=KGL[i][j]; p++; } if(p==w5) { v++; } } } printf("n"); for(int i=0;i<w5;i++) {for(int j=0;j<w5;j++) {printf("%.2f",keff[i][j]);
  • 23. printf("t"); }printf("n"); } for(int i=0;i<w5;i++) {for(int j=0;j<w5;j++) { matrix[i][j]=keff[i][j]; } } printf("n"); int n=w5,i,j,k; float a,ratio; for(i = 0; i < n; i++){ for(j = n; j < 2*n; j++){ if(i==(j-n)) matrix[i][j] = 1.0; else matrix[i][j] = 0.0; } } for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ if(i!=j){ ratio = matrix[j][i]/matrix[i][i]; for(k = 0; k < 2*n; k++){ matrix[j][k] -= ratio * matrix[i][k]; } } } } for(i = 0; i < n; i++){
  • 24. a = matrix[i][i]; for(j = 0; j < 2*n; j++){ matrix[i][j] /= a; } } for(int i=0;i<w5;i++) {for(int j=0;j<w5;j++) {inv[i][j]=matrix[i][j+n]; } } printf("n"); printf("inverse of reduce stiffness matrix is: n"); for(int i = 0; i < w5; i++){ for(int j = 0; j < w5; j++){ printf("%.9f", inv[i][j]); printf("t"); } printf("n"); } printf("n"); float load1,load2; int l1,l2; printf("please enter the forces on back seat and its notes respectively "); scanf("%f%d",&load1,&l1); printf("n"); printf("please enter the forces on front handle and its notes respectively "); scanf("%f%d",&load2,&l2); for(int i=0;i<w4;i++) {F[i]=0; } F[(3*l1)-2]=load1; F[(3*l2)-2]=load2;
  • 25. int k1=0; float F1[50]; for(int i=0;i<w4;i++) { if(i!=w1&&i!=w2&&i!=w3) {F1[k1]=F[i]; k1++; } } printf("n"); printf("force matrix"); printf("n"); for(int i=0;i<w5;i++) { printf("%f",F1[i]); printf("n"); } for(int i=0;i<w5;i++) { Q[i]=0; for(int j=0;j<w5;j++) {Q[i]=Q[i]+inv[i][j]*F1[j]; } } printf("n"); printf(" <<<<<<<<<<displacement matrix>>>>>>>"); printf("n"); for(int i=0;i<w5;i++) { printf("%.9f",Q[i]); printf("n"); }
  • 26. int kc=0; float QG[50]; for(int i=0;i<w4;i++) { if(i==w1||i==w2||i==w3) {QG[i]=0; } else {QG[i]=Q[kc]; kc++; } } printf("n"); for(int i=0;i<w4;i++) { printf("%.9f",QG[i]); printf("n"); } float Re[50]; for (int i = 0; i < w4; i++) { Re[i]=0; for (int j = 0; j < w4; j++) Re[i]= Re[i] + KGL[i][j]*QG[j]; }
  • 27. printf("n"); printf("<<<<<<<UX of each node>>>>>>"); printf("n"); int koi=0; for(int i=0;i<nod;i++) { printf("node %d => %.9f",i+1,QG[koi]); koi=koi+3; printf("n"); } printf("n"); printf("<<<<<<<UY of each node>>>>>>"); printf("n"); int Toi=1; for(int i=0;i<nod;i++) { printf("node %d => %.9f",i+1,QG[Toi]); Toi=Toi+3; printf("n"); } printf("n"); printf("<<<<<<<rotZ of each node>>>>>>"); printf("n"); int aoi=2; for(int i=0;i<nod;i++) { printf("node %d => %.9f",i+1,QG[aoi]); aoi=aoi+3; printf("n"); }
  • 28. printf("n"); printf("<<<<<<<Reaction force node>>>>>>"); printf("n"); printf("node %d => %.9f",p1,Re[w2]); printf("n"); printf("node %d => %.9f",p2,Re[w3]); return 0; }