from math import sqrt
#variable declaration
sigma_i=150;
k=0.7;
n=6;
#calculation
N_x=2**(n-1);
N=N_x/(0.01)**2; #in grains/in^2
N=N*10**6/25.4**2; # in grains/m^2
D=sqrt(1/N);
sigma0=sigma_i+k/sqrt(D);
#result
print ('\nYield Stress = %g MPa')%(sigma0);
#variable declaration
sigma0=600;
G=27.6;
G=G*10**9 #conversion to Pa
b=2.5*10**-8;
b=b*10**-2; #conversion to m
T0=sigma0/2;
T0=T0*10**6; #conversion to Pa
#calculation
lambda1=G*b/T0;
Cu_max=54;
Cu_eq=4;
Cu_min=0.5;
rho_al=2.7;
rho_theta=4.43;
wt_a=(Cu_max-Cu_eq)/(Cu_max-Cu_min);
wt_theta=(Cu_eq-Cu_min)/(Cu_max-Cu_min);
V_a=wt_a/rho_al;
V_theta=wt_theta/rho_theta;
f=V_theta/(V_a+V_theta);
r=(3*f*lambda1)/(4*(1-f));
#result
print('\nParticle Spacing = %g m\nParticle Size = %g m')%(lambda1,r);
#variable declaration
Ef=380;
Em=60;
#calculation
#Case 1
f_f1=0.1;
Ec1=Ef*f_f1+(1-f_f1)*Em;
#Case 2
f_f2=0.6;
Ec2=Ef*f_f2+(1-f_f2)*Em;
#result
print('\nEc for 10 vol%% = %g GPa\n')%(Ec1);
print('\nEc for 60 vol%% = %g GPa\n')%(Ec2);
#variable declaration
sigma_fu=5;
sigma_fu=sigma_fu*10**9; #Conversion to Pa
sigma_m=100;
sigma_m=sigma_m*10**6; #Conversion to Pa
T0=80;
T0=T0*10**6; #Conversion to Pa
f_f=0.5;
d=100;
d=d*10**-6;
B=0.5;
L1=10;
L1=L1*10**2; #conversion to m
Lc=sigma_fu*d/(2*T0);
sigma_cu1=sigma_fu*f_f*(1-Lc/(2*L1))+sigma_m*(1-f_f);
sigma_cu1=sigma_cu1*10**-9;
print('\nsigma_cu = %g GPa for L=100um\n')%(sigma_cu1);
L2=2;
L2=L2*10**-3; #conversion to m
sigma_cu2=sigma_fu*f_f*(1-Lc/(2*L2))+sigma_m*(1-f_f);
sigma_cu2=sigma_cu2*10**-9;
print('sigma_cu = %g GPa for L=2mm')%(sigma_cu2);