structure_generate.py 3.12 KB
Newer Older
fanding2000's avatar
change  
fanding2000 committed
1
2
3
4
from basic_function import format_parser
from basic_function import packaged_function
from basic_function import conformer_search
import time
5
6
import os
import sys
fanding2000's avatar
change  
fanding2000 committed
7
8
9
10
11

if __name__ == '__main__':

    time_start = time.time()

12
    # --- Load configuration from generation_config.sh ---
13
    script_dir = os.path.dirname(os.path.abspath(__file__))
14
    config_path = sys.argv[1] if len(sys.argv) > 1 else os.path.join(script_dir, "generation_config.sh")
15
16
    cfg = {}
    exec(open(config_path).read(), cfg)
fanding2000's avatar
change  
fanding2000 committed
17

18
19
20
21
22
23
    output_dir = cfg["OUTPUT_DIR"]
    work_dir = os.path.join(script_dir, output_dir)
    space_group_list = [int(x) for x in cfg["SPACE_GROUP_LIST"].split(",")]
    add_name = cfg["ADD_NAME"]
    num_generation = int(cfg["NUM_GENERATION"])
    max_workers = int(cfg["MAX_WORKERS"])
fanding2000's avatar
change  
fanding2000 committed
24
25

    # ##############################################################################################
26
27
28
    # # conformer search (uncomment to use)
    conformer_search.conformer_search(cfg["SMILES"], os.path.join(work_dir, "molecule_1"),
    num_conformers=int(cfg["GENERATE_CONFORMERS"]), max_attempts=10000, rms_thresh=0.1)
fanding2000's avatar
change  
fanding2000 committed
29
30
31
    # ##############################################################################################

    # ##############################################################################################
32
33
34
35
36
37
    # single crystal structure generate with Z'=1

    molecule1 = format_parser.read_xyz_file(os.path.join(work_dir, "molecule_1/conformers/conformer_0.xyz"))
    packaged_function.CSP_generater_parallel([molecule1], work_dir,
        need_structure=num_generation, space_group_list=space_group_list,
        add_name=f"{add_name}_C1", max_workers=max_workers, start_seed=1)
fanding2000's avatar
change  
fanding2000 committed
38
39
40
    # ##############################################################################################

    # ##############################################################################################
41
42
43
44
45
46
    # single crystal structure generate with Z'=2 (uncomment to use)

    # molecule1 = format_parser.read_xyz_file(os.path.join(work_dir, "molecule_1/conformers/conformer_0.xyz"))
    # packaged_function.CSP_generater_parallel([molecule1, molecule1], work_dir,
    #     need_structure=num_generation, space_group_list=space_group_list,
    #     add_name=f"{add_name}_C1", max_workers=max_workers, start_seed=1)
fanding2000's avatar
change  
fanding2000 committed
47
48
    # ##############################################################################################

49
50
    # ##############################################################################################
    # co-crystal structure generate (uncomment to use)
fanding2000's avatar
change  
fanding2000 committed
51

52
53
54
55
56
57
    # molecule1 = format_parser.read_xyz_file(os.path.join(work_dir, "molecule_1/conformers/conformer_0.xyz"))
    # molecule2 = format_parser.read_xyz_file(os.path.join(work_dir, "molecule_2/conformers/conformer_0.xyz"))
    # packaged_function.CSP_generater_parallel([molecule1, molecule2], work_dir,
    #     need_structure=num_generation, space_group_list=space_group_list,
    #     add_name=f"{add_name}_C1", max_workers=max_workers, start_seed=1)
    # ##############################################################################################
fanding2000's avatar
change  
fanding2000 committed
58

59
60
    time_end = time.time()
    print('time cost', time_end - time_start, 's')