0% found this document useful (0 votes)
67 views

program For Analysis of Beam by Stiffnes Member Approch: Posted By: Harshvadan On: February 11, 2011

This document contains the code for a C++ program that analyzes beams using the stiffness method. The program allows the user to input control data, structural properties, loads, and performs calculations to determine member end actions, joint displacements, and reactions. The code includes classes, functions to input data, generate stiffness matrices, perform inversions, and output results.

Uploaded by

Shachi Shah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

program For Analysis of Beam by Stiffnes Member Approch: Posted By: Harshvadan On: February 11, 2011

This document contains the code for a C++ program that analyzes beams using the stiffness method. The program allows the user to input control data, structural properties, loads, and performs calculations to determine member end actions, joint displacements, and reactions. The code includes classes, functions to input data, generate stiffness matrices, perform inversions, and output results.

Uploaded by

Shachi Shah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

BEAM

Posted by: harshvadan on: February 11, 2011

In: Uncategorized

Leave a Comment

//PROGRAM FOR ANALYSIS OF BEAM BY STIFFNES MEMBER APPROCH


//PROGRAM PREPARED BY DR. H.S.PATEL, APPLIED MECHANICS DEPARTMENT
// L.D.COLLEGE OF ENGINEERING, AHMEDABAD

// Declaration of Header Files


#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
# define MAX 25
//Declaration of Class
class beam
{
int NM,NJ,NRD,MDF,E,NTDF,ADF,X[MAX],JEND[MAX],KEND[MAX],JRL[MAX];
int NLM,NLJ,ID[MAX];
float L[MAX],SM[5][5],SJ[MAX][MAX],SJR[MAX][MAX],SFF[MAX][MAX],SRF[MAX][MAX];
float AML[MAX][MAX],AE[MAX],AJ[MAX],AC[MAX],ACR[MAX],AFC[MAX],ARL[MAX];
float D[MAX],DISP[MAX],AR[MAX],AML1,AML2,AML3,AML4,IZ[MAX];
public:
void
void
void
void
void
void
void
void
void
void
};

contrd();
structd();
sj();
sjr();
sff_srf();
sff_inv();
acm();
disp();
react();
memend();

// Member Function to input of Control Data


void beam::contrd()
{
cout<<setw(30)<< No of Members:;cin>>NM;
cout<<setw(30)<< \nNo of Restrained degree of Freedom:;cin>>NRD;
cout<<setw(30)<< \nModulus of Elasticity:;cin>>E;
NJ=NM+1;
NTDF=NJ*2;

ADF=NTDF-NRD;
MDF=4;
cout<<\nNumber Of Member
NM =<<NM;
cout<<\nNumber Of Joints
NJ =<<NJ;
cout<<\nNumber Of Total Degree Of Freedom NTDF=<<NTDF;
cout<<\nNumber Of Restrained Degree
NRD =<<NRD;
cout<<\nActual Degree Of Freedom
ADF =<<ADF;
cout<<\nMember Degree Of Freedom
MDF =<<MDF;
cout<<\nModulus Of Elasticity
E =<<E;
cout<<endl;
}
// Member Function to input of Structure Data
void beam::structd()
{
cout<<\nJoint Coordinate and Joint restrained List:\n;
for(int i=1;i<=NJ;i++)
{
cout<<\ncoordinate of joint <<i<<:;cin>>X[i];
cout<<\nJoint Translation Restrained :1 for Yes 0 for No:;cin>>JRL[2*i-1];
cout<<\nJoint Rotation Restrained :1 for Yes 0 for No:;cin>>JRL[2*i];
}
cout<<setw(15)<<\nJoint No.<<setw(15)<<X-coordinate <<setw(15)
<<Trans.restrained<<setw(15)<<Rorat.Restrained:\n;
cout<<\n\n;
for(i=1;i<=NJ;i++)
{
cout<<setw(10)<<i<<setw(10)<<X[i]<<setw(10)<<JRL[2*i-1] <<setw(10)
<<JRL[2*i]<<endl;
}
cout<<\n\n;

for (i=1;i<=NM;i++)
{
cout<<\nMI of Member <<i<<:; cin>>IZ[i];
JEND[i]=i; KEND[i]=i+1;
L[i]=X[i+1]-X[i];
}
cout<< \nMember Length MIZ Jend Kend;
cout<<\n\n;
for (i=1;i<=NM;i++)
{
cout<<i<<\t<<L[i]<<\t<<IZ[i]<<\t<<JEND[i]<<\t<<KEND[i]<<endl;
cout<<endl;
}
cout<<\n\n;
}
// Member Function to generate Unarranged Joint Stiffness matrix.

