Exemple #1
0
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
Exemple #2
0
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(f"{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)
        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
Exemple #3
0
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(f"{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_parameters(*structure.lattice.parameters)
    vor_node_struct = Structure(
        lattice,
        species,
        coords,
        coords_are_cartesian=True,
        to_unit_cell=True,
        site_properties={"voronoi_radius": prop},
    )

    return vor_node_struct
Exemple #4
0
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
Exemple #5
0
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_zeo"
    zeo_inp_filename = name + ".cssr"
    os.chdir(temp_dir)
    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)
    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
Exemple #6
0
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
Exemple #7
0
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.Structure within the
        unit cell defined by the lattice of input structure
        voronoi face centers as pymatgen.core.structure.Structure 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(f"{el} {rad_dict[el].real}\n")

        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) 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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
# -*- coding: utf-8 -*-
from zeo.high_accuracy import high_accuracy_atmnet
from zeo.netstorage import AtomNetwork

atmnet = AtomNetwork.read_from_CSSR('MgO.cssr', rad_file='MgO.rad')
atmnet.write_to_XYZ('orig_mgo.xyz', False, True)
vornet,fcs = atmnet.perform_voronoi_decomposition()
vornet.write_to_XYZ('orig_mgo_voro.xyz', 0)
vornet.analyze_writeto_XYZ('orig_mgo', 0.4, atmnet)
high_accuracy_atmnet(atmnet, 'DEF')
vornet,fcs = atmnet.perform_voronoi_decomposition()
vornet.write_to_XYZ('test_high.xyz', 0)
vornet.analyze_writeto_XYZ('mgo_high', 0.4, atmnet)
atmnet.write_to_CIF('highacc_MgO.cif')
atmnet.calculate_free_sphere_parameters('MgO.res')
#
#atmnet = AtomNetwork.read_from_CIF("mgo.cif", rad_file="MgO.rad")
#vornet = atmnet.perform_voronoi_decomposition()
#vornet.write_to_XYZ("mgo.xyz", 0)
#vornet.analyze_writeto_XYZ('mgo1', 0.4, atmnet)
#high_accuracy_atmnet(atmnet, "DEF")
#vornet = atmnet.perform_voronoi_decomposition()
#vornet.write_to_XYZ("mgo_high.xyz", 0)
#vornet.analyze_writeto_XYZ('mgo_high', 0.4, atmnet)
#atmnet.write_to_CIF("highacc_mgo.cif")
#atmnet.calculate_free_sphere_parameters('mgo.res')
#
#
#atmnet = AtomNetwork.read_from_CIF("mgo.cif", rad_file="MgO.rad")
#high_accuracy_atmnet(atmnet, "LOW")
#atmnet.write_to_XYZ("mgo_ha_lowset.xyz", False, True)
Exemple #11
0
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
from zeo.netstorage import AtomNetwork

atmnet = AtomNetwork.read_from_CSSR("MgO.cssr", rad_file="MgO.rad")
a = atmnet.perform_voronoi_decomposition()
#vornet,edge_centers, face_centers = atmnet.perform_voronoi_decomposition()
#print 'edge_centers', edge_centers
#print 'face_centers', face_centers
print len(a)

print a
def get_voronoi_percolate_nodes(structure, rad_dict=None, probe_rad=0.1):
    """
    This function is used to get voronoi percolate nodes. Different from get_percolated_node_edge,
    the vor_accessible_node_struct returned by this one does not contain neighbor information. So if you need
    neighboring information of each accessible node, you may use get_percolated_node_edge function.
    Args:
        structure (Structure): Structure object for analysis
        rad_dict (dict): optional, dictionary of radii of elements in structures.
            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:

    Returns:
        vor_node_struct, vor_accessible_node_struct, vor_edgecenter_struct, vor_facecenter_struct (Structure):


    """
    with ScratchDir('.'):
        name = "temp_zeo2"
        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(name + '_voro.xyz').molecule
        voro_accessible_node_mol = ZeoVoronoiXYZ.from_file(
            name + '_voro_accessible.xyz').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=False,
                                site_properties={"voronoi_radius": prop})

    # percolate node struct
    species = ["X"] * len(voro_accessible_node_mol.sites)
    coords = []
    prop = []
    for site in voro_accessible_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_accessible_node_struct = Structure(
        lattice,
        species,
        coords,
        coords_are_cartesian=True,
        to_unit_cell=False,
        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_origin = Structure(
        lattice,
        species,
        rot_face_centers,
        coords_are_cartesian=True,
        to_unit_cell=False,
        site_properties={"voronoi_radius": prop})
    vor_facecenter_struct = Structure.from_sites(
        list(set([i for i in vor_facecenter_struct_origin])))
    species = ["X"] * len(rot_edge_centers)
    prop = [0.0] * len(rot_edge_centers)  # Vor radius not evaluated for fc
    vor_edgecenter_struct_origin = Structure(
        lattice,
        species,
        rot_edge_centers,
        coords_are_cartesian=True,
        to_unit_cell=False,
        site_properties={"voronoi_radius": prop})
    vor_edgecenter_struct = Structure.from_sites(
        list(set([i for i in vor_edgecenter_struct_origin])))
    return vor_node_struct, vor_accessible_node_struct, vor_edgecenter_struct, vor_facecenter_struct
Exemple #14
0
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