clear all
close all
clc

setGlobalOmegaROmegaomega_2LS3LS

global LS OmegaR OmegaRp Omega omega A1h % A21
Delta = omega - Omega
Sigma = omega + Omega
if LS==2
x0=[1 0];
elseif LS==3
x0=[1 0 0];
end
tspan=[0,200];
options=odeset('RelTol',1e-12);
%[t,x]=ode23t(@noRWA,tspan,x0,options);
%[t,x]=ode23(@noRWA,tspan,x0,options);
[t,x]=ode45(@noRWA_2LS3LS,tspan,x0,options);

realx=real(x)
imagx=imag(x)
prob=x.*conj(x)


if LS==2
figure;
plot(t,realx(:,1),t,realx(:,2));
legend('realx 1 noRWA including Spontaneous Emission','realx 2 noRWA including Spontaneous Emission');

figure;
plot(t,imagx);
legend('imagx 1 noRWA including Spontaneous Emission','imagx 2 noRWA including Spontaneous Emission');


figure;
plot(t,prob(:,1),t,prob(:,2));
legend('prob 1 noRWA including Spontaneous Emission','prob 2 noRWA including Spontaneous Emission');

figure;
lambda = (sqrt(OmegaR^2+Delta^2))/2
TRoffR=(2*pi)/sqrt(OmegaR^2+Delta^2)
P1offR= 1 + (OmegaR^2*(cos(2*lambda.*t)-1))/(2*(OmegaR^2+Delta^2));
P2offR=(OmegaR^2)/(OmegaR^2+Delta^2)*sin(lambda.*t).^2;
plot(t,P1offR,t,P2offR)
legend('prob 1 RWA without Spontaneous Emission','prob 2 RWA without Spontaneous Emission');

figure;
h=plot(t,prob(:,1),'k-',t,prob(:,2),'r-',t,P1offR,'b--',t,P2offR,'m--')
legend('prob 1 noRWA including Spontaneous Emission','prob 2 noRWA including Spontaneous Emission','prob 1 RWA without Spontaneous Emission','prob 2 RWA without Spontaneous Emission') 
set(h,{'LineWidth'},{2;2;1;1})
annotation('textbox',...
    [0.7 0.4 0.2 0.35],...
    'String',{'plotting with',['\Omega_R = ' num2str(OmegaR),' s^{-1}'],['\Omega = ' num2str(Omega),' s^{-1}'],['\omega = ' num2str(omega),' s^{-1}'],['\Delta = ' num2str(Delta),' s^{-1}'], ['\Sigma = ' num2str(Sigma),' s^{-1}'], ['A_{1h} = ' num2str(A1h),' s^{-1}']},...
    'FontSize',10,...
    'FontName','Arial',...
    'LineStyle','--',...
    'EdgeColor',[1 1 0],...
    'LineWidth',2,...
    'BackgroundColor',[0.9 0.9 0.9],...
    'Color',[0.84 0.16 0]);

 figure;
 h=plot(t,prob(:,1)+prob(:,2),'k--')
 legend('prob 1 + prob 2 including Spontaneous Emissions') 

elseif LS==3
  figure;
  h=plot(t,prob(:,1),'k-',t,prob(:,2),'r-',t,prob(:,3),'g-')
  legend('prob 1 noRWA including Spontaneous Emission','prob 2 noRWA including Spontaneous Emission', 'prob 3 noRWA including Spontaneous Emission') 
  set(h,{'LineWidth'},{2;2;2})
annotation('textbox',...
    [0.7 0.4 0.2 0.4],...
    'String',{'plotting with',['\Omega_R = ' num2str(OmegaR),' s^{-1}'],['\Omega_{Rp} = ' num2str(OmegaRp),' s^{-1}'],['\Omega = ' num2str(Omega),' s^{-1}'],['\omega = ' num2str(omega),' s^{-1}'],['\Delta = ' num2str(Delta),' s^{-1}'], ['\Sigma = ' num2str(Sigma),' s^{-1}'], ['A_{1h} = ' num2str(A1h),' s^{-1}']},...
    'FontSize',10,...
    'FontName','Arial',...
    'LineStyle','--',...
    'EdgeColor',[1 1 0],...
    'LineWidth',2,...
    'BackgroundColor',[0.9 0.9 0.9],...
    'Color',[0.84 0.16 0]);
 figure;
 h=plot(t,prob(:,1)+prob(:,2)+prob(:,3),'k--')
 legend('prob 1 + prob 2 including Spontaneous Emissions') 

end

