sgm = float(args['--sigma']) if sgm < 0.0: sgm = abs(sgm) * width specorder = args['--specorder'].split(',') if 'None' in specorder and not files[0].find('POSCAR') > -1: raise ValueError( 'ERROR: specorder must be specified, unless files are POSCAR format.' ) if sid == 0: raise ValueError('ERROR: sid should be specified and should not be 0.') files.sort(key=get_key, reverse=True) nsys0 = NAPSystem(fname=files[0], specorder=specorder) a, b, c = nsys0.get_lattice_angles() if abs(a-np.pi/2) > 180.0/np.pi or abs(b-np.pi/2) > 180.0/np.pi \ or abs(c-np.pi/2) > 180.0/np.pi: raise ValueError( 'ERROR: Currently only available for orthogonal lattice, a,b,c=', a, b, c) ndivs = get_num_division(nsys0, width) if np.dot(ndivs, ndivs) > 10000000: raise ValueError('ERROR: ndivs too large.', ndivs) else: print(' # of divisions = {0:d} {1:d} {2:d}'.format(*ndivs)) pdist = np.zeros(ndivs, dtype=float) for f in files: print(' Reading {0:s}...'.format(f)) nsys = NAPSystem(fname=f, specorder=specorder)
sid = int(args['--sid']) width = float(args['-w']) sgm = float(args['--sigma']) if sgm < 0.0: sgm = abs(sgm)*width specorder = args['--specorder'].split(',') if 'None' in specorder and not files[0].find('POSCAR') > -1: raise ValueError('ERROR: specorder must be specified, unless files are POSCAR format.') if sid == 0: raise ValueError('ERROR: sid should be specified and should not be 0.') files.sort(key=get_key,reverse=True) nsys0 = NAPSystem(fname=files[0],specorder=specorder) a,b,c = nsys0.get_lattice_angles() if abs(a-np.pi/2) > 180.0/np.pi or abs(b-np.pi/2) > 180.0/np.pi \ or abs(c-np.pi/2) > 180.0/np.pi: raise ValueError('ERROR: Currently only available for orthogonal lattice, a,b,c=',a,b,c) ndivs = get_num_division(nsys0,width) if np.dot(ndivs,ndivs) > 10000000: raise ValueError('ERROR: ndivs too large.',ndivs) else: print(' # of divisions = {0:d} {1:d} {2:d}'.format(*ndivs)) pdist = np.zeros(ndivs,dtype=float) for f in files: print(' Reading {0:s}...'.format(f)) nsys = NAPSystem(fname=f,specorder=specorder) pdist += get_prob_dist(ndivs,nsys,sid,sgm) pdist = normalize_pdist(pdist,nsys0,sid)
def reduce_cij(atoms0, cij0, eps=1.e-4): """ Reduce number of independent Cij according to the crystal system of original cell. It is not Cij=Cji. """ cij = cij0 symdata = spglib.get_symmetry_dataset(atoms0) nsys = NAPSystem(ase_atoms=atoms0) sgnum = symdata['number'] a, b, c = nsys.get_lattice_lengths() alpha, beta, gamma = nsys.get_lattice_angles() aeqb = abs(a - b) < eps * min(a, b) beqc = abs(b - c) < eps * min(b, c) ceqa = abs(c - a) < eps * min(c, a) aleqpi2 = abs(alpha - np.pi / 2) < eps * np.pi / 2 bteqpi2 = abs(beta - np.pi / 2) < eps * np.pi / 2 gmeqpi2 = abs(gamma - np.pi / 2) < eps * np.pi / 2 print('Spacegroup number = ', sgnum, ' ==> ', end='') if 0 < sgnum <= 2: # Triclinic print('Triclinic') pass elif sgnum <= 15: # Monoclinic print('Monoclinic') pass elif sgnum <= 74: # Orthorhombic print('Orthorhombic') pass elif sgnum <= 142: # Tetragonal print('Tetragonal') pass elif sgnum <= 194: # Hexagonal print('Hexagonal') print('Number of independent C_ij elements are reduced to 6.') print('C_66 should be 1/2(C_11-C_12) but this is not enforced now.') if not aleqpi2: c22 = (cij[1, 1] + cij[2, 2]) / 2 c13 = (cij[0, 1] + cij[0, 2]) / 2 c55 = (cij[4, 4] + cij[5, 5]) / 2 cij[1, 1] = cij[2, 2] = c22 cij[0, 1] = cij[0, 2] = c13 cij[4, 4] = cij[5, 5] = c55 elif not bteqpi2: c11 = (cij[0, 0] + cij[2, 2]) / 2 c12 = (cij[0, 1] + cij[1, 2]) / 2 c44 = (cij[3, 3] + cij[5, 5]) / 2 cij[0, 0] = cij[2, 2] = c11 cij[0, 1] = cij[1, 2] = c12 cij[3, 3] = cij[5, 5] = c44 elif not gmeqpi2: c11 = (cij[0, 0] + cij[1, 1]) / 2 c12 = (cij[0, 2] + cij[1, 2]) / 2 c44 = (cij[3, 3] + cij[4, 4]) / 2 cij[0, 0] = cij[1, 1] = c11 cij[0, 2] = cij[1, 2] = c12 cij[3, 3] = cij[4, 4] = c44 elif sgnum <= 230: # Cubic print('Cubic') print('Number of independent C_ij elements are reduced to 3.') c11 = (cij[0, 0] + cij[1, 1] + cij[2, 2]) / 3 c12 = (cij[0, 1] + cij[0, 2] + cij[1, 2]) / 3 c44 = (cij[3, 3] + cij[4, 4] + cij[5, 5]) / 3 cij[0, 0] = cij[1, 1] = cij[2, 2] = c11 cij[0, 1] = cij[0, 2] = cij[1, 2] = c12 cij[3, 3] = cij[4, 4] = cij[5, 5] = c44 else: raise ValueError('Invalid space group number, ', sgnum) # Just symmetrize Cij for i in range(6): for j in range(i, 6): cij[j, i] = cij[i, j] return cij
def reduce_cij(atoms0,cij0,eps=1.e-4): """ Reduce number of independent Cij according to the crystal system of original cell. It is not Cij=Cji. """ cij = cij0 symdata = spglib.get_symmetry_dataset(atoms0) napsys = NAPSystem(ase_atoms=atoms0) sgnum = symdata['number'] print('Spacegroup number = ',sgnum,' ==> ',end='') a,b,c = napsys.get_lattice_lengths() alpha,beta,gamma = napsys.get_lattice_angles() aeqb = abs(a-b) < eps*min(a,b) beqc = abs(b-c) < eps*min(b,c) ceqa = abs(c-a) < eps*min(c,a) aleqpi2 = abs(alpha-np.pi/2) < eps*np.pi/2 bteqpi2 = abs(beta -np.pi/2) < eps*np.pi/2 gmeqpi2 = abs(gamma-np.pi/2) < eps*np.pi/2 if 0 < sgnum <= 2: # Triclinic print('Triclinic') pass elif sgnum <= 15: # Monoclinic print('Monoclinic') pass elif sgnum <= 74: # Orthorhombic print('Orthorhombic') pass elif sgnum <= 142: # Tetragonal print('Tetragonal') pass elif sgnum <= 194: # Hexagonal print('Hexagonal') print('Number of independent C_ij elements are reduced to 6.') print('C_66 should be 1/2(C_11-C_12) but this is not enforced now.') if not aleqpi2: c22 = (cij[1,1] +cij[2,2])/2 c13 = (cij[0,1] +cij[0,2])/2 c55 = (cij[4,4] +cij[5,5])/2 cij[1,1] = cij[2,2] = c22 cij[0,1] = cij[0,2] = c13 cij[4,4] = cij[5,5] = c55 elif not bteqpi2: c11 = (cij[0,0] +cij[2,2])/2 c12 = (cij[0,1] +cij[1,2])/2 c44 = (cij[3,3] +cij[5,5])/2 cij[0,0] = cij[2,2] = c11 cij[0,1] = cij[1,2] = c12 cij[3,3] = cij[5,5] = c44 elif not gmeqpi2: c11 = (cij[0,0] +cij[1,1])/2 c12 = (cij[0,2] +cij[1,2])/2 c44 = (cij[3,3] +cij[4,4])/2 cij[0,0] = cij[1,1] = c11 cij[0,2] = cij[1,2] = c12 cij[3,3] = cij[4,4] = c44 elif sgnum <= 230: # Cubic print('Cubic') print('Number of independent C_ij elements are reduced to 3.') c11 = (cij[0,0] +cij[1,1] +cij[2,2])/3 c12 = (cij[0,1] +cij[0,2] +cij[1,2])/3 c44 = (cij[3,3] +cij[4,4] +cij[5,5])/3 cij[0,0] = cij[1,1] = cij[2,2] = c11 cij[0,1] = cij[0,2] = cij[1,2] = c12 cij[3,3] = cij[4,4] = cij[5,5] = c44 else: raise ValueError('Invalid space group number, ',sgnum) # Just symmetrize Cij for i in range(6): for j in range(i,6): cij[j,i] = cij[i,j] return cij