Ejemplo n.º 1
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
Ejemplo n.º 2
0
def BIComputation(filename, migrant, rad_flag=True, lower=0.0, upper=0.0, rad_dict=None):
    with zopen(filename, "rt") as f:
        input_string = f.read()
    parser = CifParser_new.from_string(input_string)
    stru = parser.get_structures(primitive=False)[0]

    species = [str(sp).replace("Specie ","") for sp in stru.species]
    elements = [re.sub('[^a-zA-Z]','',sp) for sp in species]
    if migrant not in elements:
        raise ValueError("The input migrant ion not in the input structure! Please check it.")
    coordination_list, radii = get_local_envir_fromstru(stru)

    radii = {}
    if rad_flag:
        if rad_dict:
            radii = rad_dict
        else:
            radii = effec_radii
    
    atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, rad_flag)
    
    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs,faces = atmnet.perform_voronoi_decomposition(True)
    add_fcs_vornet = vornet.add_facecenters(faces)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,add_fcs_vornet)
    
    if lower and not upper:
        writeVaspFile(prefixname+"_selected.vasp",atmnet, add_fcs_vornet, lower, 10.0)
    if not lower and upper:
        writeVaspFile(prefixname+"_selected.vasp",atmnet, add_fcs_vornet, 0.0, upper)
    if lower and upper:
        writeVaspFile(prefixname+"_selected.vasp",atmnet, add_fcs_vornet, lower, upper)
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def ConnValListCom(filename, migrant=None, rad_flag=True, rad_dict=None):
    with zopen(filename, "rt") as f:
        input_string = f.read()
    parser = CifParser_new.from_string(input_string)
    stru = parser.get_structures(primitive=False)[0]
    
    species = [str(sp).replace("Specie ","") for sp in stru.species]
    elements = [re.sub('[^a-zA-Z]','',sp) for sp in species]
    if migrant not in elements:
        raise ValueError("The input migrant ion not in the input structure! Please check it.")
    coord_list,effec_radii = get_local_envir_fromstru(stru)
    
    radii = {}
    if rad_flag:
        if rad_dict:
            radii = rad_dict
        else:
            radii = effec_radii
    
    atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, rad_flag)

    vornet,edge_centers,fcs,faces = atmnet.perform_voronoi_decomposition(True)
    add_fcs_vornet = vornet.add_facecenters(faces)

    prefixname = filename.replace(".cif","")
    conn = connection_values_list(prefixname+".resex",add_fcs_vornet)
    return conn
Ejemplo n.º 6
0
def AllCom9(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]

    # print(stru)
    #获取空间群号与符号
    symm_number,symm_sybol = parser.get_symme()
    #获取icsd cif文件中的对称操作
    sitesym = parser.get_sym_opt()
    radii,migrant_radius,migrant_alpha,nei_dises,coordination_list = LocalEnvirCom(stru,migrant)
    atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, False, None)
    
    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs,faces = 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)

    voids_abs = []
    voids_rad = []
    for void in sym_vornet.nodes:
        voids_abs.append(void[2])
        voids_rad.append(void[3])
    # print("voids")
    # print(voids_abs)

   

    vorosites = [voids_abs]
    vororad = [voids_rad]
    recover_rate, recover_state, migrate_mindis = rediscovery_byRad_kdTree_onlyVertex(stru, migrant, vorosites, vororad)
    
    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)
    
    channels = Channel.findChannels(sym_vornet,atmnet,minRad,prefixname+"_select.net")
    dims_channel = []
    if len(channels)==0:
        dims_channel.append(0)
    else:
        for i in channels:
            dims_channel.append(i["dim"])
    
    
    writeVaspFile(prefixname+"_select.vasp",atmnet,sym_vornet,minRad,5.0)
    # channels = Channel.findChannels(sym_vornet,atmnet,0,prefixname+"_0.net")
            
    return radii,symm_sybol,symm_number,symprec,voids_num,sym_opt_num,uni_voids_num,minRad,migrant_alpha,nei_dises,migrant_radius,conn_val,connect,dim_network,dims_channel,recover_rate,recover_state,migrate_mindis,coordination_list
