clear all
close all
clc

setGlobalOmegaROmegaomega_noA

global OmegaR Omega omega
Delta = omega - Omega
Sigma = omega + Omega
x0=[1 0];
tspan=[0,30];
options=odeset('RelTol',1e-10);
%[t,x]=ode23t(@noRWA,tspan,x0,options);
%[t,x]=ode23(@noRWA,tspan,x0,options);
[t,x]=ode45(@noRWA_noA,tspan,x0,options);

realx=real(x)
imagx=imag(x)

figure;
plot(t,realx(:,1),t,realx(:,2));
legend('realx 1 noRWA','realx 2 noRWA');

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

prob=x.*conj(x)

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

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','prob 2 RWA');

figure;
h=plot(t,prob(:,1),'k-',t,prob(:,2),'r-',t,P1offR,'b--',t,P2offR,'m--')
legend('prob 1 noRWA','prob 2 noRWA','prob 1 RWA','prob 2 RWA') 
set(h,{'LineWidth'},{2;2;1;1})
annotation('textbox',...
    [0.4 0.2 0.2 0.3],...
    '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}']},...
    'FontSize',10,...
    'FontName','Arial',...
    'LineStyle','--',...
    'EdgeColor',[1 1 0],...
    'LineWidth',2,...
    'BackgroundColor',[0.9 0.9 0.9],...
    'Color',[0.84 0.16 0]);

