% NOESY/EXSY experiment on two coupled spins,  in a situation where
% the chemical exchange is intermediate, lines are broadened and scalar
% relaxation of the first kind must be accounted for. 
%Created from the simulations from
%               http://dx.doi.org/10.1002/ange.201410271
%
% Using approx coordinates
%
% Calculation time: seconds
%
% ptg20@cam.ac.uk

function linwei_srfk_exsy_orig() 

% Magnet induction 
sys.magnet=11.75;

% Isotopes 
sys.isotopes={'1H','1H',...
              '1H','1H'};  

% Coordinates (Angstrom)  
inter.coordinates={[-0.0    0.0    0.0];
                   [4.28   0.0    0.0];
                   [-0.0    0.0    0.0];
                   [4.28   0.0    0.0];};
  


% Scalar couplings
inter.coupling.scalar=cell(4);  
inter.coupling.scalar{2,1}= 2.5e+000; 
inter.coupling.scalar{3,4}=  1.5e+000; 


 


% Experimental chemical shifts
inter.zeeman.matrix=cell(1,4);
inter.zeeman.matrix=shift_iso(inter.zeeman.matrix,1:4,[7.1 6.6 6.97 6.90]);
% Chemical kinetics
kplus=2e0; kminus=2e0;
inter.chem.parts={[1  2]...
                  [3  4]};
inter.chem.rates=[-kplus  kminus
                   kplus -kminus];
inter.chem.concs=[kminus kplus];

% Relaxation theory 
inter.relaxation={'redfield','SRFK'};
inter.equilibrium='zero';
inter.rlx_keep='kite';
inter.tau_c={10e-12 10e-12};
inter.srfk_tau_c={[1 1/kplus]};
inter.srfk_mdepth=cell(4);
inter.srfk_mdepth{2,1}=0.7;
inter.srfk_mdepth{3,4}=0.7;


% Basis set
bas.formalism='sphten-liouv';
bas.approximation='IK-1';
bas.connectivity='scalar_couplings';
bas.level=4;
bas.space_level=3;

% Disable Krylov algorithm
sys.disable={'krylov'};
sys.enable={'greedy'};

% Proximity cut-off
sys.tols.prox_cutoff=10.0;

% Spinach housekeeping 
spin_system=create(sys,inter); 
spin_system=basis(spin_system,bas);

% Sequence parameters
parameters.offset=3500;
parameters.sweep=[1000 1000];
parameters.npoints=[1024 1024];
parameters.zerofill=[2048 2048];
parameters.spins={'1H'};
parameters.axis_units='ppm';
parameters.tmix=1.500;

% Concentration-aware initial state
parameters.rho0=state(spin_system,'Lz','1H','chem');

% Simulation
fid=liquid(spin_system,@noesy,parameters,'nmr');

% Apodization
fid.cos=apodization(fid.cos,'sqcosbell-2d');
fid.sin=apodization(fid.sin,'sqcosbell-2d');

% F2 Fourier transform
f1_cos=real(fftshift(fft(fid.cos,parameters.zerofill(2),1),1));
f1_sin=real(fftshift(fft(fid.sin,parameters.zerofill(2),1),1));

% States signal
f1_states=f1_cos-1i*f1_sin;

% F1 Fourier transform
spectrum=fftshift(fft(f1_states,parameters.zerofill(1),2),2);

% Destreaking
spectrum=destreak(spectrum);

% Plotting
figure(); plot_2d(spin_system,-real(spectrum),parameters,...
                  20,[0.0005 0.01 0.025 0.25],2,256,6,'both');
%try_to_savefig(gcf,'aziridine_exsy_2.fig');

end

