1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// Example program
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
//Max Stress of Fixed Beam under unsymmetric eccentric loading
int main()
{
float Force, FxDistance, FyDistance, BeamWidth, BeamHeight, BeamDepth, MomentX, MomentY, NormalStress, AreaOfAction, AllowableStress, x, y;
cout << "Please input Allowable Stress in MPa \n";
cin >> AllowableStress;
cout << "Please input Force in Newtons \n";
cin >> Force;
cout << "Please input the distance from the X-Axis \n";
cin >> FxDistance;
cout << "Please input the distance from the Y-Axis \n";
cin >> FyDistance;
cout << "Please input the Beam Width in meters \n";
cin >> BeamWidth;
cout << "Please input the Beam Depth in meters \n";
cin >> BeamDepth;
MomentX = Force*FxDistance;
MomentY = Force*FyDistance;
AreaOfAction = BeamWidth*BeamDepth;
NormalStress = Force/AreaOfAction;
////////////////////////////////////////////////////////////////////////////////
float BendingStressX, BendingStressY, cx, cy, Ix, Iy, MaxStress;
Ix = (1/12)*(BeamWidth)*(pow(BeamDepth,3));
Iy = (1/12)*(BeamDepth)*(pow(BeamWidth,3));
cx = BeamWidth/2;
cy = BeamDepth/2;
BendingStressX = ((MomentX)*(cy))/(Ix);
BendingStressY = ((MomentY)*(cx))/(Iy);
MaxStress = (BendingStressX + BendingStressY + NormalStress);
////////////////////////////////////////////////////////////////////////////////
cout << "Your Maximum Stress is approximately: " << MaxStress << "MPa" << endl;
x = MaxStress;
y = AllowableStress;
if (x>y)
{ cout << "WARNING: Max Stress exceeds Allowable Stress." << endl;
}
else
{
cout << "Max Stress is within safe parameters." << endl;
}
cout << "End of Program.";
return 0;
}
|