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


Python netstorage.AtomNetwork类代码示例

本文整理汇总了Python中zeo.netstorage.AtomNetwork的典型用法代码示例。如果您正苦于以下问题:Python AtomNetwork类的具体用法?Python AtomNetwork怎么用?Python AtomNetwork使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_voronoi_nodes

def get_voronoi_nodes(structure, rad_dict=None, probe_rad=0.1):
    """
    Analyze the void space in the input structure using voronoi decomposition
    Calls Zeo++ for Voronoi decomposition

    Args:
        structure: pymatgen.core.structure.Structure
        rad_dict (optional): Dictionary of radii of elements in structure.
            If not given, Zeo++ default values are used.
            Note: Zeo++ uses atomic radii of elements.
            For ionic structures, pass rad_dict with ionic radii
        probe_rad (optional): Sampling probe radius in Angstroms. Default is
            0.1 A

    Returns:
        voronoi nodes as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
    """

    temp_dir = tempfile.mkdtemp()
    current_dir = os.getcwd()
    name = "temp_zeo1"
    zeo_inp_filename = name + ".cssr"
    os.chdir(temp_dir)
    ZeoCssr(structure).write_file(zeo_inp_filename)
    rad_file = None
    rad_flag = False

    if rad_dict:
        rad_file = name + ".rad"
        rad_flag = True
        with open(rad_file, 'w+') as fp:
            for el in rad_dict.keys():
                print >>fp, "{} {}".format(el, rad_dict[el].real)

    atmnet = AtomNetwork.read_from_CSSR(zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file)
    vornet = atmnet.perform_voronoi_decomposition()
    vornet.analyze_writeto_XYZ(name, probe_rad, atmnet)
    voronoi_out_filename = name + '_voro.xyz'
    voronoi_node_mol = ZeoVoronoiXYZ.from_file(voronoi_out_filename).molecule
    #print voronoi_node_mol
    species = ["X"] * len(voronoi_node_mol.sites)
    coords = []
    prop = []
    for site in voronoi_node_mol.sites:
        coords.append(list(site.coords))
        prop.append(site.properties['voronoi_radius'])

    lattice = Lattice.from_lengths_and_angles(
        structure.lattice.abc, structure.lattice.angles
    )
    voronoi_node_struct = Structure(
        lattice, species, coords, coords_are_cartesian=True,
        site_properties={"voronoi_radius": prop}
    )

    os.chdir(current_dir)
    shutil.rmtree(temp_dir)

    return voronoi_node_struct
开发者ID:mathematicus,项目名称:pymatgen,代码行数:60,代码来源:zeoio.py

示例2: get_void_volume_surfarea

def get_void_volume_surfarea(structure, rad_dict=None, chan_rad=0.3,
                             probe_rad=0.1):
    """
    Computes the volume and surface area of isolated void using Zeo++.
    Useful to compute the volume and surface area of vacant site.

    Args:
        structure: pymatgen Structure containing vacancy
        rad_dict(optional): Dictionary with short name of elements and their
            radii.
        chan_rad(optional): Minimum channel Radius.
        probe_rad(optional): Probe radius for Monte Carlo sampling.

    Returns:
        volume: floating number representing the volume of void
    """
    with ScratchDir('.'):
        name = "temp_zeo"
        zeo_inp_filename = name + ".cssr"
        ZeoCssr(structure).write_file(zeo_inp_filename)

        rad_file = None
        if rad_dict:
            rad_file = name + ".rad"
            with open(rad_file, 'w') as fp:
                for el in rad_dict.keys():
                    fp.write("{0}     {1}".format(el, rad_dict[el]))

        atmnet = AtomNetwork.read_from_CSSR(zeo_inp_filename, True, rad_file)
        vol_str = volume(atmnet, 0.3, probe_rad, 10000)
        sa_str = surface_area(atmnet, 0.3, probe_rad, 10000)
        print vol_str, sa_str
        vol = None
        sa = None
        for line in vol_str.split("\n"):
            if "Number_of_pockets" in line:
                fields = line.split()
                if float(fields[1]) > 1:
                    vol = -1.0
                    break
                if float(fields[1]) == 0:
                    vol = -1.0
                    break
                vol = float(fields[3])
        for line in sa_str.split("\n"):
            if "Number_of_pockets" in line:
                fields = line.split()
                if float(fields[1]) > 1:
                    #raise ValueError("Too many voids")
                    sa = -1.0
                    break
                if float(fields[1]) == 0:
                    sa = -1.0
                    break
                sa = float(fields[3])

    if not vol or not sa:
        raise ValueError("Error in zeo++ output stream")
    return vol, sa
开发者ID:zacharygibbs,项目名称:pymatgen,代码行数:59,代码来源:zeoio.py

示例3: get_high_accuracy_voronoi_nodes

