close all
clear all

Ncycles = logspace(0,12);

sigma_adm_Ac_0cylces = 1200e6;
sigma_adm_Ac_20Mcylces = 500e6;

sigma_adm_Ac = sigma_adm_Ac_0cylces - (sigma_adm_Ac_0cylces - sigma_adm_Ac_20Mcylces)/log10(20e6)*log10(Ncycles);
sigma_adm_Ac(Ncycles>20e6) = sigma_adm_Ac_20Mcylces;

p1 = semilogx(Ncycles,sigma_adm_Ac/1e6,'LineWidth',2,'color','b');
ylim([0,1200])

sigma_adm_Ti_0cylces = 900e6;

sigma_adm_Ti = sigma_adm_Ti_0cylces./(0.5*log10(Ncycles)+1);

hold on;
p2 = semilogx(Ncycles,sigma_adm_Ti/1e6,'LineWidth',2,'color','r');
ylim([0,1200])
xlabel('Number of cycles','FontSize',18)
ylabel('Admissible stress [MPa]','FontSize',18)
fontsize(gca, 15,'points')
title('Stainless steel and titanium Wohler curves')

%Report the points you want to plot on S/N figure
%Units are [number of cycles] on x-axis and [MPa] on y-axis

P1 = [0,0];
P2 = [0,0];
P3 = [0,0];
P4 = [0,0];
P5 = [0,0];
P6 = [0,0];

plot(P1(1),P1(2),'bo',markersize=10,MarkerFaceColor='b') 
plot(P2(1),P2(2),'bo',markersize=10,MarkerFaceColor='b') 
plot(P3(1),P3(2),'bo',markersize=10,MarkerFaceColor='b') 

plot(P4(1),P4(2),'ro',markersize=10,MarkerFaceColor='r') 
plot(P5(1),P5(2),'ro',markersize=10,MarkerFaceColor='r') 
plot(P6(1),P6(2),'ro',markersize=10,MarkerFaceColor='r') 

line([P1(1) P1(1)],[0 P1(2)],'color','b','linestyle','--')
line([P2(1) P2(1)],[0 P2(2)],'color','b','linestyle','--')
line([P3(1) P3(1)],[0 P3(2)],'color','b','linestyle','--')

line([P4(1) P4(1)],[0 P4(2)],'color','r','linestyle','--')
line([P5(1) P5(1)],[0 P5(2)],'color','r','linestyle','--')
line([P6(1) P6(1)],[0 P6(2)],'color','r','linestyle','--')

line([1 P1(1)],[P1(2) P1(2)],'color','b','linestyle','--')
line([1 P2(1)],[P2(2) P2(2)],'color','b','linestyle','--')
line([1 P3(1)],[P3(2) P3(2)],'color','b','linestyle','--')
line([1 P4(1)],[P4(2) P4(2)],'color','r','linestyle','--')
line([1 P5(1)],[P5(2) P5(2)],'color','r','linestyle','--')
line([1 P6(1)],[P6(2) P6(2)],'color','r','linestyle','--')


legend([p1,p2],{'SS','Ti'})

