当前位置: 首页>>代码示例>>Python>>正文


Python Poscar.write_file方法代码示例

本文整理汇总了Python中pymatgen.io.vasp.inputs.Poscar.write_file方法的典型用法代码示例。如果您正苦于以下问题:Python Poscar.write_file方法的具体用法?Python Poscar.write_file怎么用?Python Poscar.write_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatgen.io.vasp.inputs.Poscar的用法示例。


在下文中一共展示了Poscar.write_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_sd_flags

# 需要导入模块: from pymatgen.io.vasp.inputs import Poscar [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Poscar import write_file [as 别名]
def set_sd_flags(poscar_input=None, n_layers=2, top=True, bottom=True,
                 poscar_output='POSCAR2'):
    """
    set the relaxation flags for top and bottom layers of interface.
    The upper and lower bounds of the z coordinate are determined
    based on the slab.
    Args:
         poscar_input: input poscar file name
         n_layers: number of layers to be relaxed
         top: whether n_layers from top are be relaxed
         bottom: whether n_layers from bottom are be relaxed
         poscar_output: output poscar file name
    Returns:
         None
         writes the modified poscar file
    """
    poscar1 = Poscar.from_file(poscar_input)
    sd_flags = np.zeros_like(poscar1.structure.frac_coords)
    z_coords = poscar1.structure.frac_coords[:, 2]
    z_lower_bound, z_upper_bound = None, None
    if bottom:
        z_lower_bound = np.unique(z_coords)[n_layers - 1]
        sd_flags[np.where(z_coords <= z_lower_bound)] = np.ones((1, 3))
    if top:
        z_upper_bound = np.unique(z_coords)[-n_layers]
        sd_flags[np.where(z_coords >= z_upper_bound)] = np.ones((1, 3))
    poscar2 = Poscar(poscar1.structure, selective_dynamics=sd_flags.tolist())
    poscar2.write_file(filename=poscar_output)
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:30,代码来源:utils.py

示例2: plot_images

# 需要导入模块: from pymatgen.io.vasp.inputs import Poscar [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Poscar import write_file [as 别名]
 def plot_images(self, outfile):
     """
     Generates a POSCAR with the calculated diffusion path with respect to the first endpoint.
     :param outfile: Output file for the POSCAR
     """
     sum_struct = self.__images[0].sites
     for image in self.__images:
         for site_i in self.__relax_sites:
             sum_struct.append(PeriodicSite(image.sites[site_i].specie, image.sites[site_i].frac_coords,
                                            self.__images[0].lattice, to_unit_cell=True, coords_are_cartesian=False))
     sum_struct = Structure.from_sites(sum_struct, validate_proximity=False)
     p = Poscar(sum_struct)
     p.write_file(outfile)
开发者ID:shaunrong,项目名称:NEB_PathFinder,代码行数:15,代码来源:PathFinder.py

示例3: slab_from_file

# 需要导入模块: from pymatgen.io.vasp.inputs import Poscar [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Poscar import write_file [as 别名]
                           hkl=[1, 1, 1],
                           min_thick=10,
                           min_vac=25,
                           primitive=False, from_ase=True)
# substrate_slab = slab_from_file([0,0,1], 'POSCAR_substrate')
mat2d_slab = slab_from_file([0, 0, 1], 'POSCAR_2D')
# get the in-plane lattice aligned slabs
# substrate_slab.to(fmt='poscar', filename='POSCAR_substrate_slab.vasp')
mat2d_slab.to(fmt='poscar', filename='POSCAR_mat2d_slab.vasp')
# selective dynamics flag
sd_flags = CalibrateSlab.set_sd_flags(
    interface=substrate_slab,
    n_layers=nlayers_substrate,
    top=True, bottom=False)
poscar = Poscar(substrate_slab, selective_dynamics=sd_flags)
poscar.write_file(filename='POSCAR_substrate_slab.vasp')
# get aligned lattices
substrate_slab_aligned, mat2d_slab_aligned = get_aligned_lattices(
    substrate_slab,
    mat2d_slab,
    max_area=400,
    max_mismatch=0.05,
    max_angle_diff=1,
    r1r2_tol=0.01)
substrate_slab_aligned.to(fmt='poscar',
                          filename='POSCAR_substrate_aligned.vasp')
mat2d_slab_aligned.to(fmt='poscar',
                      filename='POSCAR_mat2d_aligned.vasp')