def get_high_accuracy_voronoi_nodes(structure, rad_dict, probe_rad=0.1):
    """
    Analyze the void space in the input structure using high accuracy
    voronoi decomposition.
    Calls Zeo++ for Voronoi decomposition.

    Args:
        structure: pymatgen.core.structure.Structure
        rad_dict (optional): Dictionary of radii of elements in structure.
            If not given, Zeo++ default values are used.
            Note: Zeo++ uses atomic radii of elements.
            For ionic structures, pass rad_dict with ionic radii
        probe_rad (optional): Sampling probe radius in Angstroms.
            Default is 0.1 A

    Returns:
        voronoi nodes as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
        voronoi face centers as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
    """

    with ScratchDir('.'):
        name = "temp_zeo1"
        zeo_inp_filename = name + ".cssr"
        ZeoCssr(structure).write_file(zeo_inp_filename)
        rad_flag = True
        rad_file = name + ".rad"
        with open(rad_file, 'w+') as fp:
            for el in rad_dict.keys():
                print("{} {}".format(el, rad_dict[el].real), file=fp)

        atmnet = AtomNetwork.read_from_CSSR(
            zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file)
        # vornet, vor_edge_centers, vor_face_centers = \
        #        atmnet.perform_voronoi_decomposition()
        red_ha_vornet = \
            prune_voronoi_network_close_node(atmnet)
        # generate_simplified_highaccuracy_voronoi_network(atmnet)
        # get_nearest_largest_diameter_highaccuracy_vornode(atmnet)
        red_ha_vornet.analyze_writeto_XYZ(name, probe_rad, atmnet)
        voro_out_filename = name + '_voro.xyz'
        voro_node_mol = ZeoVoronoiXYZ.from_file(voro_out_filename).molecule

    species = ["X"] * len(voro_node_mol.sites)
    coords = []
    prop = []
    for site in voro_node_mol.sites:
        coords.append(list(site.coords))
        prop.append(site.properties['voronoi_radius'])

    lattice = Lattice.from_lengths_and_angles(
        structure.lattice.abc, structure.lattice.angles)
    vor_node_struct = Structure(
        lattice, species, coords, coords_are_cartesian=True,
        to_unit_cell=True, site_properties={"voronoi_radius": prop})

    return vor_node_struct
开发者ID:gpetretto,项目名称:pymatgen,代码行数:58,代码来源:zeopp.py

示例4: get_free_sphere_params

def get_free_sphere_params(structure, rad_dict=None, probe_rad=0.1):
    """
    Analyze the void space in the input structure using voronoi decomposition
    Calls Zeo++ for Voronoi decomposition.

    Args:
        structure: pymatgen.core.structure.Structure
        rad_dict (optional): Dictionary of radii of elements in structure.
            If not given, Zeo++ default values are used.
            Note: Zeo++ uses atomic radii of elements.
            For ionic structures, pass rad_dict with ionic radii
        probe_rad (optional): Sampling probe radius in Angstroms. Default is
            0.1 A

    Returns:
        voronoi nodes as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
        voronoi face centers as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
    """

    with ScratchDir('.'):
        name = "temp_zeo1"
        zeo_inp_filename = name + ".cssr"
        ZeoCssr(structure).write_file(zeo_inp_filename)
        rad_file = None
        rad_flag = False

        if rad_dict:
            rad_file = name + ".rad"
            rad_flag = True
            with open(rad_file, 'w+') as fp:
                for el in rad_dict.keys():
                    fp.write("{} {}\n".format(el, rad_dict[el].real))

        atmnet = AtomNetwork.read_from_CSSR(
            zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file)
        out_file = "temp.res"
        atmnet.calculate_free_sphere_parameters(out_file)
        if os.path.isfile(out_file) and os.path.getsize(out_file) > 0:
            with open(out_file, "rt") as fp:
                output = fp.readline()
        else:
            output = ""
    fields = [val.strip() for val in output.split()][1:4]
    if len(fields) == 3:
        fields = [float(field) for field in fields]
        free_sphere_params = {'inc_sph_max_dia': fields[0],
                              'free_sph_max_dia': fields[1],
                              'inc_sph_along_free_sph_path_max_dia': fields[2]}
    return free_sphere_params
开发者ID:gpetretto,项目名称:pymatgen,代码行数:51,代码来源:zeopp.py

示例5: get_voronoi_nodes

