%   Stimulated Raman Adiabatic Passage (STIRAP)
%  IHP course 
% mazyar.mirrahimi@inria.fr
% pierre.rouchon@mines-paristech.fr
% October 2010
clear all; i=sqrt(-1);
%% population transfert  from |g> to [e>
Wg0=1;We0=1;eps=0.05;
G=[1 0 0]';E=[0 1 0]'; F=[ 0 0 1]'; 
Xgf=(G*F'+F*G'); Xef=(E*F'+F*E');
t=3*pi/2/eps*[0:0.005:1];nt=length(t);dt=t(2)-t(1);
Phi=zeros(3,nt);We=zeros(1,nt);Wg=zeros(1,nt);
Phi(:,1)=G;
for it=2:nt
  sg=max(pi/2,min(3*pi/2,eps*t(it))); Wg(it)=Wg0*(cos(sg)^2);
  se=max(0,min(pi,eps*t(it))); We(it)=We0*(sin(se)^2);
  H=(Wg(it)/2)*Xgf + (We(it)/2)*Xef;
  Phi(:,it)=expm(-i*dt*H)*Phi(:,it-1);
end
figure(1); clf;
subplot(211)
plot(eps*t/pi,Wg,'r',eps*t/pi,We,'b','linewidth',3);
title(['STIRAP  from |g> to |e> (\epsilon=',num2str(eps,2),')'],'fontsize',18);
legend('\Omega_g_f','\Omega_e_f');
xlabel('s/\pi');
subplot(212)
Pg=Phi(1,:).*conj(Phi(1,:));Pe=Phi(2,:).*conj(Phi(2,:));Pf=Phi(3,:).*conj(Phi(3,:));
plot(eps*t/pi,Pg,'r',eps*t/pi,Pe,'b',eps*t/pi,Pf,'g','linewidth',3);set(gca,'fontsize',16);
legend('|\phi_g|^2','|\phi_e|^2','|\phi_f|^2');
xlabel('s/\pi');


return

% s=pi*[0:0.01:1];Wg=sin(s)/2-sin(2*s)/4; We=sin(s);
% figure(10), clf; 
% plot(s/pi,Wg,'r',s/pi,We,'b','linewidth',3);set(gca,'fontsize',16);
% legend('\Omega_g_f','\Omega_e_f');xlabel('s/\pi');
