def write_input(self, atoms, properties=None, system_changes=None): FileIOCalculator.write_input(self, atoms, properties, system_changes) struct = crys.atoms2struct(atoms) self.cell = common.str_arr(struct.cell) self.kpoints = pwscf.kpoints_str_pwin(kpts2mp(atoms, self.kpts)) if isinstance(self.pp, types.StringType): pseudos = ["%s.%s" %(sym, self.pp) for sym in struct.symbols_unique] else: assert len(self.pp) == struct.ntypat pseudos = [] for sym in struct.symbols_unique: for ppi in self.pp: if ppi.startswith(sym): pseudos.append(ppi) break assert len(pseudos) == struct.ntypat self.atspec = pwscf.atspec_str(symbols=struct.symbols_unique, masses=struct.mass_unique, pseudos=pseudos) self.atpos = pwscf.atpos_str(symbols=struct.symbols, coords=struct.coords_frac) self.natoms = struct.natoms self.ntyp = struct.ntypat if self.backup: for fn in [self.infile, self.outfile]: if os.path.exists(fn): common.backup(fn) common.file_write(self.infile, self.fill_infile_templ())
def write_input(self, atoms, properties=None, system_changes=None): FileIOCalculator.write_input(self, atoms, properties, system_changes) struct = crys.atoms2struct(atoms) self.cell = common.str_arr(struct.cell) self.kpoints = pwscf.kpoints_str_pwin(kpts2mp(atoms, self.kpts)) if isinstance(self.pp, bytes): pseudos = [ "%s.%s" % (sym, self.pp) for sym in struct.symbols_unique ] else: assert len(self.pp) == struct.ntypat pseudos = [] for sym in struct.symbols_unique: for ppi in self.pp: if ppi.startswith(sym): pseudos.append(ppi) break assert len(pseudos) == struct.ntypat self.atspec = pwscf.atspec_str(symbols=struct.symbols_unique, masses=struct.mass_unique, pseudos=pseudos) self.atpos = pwscf.atpos_str(symbols=struct.symbols, coords=struct.coords_frac) self.natoms = struct.natoms self.ntyp = struct.ntypat if self.backup: for fn in [self.infile, self.outfile]: if os.path.exists(fn): common.backup(fn) common.file_write(self.infile, self.fill_infile_templ())
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 loop_ _symmetry_equiv_pos_as_xyz x,y,z Only a,b,c,alpha,beta,gamma and the fractional coords as found in the file are used.
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 loop_ _symmetry_equiv_pos_as_xyz x,y,z Only a,b,c,alpha,beta,gamma and the fractional coords as found in the file are used.