Exemplo n.º 1
0
def AllCom3(filename, standard, migrant=None, rad_flag=True, effective_rad=True, rad_file=None, rad_store_in_vasp=True):
    radii = {}
    if rad_flag and effective_rad:
        #考虑如何利用migrant_radius与migrant_alpha
        radii, migrant_radius, migrant_alpha, nei_dises = LocalEnvirCom(filename,migrant)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    rad_flag = False
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    if migrant:
        os.remove(remove_filename)

    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)
    sym_vornet,voids = get_Symmetry(atmnet, vornet)

    writeBIFile(prefixname+"_origin.bi",atmnet,sym_vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet,rad_store_in_vasp)

    minRad = standard*migrant_alpha*0.85
    channels = Channel.findChannels(sym_vornet,atmnet,minRad,prefixname+".net")
    
    dims = []
    if len(channels)==0:
        dims.append(0)
    else:
        for i in channels:
            dims.append(i["dim"])
    return migrant_alpha,radii,minRad,nei_dises,dims,voids
Exemplo n.º 2
0
def AllCom2(filename, probe_rad, num_sample, migrant=None, rad_flag=True, effective_rad=True, rad_file=None, rad_store_in_vasp=True, minRad=0.0, maxRad=0.0):
    radii = {}
    if rad_flag and effective_rad:
        radii = getIonicRadii(filename)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    # high_accur_atmnet = atmnet.copy()
    # high_accuracy_atmnet(high_accur_atmnet, "S50")

    if migrant:
        os.remove(remove_filename)

    prefixname = filename.replace(".cif","")
    # vornet,edge_centers,fcs = high_accur_atmnet.perform_voronoi_decomposition(False)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)

    sym_vornet,voids = get_Symmetry(atmnet, vornet)

    writeBIFile(prefixname+"_origin.bi",atmnet,sym_vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet,rad_store_in_vasp)

    writeVaspFile(prefixname+"_selected.vasp",atmnet,sym_vornet,rad_store_in_vasp,minRad,maxRad)

    channels = Channel.findChannels(sym_vornet,atmnet,minRad,prefixname+"_channel.net")
    
    dims = []
    for i in channels:
        dims.append(i["dim"])
    return dims,voids
Exemplo n.º 3
0
def ASACom(filename, probe_rad, num_sample, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}
    if rad_flag and effective_rad:
        radii = LocalEnvirCom(filename)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    if migrant:
        os.remove(remove_filename)
    prefixname = filename.replace(".cif","")
    asa_new(prefixname+".zsa",False,atmnet,probe_rad,probe_rad,num_sample)
Exemplo n.º 4
0
def AllCom6(filename, standard, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}    
    with zopen(filename, "rt") as f:
        input_string = f.read()
    parser = CifParser_new.from_string(input_string)
    stru = parser.get_structures(primitive=False)[0]  
    #获取空间群号与符号
    symm_number,symm_sybol = parser.get_symme()
    #获取icsd cif文件中的对称操作
    sitesym = parser.get_sym_opt()

    if rad_flag and effective_rad:
        #考虑如何利用migrant_radius与migrant_alpha
        radii,migrant_radius,migrant_alpha,nei_dises,coordination_list = LocalEnvirCom(stru,migrant)
    if migrant:
        atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, rad_flag, rad_file)
    else:
        atmnet = AtomNetwork.read_from_CIF(filename, radii, rad_flag, rad_file)
    
    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)

    symprec = 0.01
    sym_opt_num = len(sitesym)
    voids_num = len(vornet.nodes)

    sym_vornet,voids =  get_labeled_vornet(vornet, sitesym, symprec)
    uni_voids_num = len(voids)

    # 衡量计算得到的对称性独立的间隙数与 对称性独立间隙最小数 之间的差异
    dif = abs(uni_voids_num - voids_num/sym_opt_num) / (voids_num/sym_opt_num)

    recover_rate, recover_state, true_recover_dis = rediscovery(migrant,voids,stru)

    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet)

    conn_val = connection_values_list(prefixname+".resex", sym_vornet)
    minRad = standard*migrant_alpha*0.85
    dim_network,connect = ConnStatus(conn_val,minRad)
    writeVaspFile(prefixname+"_"+str(round(minRad,4))+".vasp",atmnet,sym_vornet,minRad,5.0)

    channels = Channel.findChannels(sym_vornet,atmnet,minRad,prefixname+"_"+str(round(minRad,4))+".net")
    dims_channel = []
    if len(channels)==0:
        dims_channel.append(0)
    else:
        for i in channels:
            dims_channel.append(i["dim"])
    # return symm_sybol,symm_number,symprec,uni_voids_num,conn_val,connect,dim_network,dims_channel,migrant_alpha,radii,minRad,nei_dises,recover_rate, recover_state, true_recover_dis,coordination_list
    return symm_sybol, symm_number, sym_opt_num, voids_num, symprec, uni_voids_num, dis, recover_rate, recover_state, true_recover_dis
