|
12 | 12 | from maml.apps.bowsr.model.megnet import MEGNet
|
13 | 13 | from maml.apps.bowsr.optimizer import BayesianOptimizer
|
14 | 14 | from pymatgen.core import Structure
|
15 |
| -from pymatgen.entries.computed_entries import ComputedStructureEntry |
16 | 15 | from tqdm import tqdm
|
17 | 16 |
|
18 | 17 | from matbench_discovery import DEBUG, timestamp, today
|
|
39 | 38 | job_name = f"bowsr-{energy_model}-wbm-{task_type}{'-debug' if DEBUG else ''}"
|
40 | 39 | out_dir = os.environ.get("SBATCH_OUTPUT", f"{module_dir}/{today}-{job_name}")
|
41 | 40 |
|
42 |
| -data_path = DATA_FILES.wbm_initial_structures |
| 41 | +data_path = { |
| 42 | + "IS2RE": DATA_FILES.wbm_initial_structures, |
| 43 | + "RS2RE": DATA_FILES.wbm_computed_structure_entries, |
| 44 | +}[task_type] |
| 45 | + |
43 | 46 |
|
44 | 47 | slurm_vars = slurm_submit(
|
45 | 48 | job_name=job_name,
|
|
73 | 76 | # %%
|
74 | 77 | df_wbm = pd.read_json(data_path).set_index("material_id")
|
75 | 78 |
|
76 |
| -df_this_job: pd.DataFrame = np.array_split(df_wbm, slurm_array_task_count)[ |
| 79 | +df_in: pd.DataFrame = np.array_split(df_wbm, slurm_array_task_count)[ |
77 | 80 | slurm_array_task_id - 1
|
78 | 81 | ]
|
79 | 82 |
|
|
90 | 93 | run_params = dict(
|
91 | 94 | bayes_optim_kwargs=bayes_optim_kwargs,
|
92 | 95 | data_path=data_path,
|
93 |
| - df=dict(shape=str(df_this_job.shape), columns=", ".join(df_this_job)), |
| 96 | + df=dict(shape=str(df_in.shape), columns=", ".join(df_in)), |
94 | 97 | energy_model=energy_model,
|
95 | 98 | maml_version=version("maml"),
|
96 | 99 | energy_model_version=version(energy_model),
|
|
106 | 109 | # %%
|
107 | 110 | model = MEGNet()
|
108 | 111 | relax_results: dict[str, dict[str, Any]] = {}
|
| 112 | +input_col = {"IS2RE": "initial_structure", "RS2RE": "relaxed_structure"}[task_type] |
109 | 113 |
|
110 |
| -if task_type == "IS2RE": |
111 |
| - structures = df_this_job.initial_structure.map(Structure.from_dict).to_dict() |
112 |
| -elif task_type == "RS2RE": |
113 |
| - structures = df_this_job.cse.map( |
114 |
| - lambda x: ComputedStructureEntry.from_dict(x).structure |
115 |
| - ).to_dict() |
116 |
| -else: |
117 |
| - raise ValueError(f"Unknown {task_type = }") |
| 114 | +if task_type == "RS2RE": |
| 115 | + df_in[input_col] = [x["structure"] for x in df_in.computed_structure_entry] |
118 | 116 |
|
| 117 | +structures = df_in[input_col].map(Structure.from_dict).to_dict() |
119 | 118 |
|
120 | 119 | for material_id in tqdm(structures, desc="Main loop", disable=None):
|
121 | 120 | structure = structures[material_id]
|
|
0 commit comments