from pypospack.io.vasp import Poscar
from pypospack.crystal import make_super_cell

_bulk_filename = "Ni_fcc_110_unit.gga.relaxed.vasp"
_bulk_poscar = Poscar()
_bulk_poscar.read(_bulk_filename)
_surface_filename = "Ni_fcc_110_surf.vasp"
_surface_sc = [1, 1, 10]
_surface_sc = Poscar(make_super_cell(_bulk_poscar, _surface_sc))
_surface_slab_pct_of_z = 0.5
_surface_slab_thickness = _surface_sc.a3 * _surface_slab_pct_of_z

atoms_to_remove = []
for a in _surface_sc.atomic_basis:
    print(a.position, a.position[2] < _surface_slab_pct_of_z)
    if not a.position[2] < _surface_slab_pct_of_z:
        atoms_to_remove.append([a.symbol, list(a.position)])

for a in atoms_to_remove:
    symbol = a[0]
    position = a[1]
    print('removing {} atom @ {}'.format(str(a[0]), str(a[1])))
    _surface_sc.remove_atom(symbol=symbol, position=position)

for a in _surface_sc.atomic_basis:
    print(a.symbol, a.position)

_surface_sc.write(_surface_filename)
Exemplo n.º 2
0
from pypospack.io.vasp import Poscar
from pypospack.crystal import make_super_cell

_bulk_filename = "Ni_fcc_111_unit.gga.relaxed.vasp"
_bulk_poscar = Poscar()
_bulk_poscar.read(_bulk_filename)
_isf_filename = "Ni_fcc_isf.vasp"
print('a1', _bulk_poscar.a1)
print('a1', _bulk_poscar.a2)
print('a1', _bulk_poscar.a3)

_isf_sc = [1, 1, 5]
_isf_sc = Poscar(make_super_cell(_bulk_poscar, _isf_sc))
import numpy as np
_isf_sc.H[2, 2] = _isf_sc.H[2, 2] * 0.933333
for a in _isf_sc.atomic_basis:
    a.position[2] = a.position[2] / 0.933333
_isf_sc.write(_isf_filename)
Exemplo n.º 3
0
    _latticeconstant = {}
    _latticeconstant['a'] = 5.022  # Angs
    _latticeconstant['b'] = 5.022  # Angs
    _latticeconstant['c'] = 5.511  # Angs
    _latticeconstant['alpha'] = 90  #deg
    _latticeconstant['beta'] = 90  # degrees
    _latticeconstant['gamma'] = 120  # degrees

    # make ASE structure
    from ase import Atoms, Atom
    SiO2_aq = SiO2_a_quartz(directions=_directions,
                            size=(1, 1, 1),
                            symbol=('Si', 'O'),
                            latticeconstant=_latticeconstant)

    # convert to pypospack.crystal.SimulationCell
    from pypospack.crystal import SimulationCell
    SiO2_pyp = SimulationCell(SiO2_aq)

    # write the poscar file
    from pypospack.io.vasp import Poscar
    SiO2_poscar = Poscar(SiO2_pyp)
    SiO2_poscar.write('SiO2_aq_cubic.vasp')

    # write lammps structure
    from pypospack.io.lammps import LammpsStructure
    SiO2_lammps = LammpsStructure(SiO2_pyp)
    SiO2_lammps.write(filename='SiO2_aq_cubic.lammps',
                      symbol_list=['Si', 'O'],
                      atom_style='charge')  #or 'atomic'
Exemplo n.º 4
0
import argparse
from pypospack.io.vasp import Poscar
_description = 'Normalizes the H-matrix'
_parser = argparse.ArgumentParser(description=_description)
_parser.add_argument('--in', action='store', dest='filename_in', type=str)
_parser.add_argument('--out', action='store', dest='filename_out', type=str)

_args = _parser.parse_args()
_filename_in = _args.filename_in
_filename_out = _args.filename_out

