%  Problem 1 - Exam II - Spring 2012
%
%  This script computes the safety factor for a rod that is undergoing both
%  torsion and bending.
%
% 
% Bending Stress on the rod     12.7 MPa
% Shear Stress on the rod     31.8 MPa
% von Mises Stress     56.6 MPa
% The safety factor for the rod      5.7

%  Compute the stress caused by the bending moment

clear all

Diameter = 20;          %  Diameter of the rod in mm
Syield = 320;           %  Yield Stress in MPa

Moment = 100 * 100;     %  Newton millimeters
Stress = Stress_Round_Bend_m(Diameter, Moment);

Torque = 50 * 1000;     %  Newton millimeters
Shear = Shear_Round_Torque_m(Diameter, Torque);

%  Combine the shear and the stress with von Mises

VMstress = VM_Stress(Stress, 0, 0, 0, Shear, 0);

%  Compute the safety factor

N = Syield / VMstress;

fprintf('Bending Stress on the rod %8.1f MPa\n', Stress);
fprintf('Shear Stress on the rod %8.1f MPa\n', Shear);
fprintf('von Mises Stress %8.1f MPa\n', VMstress);
fprintf('The safety factor for the rod %8.1f\n', N);