# merge substrate and mat2d in all possible ways
hetero_interfaces = generate_all_configs(mat2d_slab_aligned,
                                         substrate_slab_aligned,
开发者ID:izxle,项目名称:MPInterfaces,代码行数:33,代码来源:hetero_interface.py

示例4: Interface

# 需要导入模块: from pymatgen.io.vasp.inputs import Poscar [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Poscar import write_file [as 别名]
    iface = Interface(strt, hkl=hkl,
                      min_thick=min_thick, min_vac=min_vac,
                      supercell=supercell, surface_coverage=0.01,
                      ligand=hydrazine, displacement=displacement,
                      adatom_on_lig='N', adsorb_on_species='Pb',
                      primitive=False)
    iface.create_interface()
    iface.sort()
    # extract bare slab
    iface_slab = iface.slab
    iface_slab.sort()
    # set selective dynamics flags as required
    true_site = [1, 1, 1]
    false_site = [0, 0, 0]
    sd_flag_iface = []
    sd_flag_slab = []
    # selective dynamics flags for the interface
    for i in iface.sites:
        sd_flag_iface.append(false_site)
    # selective dynamics flags for the bare slab
    for i in iface_slab.sites:
        sd_flag_slab.append(false_site)
    interface_poscar = Poscar(iface, selective_dynamics=sd_flag_iface)
    slab_poscar = Poscar(iface_slab, selective_dynamics=sd_flag_slab)
    # poscars without selective dynamics flag
    iface.to('poscar', 'POSCAR_interface.vasp')
    iface_slab.to('poscar', 'POSCAR_slab.vasp')
    # poscars with selective dynamics flag
    interface_poscar.write_file("POSCAR_interface_with_sd.vasp")
    slab_poscar.write_file("POSCAR_slab_with_sd.vasp")
开发者ID:izxle,项目名称:MPInterfaces,代码行数:32,代码来源:create_interface.py

示例5: Interface

# 需要导入模块: from pymatgen.io.vasp.inputs import Poscar [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Poscar import write_file [as 别名]
import sys

from pymatgen.core import Structure
from pymatgen.io.vasp.inputs import Poscar

from mpinterfaces.interface import Interface

 
if __name__=='__main__':
    # input structure file: bulk
    fin = 'POSCAR.bulk'
    # output file name
    fout = 'POSCAR'
    hkl = [0,0,1] # hkl wrt the input structure
    min_thick = 15 # angstroms
    min_vac = 30 # angstroms
    #use ase to create an orthogonal slab
    bulk = Structure.from_file(fin) 
    iface = Interface(bulk, hkl=hkl, 
                      min_thick=min_thick, min_vac=min_vac,
                      primitive= False, from_ase = True)
    iface.create_interface()
    iface.sort()
    #set selective dynamics flags
    # 1 --> T and 0 --> F
    sd_flags = [[1,1,1]  for i in iface.sites]
    iface_poscar = Poscar(iface, selective_dynamics= sd_flags)
    #write to file
    iface_poscar.write_file(fout)
开发者ID:JARVIS-Unifies,项目名称:MPInterfaces,代码行数:31,代码来源:create_slab.py

示例6: enumerate

# 需要导入模块: from pymatgen.io.vasp.inputs import Poscar [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Poscar import write_file [as 别名]
                                              translations=None,
                                              rotations=None,
                                              samples=20, lowest=5,
                                              ecut=energy)
    for i, iface in enumerate(interfaces):
        print("Coloumb Energy")
        print(i, iface[0])
        iface[1].to('poscar', 'POSCAR_interface' + str(iface[0]) + '.vasp')
        iface_slab = iface[1].slab
        iface_slab.sort()
        # set selective dynamics flags as required
        true_site = [1, 1, 1]
        false_site = [0, 0, 0]
        sd_flag_iface = []
        sd_flag_slab = []
        # selective dynamics flags for the interface
        for i in iface.sites:
            sd_flag_iface.append(false_site)
        # selective dynamics flags for the bare slab
        for i in iface_slab.sites:
            sd_flag_slab.append(false_site)
            interface_poscar = Poscar(iface[1],
                                      selective_dynamics=sd_flag_iface)
            slab_poscar = Poscar(iface_slab,
                                 selective_dynamics=sd_flag_slab)
            # slab poscars without selective dynamics flag
            iface_slab.to('poscar', 'POSCAR_slab' + str(iface[0]) + '.vasp')
            # poscars with selective dynamics flag
            interface_poscar.write_file("POSCAR_interface_with_sd" + str(iface[0]) + '.vasp')
            slab_poscar.write_file("POSCAR_slab_with_sd" + str(iface[0]) + '.vasp')
开发者ID:izxle,项目名称:MPInterfaces,代码行数:32,代码来源:ligand_interface.py


注:本文中的pymatgen.io.vasp.inputs.Poscar.write_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。