Ejemplo n.º 7
0
def bmd_com(filename, migrant, rad_flag=True, lower=None, upper=10.0, 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]
    
    species = [str(sp).replace("Specie ","") for sp in stru.species]
    elements = [re.sub('[^a-zA-Z]','',sp) for sp in species]
    if migrant not in elements:
        raise ValueError("The input migrant ion not in the input structure! Please check it.")
    effec_radii,migrant_radius,migrant_alpha,nei_dises,coordination_list = LocalEnvirCom(stru,migrant)
    
    radii = {}
    if rad_flag:
        if rad_dict:
            radii = rad_dict
        else:
            radii = effec_radii
    
    atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, rad_flag)
    
    prefixname = filename.replace(".cif","")
    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)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet)
    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet)

    voids_abs = []
    for void in sym_vornet.nodes:
        voids_abs.append(void[2])

    bottlenecks = []
    for bt in sym_vornet.edges:
        bottlenecks.append(bt[2])

    vorosites = [voids_abs, bottlenecks, fcs]
    recover_rate, recover_state, migrate_mindis = rediscovery_kdTree(migrant,vorosites,stru)

    minRad = 0.0
    if lower:
        minRad = lower
    else:
        standard = STD_SURF_DIS[migrant]
        minRad = standard*migrant_alpha*0.85
    conn_val = connection_values_list(prefixname+".resex", sym_vornet)
    dim_network,connect = ConnStatus(minRad, conn_val)
    writeVaspFile(prefixname+".vasp",atmnet, sym_vornet, minRad, upper)
    channels = Channel.findChannels(sym_vornet, atmnet, minRad, prefixname+".net")
    
    dims = []
    for i in channels:
        dims.append(i["dim"])

    return radii, minRad, conn_val, connect, dim_network, dims, migrate_mindis
Ejemplo n.º 8
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)
Ejemplo n.º 9
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")
Ejemplo n.º 10
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
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
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
Ejemplo n.º 14
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
Ejemplo n.º 15
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)
Ejemplo n.º 16
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
Ejemplo n.º 17
0
from cavd.netstorage import AtomNetwork
from cavd.area_volume import volume, surface_area

atmnet = AtomNetwork.read_from_CSSR("MgO_vac1.cssr", rad_file="MgO.rad")
vol_str = volume(atmnet, 0.1, 0.05, 20000)
lines = vol_str.split('\n')
for line in lines:
    if "Number_of_pockets" in line:
        print '---------'
        print line
        print '---------'
vol_str, ha_atmnet = volume(atmnet, 0.1, 0.05, 7000, True)
lines = vol_str.split('\n')
for line in lines:
    if "Number_of_pockets" in line:
        print '---------'
        print line
        print '---------'
#print "--------"
#print vol_str
#print "--------"
sa_str = surface_area(atmnet, 0.1, 0.05, 7000, False)
lines = sa_str.split('\n')
for line in lines:
    if "Number_of_pockets" in line:
        print '---------'
        print line.split()
        print '---------'
#print "--------"
#print sa_str
#print "--------"
Ejemplo n.º 18
0
def AllCom(filename, minRad, maxRad, 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]

    # print(stru)
    #获取空间群号与符号
    symm_number,symm_sybol = parser.get_symme()
    #获取icsd cif文件中的对称操作
    sitesym = parser.get_sym_opt()
    radii,migrant_radius,migrant_alpha,nei_dises,coordination_list = LocalEnvirCom(stru,migrant)
    atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, True, None)
    
    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs,faces = atmnet.perform_voronoi_decomposition(True)
   
    symprec = 0.01
    sym_opt_num = len(sitesym)
    voids_num = len(vornet.nodes)

    # writeNETFile(prefixname+"_origin_nofcs.net",atmnet,vornet)
    add_fcs_vornet = vornet.add_facecenters(faces)
    # writeNETFile(prefixname+"_origin_addfcs.net",atmnet,add_fcs_vornet)
    # writeVaspFile(prefixname+"_origin_addfcs.vasp",atmnet,add_fcs_vornet)

    # spg_vornet,uq_voids = get_equivalent_vornet(add_fcs_vornet, 0.01)

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

    voids_abs = []
    voids_rad = []
    for void in sym_vornet.nodes:
        voids_abs.append(void[2])
        voids_rad.append(void[3])
    # print("voids")
    # print(voids_abs)

    bottlenecks = []
    bottlenecs_rad = []
    for bt in sym_vornet.edges:
        frac_bt = bt[2]
        # frac_bt = [round(p%1.0, 6) for p in frac_bt]
        # frac_bt = [p%1.0 for p in frac_bt]
        # if frac_bt not in bottlenecks:
        bottlenecks.append(frac_bt)
        bottlenecs_rad.append(bt[3])
    # print("bottlenecks")
    # print(bottlenecks)
    
    # print("fcs",fcs)
    fcens = []
    fcens_rad = []
    for fc in fcs:
        fcens.append(fc[0])
        fcens_rad.append(fc[1])
    # print("facecenters")
    # print(facecenters)

    vorosites = [voids_abs, bottlenecks, fcens]
    vororad = [voids_rad, bottlenecs_rad, fcens_rad]
    # recover_rate, recover_state, migrate_mindis = rediscovery_kdTree(migrant,vorosites,stru)
    recover_rate, recover_state, migrate_mindis = rediscovery_byRad_kdTree(stru, migrant, vorosites, vororad)
    
    writeNETFile(prefixname+"_origin.net",atmnet,sym_vornet)
    writeVaspFile(prefixname+"_origin.vasp",atmnet,sym_vornet)

    conn_val = connection_values_list(prefixname+".resex", sym_vornet)
    dim_network,connect = ConnStatus(conn_val, minRad, maxRad)
    
    channels = Channel.findChannels2(sym_vornet,atmnet,minRad,maxRad,prefixname+"_select.net")
    dims_channel = []
    if len(channels)==0:
        dims_channel.append(0)
    else:
        for i in channels:
            dims_channel.append(i["dim"])
    
    
    writeVaspFile(prefixname+"_select.vasp",atmnet,sym_vornet,minRad,maxRad)
    # channels = Channel.findChannels(sym_vornet,atmnet,0,prefixname+"_0.net")
            
    return radii,symm_sybol,symm_number,symprec,voids_num,sym_opt_num,uni_voids_num,minRad,migrant_alpha,nei_dises,migrant_radius,conn_val,connect,dim_network,dims_channel,recover_rate,recover_state,migrate_mindis,coordination_list
