def cluster(path): rec = 'Cluster Cutting begins.\n' rec += '---' * 25 print(rec) record(path, rec) # read parameters from ini file Ini = ReadIni() name, slab_or_molecule, group, lattice_parameter, number_of_atoms, geometry, fixed_atoms = Ini.get_basic_info( ) center_atoms, factors, deleted_atoms, coord, add_h, out_layer_number = Ini.get_cluster( ) cutting_setting = [coord, add_h] record_data_json(path, 'central atoms', center_atoms, section='cluster') record_data_json(path, 'cutting factors', factors, section='cluster') record_data_json(path, 'deleted atoms', deleted_atoms, section='cluster') cutting_setting_dict = { 'coord': coord, 'add_h': add_h, 'out_layer_number': out_layer_number } record_data_json(path, 'cutting setting', cutting_setting_dict, section='cluster') # get bilayer jobs rpa_jobs = get_jobs(path) cluster_jobs = [job for job in rpa_jobs if job.layertype == 'bilayer'] for job in cluster_jobs: if 'rpa' in job.path: job.path = job.path.replace('rpa', 'cluster') elif 'geo_opt' in job.path: job.path = job.path.replace('geo_opt', 'cluster') job.method = 'cluster' # generate clusters cluster_path = os.path.join(path, 'cluster') mkdir(cluster_path) Cluster.creat_json_file(cluster_path) for job in cluster_jobs: Clu = Cluster.ClusterCutter(job, center=center_atoms, name=name, fixed_atoms=fixed_atoms, factors=factors, cutting_setting=cutting_setting, deleted_atoms=deleted_atoms) if not Cluster.if_cluster_already_generated(job): Clu.get_cluster() if out_layer_number is True: Clu.write_xyz_with_layernumber() else: Clu.write_xyz() rec = 'Cluster Cutting finished!\n' rec += '***' * 25 print(rec) record(path, rec)
def cluster(path): rec = 'Cluster Cutting begins.\n' rec += '---' * 25 print(rec) record(path, rec) # read infos from input.ini file Ini = IniReader() project_name, system_type, group_type, lattice_parameter, number_atoms, geometry, fixed_atoms = Ini.get_basic_info( ) central_atoms, factors, deleted_atoms, coord, add_h, out_layer_number = Ini.get_cluster( ) cutting_setting = [coord, add_h] record_data_json(path, 'central atoms', central_atoms, section='cluster') record_data_json(path, 'cutting factors', factors, section='cluster') record_data_json(path, 'deleted atoms', deleted_atoms, section='cluster') cutting_setting_dict = { 'coord': coord, 'add_h': add_h, 'out_layer_number': out_layer_number } record_data_json(path, 'cutting setting', cutting_setting_dict, section='cluster') geo_file = os.path.join(os.path.join(path, 'geo_opt'), 'geo_opt.out') job = os.path.join(path, 'cluster') job = Job(job) Clu = Cluster.ClusterCutter(job, geo_file, factors=factors, name=project_name, central_atoms=central_atoms, fixed_atoms=fixed_atoms, cutting_setting=cutting_setting, deleted_atoms=deleted_atoms) Clu.get_cluster() if out_layer_number is True: Clu.write_xyz_with_layernumber() else: Clu.write_xyz() rec = 'Cluster Cutting finished!\n' rec += '***' * 25 print(rec) record(path, rec)
def test_MgO(): path = r'C:\Users\ccccc\Documents\Theoritische Chemie\Masterarbeit\test\cluster' Cluster.creat_json_file(path) job = r'C:\Users\ccccc\Documents\Theoritische Chemie\Masterarbeit\test\geo_opt\x_1\z_2' dimen, lattice, geo = read_infomation(job) job = Job(job) center_upp = [25, 25] center_und = [9, 9] center = [center_upp, center_und] fixed_atoms = [13, 24] fac_upp = [0.3, 0.5, 0.5] fac_und = [0.4, 0.6, 0.6] factors = [fac_upp, fac_und] Clu = Cluster.ClusterCutter(job, name='MgO', centre=center, basic_infos=[dimen, lattice, geo], factors=factors, fixed_atoms=fixed_atoms) Clu.final_cluster = Clu.choose_atoms_from_distance() Clu.write_xyz(Clu.choosed_atoms)
def test_cut_cluster(job): fac_upp = [1.2, 1.8, 1.3] fac_und = [1.2, 1.8, 1.3] factors = [[1, 1, 0.7], [1, 1.5, 0.7]] Clu = Cluster.ClusterCutter(job, centre=[[3, 4], [7, 8]], name='BlackP', factors=factors, size='S') nat = Clu.nat[0] x = Clu.x[0] y = Clu.y[0] z = Clu.z[0] atom = Cluster.Atom(nat, x, y, z) cent = Clu.centre test_cal_dis(atom, cent, Clu) #test_cal_vec_dis(atom, cent, Clu) # test_choose_atom(Clu) # test_get_layer(Clu) # test_cal_atom_dis(Clu) # test_cal_coordniate_number(Clu) # test_cal_coor_all_atoms(Clu) # test_select_atoms_according_coor(Clu) Clu.write_xyz_with_layernumber()
def test_SiO2(): path = r'C:\Users\ccccc\Documents\Theoritische Chemie\Masterarbeit\test\cluster' #path = r'/users/shch/project/Masterarbeit/Test/cluster' Cluster.creat_json_file(path) job = r'C:\Users\ccccc\Documents\Theoritische Chemie\Masterarbeit\test\geo_opt\x_1\z_1' #job = r'/users/shch/project/Masterarbeit/Test/geo_opt/x_1/z_1' dimen, lattice, geo = read_infomation(job) job = Job(job) #centre=[16, 16] centre = [2, 4] fac_upp = [0.85, 1.1, 1.1] fac_und = fac_upp factors = [fac_upp, fac_und] deleted_atoms = [54, 49] #deleted_atoms = [] #centre = [[2, 2], [13, 13]] Clu = Cluster.ClusterCutter(job, name='SiO2-H2O', centre=centre, basic_infos=[dimen, lattice, geo], factors=factors, size='M', fixed_atoms=[10, 17], deleted_atoms=deleted_atoms) original_atoms = Clu.original_atoms cnt = 1 Clu.write_xyz()