Exemplo n.º 5
0
def VoidNetCom(filename, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}
    if rad_flag and effective_rad:
        radii = LocalEnvirCom(filename)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)
    if migrant:
        os.remove(remove_filename)
    prefixname = filename.replace(".cif","")
    writeZVisFile(prefixname+".zvis", False, atmnet, vornet)
Exemplo n.º 6
0
def ConnValCom(filename, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}
    if rad_flag and effective_rad:
        radii = LocalEnvirCom(filename)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    if migrant:
        os.remove(remove_filename)
    prefixname = filename.replace(".cif","")
    Ri,Rf,Rif = atmnet.through_VorNet(prefixname+".res")
    return Ri,Rf,Rif
Exemplo n.º 7
0
def ChannelCom(filename, probe_rad, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}
    if rad_flag and effective_rad:
        radii = LocalEnvirCom(filename)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)
    if migrant:
        os.remove(remove_filename)
    prefixname = filename.replace(".cif","")
    Channel.findChannels(vornet,atmnet,probe_rad,prefixname+".net")
Exemplo n.º 8
0
def main():
    path = "./cifs/"
    filetype = ".cif"
    filenames = batch_read_filename(path, filetype)
    for file in filenames:
        whole_filename = file + ".cif"
        whole_radfilename = file + ".rad"
        out_whole_file = file + ".res"
        infile = path + whole_filename
        inradfile = path + whole_radfilename
        outfile = path + out_whole_file
        remove_filename = getRemoveMigrantFilename(infile, "Li")
        atmnet = AtomNetwork.read_from_CIF(remove_filename, rad_file=inradfile)
        atmnet.calculate_free_sphere_parameters(outfile)
Exemplo n.º 9
0
def ConnValListCom(filename, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}
    if rad_flag and effective_rad:
        radii = LocalEnvirCom(filename)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)
    if migrant:
        os.remove(remove_filename)
    prefixname = filename.replace(".cif","")
    conn = connection_values_list(prefixname+".resex",vornet)
    return conn
Exemplo n.º 10
0
def BIComputation(filename, migrant=None, rad_flag=True, effective_rad=True, rad_file=None, rad_store_in_vasp=True,  minRad=0.0, maxRad=0.0):
    radii = {}
    if rad_flag and effective_rad:
        radii,migrant_radius,migrant_alpha, nei_dises = LocalEnvirCom(filename,migrant)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)
    #delete temp file
    if migrant:
        os.remove(remove_filename)
    prefixname = filename.replace(".cif","")
    writeBIFile(prefixname+"_origin.bi",atmnet,vornet)
    writeBIFile(prefixname+"_selected.bi",atmnet,vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,vornet,rad_store_in_vasp)
    writeVaspFile(prefixname+"_selected.vasp",atmnet,vornet,rad_store_in_vasp,minRad,maxRad)
Exemplo n.º 11
0
def AllCom(filename, probe_rad, num_sample, migrant=None, rad_flag=True, effective_rad=True, rad_file=None, minRad=0.0, maxRad=0.0):
    radii = {}
    if rad_flag and effective_rad:
        #考虑如何利用migrant_radius与migrant_alpha
        symm_number, radii,migrant_radius,migrant_alpha, nei_dises,coordination_list = LocalEnvirCom(filename,migrant)
    if migrant:
        remove_filename = getRemoveMigrantFilename(filename,migrant)
    else:
        remove_filename = filename
    atmnet = AtomNetwork.read_from_CIF(remove_filename, radii, rad_flag, rad_file)
    # high_accur_atmnet = atmnet.copy()
    # high_accuracy_atmnet(high_accur_atmnet, "S50")

    if migrant:
        os.remove(remove_filename)

    prefixname = filename.replace(".cif","")
    # vornet,edge_centers,fcs = high_accur_atmnet.perform_voronoi_decomposition(False)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)

    sym_vornet,voids = get_Symmetry(atmnet, vornet)

    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet)

    probe_rad = migrant_radius*migrant_alpha
    minRad = migrant_radius*migrant_alpha*0.85
    maxRad = migrant_radius*migrant_alpha*1.15
    print(minRad)
    print(maxRad)

    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet,minRad,maxRad)
    writeVaspFile(prefixname+"_selected.vasp",atmnet,sym_vornet,minRad,maxRad)
    
    channels = Channel.findChannels(sym_vornet,atmnet,0.60,prefixname+".net")
    conn = connection_values_list(prefixname+".resex", sym_vornet)
    oneD,twoD,threeD = ConnStatus(minRad, conn)
    
    dims = []
    for i in channels:
        dims.append(i["dim"])
    return conn,oneD,twoD,threeD,nei_dises,dims,voids,coordination_list