print('filename_in:{}'.format(_filename_in))
_poscar = Poscar()
_poscar.read(_filename_in)
print('a0:{}'.format(_poscar.a0))
print('H:\n{}'.format(_poscar.H))
print('filename_out:{}'.format(_filename_out))
_poscar.normalize_h_matrix()
print(80 * '-')
print('a0:{}'.format(_poscar.a0))
print('H:\n{}'.format(_poscar.H))
_poscar.write(_filename_out)
Exemplo n.º 5
0
        # convert pypospack -> LAMMPS structure
        if is_write_lammps_structures:
            v['lammps_obj'] = LammpsStructure(v['pypospack_obj'])
            v['lammps_fname'] = '{}.structure'.format(k)
            v['lammps_obj'].write(filename=os.path.join(
                dst_structure_dir, v['lammps_fname']),
                                  symbol_list=v['symbol_list'],
                                  atom_style=v['lmps_atom_style'])
            print('{}->{}'.format(k, v['lammps_fname']))

    structures['Si_dia_333'] = OrderedDict()
    structures['Si_dia_333']['pypospack_obj'] = crystal.make_super_cell(
        structure=structures['Si_dia_unit']['pypospack_obj'], sc=[3, 3, 3])
    poscar = Poscar(structures['Si_dia_333']['pypospack_obj'])
    poscar.write(os.path.join(dst_structure_dir, 'Si_dia_333.vasp'))
    lammps_structure = LammpsStructure(
        structures['Si_dia_333']['pypospack_obj'])
    lammps_structure.write(filename=os.path.join(dst_structure_dir,
                                                 'Si_dia_333.structure'),
                           symbol_list=['Si'],
                           atom_style='atomic')

    structures['Si_dia_333_vac'] = OrderedDict()
    structures['Si_dia_333_vac']['pypospack_obj'] = SimulationCell(
        structures['Si_dia_333']['pypospack_obj'])
    structures['Si_dia_333_vac']['pypospack_obj'].add_vacancy(
        symbol='Si', position=[0.0000, 0.0000, 0.0000])
    poscar = Poscar(structures['Si_dia_333_vac']['pypospack_obj'])
    poscar.write(os.path.join(dst_structure_dir, 'Si_dia_333_vac.vasp'))
    lammps_structure = LammpsStructure(
Exemplo n.º 6
0
import ase.build
import numpy as np
from pypospack.crystal import SimulationCell


class DiamondStructure(SimulationCell):
    def __init__(self, symbols=['Si'], a=5.43):

        assert isinstance(symbols, list)
        assert len(symbols) == 1

        SimulationCell.__init__(self)
        self.H = np.array([[a, 0, 0], [0, a, 0], [0, 0, a]])
        self.add_atom(symbol=symbols[0], position=[0.0, 0.0, 0.0])
        self.add_atom(symbol=symbols[0], position=[0.25, 0.25, 0.25])
        self.add_atom(symbol=symbols[0], position=[0.00, 0.50, 0.50])
        self.add_atom(symbol=symbols[0], position=[0.25, 0.75, 0.75])
        self.add_atom(symbol=symbols[0], position=[0.50, 0.00, 0.50])
        self.add_atom(symbol=symbols[0], position=[0.75, 0.25, 0.75])
        self.add_atom(symbol=symbols[0], position=[0.50, 0.50, 0.00])
        self.add_atom(symbol=symbols[0], position=[0.75, 0.75, 0.25])


if __name__ == "__main__":
    from pypospack.io.vasp import Poscar
    filename = "Si_dia_unit.vasp"

    cell = DiamondStructure(symbols=['Si'], a=5.43)
    poscar = Poscar(obj_cell=DiamondStructure(symbols=['Si'], a=5.43))
    poscar.write(filename=filename)
Exemplo n.º 7
0
                x[0] = x[0] / simulation_cell.H[0, 0]
                x[1] = x[1] / simulation_cell.H[1, 1]
                x[2] = n * layer_spacing / simulation_cell.H[2, 2]
                simulation_cell.add_atom(s, x)
    return simulation_cell


if __name__ == "__main__":
    from pypospack.io.vasp import Poscar
    # INTRINSIC STACKING FAULT
    symbols = ['Ni']
    stacking_sequence = "ABC,ABC,AC,ABC,ABC"
    simulation_cell = make_fcc_stacking_fault(symbols, stacking_sequence)
    simulation_cell.normalize_h_matrix()
    poscar = Poscar(simulation_cell)
    poscar.write('Ni_fcc_isf.vasp')

    symbols = ['Ni']
    stacking_sequence = "ABC,ABC,ABAC,ABC,ABC"
    simulation_cell = make_fcc_stacking_fault(symbols, stacking_sequence)
    simulation_cell.normalize_h_matrix()
    poscar = Poscar(simulation_cell)
    poscar.write('Ni_fcc_esf.vasp')

    symbols = ['Ni']
    stacking_sequence = "ABC,ABC,AABC,ABC,ABC"
    simulation_cell = make_fcc_stacking_fault(symbols, stacking_sequence)
    simulation_cell.normalize_h_matrix()
    poscar = Poscar(simulation_cell)
    poscar.write('Ni_fcc_usf.vasp')
Exemplo n.º 8
0
class VaspSimulation():
    def __init__(self, simulation_path="."):
        self.simulation_path = simulation_path
        self.poscar = Poscar()
        self.incar = Incar()
        self.kpoints = Kpoints()
        self.potcar = Potcar()
        self.submission_script = SlurmSubmissionScript()

    @property
    def symbols(self):
        return self.incar.symbols

    @property
    def xc(self):
        return self.potcar.xc

    @xc.setter
    def xc(self, xc):
        self.potcar.xc = xc

    def read_incar(self, filename=None):
        if filename is None:
            filename_ = os.path.join(self.simulation_path, "INCAR")
        else:
            filename_ = filename

        self.incar.read(filename=filename_)

    def write_incar(self, filename=None):
        if filename is None:
            filename_ = os.path.join(self.simulation_path, "INCAR")
        else:
            filename_ = filename

        self.incar.write(filename=filename_)

    def write_poscar(self, filename=None):
        if filename is None:
            filename_ = os.path.join(self.simulation_path, "POSCAR")
        else:
            filename_ = filename

        self.poscar.write(filename=filename_)

    def write_potcar(self, xc='GGA', filename=None):
        self.xc = xc

        if filename is None:
            filename_ = os.path.join(self.simulation_path, 'POTCAR')
        else:
            filename_ = filename

        self.potcar.symbols = self.symbols
        self.potcar.write(filename=filename_)

    def write_kpoints(self, filename=None):
        if filename is None:
            filename_ = os.path.join(self.simulation_path, "KPOINTS")
        else:
            fiename_ = filename

        self.kpoints.write(filename_)

    def write_submission_script(self, filename=None):
        if filename is None:
            filename_ = os.path.join(self.simulation_path, "runjob.slurm")
        else:
            filename_ = filename

        self.simulation_script.write(filename=filename_)

    def write(self, path, is_clobber=False):
        self.simulation_path = path

        try:
            os.path.mkdir(path)
        except FileExistsError as e:
            if is_clobber:
                shutil.rmthree(path)
                os.path.mkdir(path)
            else:
                raise

        self.write_poscar()
        self.write_potcar()
        self.write_incar()
        self.write_kpoints()
        self.write_submission_script()
Exemplo n.º 9
0
        self.add_atom(symbol=symbol, position=[0.500000, 0.000000, 0.500000])
        self.add_atom(symbol=symbol, position=[0.000000, 0.500000, 0.500000])
        self.add_atom(symbol=symbol, position=[0.500000, 0.500000, 0.000000])
        self.add_atom(symbol=symbol, position=[0.750000, 0.250000, 0.750000])
        self.add_atom(symbol=symbol, position=[0.750000, 0.750000, 0.250000])

    def initialize_primitive_cell(self, symbol='Si', a0=5.431):
        self.a0 = a0
        a1 = 1 / 2 * np.array([0, 1, 1])
        a2 = 1 / 2 * np.array([1, 0, 1])
        a3 = 1 / 2 * np.array([1, 1, 0])
        self.H = np.stack((a1, a2, a3))
        self.add_atom(symbol=symbol, position=[0.7500, 0.75000, 0.75000])
        self.add_atom(symbol=symbol, position=[0.5000, 0.50000, 0.50000])


if __name__ == "__main__":
    from pypospack.io.vasp import Poscar

    o = Poscar(obj_cell=Diamond(symbols=['Si'], a0=5.431, cell_type='cubic'))
    o.write(filename="Si_dia_unit.vasp")

    o = Poscar(
        obj_cell=Diamond(symbols=['Si'], a0=5.431, cell_type='primitive'))
    o.write(filename='Si_dia_prim.vasp')

    o = Diamond(symbols=['Si'], a0=5.431, cell_type='primitive')
    print(o.b1)
    print(o.b2)
    print(o.b3)