def make_bulk_structure(filename_poscar_in,
                        filename_outcar_in=None,
                        supercell=None):
    poscar_in = vasp.Poscar()
    poscar_in.read(filename=filename_poscar_in)

    if filename_outcar_in is not None:
        # add magnetic moments to the structure
        outcar_in = vasp.Outcar()
        outcar_in.read(filename=filename_outcar_in)
        magnetic_moments = outcar_in.get_magnetic_moments()
        for i, atom in enumerate(poscar_in.atomic_basis):
            atom.magmom = magnetic_moments[i][-1]
        z_distances = [k.position[2] for k in poscar_in.atomic_basis]
        min_z_distance = min(z_distances)
        for atom in poscar_in.atomic_basis:
            atom.position[2] = atom.position[2] - min_z_distance

    # make supercell
    if supercell is not None:
        poscar_out = vasp.Poscar(
            crystal.make_super_cell(structure=poscar_in, sc=supercell))
    else:
        poscar_out = poscar_in

    # sort by z_axis
    new_atomic_basis = []
    while len(poscar_out.atomic_basis) > 0:
        z_distances = [k.position[2] for k in poscar_out.atomic_basis]
        idx_min = z_distances.index(min(z_distances))
        new_atomic_basis.append(copy.deepcopy(
            poscar_out.atomic_basis[idx_min]))
        del poscar_out.atomic_basis[idx_min]
    poscar_out.atomic_basis = new_atomic_basis
    return poscar_out
    def write_lammps_structure_filename(self):
        _supercell = self.supercell
        _structure_filename_src \
                = self.configuration['structure']['structure_filename']
        _structure = vasp.Poscar()
        _structure.read(_structure_filename_src)

        self.structure = crystal.make_super_cell(structure=_structure,
                                                 sc=_supercell)

        self.lammps_structure = lammps.LammpsStructure(\
                obj=self.structure)

        _str_out = self.lammps_input_file_to_string()

        _lammps_filename = os.path.join(self.task_directory, filename)
        with open(_lammps_filename, 'w') as f:
            f.write(_str_out)
Esempio n. 3
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)
Esempio n. 4
0
    result = None
    n = 2
    for i0 in range(-n, n+1):
        for i1 in range(-n, n+1):
            for i2 in range(-n, n+1):
                rp = r+np.dot(a0*H.T, [i0,i1,i2])
                d = np.linalg.norm(rp)
                if (result is None) or (result[1] > d):
                    result = (rp, d)
    return result[0]

poscar_filename = 'Ni_fcc_unit.gga.relaxed.vasp'
cell_poscar = Poscar()
cell_poscar.read(poscar_filename)
cell_poscar.normalize_h_matrix()
cell_sc = make_super_cell(structure=cell_poscar,sc=[3,3,3])
_positions = [a.position for a in cell_sc.atomic_basis]
_n_atoms = len(_positions)
min_distances = []
for i in range(1,_n_atoms):
    r1 = np.array(_positions[0])
    r2 = np.array(_positions[i])
    r = r2-r1
    r_min = brute_minimum_image_convention(r=r,H=cell_sc.H,a0=cell_sc.a0)
    d = np.linalg.norm(r_min)
    min_distances.append(d*cell_poscar.a0*cell_poscar.a1)
min_distances = np.array(min_distances)
distances = np.linspace(
        np.min(min_distances),
        np.max(min_distances),
        100)
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)
Esempio n. 6
0
            v['vasp_obj'].write(
                os.path.join(dst_structure_dir, v['vasp_fname']))
            print('{}->{}'.format(k, v['vasp_fname']))

        # 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'])
Esempio n. 7
0
import os, shutil, subprocess
from pypospack.crystal import SimulationCell
import pypospack.io.vasp as vasp
import pypospack.crystal as crystal
import pypospack.io.slurm as minimize_init_slurm

# define simulation cell
cell = SimulationCell()
cell.a0 = 3.447
cell.add_atom('Fe', [0.0, 0.0, 0.0], magmom=3.00)
cell.add_atom('Fe', [0.5, 0.5, 0.0], magmom=3.00)
cell.add_atom('Fe', [0.5, 0.0, 0.5], magmom=-3.00)
cell.add_atom('Fe', [0.0, 0.5, 0.5], magmom=-3.00)

from pypospack.crystal import make_super_cell
poscar = vasp.Poscar(make_super_cell(structure=cell, sc=[3, 3, 3]))
poscar.add_atom('Fe', [1. / 6., 0.0, 0.0])
poscar.write("POSCAR")

s_out = ""
for atom in poscar.atomic_basis:
    s_out += "{:<4}{:10.6f}{:10.6f}{:10.6f}\n".format(atom.symbol,
                                                      atom.position[0],
                                                      atom.position[1],
                                                      atom.position[2])

with open('Fe_defect.gulp.structure', 'w') as f:
    f.write(s_out)