Exemplo n.º 12
0
def ChannelCom(filename, probe_rad = None, migrant=None, rad_flag=True, rad_dict=None, symprec=0.01):
    with zopen(filename, "rt") as f:
        input_string = f.read()
    parser = CifParser_new.from_string(input_string)
    stru = parser.get_structures(primitive=False)[0]
       
    radii = {}
    if rad_flag:
        if rad_dict:
            radii = rad_dict
        else:
            coordination_list, effec_radii = get_local_envir_fromstru(stru)
            radii = effec_radii
    
    species = [str(sp).replace("Specie ","") for sp in stru.species]
    elements = [re.sub('[^a-zA-Z]','',sp) for sp in species]
    if migrant:
        if migrant not in elements:
            raise ValueError("The input migrant ion not in the input structure! Please check it.")
        atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, rad_flag)
    else:
        atmnet = AtomNetwork.read_from_CIF(filename, radii, rad_flag)
        
    vornet,edge_centers,fcs,faces = atmnet.perform_voronoi_decomposition(True)
    add_fcs_vornet = vornet.add_facecenters(faces)
    
    sitesym = parser.get_sym_opt()
    sym_vornet,voids =  get_labeled_vornet(add_fcs_vornet, sitesym, symprec)
    prefixname = filename.replace(".cif","")
    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet)

    channels = Channel.findChannels(sym_vornet, atmnet, probe_rad, prefixname+".net")
    
    dims = []
    for i in channels:
        dims.append(i["dim"])
    return dims
Exemplo n.º 13
0
def AllCom5(filename, standard, migrant=None, rad_flag=True, effective_rad=True, rad_file=None):
    radii = {}
    with zopen(filename, "rt") as f:
        input_string = f.read()
    parser = CifParser_new.from_string(input_string)
    stru = parser.get_structures(primitive=False)[0]
    
    #获取空间群号与符号
    symm_number,symm_sybol = parser.get_symme()

    if rad_flag and effective_rad:
        #考虑如何利用migrant_radius与migrant_alpha
        radii,migrant_radius,migrant_alpha,nei_dises,coordination_list = LocalEnvirCom(stru,migrant)
    if migrant:
        atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, rad_flag, rad_file)
    else:
        atmnet = AtomNetwork.read_from_CIF(filename, radii, rad_flag, rad_file)
    
    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)

    print("\nSymmetry number from cif: ", symm_number)
    max_symm = 0
    positions = []
    lattice = vornet.lattice
    for i in vornet.nodes:
        positions.append(i[2])
    for j in range(10):
        symprec = 0.01 + j*0.01
        symm_num_vornet =  get_symnum_sites(lattice, positions, symprec)

        if max_symm < symm_num_vornet:
            max_symm = symm_num_vornet 
            max_symm_info = (max_symm, symprec)

        if symm_num_vornet == symm_number:
            print("Distance tolerance in Cartesian coordinates to find crystal symmetry: ",symprec)
            print("Symmetry number from Voronoi network: ", symm_num_vornet)
            print("\n")
            sym_vornet, voids = get_equivalent_vornet(vornet,symprec)
            break

        #在0.01-0.10范围内均无法得到与cif文件中一致的空间群号,使用在此过程中出现的最大值代替
        elif j == 9:
            print("The Symmetry calculated from Vornet (with symprec 0.01-0.1) is different from that obtained from cif files.")
            print("Using the lagest value of symm_num_vornet instead!")
            symm_num_vornet = max_symm_info[0]
            symprec = max_symm_info[1]
            print("Distance tolerance in Cartesian coordinates to find crystal symmetry: ",symprec)
            print("Symmetry number of Voronoi network: ", symm_num_vornet)
            print("\n")
            sym_vornet, voids = get_equivalent_vornet(vornet,symprec)

    recover_rate, recover_state, true_recover_dis = rediscovery(migrant,voids,stru)

    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet)

    conn_val = connection_values_list(prefixname+".resex", sym_vornet)
    minRad = standard*migrant_alpha*0.85
    dim_network,connect = ConnStatus(conn_val,minRad)
    writeVaspFile(prefixname+"_"+str(round(minRad,4))+".vasp",atmnet,sym_vornet,minRad,5.0)

    channels = Channel.findChannels(sym_vornet,atmnet,minRad,prefixname+"_"+str(round(minRad,4))+".net")
    dims_channel = []
    if len(channels)==0:
        dims_channel.append(0)
    else:
        for i in channels:
            dims_channel.append(i["dim"])
    return symm_sybol,symm_number,symm_num_vornet,symprec,conn_val,connect,dim_network,dims_channel,migrant_alpha,radii,minRad,nei_dises,recover_rate, recover_state, true_recover_dis,coordination_list
