You are on page 1of 6

APPENDIX

PROGRAM TO CALCULATE MOMENT FROM STRESS VALUES


Following program is used to calculate total moment at a cross section from the
corresponding nodal stress values at the cross section.

#include<stdio.h>
#include<iostream.h>
#include<MATH.h>
#include<fstream.h>
#include<ctype.h>
class Node{
public:
float x,y;
double stress,stress2,moment,larm,area,sstress;
int processed;
};
void main(){
float A,B,C,D,t1,t2,t3,t4,wl,da,ufa,lfa,wa;
float y,dew,wew,lfew,temp,oriy,Ixx;
int i,n=3,nofelements,cnt,nk,nn,j;
double totalmoment=0,totalstress,cony,moment;
Node nodes[100];
FILE *fp;
float xx,yy,zz;
int v1;
double stre,sxy,sstre;
char str[150];
double changedc,changedt2,lfl,deckarea,ufarea,warea,lfarea;
double tarea,deckcg,ufcg,wcg,lfcg,Es,Ec,m;
cout<<"enter the values: ";
cout<<"\nB(width of cell)";
cin>>B;
cout<<"\nC(width of upper flange)";
cin>>C;
cout<<"\nD(upper to bottom flange length)";
cin>>D;
cout<<"\nt1(thickness of upper flange)";
cin>>t1;
cout<<"\nt2(thickness of web)";
cin>>t2;
cout<<"\nt3(thickness of bottom flange)";
cin>>t3;
cout<<"\nt4(thickness of concrete deck)";

cin>>t4;
cout<<"\nenter the no of cells";
cin>>n;
cout<<"enter the no of keypoints";
cin>>nk;
for(i=0;i<nk;i++)
{cout<<"enter the keypoint "<<i+1<<" ";
cin>>nodes[i].x>>nodes[i].y;
}
//cout<<"1st keypoint:"<<nodes[0].x<<" "<<nodes[0].y;
A=nodes[1].x-nodes[0].x;
cout<<"enter the element widths for:";
cout<<"\nconcrete deck:";
cin>>dew;
cout<<"\nweb:";
cin>>wew;
cout<<"\nlower flange:";
cin>>lfew;
cout<<"enter Es:";
cin>>Es;
cout<<"enter Ec:";
cin>>Ec;
m=Es/Ec;
cout<<"m= "<<m;
changedc=C*m;
changedt2=t2*m;
lfl=(n*B+t2)*m;
deckarea=A*t4;
ufarea=(n+1)*t1*changedc;
warea=(n+1)*(D-t1-t3)*changedt2;
lfarea=lfl*t3;
deckcg=D+t4/2;
ufcg=D-t1/2;
wcg=D/2-t1/2+t3/2;
lfcg=t3/2;
tarea=(deckarea+ufarea+warea+lfarea);
oriy=(deckarea*deckcg+ufarea*ufcg+warea*wcg+lfarea*lfcg)/tarea;
// cout<<"y= "<<y;
cout<<"y= "<<oriy;
//cout<<"enter y: ";
//cin>>y;
y=D+t4/2-oriy;
wl=D-t1-t3;
Ixx=(deckarea*t4*t4/12+deckarea*y*y)+(ufarea*t1*t1/12+ufarea*pow((y-t4/2t1/2),2))
+(warea*pow(wl,2)/12+warea*pow((wl/2+t1+t4/2-y),2))+
(lfarea*t3*t3/12+lfarea*pow((D+t4/2-t3/2-y),2));
cout<<"\nIxx="<<Ixx;
nn=nk;
cnt=1;

II

while( cnt <= ((A/dew)-1) )


{ nodes[nn].x=nodes[0].x+dew*cnt;
nodes[nn].y=nodes[0].y;
nn++;
cnt++;
}
//nn=j;
temp=(D-t1/2-t3/2)/wew-1;
for(i=1;i<=n+1;i++)
{ cnt=1;
while( cnt <= temp )
{
nodes[nn].x=nodes[i*2].x;
nodes[nn].y=nodes[i*2].y-wew*cnt;
nn++;
cnt++;
}
}
//j=nkp;
temp = n*B/lfew;
cnt=0;
float diff;
float t;
int inc=1;
while( cnt < temp )
{ cnt++;
t=lfew*cnt;
diff=t-(inc)*B;
if ( diff==0) {
inc++;
continue;
}
else
// if((int)diff!=0)
{
nodes[nn].x=nodes[3].x+t;
nodes[nn].y=nodes[3].y;
nn++;
}
}
int nno;
float sx,sy,sz;
FILE *fout;
fout=fopen("out8b3.txt","r");
fseek(fout,0,SEEK_SET);
fgets(str,150,fout);
while (fgets(str,150,fout)!=NULL){
sscanf(str,"%d %f %f %f %f %f %f",&nno,&xx,&yy,&zz,&sx,&sy,&sz);
//cout<<nno<<" "<<xx<<" "<<yy<<" "<<zz<<" "<<sx<<" "<<sy<<" "<<sz<<"\n";

III

for(i=0;i<nn;i++)
{
if( xx==nodes[i].x && yy==nodes[i].y)
{nodes[i].stress=sz;
// nodes[i].stress2=sstre;
}
}
}
//cout<<"\n"<<xx<<" "<<yy<<" "<<stre<<" "<<sstre;
//nodes[0].x=0;nodes[0].y=0;nodes[0].stress=-2.0285;nodes[0].stress2=0.12520e-15;
//float dist=(nodes[5].x-nodes[3].x)/2;
for(i=0;i<nn;i++) {
nodes[i].processed=0;
if( nodes[i].y==0)
{ if( nodes[i].x==0 || nodes[i].x == A)
nodes[i].area=dew*t4/2;
else
{ //if(fabs(dist-nodes[i].x)<=dew)
//nodes[i].area=dew*t4/2+fabs(dist-nodes[i].x)*t4;
// else
nodes[i].area=dew*t4;
}
}
else
if(i%2==0&&i<=2*n+2)
nodes[i].area=C*t1;
else if(i==3||i==(2*n+3))
nodes[i].area=(wew/2-t3/2)*t2+(lfew/2+t2/2)*t3;
//else if(isdigit(fabs(nodes[i].x-nodes[2].x)/B))
else if(nodes[i].y==nodes[3].y)
{ //if(fabs(dist-nodes[i].x)<=dew)
// nodes[i].area=lfew*t3/2+fabs(dist-nodes[i].x)*t3;
//else
if(i%2==1 && i<=2*n+3)
nodes[i].area=lfew*t3+(wew/2-t3/2)*t2;
else
nodes[i].area=lfew*t3;
}
else if(nodes[i].x==nodes[2].x || nodes[i].x==nodes[4].x ||nodes[i].x==nodes[6].x
|| nodes[i].x==nodes[8].x
||nodes[i].x==nodes[10].x || nodes[i].x==nodes[12].x ||
nodes[i].x==nodes[14].x || nodes[i].x==nodes[16].x
||nodes[i].x==nodes[18].x || nodes[i].x==nodes[20].x )
{ if(nodes[i].y==nodes[2].y-wew)
nodes[i].area=t2*wew/2+fabs(wew-t1/2)*t2;
else
nodes[i].area=t2*wew;

IV

}
}
//cout<<"after area\n";
//cony=D+t4/2-y;
for(j=0;j<nn;j++)
{ nodes[j].larm= fabs(y+nodes[j].y);
moment= nodes[j].larm*nodes[j].stress*nodes[j].area;
if(moment<0)
nodes[j].moment=-moment;
else
nodes[j].moment=moment;
}
cout<<"y= "<<oriy<<"\n";
cout<<"I:"<<Ixx;
double finalmoment=0;
for(i=1;i<=n;i++)
{ for(j=0;j<nn;j++)
{
if(nodes[j].x == B/2+nodes[3].x+B*(i-1))
{
if(nodes[j].y==0)
{ nodes[j].processed=1;
nodes[j-1].moment+=nodes[j].moment/2;
nodes[j+1].moment+=nodes[j].moment/2;
}
else if(nodes[j].y==nodes[3].y)
{
if(lfew==B/2)
{nodes[j].processed=1;
nodes[2*i+1].moment+=nodes[j].moment/2;
nodes[2*i+3].moment+=nodes[j].moment/2;
}
else
{nodes[j].processed=1;
nodes[j-1].moment+=nodes[j].moment/2;
nodes[j+1].moment+=nodes[j].moment/2;
}
}
}
}
}
double moment1;
cout<<"enter the moment:\n";
cin>>moment1;
for(j=1;j<=n+1;j++)
{ totalmoment=0;

for(i=0;i<nn;i++)
if( (nodes[i].x <= B/2+nodes[3].x+B*(j-1)) &&
(nodes[i].processed==0) )
{
totalmoment+=nodes[i].moment;
nodes[i].processed=1;
}
cout<<"\n";
cout<<"\ntotal moment: "<<totalmoment;
cout<<"\ndistribution factor:"<<totalmoment*(n+1)/moment1;
finalmoment+=totalmoment;
}
cout<<"\nmoment: "<<finalmoment;
}

VI

You might also like