-------------------------------------------------------------------------------
--                                                                           --
--                          Experiment Source Code                           --
--              Delta NMR Experiment & Machine Control Interface             --
--                                                                           --
--                     Copyright (c) 2005 JEOL Ltd                           --
--                            All Rights Reserved                            --
--                                                                           --
-------------------------------------------------------------------------------
-- HELP.eng: HETCOR with pmlg decoupling
-- Category: solids, 2D, heteronuclear correlation

header
    filename    => "hetcor_cp-noe-2D";
    sample_id   => "";
    comment     => "HETCOR with pmlg decoupling";
    process     =  "2d_solid_scale.list";
    include "header_solid";
end header;

instrument
    include "instrument_solid";
end instrument;

acquisition
    x_domain    => "Carbon13";
    x_offset    => 100[ppm];
    x_sweep     => 350[ppm];
    x_points_input     =>    512;
    x_points            =?    if x_points_input/x_sweep < 50 [ms] then x_points_input else 2;

    scans       => 8;
    x_prescans  => 0;
    mod_return  => 1;

    y_domain    => "Proton";
    y_offset    => 14[ppm];


    include "acquisition_solid";
end acquisition;

pulse
    collect COMPLEX,OBS COMPLEX,IRR;
    initial_wait            =  10.0[ms];
    
    tauNOE                  => 0.5[s], help "NOE mixing time";
    irr_domain              =  y_domain, help "decoupled nucleus";
    irr_offset              =  y_offset, help "decoupler offset";

    irr_width_90            => irr90, help "90deg pulse width for irr_amp_pulse";
    irr_width_180           => irr_width_90*2; 
    irr_amp_pulse           => 100[%], 0[%]->100[%]:0.01[%], help "set ampliper for irr pulse";
    irr_amp_cwdec         => 60[%], 0[%]->100[%] : 0.01[%], help "amplitude of decoupling";

    obs_width_90            => x90, help "90deg pulse width for obs_amp_pulse";
    obs_width_180           => x90*2, help "180deg pulse width for obs_amp_pulse";
    obs_amp_pulse           => 100[%], 0[%]->100[%]:0.01[%], help "set ampliper for X pulse";

    irr_width_lg90          => irr90, help "90deg pulse width for lg_amp";
    irr_width_lg            =  irr_width_lg90 * 4 * SQRT(2) / SQRT(3);
    irr_amp_lg              => 100[%], 0[%]->100[%]:0.01[%], help "set ampliper for PMLG";

    PMLGn                   =? 3, help "PMLGn pulse divided into 3 steps";
    irr_width_lg_element    => irr_width_lg / PMLGn;
    irr_width_lg_e_round    =? round(irr_width_lg_element / 5[ns]) * 5[ns];

    bef_trig_1              =  2000[ns];
    bef_trig_2              =  1500[ns];
    t_trig                  =  1400[ns];
    aft_trig                =  1200[ns];
    t_w                     =  bef_trig_1 + bef_trig_2 + t_trig + aft_trig;

y_Setup              =? "#Setup Y Dimension#";
    Scale_factor_y          => 0.47, help "Theoretical Scaling Factor";
    Scale_y_sweep           =  1 / Scale_factor_y;
   
    lg_loop                 => 2, 0->100:1, help "loop number for PMLG";
    cycle_time_y            =  (irr_width_lg_e_round * 2 * PMLGn + t_w) * 2 * lg_loop;
    y_sweep                 =  1/cycle_time_y;

    get_freq = "pulse_service::get_freq_value";
    scaled_y_sweep       =? y_sweep / scale_factor_y * (1[Mppm] / _get_freq( y_domain ));

    y_points                => 64;
    acq_time_y              =? y_points * cycle_time_y;

CP_Setup             =? "#Setup CP#";

    include "cp_solid";

Dec_Setup            =? "#Setup Decoupling#";

    irr_dec_offset          => 5[ppm], help "offset for decoupling";

    include "dec_solid";
    tri_domain       = irr_domain;
    tri_offset       = irr_dec_offset;

Others_Setup     =? "#Setup Others#";

    relaxation_delay => 5[s], help"inter-pulse delay";
    repetition_time  =? relaxation_delay + x_acq_time,help"relaxation_delay+x_acq_time";
    z_filter  =>  1[ms];
    obs_atn                 => xatn, help "attenuator of x_pulse";
    irr_atn                 => irratn, help "set attenuator for irr pulse";

    irr_phs_prep    =  {{ 0, 0,90,90,180,180,270,270},{90,90,180,180,270,270,0,0}}.ystep(180%2);
    irr_phs_lg      =  { 0};
    irr_phs_cp      =  {270,90,0,180,90,270,180,0};
    obs_phs_cp      =  {270,270,180,180,90,90,0,0};
    obs_phs_acq1    =  {180,0,90,270,0,180,270,90}.ystep(180%2);
obs_phs_flip   =  {0};
obs_phs_store    =  {180};

    irr_phs_cwdec   =  {270,90,0,180,90,270,180,0};
    irr_phs_dec     =  {0};
    obs_phs_dec     =  {8(0)};
    irr_phs_flip    =  {0,180,90,270,180,0,270,90};
    obs_phs_read    =  {0,180,90,270,180,0,270,90};
    obs_phs_acq2    = {0,0,90,90,180,180,270,270}.ystep(180%2);

    include "pulse_solid";
    module_config = "solid_sample continuous_fid";

begin
    initial_wait;
    relaxation_delay;

    irr_width_90, (tri.gate, tri.phs.irr_phs_prep, tri.amp.irr_amp_pulse, tri.atn.irr_atn);

    parallel
        justify center
            loop ystep {0->512:1} times
                loop lg_loop times
                    t_w;
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+ 34.6, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+103.9, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+173.2, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+353.2, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+283.9, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+214.6, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    t_w;
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+ 34.6+180, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+103.9+180, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+173.2+180, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+353.2+180, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+283.9+180, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                    irr_width_lg_e_round, (irr.gate, irr.phs.irr_phs_lg+214.6+180, irr.amp.irr_amp_lg, irr.atn.irr_atn);
                end loop;
            end loop;
        justify center
            obs_width_180, (OBS.GATE, OBS.PHS.obs_phs_dec, OBS.AMP.obs_amp_pulse, OBS.ATN.obs_atn);
    end parallel;

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

    on (tri.gate, tri.phs.irr_phs_cwdec, tri.amp.irr_amp_cwdec, tri.atn.irr_atn);
    acq( dead_time, delay, obs_phs_acq1 );
    off (tri.gate);
   irr_width_90, (tri.gate, tri.phs.irr_phs_flip, tri.amp.irr_amp_pulse, tri.atn.irr_atn);
  obs_width_90, (OBS.GATE, OBS.PHS.obs_phs_flip, OBS.AMP.obs_amp_pulse, OBS.ATN.obs_atn);
  z_filter;
  obs_width_90, (OBS.GATE, OBS.PHS.obs_phs_store, OBS.AMP.obs_amp_pulse, OBS.ATN.obs_atn);

   tauNOE;
   obs_width_90, (OBS.GATE, OBS.PHS.obs_phs_read, OBS.AMP.obs_amp_pulse, OBS.ATN.obs_atn);

    on (tri.gate, tri.phs.irr_phs_dec,tri.amp.irr_amp_dec, tri.atn.irr_atn,tri.inline_noise.irr_noise);
    acq( dead_time, delay, obs_phs_acq2 );
    off (tri.gate);
end pulse;