def press(spin_system, te1=34, te2=34): #---------------------------------------------------------------------- # This is an example PyGAMMA pulse sequence for use in Vespa-Simulation # # A timing diagram for this pulse sequence can be found in the Appendix # of the Simulation User Manual. #---------------------------------------------------------------------- # the isotope string used to sort/select the metabolites of interest is passed # in the sim_desc object so the user can tailor other object within their # code to be nuclei specific, such as the observe operator or pulses obs_iso = '1H' # extract the dynamically changing variable from loop 1 and 2 for 'te1' and # 'te2', divide by 1000.0 because the GUI states that values are entered in # [ms], but PyGAMMA wants [sec] te1 = te1 / 1000.0 te2 = te2 / 1000.0 # set up steady state and observation variables H = pg.Hcs(spin_system) + pg.HJ(spin_system) D = pg.Fm(spin_system, obs_iso) ac = pg.acquire1D(pg.gen_op(D), H, 0.000001) ACQ = ac sigma0 = pg.sigma_eq(spin_system) # excite, propagate, refocus and acquire the data sigma1 = pg.Iypuls(spin_system, sigma0, obs_iso, 90.0) Udelay = pg.prop(H, te1 * 0.5) sigma0 = pg.evolve(sigma1, Udelay) sigma1 = pg.Iypuls(spin_system, sigma0, obs_iso, 180.0) Udelay = pg.prop(H, (te1 + te2) * 0.5) sigma0 = pg.evolve(sigma1, Udelay) sigma1 = pg.Iypuls(spin_system, sigma0, obs_iso, 180.0) Udelay = pg.prop(H, te2 * 0.5) sigma0 = pg.evolve(sigma1, Udelay) # instantiate and save transition table of simulation results # note. this step copies the TTable1D result from the ACQ into # a TTable1D object in the sim_desc object. Thus, when # we return from this function and the ACQ variable gets # garbage collected, our copy of the results in not affected return pg.TTable1D(ACQ.table(sigma0))
def apply_crushed_180_rf(sys, sigma, dephase_ang=[0.0, 90.0, 180.0, 270.0], type='crusher'): sigma_mult = [] for i in dephase_ang: sigma_mult.append(pg.gen_op(sigma)) for i, angle in enumerate(dephase_ang): riz = pg.gen_op(pg.Rz(sys, angle)) sigma_mult[i] = pg.evolve(sigma_mult[i], riz) sigma_mult[i] = pg.Iypuls(sys, sigma_mult[i], '1H', 180.0) if type == 'bipolar': riz = pg.gen_op(pg.Rz(sys, -1 * angle)) sigma_mult[i] = pg.evolve(sigma_mult[i], riz) sigma_mult[i] *= 0.25 if i == 0: sigma_res = pg.gen_op(sigma_mult[i]) else: sigma_res += sigma_mult[i] return sigma_res
pwf = pg.PulWaveform(pulse, ptime, "TestPulse") pulc = pg.PulComposite(pwf, sys, "1H") H = pg.Hcs(sys) + pg.HJ(sys) D = pg.Fm(sys) Udelay1 = pg.prop(H, t1) Udelay2 = pg.prop(H, t2) # Neet to effectively typecast D as a gen_op. ac = pg.acquire1D(pg.gen_op(D), H, 0.001) ACQ = ac sigma0 = pg.sigma_eq(sys) sigma1 = pg.Iypuls(sys, sigma0, 90.0) #Apply a 90y pulse sigma0 = pg.evolve(sigma1, Udelay1) #Evolve through T1 Ureal180 = pulc.GetUsum(-1) #Get the propagator for steps of 180 sigma1 = Ureal180.evolve(sigma0) #Evolve through pulse sigma0 = pg.evolve(sigma1, Udelay2) #Evolve through T2 mx = ACQ.table(sigma0) #Transitions table (no lb) mx.dbwrite(outfile, out_name, specfreq, sys.spins(), 0, header)
def steam(spin_system, te=20, tm=10): # ------------------------------------------------------------------------ # This is an example PyGAMMA pulse sequence for use in Vespa-Simulation # # A timing diagram for this pulse sequence can be found in the Appendix # of the Simulation User Manual. # ------------------------------------------------------------------------ # the isotope string used to sort/select the metabolites of interest is passed # in the sim_desc object so the user can tailor other object within their # code to be nuclei specific, such as the observe operator or pulses obs_iso = '1H' # extract the dynamically changing variable from loops 1 and 2 for 'te' # and 'tm', divide by 1000.0 because the GUI states that values are # entered in [ms], but PyGAMMA wants [sec] te = te / 1000.0 tm = tm / 1000.0 # set up steady state and observation variables H = pg.Hcs(spin_system) + pg.HJ(spin_system) D = pg.Fm(spin_system, obs_iso) ac = pg.acquire1D(pg.gen_op(D), H, 0.000001) ACQ = ac # excite, propagate, refocus and acquire the data # # for the case of STEAM, we need to simulate crusher gradients around the # second and third 90 pulses. We do this by creating 4 copies of the # operator matrix at that point, rotate respectively by 0, 90, 180 and 270 # degrees to each other, apply the 90 pulses and TM period, and then # add the four back into one normalized matrix. dephase_ang = [0.0, 90.0, 180.0, 270.0] Udelay1 = pg.prop(H, te * 0.5) Udelay2 = pg.prop(H, tm) sigma0 = pg.sigma_eq(spin_system) # first 90 pulse, excite spins sigma0 = pg.Iypuls(spin_system, sigma0, obs_iso, 90.0) # nutate TE/2 sigma0 = pg.evolve(sigma0, Udelay1) # Now we need to create the effect of crushers around the 2nd and 3rd # 90 pulses. This is done by creating 4 copies of spin state and repeating # the rest of the sequence for four different rotations around z-axis sigma_mult = [] for i in dephase_ang: sigma_mult.append(pg.gen_op(sigma0)) for i, angle in enumerate(dephase_ang): # calculate and apply rotation around z-axis riz = pg.gen_op(pg.Rz(spin_system, angle)) sigma_mult[i] = pg.evolve(sigma_mult[i], riz) # second 90 pulse sigma_mult[i] = pg.Ixpuls(spin_system, sigma_mult[i], obs_iso, 90.0) # this function removes all coherences still in transverse plane # this removes all stimulated echos from first and second 90 pulse pg.zero_mqc(spin_system, sigma_mult[i], 0, -1) # third 90 pulse sigma_mult[i] = pg.Ixpuls(spin_system, sigma_mult[i], obs_iso, 90.0) # undo rotation around z-axis sigma_mult[i] = pg.evolve(sigma_mult[i], riz) # scale results based on the number of phase angles sigma_mult[i] *= 1.0 / float(len(dephase_ang)) # sum up each rotated/unrotated results if i == 0: sigma_res = pg.gen_op(sigma_mult[i]) else: sigma_res += sigma_mult[i] # last TE/2 nutation sigma0 = pg.evolve(sigma_res, Udelay1) # instantiate and save transition table of simulation results # note. this step copies the TTable1D result from the ACQ into # a TTable1D object in the sim_desc object. Thus, when # we return from this function and the ACQ variable gets # garbage collected, our copy of the results in not affected return pg.TTable1D(ACQ.table(sigma0))
'car': 0, 'size': t2pts, 'label': '1H', 'encoding': 'direct', 'time': False, 'freq': True } } fid = pg.row_vector(t2pts) #block_1D tmp(t2pts); // 1D-data block storage H = pg.Hcs(sys)+ pg.HJw(sys) # // Hamiltonian, weak coupling detect = pg.gen_op(pg.Fp(sys)) # // F+ for detection operator sigma0 = pg.sigma_eq(sys) # // equilibrium density matrix sigma1 = pg.Iypuls(sys, sigma0, 90) pg.FID(sigma1,detect,H,dt2,t2pts,fid) pg.exponential_multiply(fid,-5) spec = fid.FFT() npspec = spec.toNParray() uc0 = ng.fileiobase.unit_conversion(udic[0]['size'], udic[0]['complex'], udic[0]['sw'], udic[0]['obs'], udic[0]['car']) ################################################################################## # Plot 1D spectrum
header = (s1, s2) sys = pg.sys_dynamic() sys.read(infile) specfreq = sys.Omega() mx = pg.TTable1D() H = pg.Ho(sys) detect = pg.Fm(sys) sigma0 = pg.sigma_eq(sys) sigmap = pg.Iypuls(sys, sigma0, 90.) L = pg.Hsuper(H) L *= pg.complex(0,1) L += pg.Kex(sys, H.get_basis()); ACQ1 = pg.acquire1D(pg.gen_op(detect), L) mx = ACQ1.table(sigmap); #mx.dbwrite_old(outfile, "test_lines", -10, 10, specfreq, .1, 0, header) mx.dbwrite(outfile, runname, specfreq, sys.spins(), 0, header)