Programme For Priciple Stress and Its Direction Cosin
Programme For Priciple Stress and Its Direction Cosin
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<iomanip.h>
class tensor
{
float cx,cy,cz,txy,txz,tyx,tyz,tzx,tzy;
float i1,i2,i3,b,c,d,alpha,p,q,r,c1,c2,c3,k;
float A1,B1,C1,K1,l1,m1,n1;
float A2,B2,C2,K2,l2,m2,n2;
float A3,B3,C3,K3,l3,m3,n3;
public:
void getdata();
void process();
void cosign();
void result();
};
void tensor :: getdata()
{
cout<<"Enter the elements of stress tensor matrix (mpa)in 1st row one by
one:"<<"\n";
cin>>cx>>txy>>txz;
cout<<"Enter the elements of stress tensor matrix (mpa)in 2nd row one by
one:"<<"\n";
cin>>tyx>>cy>>tyz;
cout<<"Enter the elements of stress tensor matrix (mpa)in 3rd row one by
one:"<<"\n";
cin>>tzx>>tzy>>cz;
}
void tensor :: process()
{
i1 = cx + cy + cz;
i2 = (cx*cy)+(cy*cz)+(cz*cx)-(txy*tyx)-(tyz*tzy)-(tzx*txz);
i3 = cx*((cy*cz)-(tyz*tzy)) - txy*((tyx*cz)-(tyz*tzx)) + txz*((tyx*tzy)(tzx*cy));
b = -i1;
c = i2;
d = -i3;
p = c-((b*b)/3);
q = 2*(pow(b,3)/27) - (b*c/3) + d;
if(p<=0)
{
r = sqrt(-p/3);
alpha = acos(-q/(2*pow(r,3)))*57.3;
c1 = 2*r*cos((alpha/3)/57.3)-(b/3);
c2 = -2*r*cos(((alpha/3)+60)/57.3)-(b/3);
c3 = -2*r*cos(((alpha/3)-60)/57.3)-(b/3);
}
else
{
}
void
{
A1 =
B1 =
C1 =
K1 =
l1 =
m1 =
n1 =
tensor :: cosign()
A2
B2
C2
K2
l2
m2
n2
=
=
=
=
=
=
=
((cy-c2)*(cz-c2)-(tyz*tzy));
-(tyx*(cz-c2)-(tzx*tyz));
(tyx*tzy)-(tzx*(cy-c2));
sqrt( A2*A2+ B2*B2+ C2*C2);
A2/K2;
B2/K2;
C2/K2;
A3
B3
C3
K3
l3
m3
n3
=
=
=
=
=
=
=
((cy-c3)*(cz-c3)-(tyz*tzy));
-(tyx*(cz-c3)-(tzx*tyz));
(tyx*tzy)-(tzx*(cy-c3));
sqrt( A3*A3+ B3*B3+ C3*C3);
A3/K3;
B3/K3;
C3/K3;
((cy-c1)*(cz-c1)-(tyz*tzy));
-(tyx*(cz-c1)-(tzx*tyz));
(tyx*tzy)-(tzx*(cy-c1));
sqrt( A1*A1+ B1*B1+ C1*C1);
A1/K1;
B1/K1;
C1/K1;
}
void tensor :: result()
{
if(p<=0)
{
cout<<"---------------------- R E S U L T
-------------------------------------"<<"\n";
cout.precision(3);
cout.width(10);
cout.setf(ios::showpoint);
cout.setf(ios::showpos);
cout.setf(ios::fixed,ios::floatfield);
cout.setf(ios::left,ios::adjustfield);
cout<<"STRESSES INVARIENTS:
PRINCIPLE STRESSES:"<<"\n";
cout<<"i1 = "<<i1<<" Mpa
c1 = "<<c1<<" Mpa"<<"\n";
cout<<"i2 = "<<i2<<" Mpa
c2 = "<<c2<<" Mpa"<<"\n";
cout<<"i3 = "<<i3<<" Mpa
c3 = "<<c3<<" Mpa"<<"\n";
cout<<"-----------------------------------------------------------------------"<<"\n";
cout<<"p = "<<p<<"\n";
cout<<"q = "<<q<<"\n";
cout<<"r = "<<r<<"\n";
cout<<"alpha = "<<alpha<<" Degree"<<"\n";
cout<<"-----------------------------------------------------------------------"<<"\n";
cout<<"DIRECTION COSIN OF c1 | DIRECTION COSIN OF c2 | DIRECTION COSIN
OF c3"<<"\n";
cout<<"A1 = "<<A1<<"
A2 = "<<A2<<"
A3 =
"<<A3<<"\n";
cout<<"B1 = "<<B1<<"
B2 = "<<B2<<"
B3 =
"<<B3<<"\n";
cout<<"C1 = "<<C1<<"
C2 = "<<C2<<"
C3 =
"<<C3<<"\n";
cout<<"K1 = "<<K1<<"
K2 = "<<K2<<"
K3 =
"<<K3<<"\n";
cout<<"-----------------------------------------------------------------------"<<"\n";
cout<<"l1 = "<<l1<<"
l2 = "<<l2<<"
l3 =
"<<l3<<"\n";
cout<<"m1 = "<<m1<<"
m2 = "<<m2<<"
m3 =
"<<m3<<"\n";
cout<<"n1 = "<<n1<<"
n2 = "<<n2<<"
n3 =
"<<n3<<"\n";
cout<<"-----------------------------------------------------------------------"<<"\n";
}
}
int main()
{
clrscr();
tensor a;
a.getdata();
a.process();
a.cosign();
a.result();
getch();
return 0;
}
INPUT
Enter the elements of stress tensor matrix (mpa)in 1st row one by one:
150
60
-80
Enter the elements of stress tensor matrix (mpa)in 2nd row one by one:
60
70
35
Enter the elements of stress tensor matrix (mpa)in 3rd row one by one:
-80
35
90
OUTPUT
---------------------- R E S U L T -----------------------------------STRESSES INVARIENTS:
PRINCIPLE STRESSES:
i1 = +310.000 Mpa
c1 = +212.612 Mpa
i2 = +19075.000 Mpa
c2 = +111.946 Mpa
i3 = -346750.000 Mpa
c3 = -14.572 Mpa
----------------------------------------------------------------------p = -12958.333
q = +111092.594
r = +65.722
alpha = +101.291 Degree
----------------------------------------------------------------------DIRECTION COSIN OF c1 | DIRECTION COSIN OF c2 | DIRECTION COSIN OF c3
A1 = +16260.825
A2 = -304.469
A3 = +7618.845
B1 = +4556.693
B2 = -1483.255
B3 = -9074.314
C1 = -9308.925
C2 = -1255.660
C3 = +8865.753
K1 = +19282.996
K2 = +1967.086
K3 = +14798.363
----------------------------------------------------------------------l1 = +0.843
l2 = -0.155
l3 = +0.515
m1 = +0.236
m2 = -0.754
m3 = -0.613
n1 = -0.483
n2 = -0.638
n3 = +0.599
-----------------------------------------------------------------------