예제 #1
0
def test_atpos_str():
    assert pwscf.atpos_str(['X'],
                           np.array([[0.1, 1, 1]]),
                           fmt='%g',
                           delim='_',
                           eps=0.0) == 'X_0.1_1_1'
    assert pwscf.atpos_str(['X'],
                           np.array([[0.1, 1, 1]]),
                           fmt='%g',
                           delim='_',
                           eps=0.2) == 'X_0_1_1'
예제 #2
0
 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())
예제 #3
0
    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())
예제 #4
0
파일: 10input.py 프로젝트: elcorto/pwtools
templates = [batch.FileTemplate(basename='pw.in')]

# rs-AlN
st = crys.Structure(coords_frac=np.array([[0.0]*3, [0.5]*3]),
                    symbols=['Al','N'],
                    cryst_const=np.array([2.76]*3 + [60]*3))

params_lst = []
for ecutwfc in np.linspace(30,100,8):
    params_lst.append([sql.SQLEntry(key='ecutwfc', sqlval=ecutwfc),
                       sql.SQLEntry(key='ecutrho', sqlval=4.0*ecutwfc),
                       sql.SQLEntry(key='cell', sqlval=common.str_arr(st.cell)),
                       sql.SQLEntry(key='natoms', sqlval=st.natoms),
                       sql.SQLEntry(key='atpos',
                                    sqlval=pwscf.atpos_str(st.symbols,
                                                           st.coords_frac)),
                      ])

calc = batch.ParameterStudy(machines=theo,
                            templates=templates,
                            params_lst=params_lst, 
                            study_name='convergence_test_cutoff',
                            )
calc.write_input(sleep=0, backup=False, mode='w')

if not os.path.exists('calc'):
    os.symlink('calc_theo', 'calc')

common.system("cp -r ../../../test/files/qe_pseudos calc_theo/pseudo; gunzip calc_theo/pseudo/*")
예제 #5
0
파일: cif2any.py 프로젝트: elcorto/pwtools
    """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.

CPMD
----
예제 #6
0
파일: cif2any.py 프로젝트: zari277/pwtools
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.

CPMD
----
예제 #7
0
def test_atpos_str():
    assert pwscf.atpos_str(["X"], np.array([[0.1, 1, 1]]), fmt="%g", delim="_", eps=0.0) == "X_0.1_1_1"
    assert pwscf.atpos_str(["X"], np.array([[0.1, 1, 1]]), fmt="%g", delim="_", eps=0.2) == "X_0_1_1"