Exemplo n.º 14
0
    renderer.SetBackground(0.0,0.3,0.1)
    renderer.ResetCamera()
    renderer.GetActiveCamera().Azimuth(30)
    renderer.GetActiveCamera().Elevation(-30)
    renderer.GetActiveCamera().Zoom(1) 
    renderer.ResetCameraClippingRange()

    renWin.AddRenderer(renderer)

    iRen = vtk.vtkRenderWindowInteractor()
    iRen.SetRenderWindow(renWin)
    iRen.Initialize()
    renWin.Render()
    return iRen

if __name__ == '__main__':
    
    radii = {}
    atmnet = AtomNetwork.read_from_CIF("icsd_16713.cif", radii, False, None)
    vornet,edge_centers,fcs = atmnet.perform_voronoi_decomposition(False)
    channels = Channel.findChannels(vornet,1.1,"icsd_16713.net")
    print(channels[0].nodes)
    print(channels[0].connections)

    #test code
    #atmnet = [['Li1+', [0.2029999941587448, 0.550000011920929, 0.3399999141693115]], ['Li1+', [0.7970000058412552, 0.550000011920929, 0.1600000262260437]], ['Li1+', [0.7970000058412552, 0.44999998807907104, 0.6600000262260437]], ['Li1+', [0.2029999941587448, 0.44999998807907104, 0.8399999737739563]], ['Li1+', [0.703000009059906, 0.050000011920928955, 0.3399999141693115]], ['Li1+', [0.296999990940094, 0.050000011920928955, 0.1600000262260437]], ['Li1+', [0.296999990940094, 0.949999988079071, 0.6600000262260437]], ['Li1+', [0.703000009059906, 0.949999988079071, 0.8399999737739563]], ['C4+', [0.0, 0.9429999999701977, 0.75]], ['C4+', [0.0, 0.05700000002980232, 0.25]], ['C4+', [0.5, 0.4429999887943268, 0.75]], ['C4+', [0.5, 0.5569999814033508, 0.25]], ['O2-', [0.0, 0.6870000064373016, 0.75]], ['O2-', [0.0, 0.31299999356269836, 0.25]], ['O2-', [0.5, 0.18700000643730164, 0.75]], ['O2-', [0.5, 0.812999963760376, 0.25]], ['O2-', [0.14499999582767487, 0.06699997186660767, 0.8199999928474426]], ['O2-', [0.8550000041723251, 0.06699997186660767, 0.6800000071525574]], ['O2-', [0.8550000041723251, 0.9330000281333923, 0.18000000715255737]], ['O2-', [0.14499999582767487, 0.9330000281333923, 0.3199999928474426]], ['O2-', [0.6449999809265137, 0.5669999718666077, 0.8199999928474426]], ['O2-', [0.35500001907348633, 0.5669999718666077, 0.6800000071525574]], ['O2-', [0.35500001907348633, 0.4330000877380371, 0.18000000715255737]], ['O2-', [0.6449999809265137, 0.4330000877380371, 0.3199999928474426]]]
    #channels=[1,2]
    
    iRen = renderer = Display(atmnet, channels[0])
    iRen.Start()
Exemplo n.º 15
0
from cavd.netstorage import AtomNetwork
from cavd.netio import *

remove_filename = getRemoveMigrantFilename("Li2CO3-LDA.cif", "Li")
atmnet = AtomNetwork.read_from_CIF(remove_filename, False)
vornet, edge_centers, fcs = atmnet.perform_voronoi_decomposition()
writeBIfile("Li2CO3-LDA.bi", vornet, 0.2)
writeVaspFile("Li2CO3-LDA.vasp", atmnet, vornet, True, 0.2)
if atmnet.through_VorNet("Li2CO3-LDA.res", 0.5):
    print("a sphere with radius id 0.5A can free through in this structure!")
else:
    print(
        "a sphere with radius id 0.5A can not free through in this structure!")