def csl_elem_div_thm_l2(t0, l_g2n_g2): """ The csl basis vectors are obtained from the diagonal matrix using the algorithm specified in doi:10.1107/S056773947601231X. There are two algorithms specified based on numerators or denominators of the T0 matrix. The denominators are used in this function. Parameters --------------- T0: numpy array The transformation matrix in G1n reference frame l_g2n_g2: numpy array The 'new' basis vectors of g2 lattice (g2n) in g2 reference frame Returns ------------ l_csl_g2: numpy array The CSL basis vectors in g2 reference frame """ t0 = np.array(t0) l2 = np.array(l_g2n_g2) if t0.shape[0] == 3: q1 = int_man.rat(np.array(t0[0, 0]), 1e-06)[1][0][0] q2 = int_man.rat(np.array(t0[1, 1]), 1e-06)[1][0][0] q3 = int_man.rat(np.array(t0[2, 2]), 1e-06)[1][0][0] l_csl_g2 = np.dot(l2, np.array([[q1, 0, 0], [0, q2, 0], [0, 0, q3]])) elif t0.shape[0] == 2: q1 = int_man.rat(np.array(t0[0, 0]), 1e-06)[1][0][0] q2 = int_man.rat(np.array(t0[1, 1]), 1e-06)[1][0][0] l_csl_g2 = np.dot(l2, np.array([[q1, 0, 0], [0, q2, 0]])) return l_csl_g2
def csl_elem_div_thm_l1(T0, l_g1n_g1): """ The csl basis vectors are obtained from the diagonal matrix using the algorithm specified in doi:10.1107/S056773947601231X. There are two algorithms specified based on numerators or denominators of the T0 matrix. The numerators are used in this function. Parameters --------------- T0: numpy array The transformation matrix in G1n reference frame l_g1n_g1: numpy array The 'new' basis vectors of g1 lattice (g1n) in g1 reference frame Returns ------------ l_csl_g1: numpy array The CSL basis vectors in g1 reference frame """ T0 = np.array(T0) L1 = np.array(l_g1n_g1) if T0.shape[0] == 3: p1 = int_man.rat(np.array(T0[0, 0]), 1e-06)[0][0][0] p2 = int_man.rat(np.array(T0[1, 1]), 1e-06)[0][0][0] p3 = int_man.rat(np.array(T0[2, 2]), 1e-06)[0][0][0] l_csl_g1 = np.dot(L1, np.array([[p1, 0, 0], [0, p2, 0], [0, 0, p3]])) elif T0.shape[0] == 2: p1 = int_man.rat(np.array(T0[0, 0]), 1e-06)[0][0][0] p2 = int_man.rat(np.array(T0[1, 1]), 1e-06)[0][0][0] l_csl_g1 = np.dot(L1, np.array([[p1, 0, 0], [0, p2, 0]])) return l_csl_g1
def sigma_calc(t_g1tog2_g1): """ Computes the sigma of the transformation matrix * if det(T) = det(T^{-1}) then sigma1 = sigma2 is returned * if det(T) \\neq det(T^{-1}) then max(sigma1, sigma2) is returned """ R = np.array(t_g1tog2_g1) R2 = np.linalg.det(R)*np.linalg.inv(R) n1, d1 = int_man.rat(R) n2, d2 = int_man.rat(R2) # ----------------------------- Sigma21 = int_man.lcm_array(d1[:]) # ----------------------------- Sigma22 = int_man.lcm_array(d2[:]) Sigma = np.array([Sigma21, Sigma22]).max() return Sigma
sig_type = 'specific' ca_rat = 3 lat_type = 'tP_ca' l1 = lat.Lattice(lat_type, ca_rat) elif test_case == 6: sig_type = 'common' lat_type = 'cI_Id' l1 = lat.Lattice(lat_type) sig_rots = {} sig_num = np.arange(1000) + 1 for i in sig_num: print i sig_rots[str(i)] = csl_util.csl_rotations(i, sig_type, l1) if sig_type == 'common': pkl_file = l1.elem_type + '_csl_' + sig_type + '_rotations' + '.pkl' jar = open(pkl_file, 'wb') pickle.dump(sig_rots, jar) jar.close() if sig_type == 'specific': lat_tau = l1.lat_params['a']**2/l1.lat_params['c']**2 [N, D] = int_man.rat(lat_tau) pkl_file = l1.elem_type + '_csl_' + sig_type + \ '_tau_'+str(N[0][0])+'_'+str(D[0][0])+'_rotations' + '.pkl' jar = open(pkl_file, 'wb') pickle.dump(sig_rots, jar) jar.close()
sig_type = 'specific' ca_rat = 3 lat_type = 'tP_ca' l1 = lat.Lattice(lat_type, ca_rat) elif test_case == 6: sig_type = 'common' lat_type = 'cP_Id' l1 = lat.Lattice(lat_type) sig_rots = {} sig_num = np.arange(100) + 1 for i in sig_num: print i sig_rots[str(i)] = csl_util.csl_rotations(i, sig_type, l1) if sig_type == 'common': pkl_file = l1.elem_type + '_csl_' + sig_type + '_rotations' + '.pkl' jar = open(pkl_file, 'wb') pickle.dump(sig_rots, jar) jar.close() if sig_type == 'specific': lat_tau = l1.lat_params['a']**2/l1.lat_params['c']**2 [N, D] = int_man.rat(lat_tau) pkl_file = l1.elem_type + '_csl_' + sig_type + \ '_tau_'+str(N[0][0])+'_'+str(D[0][0])+'_rotations' + '.pkl' jar = open(pkl_file, 'wb') pickle.dump(sig_rots, jar) jar.close()