Ejemplo n.º 19
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
Ejemplo n.º 20
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!")
Ejemplo n.º 21
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()
Ejemplo n.º 22
0
def AllCom8(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]

    # print(stru)
    #获取空间群号与符号
    symm_number,symm_sybol = parser.get_symme()
    #获取icsd cif文件中的对称操作
    sitesym = parser.get_sym_opt()
    radii,migrant_radius,migrant_alpha,nei_dises,coordination_list = LocalEnvirCom(stru,migrant)
    atmnet = AtomNetwork.read_from_RemoveMigrantCif(filename, migrant, radii, True, None)
    
    prefixname = filename.replace(".cif","")
    vornet,edge_centers,fcs,faces = atmnet.perform_voronoi_decomposition(True)
    writeVaspFile(prefixname+"_origin_nofcs.vasp",atmnet,vornet)
    spg_vornet,uq_voids = get_equivalent_vornet(vornet, 0.01)

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

    writeNETFile(prefixname+"_origin_nofcs.net",atmnet,vornet)
    add_fcs_vornet = vornet.add_facecenters(faces)
    writeNETFile(prefixname+"_origin_addfcs.net",atmnet,add_fcs_vornet)
    writeVaspFile(prefixname+"_origin_addfcs.vasp",atmnet,add_fcs_vornet)

    spg_vornet,uq_voids = get_equivalent_vornet(add_fcs_vornet, 0.01)

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

    voids_abs = []
    for void in sym_vornet.nodes:
        voids_abs.append(void[2])
    # print("voids")
    # print(voids_abs)

    bottlenecks = []
    for bt in sym_vornet.edges:
        bottlenecks.append(bt[2])
    # print("bottlenecks")
    # print(bottlenecks)
    
    # print("fcs",fcs)
    # facecenters = []
    # for fc in fcs:
    #     facecenters.append(atmnet.absolute_to_relative(fc[0], fc[1], fc[2]))
    # print("facecenters")
    # print(facecenters)

    vorosites = [voids_abs, bottlenecks, fcs]
    recover_rate, recover_state, migrate_mindis = rediscovery_kdTree(migrant,vorosites,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(minRad, conn_val)
    writeVaspFile(prefixname+"_"+str(round(minRad,4))+".vasp",atmnet,sym_vornet,minRad,5.0)
    channels = Channel.findChannels(sym_vornet,atmnet,0,prefixname+"_0.net")
    channels = Channel.findChannels(sym_vornet,atmnet,minRad,prefixname+"_"+str(round(minRad,4))+".net")
    
    return symm_sybol,symm_number,symprec,voids_num,sym_opt_num,uni_voids_num,recover_rate,recover_state,migrate_mindis