function [S] = CorrectedStrengthEnglishSh(load, size, surf, temp, reliab, mat, S_ut)
% Calculates correction factors and uses these vaues to find the corrected
% strength (yeild or endurance). Shows C values.
%
% Synopsis: [S] = CorrectedStrengthSh(load, size, surf, temp, reliab,
% S_prime)
%
% input:    load = (required) 'bending' or 'axial'. Must be a string. Use
%                   bending case for all cases that are non-axial.
%           size = (required) Must be a structured array. size must contain
%                   size.shape: 'rectangle' or 'circle'
%                   size.rotation: 'nonrotating' or 'rotating'
%                   size.dim: 1x1 (radius of circle) or 1x2 (height - the
%                   cubed length, and width); must be in inches.
%           surf = (required) 'ground' or 'machined' or 'hot-rolled' or
%                   'as-forged' or 1.
%           temp = (required) 0 to 1020 degrees F
%           reliab = (required) 50, 90, 99, 99.9, 99.99, or
%                   99.999 percent
%           mat = (required) 'steel', 'iron', or 'aluminum'. Must be a
%                  sting.
%           S_ut = (required) The ultamate tensile strength. Must be in
%                   kpsi.
%
% output:   S = corrected strength value in kpsi.
%
% Note: For the following variables 1 can be assigned to them:
%       load, surf, temp, and reliab. When this occurs the C value for
%       theses variables is simply made equal to one.
%
%
% All values must be constants, no matricies allowed. Use the following to
% get around this rule though:
%
% use matix for the size, mat, or other variable, for example:
%
% Reliability = [50, 90, 99];
% len = length(Reliability);
% S = ones(1,len);
% for coun = 1:len
%   reliab = Reliability(coun);
%   S(1,coun) = CorrectedStrengthEnglish(load, size, surf, temp, reliab, mat, S_ut);
% end



%%%%%% Loading %%%%%%%
if strcmp(load,'bending')
    C_load = 1;
elseif strcmp(load,'axial')
    C_load = 0.7;
else
    error('CorrectedStrength:WrongWord', 'Must specify either "bending" or "axial" only for load.')
    C_load = 1;
end


%%%%%% Size %%%%%%%
if strcmp(size.shape,'rectangle')
    A_95 = 0.05.*size.dim(1,1).*size.dim(1,2);
elseif strcmp(size.shape,'circle')
    if strcmp(size.rotation,'rotating')
        A_95 = 0.0766.*(size.dim).^2;
    elseif strcmp(size.rotation,'nonrotating')
        A_95 = 0.010462.*(size.dim).^2;
    else
        error('CorrectedStrength:WrongWord', 'Must specify either "rotating" or "nonrotating" only for size.rotation.')
    end
else
    error('CorrectedStrength:WrongWord', 'Must specify either "rectangle" or "circle" only for size.shape.')
end

d_equi = (A_95/0.0766)^(1/2);

if d_equi <= 0.3
    C_size = 1;
elseif (d_equi > 0.3) && (d_equi <= 10)
    C_size = 0.869.*d_equi.^(-0.097);
else
    fprintf('Error: Equivalent diameter is too large.')
    C_size = 1;
end



%%%%%% Surface %%%%%%%
if strcmp(surf,'ground')
    C_surf = 1.34.*(S_ut).^(-0.085);
elseif strcmp(surf,'machined')
    C_surf = 2.7.*(S_ut).^(-0.265);
elseif strcmp(surf,'hot-rolled')
    C_surf = 14.4.*(S_ut).^(-0.718);
elseif strcmp(surf,'as-forged')
    C_surf = 39.9.*(S_ut).^(-0.995);
elseif surf == 1; % Special case where C_surf is given as 1.
    C_surf = 1;
else
    error('CorrectedStrength:WrongWord', 'Must specify acceptable word for surf.')
    C_surf = 1;
end


%%%%%% Temperature %%%%%%%
if temp <= 840
    C_temp = 1;
elseif temp <= 1020
    C_temp = 1-0.0032*(temp - 840);
elseif temp == 1; % Special case where C_temp is given as 1.
    C_temp = 1;
else
    error('CorrectedStrength:WrongWord', 'Temperature outside of acceptable range.')
    C_temp = 1;
end


%%%%%% Reliable %%%%%%%
if reliab == 50;
    C_reliab = 1;
elseif reliab == 90;
    C_reliab = 0.897;
elseif reliab == 99;
    C_reliab = 0.814;
elseif reliab == 99.9;
    C_reliab = 0.753;
elseif reliab == 99.99;
    C_reliab = 0.702;
elseif reliab == 99.999;
    C_reliab = 0.659;
elseif reliab == 1; % Special case where C_reliab is given as 1.
    C_reliab = 1;
else
    error('CorrectedStrength:WrongValues', 'Must use only the accepted values.');
    C_reliab = 1;
end


%%%%%% Material %%%%%%%
if strcmp(mat,'steel');
    if S_ut < 200;
        S_prime = 0.5.*S_ut;
    else
        S_prime = 100;
    end
elseif strcmp(mat,'iron');
    if S_ut < 60;
        S_prime = 0.4.*S_ut;
    else
        S_prime = 24;
    end
elseif strcmp(mat,'aluminum');
    if S_ut < 48;
        S_prime = 0.4.*S_ut;
    else
        S_prime = 19;
    end
else
    error('CorrectedStrength:WrongWord', 'Must specify acceptable word for mat.')
end

C_load, C_size, C_surf, C_temp, C_reliab, S_prime

%%%%%% output %%%%%%%
S = C_load.*C_size.*C_surf.*C_temp.*C_reliab.*S_prime;