Simply Supported Beam Analysis (Visual C++)
Simply Supported Beam Analysis (Visual C++)
cpp 1
// Analysis of a single span simply supported beam
// Computation of end reactions, shear and bending moment
// Underlying Concept: Principle of superposition
// Environment: Visual C++ 2008 Express Edition
// Programmer: Prof. S A Vasanwala
// Debugger: Prakash Agarwal
// Date: 05/02/2010
cout << "\nLoad number: " << k << endl << endl
<< "Load Type 1: Concentrated Load " << endl
<< " Type 2: Uniformly Distributed Load " << endl
<< " Type 3: Triangular Load - Left to Right " << endl
<< " Type 4: Triangular Load - Right to Left " << endl;
// Computation of reactions
switch(type)
{
case 1:
s = a;
break;
case 2:
s = a + (c / 2.0);
break;
case 3:
s = a + (2 * c / 3.0);
break;
case 4:
s = a + (c / 3.0);
break;
default:
cout << "\nInvalid Load Type "
<< "\nTerminating..." << endl;
exit(0);
}
t = l - s;
R1 = W * t / l;
R2 = W - R1;
RL = RL + R1;
RR = RR + R2;
// Computation of moments
dist = (j - 1) * (l / no_section);
if (dist <= a)
{
moment[j] = moment[j] + (R1 * dist);
shear[j] = shear[j] + R1;
}
else if (dist >= (a + c))
{
moment[j] = moment[j] + R2 * (l - dist);
shear[j] = shear[j] - R2;
}
else
{
// Moment within load cover
b1 = dist - a;
if (type == 2)
{
W1 = W * b1 / c;
moment[j] = moment[j] + R1 * (a + b1)
- W1 * b1 / 2.0;
shear[j] = shear[j] + R1 - W1;
}
else if (type == 3)
{
W1 = W * (b1 / c) * (b1 / c); // Hint: Similar triangles
moment[j] = moment[j] + R1 * (a + b1)
- W1 * b1 / 3.0;
shear[j] = shear[j] + R1 - W1;
f:\Simply Supported Beam\Simply Supported Beam\Simply Supported Beam.cpp 3
}
else if (type ==4)
{
// Note: Computations from right side unlike in...
// ...previous cases
b1 = c - b1;
W1 = W * (b1 / c) * (b1 / c);
moment[j] = moment[j] + R2 * (1 - a - c + b1)
- W1 * b1 / 3.0;
shear[j] = shear[j] - R2 + W1;
}
}
} // End of j loop
} // End of k loop
char press;
cout.setf(ios::fixed | ios::showpoint);
cout.precision(2);
cout << "\nLeft hand reaction [kN]: " << RL << endl
<< "\nRight hand reaction [kN]: " << RR << endl;
cout << "\nMaximum moment [kN.m]: " << max_moment << endl
<< "At a distance " << dist_x << " m from left support "
<< endl;
}