-------------------------------------------------------------------------------
--                                                                           --
--                          Experiment Source Code                           --
--              Delta NMR Experiment & Machine Control Interface             --
--                                                                           --
--                     Copyright (c) 2009 JEOL Ltd                           --
--                            All Rights Reserved                            --
--                                                                           --
-------------------------------------------------------------------------------
----By Rongchun Zhang, 2022/02/09
----Ref: Rongchun Zhang et al. J. Magn. Reson. 2016, 266, 59-66
---Record a CP and a NOE spectrum separately in a single experiment
----Mobile signals come from pure 1H-13C NOE effect
-- HELP.eng: Cross Polarization with polarization inversion ++ NOE
-- Category: solids, 1D standard, cpmas
--- loop (+XCP -- -XCP -- -XCP -- +XCP)--NOE
header
    filename  		=> "cp-noe-2s-1D";
    sample_id 		=> "";
    comment   		=> "Cross Polarization with transient NOE";
    process   		=  "1d_solid.list";
    include "header_solid";
end header;

instrument
    include "instrument_solid";
end instrument;

acquisition
	x_domain			=>	"Carbon13";
	x_offset			=>	100[ppm];
	x_sweep				=>	300[ppm];
	x_points_input     =>    512;
    x_points            =?    if x_points_input/x_sweep < 50 [ms] then x_points_input else 2;
	scans				=>	4;
	x_prescans			=>	0;
	mod_return			=>	1;
	include "acquisition_solid";
end acquisition;

pulse
	collect COMPLEX,OBS;
	include "pulse_solid";
	include "dec_solid";
	
CP_Setup         =? "#Setup CP#";

	irr_shape_cp		= "constant_cp";
     irr_shape_cp2		= "constant_cp2";
	irr_width_90		=>	irr90,										help "90deg pulse width for excitation pulse";
	irr_amp_prep		=>	100[%], 0[%]->100[%]:0.01[%],				help "amplitude of excitation pulse";

	obs_shape_cp		=>	"constant_cp", ("constant_cp", "RAMP_cp"),help "CP shape for obs channel";
     obs_shape_cp2		=>	"constant_cp2", ("constant_cp2", "RAMP_cp2"),help "CP shape for obs channel";
   
	contact_time		=>	2[ms], 10[us]->20[ms]:10[us],				help "contact time";
	irr_amp_cp			=>	70[%], 0[%]->90[%]:0.01[%],					help "CP amplitude of irr channel";
	irr_amp_cp2         => irr_amp_cp;
     obs_amp_cp			=>	70[%], 0[%]->90[%]:0.01[%],					help "CP amplitude of obs channel";
     obs_amp_cp2          =>  obs_amp_cp;
when
	obs_shape_cp = "ramp_cp" do
		obs_amp_grad	=>	10[%], -100[%]->100[%]:0.1[%],				help "obs CP sweep range (-obs_amp_grad/2->+obs_amp_grad)";
end when;
when
	obs_shape_cp2 = "ramp_cp2" do
		obs_amp_grad2	=>	-obs_amp_grad,				help "obs CP sweep range (-obs_amp_grad/2->+obs_amp_grad)";
end when;

    irr_noise			=>	"CW",("CW", "SPINAL64", "TPPM", "XiX"),	help "decoupling sequence";

	initial_wait		=	10.0[ms];

	irr_Setup			=? "#Setup Irradiation#";
	irr_domain			=>	"Proton",									help "decoupled nucleus";
	irr_offset			=>	5[ppm],										help "decoupler offset";
    tauNOE   => 0.5[s], help "transient NOE mixing time";
  
    num_cp_cycle => 2;
    obs_width_90   =>  3[us], help "90deg pulse width for X excitation pulse";
	obs_amp_pulse  => 100[%], 0[%]->100[%]:0.01[%], help "amplitude of X excitation pulse";
  	irr_amp_cwdec  => 80[%], 0[%]->90[%]:0.01[%], help "amplitude of CW decoupling pulse";


    recycle_Setup		=? "#Setup Recycle Times#";
	relaxation_delay	=>	5.0[s],										help "relaxation delay";
	repetition_time		=?	relaxation_delay + x_acq_time,				help"relaxation_delay+x_acq_time";

    atn_Setup           =? "#Experiment Attenuator Settings#";
	obs_atn				=>	xatn,										help "attenuator for obs";
	irr_atn				=>	irratn,										help "attenuator for irr";

	irr_phs_prep	=	{ 90, 270};
	irr_phs_cp		=	{ 0,0};
     irr_phs_cp2     =     {180,180};
	irr_phs_cwdec	=	{ 180,0 };
	irr_phs_dec	=	{ 0 };
	obs_phs_cp		= { 0,0,180,180,90,90,270,270};
     obs_phs_cp2     = { 180,180,0,0,270,270,90,90};
	irr_phs_flip   =  {90, 270};
	obs_phs_read  = {0,180,90,270};
	obs_phs_acq1  = {0,180,180,0,90,270,270, 90}; ---phase for CP
	obs_phs_acq2  = {0, 180, 90, 270}; -----phase for NOE
 
obs_phs_flip1 =  {270};
obs_phs_flip2 =  {90};
irr_phs_flip3 =  {270, 90};

	module_config		= "solid_sample continuous_fid";

begin
    initial_wait;
	relaxation_delay;
	  irr_width_90, (irr.gate, irr.phs.irr_phs_prep, irr.amp.irr_amp_prep, irr.atn.irr_atn);

  loop num_cp_cycle times
	contact_time, (irr.gate, irr.phs.irr_phs_cp, irr.shape.{irr_shape_cp,"irr"}, irr.atn.irr_atn,
				   obs.gate, obs.phs.obs_phs_cp, obs.shape.{obs_shape_cp,"obs"}, obs.atn.obs_atn);

    contact_time, (irr.gate, irr.phs.irr_phs_cp2, irr.shape.{irr_shape_cp2,"irr"}, irr.atn.irr_atn,
				   obs.gate, obs.phs.obs_phs_cp2, obs.shape.{obs_shape_cp2,"obs"}, obs.atn.obs_atn);

    contact_time, (irr.gate, irr.phs.irr_phs_cp2, irr.shape.{irr_shape_cp2,"irr"}, irr.atn.irr_atn,
				   obs.gate, obs.phs.obs_phs_cp2, obs.shape.{obs_shape_cp2,"obs"}, obs.atn.obs_atn);

    contact_time, (irr.gate, irr.phs.irr_phs_cp, irr.shape.{irr_shape_cp,"irr"}, irr.atn.irr_atn,
				   obs.gate, obs.phs.obs_phs_cp, obs.shape.{obs_shape_cp,"obs"}, obs.atn.obs_atn);

 end loop;
   on (irr.gate, irr.phs.irr_phs_cwdec, irr.amp.irr_amp_cwdec, irr.atn.irr_atn);
   acq( dead_time, delay, obs_phs_acq1 );
   off (irr.gate);

  irr_width_90, (irr.gate, irr.phs.irr_phs_flip, irr.amp.irr_amp_prep, irr.atn.irr_atn);
  tauNOE;
	obs_width_90, (obs.gate, obs.phs.obs_phs_read, obs.amp.obs_amp_pulse, obs.atn.obs_atn);

    on (irr.gate, irr.phs.irr_phs_dec, irr.amp.irr_amp_dec, irr.atn.irr_atn, irr.noise.irr_noise);
	acq( dead_time, delay, obs_phs_acq2 );
	off (irr.gate);

end pulse;