def cleave_operation(): struct = readstructure() if isinstance(Structure, Molecule): print("cleave operation is only supported for periodic structure") return print('your choice ?') print('{} >>> {}'.format('1', 'cleave surface')) print('{} >>> {}'.format('2', 'cleave sphere cluster')) print('{} >>> {}'.format('3', 'cleave shell structure')) wait_sep() in_str = "" while in_str == "": in_str = input().strip() choice = int(in_str) if choice == 1: print( " input the miller index, minimum size in angstroms of layers containing atomssupercell" ) print( " and Minimize size in angstroms of layers containing vacuum like this:" ) print(' 1 0 0 | 5 | 5') print(' it means miller index is [1,0,0]') print(" min_slab_size is 5 Ang ") print(" min_vacum_size is 5 Ang ") print(" or like this : ") print(' 2 | 5 | 5') print(' it will generate all slab with miller index less than 2') def generate_selected_slab(in_str): tmp_list = in_str.split('|') miller_index = [int(x) for x in tmp_list[0].strip().split()] min_slab_size = float(tmp_list[1]) min_vac_size = float(tmp_list[2]) slab = SlabGenerator(struct, miller_index, min_slab_size=min_slab_size, min_vacuum_size=min_vac_size, lll_reduce=True) slab_struct = slab.get_slab() slab_struct.sort() miller_str = [str(i) for i in miller_index] filename = '_'.join(miller_str) + '.vasp' slab_struct.to(filename=filename, fmt='POSCAR') def generate_all_slab(in_str): tmp_list = in_str.split('|') max_index = int(tmp_list[0]) min_slab_size = float(tmp_list[1]) min_vac_size = float(tmp_list[2]) slabs = generate_all_slabs(struct, max_index=max_index, min_slab_size=min_slab_size, min_vacuum_size=min_vac_size, lll_reduce=True) for slab_struct in slabs: slab_struct.sort() miller_str = [str(i) for i in slab_struct.miller_index] filename = '_'.join(miller_str) + '.vasp' slab_struct.to(filename=filename, fmt='POSCAR') wait_sep() in_str = "" while in_str == "": in_str = input().strip() len_para = len(in_str.split('|')[0].split()) #if in_str.strip().startswith('a'): if len_para == 3: generate_selected_slab(in_str) #elif in_str.strip().startswith('b'): elif len_para == 1: generate_all_slab(in_str) else: print("unknow format") os._exit() elif choice == 2: print( " input the center atom index, sphere radius and vacuum layer thickness" ) print(' 1 3.5 15') print( ' it means the sphere will be selected according to the 1st atom') print( " with the radius equals 5Ang, and vacuum layer thickness is 15 Ang" ) wait_sep() in_str = "" while in_str == "": in_str = input().strip() para = in_str.split() center_atom = int(para[0]) - 1 radius = float(para[1]) vacuum = float(para[2]) center_coord = struct[center_atom].coords sites = struct.get_neighbors_in_shell(center_coord, 0, radius) coords = [site[0].coords for site in sites] species = [site[0].specie for site in sites] mol = Molecule(coords=coords, species=species) max_dist = np.max(mol.distance_matrix) a = b = c = max_dist + vacuum box_struct = mol.get_boxed_structure(a, b, c) file_name = "sphere.vasp" box_struct.to(filename=file_name, fmt='poscar') elif choice == 3: print( " input the center atom index, start radius, shell thickness and") print(" vacuum layer thickness") print(' 1 5 10 15') print( ' it means the ball shell will be selected according to the 1st atom' ) print(" with the 5< r <15Ang, and vacuum layer thickness is 15 Ang") wait_sep() in_str = "" while in_str == "": in_str = input().strip() para = in_str.split() center_atom = int(para[0]) - 1 radius = float(para[1]) shell = float(para[2]) vacuum = float(para[3]) center_coord = struct[center_atom].coords sites = struct.get_neighbors_in_shell(center_coord, radius, shell) coords = [site[0].coords for site in sites] species = [site[0].specie for site in sites] mol = Molecule(coords=coords, species=species) max_dist = np.max(mol.distance_matrix) a = b = c = max_dist + vacuum box_struct = mol.get_boxed_structure(a, b, c) file_name = "shell.vasp" box_struct.to(filename=file_name, fmt='poscar') else: print("unkown choice") return