from math import pi
from math import sqrt
#variable declaration
sigma_u=158; # in ksi
sigma0=147; # in ksi
sigma_e=75; # in ksi
l_max=75; # in ksi
l_min=-25; # in ksi
sf=2.5;
#calculation
sigma_m=(l_max+l_min)/2;
sigma_a=(l_max-l_min)/2;
sigma_e=sigma_e/sf;
A=sigma_a/sigma_e+sigma_m/sigma_u;
D=sqrt(4*A/pi);
#result
print('\nBar Diameter = %g in')%(D);
#variable declaration
sigma_b=75.0;
e_b=0.000645;
e_f=0.3;
E=22*10**4;
c=-0.6;
#calculation
d_e_e=float(2*sigma_b/E);
d_e_p=2*e_b-d_e_e;
N=((d_e_p/(2*e_f))**(1/c))/2;
#result
print('\nd_e_e = %g\nd_e_p = %g\nNumber of Cycles = %g cycles')%(d_e_e,d_e_p,N);
from math import pi
#variable declaration
ai=0.5;
ai=ai*10**-3; #conversion to m
sigma_max=180.0;
Kc=100.0;
alpha=1.12;
p=3.0;
A=6.9*10**-12;
#calculation
af=(Kc/(sigma_max*alpha))**2/pi;
Nf=float(af**(1-(p/2))-ai**(1-(p/2)))/float((1-p/2)*A*(sigma_max**3)*(pi**(p/2))*(alpha**p));
#result
print('Fatigue Cycles = %g cycles')%(Nf);
from math import sqrt
from math import pi
#variable declaration
rho=0.0004;
S_u=190000;
M=200;
Pm=5000;
D=0.5;
dh=0.05;
r=dh/2;
Kt=2.2;
#calculation
Kf=1+(Kt-1)/(1+sqrt(rho/r));
q=(Kf-1)/(Kt-1);
A=pi/4*D**2;
sigma_m=Pm/A;
I=pi/64*D**4;
sigma_a=Kf*((M*D)/(2*I));
sigma_max=sigma_a+sigma_m;
sigma_min=sigma_a-sigma_m;
sigma_e=S_u/2;
sigma_a1=sigma_e/Kf*(1-sigma_m/S_u);
#result
print('\nMean Stress = %g psi\nFluctuating Bending Stress = %g psi\nEffective Maximum Stress = %g psi\nEffective Minimum Stress = %g psi\nsigma_a = %g psi\n\n\nNote: Calculation Errors in the book')%(sigma_m,sigma_a,sigma_max,sigma_min,sigma_a1);
#variable declaration
Kt=1.68;
q=0.9;
sigma_ed=42000;
Cs=0.9;
Cf=0.75;
Cz=0.81;
#calculation
Kf=q*(Kt-1)+1;
sigma_e=sigma_ed*Cs*Cf*Cz;
sigma_en=sigma_e/Kf;
#result
print('\nFatigue Limit = %g psi')%(sigma_en);
from scipy.optimize import fsolve
#variable declaration
K=189;
n=0.12;
ef=1.06;
sigma_f=190;
b=-0.08;
c=-0.66;
E=30000000.0;
E=E/1000; #conversion to ksi
s=200.0;
sigma_m=167.0;
sigma_a=17.0;
se=s**2/E;
#calculation
def f(ds):
return (ds**2)/(2*E)+(ds**((1+n)/n))/((2*K)**(1/n))-se/2;
ds=fsolve(f,1)
de=se/ds;
def f1(N2):
return (N2**(b))*(sigma_f/E)+ef*(N2**(c))-de/2;
N2=fsolve(f1,1);
N_1=N2/2;
de_e2=sigma_a/E;
def f2(N2):
return (N2**b)*((sigma_f-sigma_m)/E)+ef*(N2**c)-de_e2;
N2=fsolve(f2,1);
N_2=N2/2;
C_pd=2*60*60*8;
f=N_2/C_pd;
#result
print('\nNumber of cycles = %g cycles\nFatigue damage per cycle = %g\nNumber of cycles with correction of mean stress= %g cycles\nFatigue damage per cycle with correction of mean stress= %g damage per year\nShaft will fail in %g days')%(N_1,1/N_1,N_2,1/N_2,f);