def get_voronoi_nodes(structure, rad_dict=None, probe_rad=0.1):
    """
    Analyze the void space in the input structure using voronoi decomposition
    Calls Zeo++ for Voronoi decomposition.

    Args:
        structure: pymatgen.core.structure.Structure
        rad_dict (optional): Dictionary of radii of elements in structure.
            If not given, Zeo++ default values are used.
            Note: Zeo++ uses atomic radii of elements.
            For ionic structures, pass rad_dict with ionic radii
        probe_rad (optional): Sampling probe radius in Angstroms. Default is
            0.1 A

    Returns:
        voronoi nodes as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
        voronoi face centers as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
    """

    with ScratchDir('.'):
        name = "temp_zeo1"
        zeo_inp_filename = name + ".cssr"
        ZeoCssr(structure).write_file(zeo_inp_filename)
        rad_file = None
        rad_flag = False

        if rad_dict:
            rad_file = name + ".rad"
            rad_flag = True
            with open(rad_file, 'w+') as fp:
                for el in rad_dict.keys():
                    fp.write("{} {}\n".format(el, rad_dict[el].real))

        atmnet = AtomNetwork.read_from_CSSR(
            zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file)
        vornet, vor_edge_centers, vor_face_centers = \
            atmnet.perform_voronoi_decomposition()
        vornet.analyze_writeto_XYZ(name, probe_rad, atmnet)
        voro_out_filename = name + '_voro.xyz'
        voro_node_mol = ZeoVoronoiXYZ.from_file(voro_out_filename).molecule

    species = ["X"] * len(voro_node_mol.sites)
    coords = []
    prop = []
    for site in voro_node_mol.sites:
        coords.append(list(site.coords))
        prop.append(site.properties['voronoi_radius'])

    lattice = Lattice.from_lengths_and_angles(
        structure.lattice.abc, structure.lattice.angles)
    vor_node_struct = Structure(
        lattice, species, coords, coords_are_cartesian=True,
        to_unit_cell=True, site_properties={"voronoi_radius": prop})

    # PMG-Zeo c<->a transformation for voronoi face centers
    rot_face_centers = [(center[1], center[2], center[0]) for center in
                        vor_face_centers]
    rot_edge_centers = [(center[1], center[2], center[0]) for center in
                        vor_edge_centers]

    species = ["X"] * len(rot_face_centers)
    prop = [0.0] * len(rot_face_centers)  # Vor radius not evaluated for fc
    vor_facecenter_struct = Structure(
        lattice, species, rot_face_centers, coords_are_cartesian=True,
        to_unit_cell=True, site_properties={"voronoi_radius": prop})

    species = ["X"] * len(rot_edge_centers)
    prop = [0.0] * len(rot_edge_centers)  # Vor radius not evaluated for fc
    vor_edgecenter_struct = Structure(
        lattice, species, rot_edge_centers, coords_are_cartesian=True,
        to_unit_cell=True, site_properties={"voronoi_radius": prop})

    return vor_node_struct, vor_edgecenter_struct, vor_facecenter_struct
开发者ID:gpetretto,项目名称:pymatgen,代码行数:75,代码来源:zeopp.py

示例6: get_high_accuracy_voronoi_nodes_alt

def get_high_accuracy_voronoi_nodes_alt(structure, rad_dict, probe_rad=0.1):
    """
    Function to replace high_accuracy_voronoi_nodes function. In testing
    mode.
    Analyze the void space in the input structure using high accuracy 
    voronoi decomposition.
    Calls Zeo++ for Voronoi decomposition.

    Args:
        structure: pymatgen.core.structure.Structure
        rad_dict (optional): Dictionary of radii of elements in structure.
            For ionic structures, pass rad_dict with ionic radii
        probe_rad (optional): Sampling probe radius in Angstroms. 
            Default is 0.1 A

    Returns:
        voronoi nodes as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
        voronoi face centers as pymatgen.core.structure.Strucutre within the
        unit cell defined by the lattice of input structure
    """

    with ScratchDir('.'):
        name = "temp_zeo1"
        zeo_inp_filename = name + ".cssr"
        ZeoCssr(structure).write_file(zeo_inp_filename)
        rad_flag = True
        rad_file = name + ".rad"
        with open(rad_file, 'w+') as fp:
            for el in rad_dict.keys():
                print >>fp, "{} {}".format(el, rad_dict[el].real)

        atmnet = AtomNetwork.read_from_CSSR(
                zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file)
        vornet, voronoi_face_centers = atmnet.perform_voronoi_decomposition()
        red_ha_vornet = \
                generate_simplified_highaccuracy_voronoi_network(atmnet)
        red_ha_vornet.analyze_writeto_XYZ(name, probe_rad, atmnet)
        voro_out_filename = name + '_voro.xyz'
        voro_node_mol = ZeoVoronoiXYZ.from_file(voro_out_filename).molecule

    species = ["X"] * len(voro_node_mol.sites)
    coords = []
    prop = []
    for site in voro_node_mol.sites:
        coords.append(list(site.coords))
        prop.append(site.properties['voronoi_radius'])

    lattice = Lattice.from_lengths_and_angles(
        structure.lattice.abc, structure.lattice.angles)
    voronoi_node_struct = Structure(
        lattice, species, coords, coords_are_cartesian=True,
        to_unit_cell=True, site_properties={"voronoi_radius": prop})


    #PMG-Zeo c<->a transformation for voronoi face centers
    rot_face_centers = [(center[1],center[2],center[0]) for center in 
                        voronoi_face_centers]
    species = ["X"] * len(rot_face_centers)
    # Voronoi radius not evaluated for fc. Fix in future versions
    prop = [0.0] * len(rot_face_centers)  
    voronoi_facecenter_struct = Structure(
        lattice, species, rot_face_centers, coords_are_cartesian=True,
        to_unit_cell=True, site_properties={"voronoi_radius": prop})

    return voronoi_node_struct, voronoi_facecenter_struct
开发者ID:zacharygibbs,项目名称:pymatgen,代码行数:66,代码来源:zeoio.py


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