def analysis(struct, symprec=1e-5): ensure_pyspg_is_imported() atoms = structure_to_spglib_atoms(struct) val = spglib.get_spacegroup(atoms) print("Spacegroup is:", val) val = spglib.refine_cell(atoms, symprec=symprec) print("Primitive", val)
def primitive(struct, symprec=1e-5): ensure_pyspg_is_imported() atoms = structure_to_spglib_atoms(struct) prim = spglib.refine_cell(atoms, symprec=symprec) sg = spglib.get_spacegroup(atoms) struct = httk.iface.spglib_if.spglib_out_to_struct(prim) struct.comment = "Spacegroup: " + sg return struct
def writeCIF (cell, prec, basename): # Find spacegroup name and number sg = spglib.get_spacegroup(cell, symprec=prec) sg, sgid = sg.split(" (") sgid = sgid.replace(")", "") # Find detailed info about the refined cell lattice, scaled_positions, numbers = spglib.refine_cell (cell, prec) a, b, c, alpha, beta, gamma = cellParameters (lattice) f = open((basename + " " + sg + ".cif").replace("/","|"), "w") f.write ("# Symmetrized structure with precision = %g\n" % prec) f.write (("data_" + basename + sg + "\n").replace(" ", "_")) f.write ("_cell_length_a %.7g\n" % a) f.write ("_cell_length_b %.7g\n" % b) f.write ("_cell_length_c %.7g\n" % c) f.write ("_cell_angle_alpha %.7g\n" % alpha) f.write ("_cell_angle_beta %.7g\n" % beta) f.write ("_cell_angle_gamma %.7g\n" % gamma) f.write ("_symmetry_space_group_name_H-M '" + sg + "'\n") f.write ("_symmetry_Int_Tables_number " + str(sgid) + "\n") # Write out atomic positions f.write (""" loop_ _atom_site_label _atom_site_type_symbol _atom_site_occupancy _atom_site_fract_x _atom_site_fract_y _atom_site_fract_z """) for pos, at in zip(scaled_positions, numbers): sym = element_symbols[at] f.write ("%s %s 1.0 %.7f %.7f %.7f\n" % (sym, sym, pos[0], pos[1], pos[2])) f.close()
print " %d -> %d" % ( i+1, x+1 ) print print "[get_symmetry_dataset] ['rotations'], ['translations']" print " Symmetry operations of Rutile unitcell are:" for i, (rot,trans) in enumerate( zip( dataset['rotations'], dataset['translations'] ) ): print " --------------- %4d ---------------" % (i+1) print " rotation:" for x in rot: print " [%2d %2d %2d]" % (x[0], x[1], x[2]) print " translation:" print " (%8.5f %8.5f %8.5f)" % (trans[0], trans[1], trans[2]) print print "[refine_cell]" print " Refine distorted rutile structure" lattice, positions, numbers = spglib.refine_cell(rutile_dist, symprec=1e-1) show_cell(lattice, positions, numbers) print print "[standardize_cell]" print " Standardize distorted rutile structure:" print " (to_primitive=0 and no_idealize=0)" lattice, positions, numbers = spglib.standardize_cell(rutile_dist, to_primitive=0, no_idealize=0, symprec=1e-1) show_cell(lattice, positions, numbers) print print "[standardize_cell]" print " Standardize distorted rutile structure:"