def gen_signal(atoms, pol_direction, k=2, nrep=1): ttime = 20 steps = 100 tlist = np.linspace(0, ttime * 1e-6, steps) NS = MuonNuclearInteraction(atoms) NS.translate_rotate_sample_vec(pol_direction) print("Computing signal...", end='', flush=True) signal = np.zeros_like(tlist) # Do we need more random realizations? Celio used 4 for a 8192 dim. H space. for i in range(nrep): signal += NS.celio(tlist, k=k) signal /= nrep print('done!') del NS return signal
r = 1.17 * angtom atoms = [{ 'Position': np.array([0., 0., 0.]), 'Label': 'F' }, { 'Position': np.array([0., 0., r]), 'Label': 'mu' }, { 'Position': np.array([0., 0., 2 * r]), 'Label': 'F' }] # Time values, in seconds tlist = np.linspace(0, 10e-6, 100) # Define main class NS = MuonNuclearInteraction(atoms) # cutoff the dipolar interaction in order to avoid F-F term, # Rotate sample such that axis z used to define the atomic positions # is aligned with quantization axis which also happens to be z. # Basically the next call will do nothing NS.translate_rotate_sample_vec([0, 0, 1]) # cutoff the dipolar interaction in order to avoid F-F term signal_FmuF = NS.polarization(tlist, cutoff=1.2 * angtom) NS = MuonNuclearInteraction(atoms, log_level='info') NS.translate_rotate_sample_vec([0, 1, 0]) signal_FmuF += NS.polarization(tlist, cutoff=1.2 * angtom) NS = MuonNuclearInteraction(atoms, log_level='info') NS.translate_rotate_sample_vec([1, 0, 0])
]) #This is the Celio method for the polarization function with positive EFG. print("Computing signal for positive EFGs...", end='', flush=True) signal_positive_EFG = np.zeros( [len(LongitudinalFields), steps]) # Define the polarization signal with positive EFGs. for i, B in enumerate(LongitudinalFields): # Align the external field along z i.e. parallel to the muon spin. B_pos = B * np.array([0., 0., 1.]) NS_positive = MuonNuclearInteraction(atoms, external_field=B_pos, log_level='warn') signal_positive_EFG[i] = NS_positive.celio(tlist, k=3) del NS_positive print('done!') #This is the Celio method for the polarization function with negative EFG. print("And now for negative EFG...", end='', flush=True) # Align the external field along z i.e. parallel to the muon spin. B_neg = LongitudinalFields[2] * np.array([0., 0., 1.]) # change sign
#| ## Polarization function #| #| The muon polarization is obtained with the method introduced by Celio. steps = 200 tlist = np.linspace(0, 16e-6, steps) signals = np.zeros([6, steps], dtype=np.float) # import matplotlib as mpl; mpl.style.use(['bmh', 'paper', 'paper_twocol']) LongitudinalFields = (0.0, 0.001, 0.003, 0.007, 0.008, 0.01) for idx, Bmod in enumerate(LongitudinalFields): # Put field along muon polarization, that is always z B = Bmod * np.array([0, 0., 1.]) NS = MuonNuclearInteraction(atoms, external_field=B, log_level='info') # rotate the sample such that the muon spin is aligned with # the 111 direction (and, just for convenience, the muon position is # set to (0,0,0) ) NS.translate_rotate_sample_vec(np.array([1., 1., 1.])) print("Computing signal 4 times with LF {} T...".format(Bmod), end='', flush=True) signal_Cu = NS.celio(tlist, k=2) for i in range(3): print('{}...'.format(i + 1), end='', flush=True) signal_Cu += NS.celio(tlist, k=2) print('done!') signal_Cu /= float(i + 1 + 1)
# Computation is long and when COMPUTE==False stored values are used. if COMPUTE: print("Computing signal for positive EFGs...", end='', flush=True) signal = np.zeros((fields, axis, steps)) for i in range(fields): #| Align the magnetic fields along x. B = TF[i] * B_dir # do not rotate aanything yet R = np.eye(3) rpos = np.dot(R, pos.T).T NS = MuonNuclearInteraction(gen_atoms(rpos), external_field=B, log_level='info') signal[i, 0, :] = NS.celio(tlist, k=1) + NS.celio(tlist, k=1) del NS # rotate 45 deg with axis=z to get [110] along B direction, which is x R = rotation_matrix([0, 0, 1], np.pi / 4) rpos = np.dot(R, rpos.T).T NS = MuonNuclearInteraction(gen_atoms(rpos), external_field=B, log_level='info') signal[i, 1, :] = NS.celio(tlist, k=1) + NS.celio(tlist, k=1) del NS # rotate 45 deg again, but this time with axis y. R = rotation_matrix([0, 1, 0], np.pi / 4)
# Polarization function The muon polarization is obtained with the method introduced by Celio. """ steps = 100 tlist = np.linspace(0, 16e-6, steps) signals = np.zeros([6, steps], dtype=np.float) #LongitudinalFields = (0.0, 0.001, 0.003, 0.007, 0.008, 0.01) LongitudinalFields = (0.0, 0.0) for idx, Bmod in enumerate(LongitudinalFields): # Put field along muon polarization, that is always z B = Bmod * np.array([0, 0., 1.]) NS = MuonNuclearInteraction(atoms, external_field=B, log_level='info') # rotate the sumple such that the muon spin is aligned with # the 111 direction (and, just for convenience, the muon position is # set to (0,0,0) ) NS.translate_rotate_sample_vec(np.array([1., 1., 1.])) print("Computing signal 5 times with LF {} T...".format(Bmod), end='', flush=True) signal_Cu = NS.celio(tlist, k=6) for i in range(4): print('{}...'.format(i + 1), end='', flush=True) signal_Cu += NS.celio(tlist, k=6) print('done!') signal_Cu /= float(i + 1 + 1)