def test_angle(): # CaCl struct, the supercell will have 0 and 180 degrees -> check corner # cases st = io.read_cif('files/angle/rs.cif') st = crys.scell(st, (2,1,1)) nang = st.natoms*(st.natoms-1)*(st.natoms-2) mask_val = 999.0 for deg in [True,False]: for pbc in [True,False]: agf = crys.angles(st, pbc=pbc, mask_val=mask_val) agpy, aipy = angles(st, pbc=pbc, mask_val=mask_val) eps = np.finfo(float).eps*5 assert np.allclose(agf, agpy) assert aipy.shape[0] == nang assert len((agf != mask_val).nonzero()[0]) == nang angleidx = np.array(zip(*(agf != mask_val).nonzero())) assert (angleidx == aipy).all() assert not np.isnan(agpy).any(), "python angle nan" assert not np.isnan(agf).any(), "fortran angle nan" # do we have 0 and 180 degrees? assert (agf < eps).any(), "no zero degree cases" assert (agf - 180.0 < eps).any(), "no 180 degree cases" assert (agf >= 0.0).all(), "negative angles"
def test_angle(): # CaCl struct, the supercell will have 0 and 180 degrees -> check corner # cases tools.skip_if_pkg_missing('CifFile') st = io.read_cif('files/angle/rs.cif') st = crys.scell(st, (2, 1, 1)) nang = st.natoms * (st.natoms - 1) * (st.natoms - 2) mask_val = 999.0 for deg in [True, False]: for pbc in [True, False]: agf = crys.angles(st, pbc=pbc, mask_val=mask_val) agpy, aipy = angles(st, pbc=pbc, mask_val=mask_val) eps = np.finfo(float).eps * 5 assert np.allclose(agf, agpy) assert aipy.shape[0] == nang assert len((agf != mask_val).nonzero()[0]) == nang angleidx = np.array(list(zip(*(agf != mask_val).nonzero()))) assert (angleidx == aipy).all() assert not np.isnan(agpy).any(), "python angle nan" assert not np.isnan(agf).any(), "fortran angle nan" # do we have 0 and 180 degrees? assert (agf < eps).any(), "no zero degree cases" assert (agf - 180.0 < eps).any(), "no 180 degree cases" assert (agf >= 0.0).all(), "negative angles"
import sys import numpy as np from pwtools import crys, atomic_data, pwscf, io from pwtools.common import str_arr, seq2str from pwtools.constants import Bohr, Angstrom def indent(txt, num=4): """Indent text block by `num` white spaces.""" space = " "*num return '\n'.join(space + line for line in txt.splitlines()) # All lengths in Bohr struct = io.read_cif(sys.argv[1], units={'length': Angstrom/Bohr}) rcell = crys.recip_cell(struct.cell) norms = np.sqrt((rcell**2.0).sum(axis=1)) bar = '-'*78 mass_unique = [atomic_data.pt[sym]['mass'] for sym in struct.symbols_unique] atspec = pwscf.atspec_str(struct.symbols_unique, mass_unique, [sym + '.UPF' for sym in struct.symbols_unique]) celldm = crys.cc2celldm(struct.cryst_const) atpos_frac = pwscf.atpos_str(struct.symbols, struct.coords_frac) print("""\ Notes ----- The .cif file is assumed to contain NO symmetry information: _symmetry_space_group_name_H-M 'P 1'
#!/usr/bin/env python # # cif2sgroup.py # # Extract information from a .cif file and print an input file for WIEN2k's # "sgroup" symmetry analysis tool. Note that the Cif reader assumes P1 # symmetry, i.e. symmetry information in the cif file is ignored. Use # ase.io.read(), which seems to parse symmetry information. # # usage:: # $ cif2sgroup.py foo.cif > foo.sgroup.in # # Find primitive cell # $ sgroup -prim [-set-TOL=1e-4] foo.sgroup.in # # See ``sgroup -help`` for more options. # # Notes # ----- # The unit of length of a,b,c is not important (Angstrom, Bohr,...). import sys from pwtools import io fn = sys.argv[1] struct = io.read_cif(fn) print io.wien_sgroup_input(struct, lat_symbol='P')
import sys import numpy as np from pwtools import crys, atomic_data, pwscf, io from pwtools.common import str_arr, seq2str from pwtools.constants import Bohr, Angstrom def indent(txt, num=4): """Indent text block by `num` white spaces.""" space = " " * num return '\n'.join(space + line for line in txt.splitlines()) # All lengths in Bohr struct = io.read_cif(sys.argv[1], units={'length': Angstrom / Bohr}) rcell = crys.recip_cell(struct.cell) norms = np.sqrt((rcell**2.0).sum(axis=1)) bar = '-' * 78 mass_unique = [atomic_data.pt[sym]['mass'] for sym in struct.symbols_unique] atspec = pwscf.atspec_str(struct.symbols_unique, mass_unique, [sym + '.UPF' for sym in struct.symbols_unique]) celldm = crys.cc2celldm(struct.cryst_const) atpos_frac = pwscf.atpos_str(struct.symbols, struct.coords_frac) print("""\ Notes ----- The .cif file is assumed to contain NO symmetry information: _symmetry_space_group_name_H-M 'P 1' _symmetry_Int_Tables_number 1
#!/usr/bin/env python3 # # cif2sgroup.py # # Extract information from a .cif file and print an input file for WIEN2k's # "sgroup" symmetry analysis tool. Note that the Cif reader assumes P1 # symmetry, i.e. symmetry information in the cif file is ignored. Use # ase.io.read(), which seems to parse symmetry information. # # usage:: # $ cif2sgroup.py foo.cif > foo.sgroup.in # # Find primitive cell # $ sgroup -prim [-set-TOL=1e-4] foo.sgroup.in # # See ``sgroup -help`` for more options. # # Notes # ----- # The unit of length of a,b,c is not important (Angstrom, Bohr,...). import sys from pwtools import io fn = sys.argv[1] struct = io.read_cif(fn) print(io.wien_sgroup_input(struct, lat_symbol='P'))