void beam::sj()
{
int im[5],a,b,i,j;
for(i=1;i<=NTDF;i++)
for(j=1;j<=NTDF;j++)
SJ[i][j]=0.0;
for(int m=1;m<=NM;m++)
{
SM[1][1]=(12*E*IZ[m])/(L[m]*L[m]*L[m]);
SM[1][2]=(6*E*IZ[m])/(L[m]*L[m]);
SM[1][3]=-(12*E*IZ[m])/(L[m]*L[m]*L[m]);
SM[1][4]=(6*E*IZ[m])/(L[m]*L[m]);
SM[2][1]=(6*E*IZ[m])/(L[m]*L[m]);
SM[2][2]=(4*E*IZ[m])/(L[m]);
SM[2][3]=-(6*E*IZ[m])/(L[m]*L[m]);
SM[2][4]=(2*E*IZ[m])/(L[m]);
SM[3][1]=-(12*E*IZ[m])/(L[m]*L[m]*L[m]);
SM[3][2]=-(6*E*IZ[m])/(L[m]*L[m]);
SM[3][3]=(12*E*IZ[m])/(L[m]*L[m]*L[m]);
SM[3][4]=-(6*E*IZ[m])/(L[m]*L[m]);
SM[4][1]=(6*E*IZ[m])/(L[m]*L[m]);
SM[4][2]=(2*E*IZ[m])/(L[m]);
SM[4][3]=-(6*E*IZ[m])/(L[m]*L[m]);
SM[4][4]=(4*E*IZ[m])/(L[m]);
cout<<\nSM Matrix For Member<<m<<endl;
cout<<endl;
for(int j=1;j<=4;j++)
{
for(int k=1; k<=4;k++)
{
cout<<setw(10);
cout<<SM[j][k];
}
cout<<endl;
}
im[1]=2*JEND[m]-1;
im[2]=2*JEND[m];
im[3]=2*KEND[m]-1;
im[4]=2*KEND[m];
for(i=1;i<=MDF;i++)
{
for(j=1;j<=MDF;j++)
{
a=im[i];
b=im[j];
SJ[a][b]=SJ[a][b]+SM[i][j];
}
}

}
cout<<\n Joint Stiffness Matrix\n;
cout<<endl;
for(i=1;i<=NTDF;i++)
{
for(j=1;j<=NTDF;j++)
{
cout<<setw(10);
cout<<SJ[i][j];
}
cout<<endl;
}
}

// Member Function to rearrange Joint Stiffness Matrix


void beam::sjr()
{
int n1=0,t4,t5,a,b;
for(int i=1;i<=NTDF;i++)
{
t4=JRL[i]; n1=n1+t4;
if(t4>0)
t5=ADF+n1;
else
t5=i-n1;
ID[i]=t5;
}
for(i=1;i<=NTDF;i++)
{
for(int j=1;j<=NTDF;j++)
{
a=ID[i]; b=ID[j]; SJR[a][b]=SJ[i][j];
}
}
cout<<\nRearranged Joint Stiffness Matrix:\n; cout<<endl;
for(i=1;i<=NTDF;i++)
{
for(int j=1;j<=NTDF;j++)
{
cout<<setw(10)<<SJR[i][j];
} cout<<endl;
}
}
// Member Function to separate SFF and SRF matrices.
void beam::sff_srf()

{
cout<<\nSFF Matrix:\n; cout<<endl;
for(int i=1;i<=ADF;i++)
{
for(int j=1;j<=ADF;j++)
{
SFF[i][j]=SJR[i][j]; cout<<setw(10)<<SFF[i][j];
}
cout<<endl;
}
cout<<\nSRF Matrix:\n\n;
for(i=1;i<=NRD;i++)
{
int i1=ADF+i;
for(int j=1;j<=ADF;j++)
{
SRF[i][j]=SJR[i1][j];
cout<<setw(10)<<SRF[i][j];
}
cout<<endl;
}
}
// Member Function to invert SFF matrix
void beam::sff_inv()
{
for(int i=1;i<=ADF;i++)
{
float z=SFF[i][i];
SFF[i][i]=1.0;
for (int j=1;j<=ADF;j++)
SFF[i][j]=SFF[i][j]/z;
for(int k=1;k<=ADF;k++)
{
if((k-i) != 0)
{
z=SFF[k][i];
SFF[k][i]=0.0;
for (int j=1;j<=ADF;j++)
SFF[k][j]=SFF[k][j]-z*SFF[i][j];
}
else;
}
}
cout<<\nSFF Invers Matrix:\n;
cout<<endl;
for(i=1;i<=ADF;i++)
{
for(int j=1;j<=ADF;j++)
{
cout<<setw(10)<<SFF[i][j];

}
cout<<endl;
}
}
// Member Function to generate Load Matrix
void beam::acm()
{
int MN,JN,j1,j2,j3,j4,j5;
for(int i=1;i<=NM;i++)
{
for(int j=1;j<=MDF;j++)
{
AML[i][j]=0.0;
}
cout<<endl;
}

for(i=1;i<=NTDF;i++)
{
AE[i]=0.0;
AJ[i]=0.0;
}
cout<<\nNumber of loaded members:;cin>>NLM;
cout<<\nNumber of loaded Joints:;cin>>NLJ;
for(i=1;i<=NLM;i++)
{
cout<<\nMember Number:\n;cin>>MN;
cout<<\nFixed End Force of Left End (upward +ve)\n;cin>>AML[1][MN];
cout<<\nFixed End Moment of Left End(unticlockwise +ve)\n;cin>>AML[2][MN];
cout<<\nFixed End Force of Right End(upwaed +ve)\n;cin>>AML[3][MN];
cout<<\nFixed End Moment of Right End(unticlockwise +ve)\n;cin>>AML[4][MN];
j1=2*JEND[MN]-1;
j2=2*JEND[MN];
j3=2*KEND[MN]-1;
j4=2*KEND[MN];
AE[j1]=AE[j1]-AML[1][MN];
AE[j2]=AE[j2]-AML[2][MN];
AE[j3]=AE[j3]-AML[3][MN];
AE[j4]=AE[j4]-AML[4][MN];
}
cout<<\nEquivelent Load Vector:\n;
cout<<endl;
for(i=1;i<=NTDF;i++)
{
cout<<setw(10)<<AE[i];
//AML1[i]=-AE[i];

}
for(i=1;i<=NLJ;i++)
{
cout<<\nJoint Number:\n;cin>>JN;
cout<<\nForce at joint(upward +ve)\n;cin>>AJ[2*JN-1];
cout<<\nMoment at joint(unticlockwise +ve)\n;cin>>AJ[2*JN];
}
cout<<\nJoint Load Vector:\n;
cout<<endl;
for(i=1;i<=NTDF;i++)
{
cout<<setw(10)<<AJ[i];
}
cout<<\nCombined Load Vector:\n;
cout<<endl;
for(i=1;i<=NTDF;i++)
{
AC[i]=AE[i]+AJ[i];
cout<<setw(10)<<AC[i];
}
for(i=1;i<=NTDF;i++)
{
j5=ID[i];
ACR[j5]=AC[i];
}
cout<<\nRearranged Combined Load Vector:\n;
cout<<endl;
for(i=1;i<=NTDF;i++)
{
cout<<setw(10)<<ACR[i];
}
cout<<\nAFC Matrix:\n;
cout<<endl;
for(i=1;i<=ADF;i++)
{
AFC[i]=ACR[i];
cout<<setw(10)<<AFC[i];
}
cout<<\nARL Matrix:\n\n;
for(i=1;i<=NRD;i++)
{
int i1=ADF+i; ARL[i]=-ACR[i1];cout<<setw(10)<<ARL[i];
}
}
// Member Function to compute Joint Displacements
void beam::disp()
{
int j;
for(int i=1;i<=ADF;i++)
{

DISP[i]=0.0;
for(int j=1;j<=ADF;j++)
DISP[i]=DISP[i]+SFF[i][j]*AFC[j];
}
cout<<endl; cout<<\nDisplacement at joints:\n\n;
for(i=1;i<=ADF;i++)
{
cout<<DISP[i]<<endl;
}
cout<<\nOverall Joints Displacement Matrix:\n\n;
for(i=ADF+1;i<=NTDF;i++) DISP[i]=0.0;
for(i=1;i<=NTDF;i++)
{
j=ID[i]; D[i]=DISP[j]; cout<<setw(10)<<D[i]<<endl;
}
}
// Member Function to compute reactions
void beam::react()
{
for(int i=1;i<=NRD;i++)
{
for(int j=1;j<=ADF;j++)
{
ARL[i]=ARL[i]+SRF[i][j]*DISP[j];
}
}
cout<<endl; cout<<Reaction At Supportes:\n\n;
for(i=1;i<=NRD;i++)
{
cout<<Reaction At Support<<i<<:<<setw(10)<<ARL[i];
cout<<endl;
}
}
// Member Function to compute Member End Actions
void beam::memend()
{
for(int i=1;i<=NM;i++)
{
SM[2*i-1][2*i-1]=(12*E*IZ[i])/(L[i]*L[i]*L[i]);
SM[2*i-1][2*i]=(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i-1][2*i+1]=-(12*E*IZ[i])/(L[i]*L[i]*L[i]);
SM[2*i-1][2*+2]=(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i][2*i-1]=(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i][2*i]=(4*E*IZ[i])/(L[i]);
SM[2*i][2*i+1]=-(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i][2*i+2]=(2*E*IZ[i])/(L[i]);
SM[2*i+1][2*i-1]=-(12*E*IZ[i])/(L[i]*L[i]*L[i]);
SM[2*i+1][2*i]=-(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i+1][2*i+1]=(12*E*IZ[i])/(L[i]*L[i]*L[i]);

SM[2*i+1][2*i+2]=-(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i+2][2*i-1]=(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i+2][2*i]=(2*E*IZ[i])/(L[i]);
SM[2*i+2][2*i+1]=-(6*E*IZ[i])/(L[i]*L[i]);
SM[2*i+2][2*i+2]=(4*E*IZ[i])/(L[i]);
AML1=AML[1][i]; AML2=AML[2][i]; AML3=AML[3][i]; AML4=AML[4][i];
cout<<Member End Action Of Member<<i<< :<<endl;
for(int k=2*i-1;k<=2*i+2;k++)
{
AML1=AML1+SM[2*i-1][k]*D[k];
AML2=AML2+SM[2*i][k]*D[k];
AML3=AML3+SM[2*i+1][k]*D[k];
AML4=AML4+SM[2*i+2][k]*D[k];
}
cout<<setw(10)<<AML<<2*i-1<<setw(12)<<AML1<<endl;
cout<<setw(10)<<AML<<2*i<<setw(12)<<AML2<<endl;
cout<<setw(10)<<AML<<2*i+1<<setw(12)<<AML3<<endl;
cout<<setw(10)<<AML<<2*i+2<<setw(12)<<AML4<<endl;
}
}
// Declaration of Main Programme Analysis of Beam
void main()
{
beam b1; clrscr();
b1.contrd();
b1.structd();
b1.sj();
b1.sjr();
b1.sff_srf();
b1.sff_inv();
b1.acm();
b1.disp();
b1.react();
b1.memend();
getch();
}

You might also like