Skip to content

Commit

Permalink
Merge pull request #5 from arcann-chem/develop
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
cdavro committed May 29, 2024
2 parents 89b6efb + 169776e commit 26065b9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Since `initialization` has only a single `start` *phase*, which is self-explanat

| Phase | Description |
| --- | --- |
| `prepare` | Prepares folders and files for training the user-defined number of independent NNPs to be used in the next iteration. |
| `prepare` | Prepares folders and files for training and the user-defined number of independent NNPs to be used in the next iteration. |
| `launch` | Submits the training calculations using the `dp train` code from DeePMD-kit. |
| `check` | Verifies whether the training has completed successfully. If any traoining ended abruptly, they need to be resubmitted manually to ensure the training finishes correctly. |
| `freeze` | Freezes the NN parameters into a binary file (`.pb` extension for TensorFlow back-end) usable with LAMMPS and Python. This is done with the `dp freeze` code from DeePMD-kit. |
Expand Down
13 changes: 10 additions & 3 deletions arcann_training/exploration/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: AGPL-3.0-only #
#----------------------------------------------------------------------------------------------------#
Created: 2022/01/01
Last modified: 2024/05/15
Last modified: 2024/05/26
"""

# Standard library modules
Expand All @@ -20,7 +20,7 @@

# Local imports
from arcann_training.common.json import load_json_file, write_json_file, get_key_in_dict, load_default_json_file, backup_and_overwrite_json_file
from arcann_training.common.list import textfile_to_string_list
from arcann_training.common.list import textfile_to_string_list, string_list_to_textfile
from arcann_training.common.check import validate_step_folder, check_vmd, check_dcd_is_valid, check_nc_is_valid


Expand Down Expand Up @@ -111,6 +111,7 @@ def main(
completed_count = 0
skipped_count = 0
forced_count = 0
failed_explorations_list = []

for system_auto_index, system_auto in enumerate(main_json["systems_auto"]):
# Counters
Expand Down Expand Up @@ -173,6 +174,7 @@ def main(
timings.append(float(timings_str[0].split(" ")[3]))
del timings_str
else:
failed_explorations_list.append(f"{lammps_output_file.parent}")
arcann_logger.critical(f"'{lammps_output_file}' failed. Check manually.")
del lammps_output, lammps_output_file, traj_file, model_deviation_filename

Expand Down Expand Up @@ -213,6 +215,7 @@ def main(
timings.append(float(matches[0]))
del timings_str
else:
failed_explorations_list.append(f"{lammps_output_file.parent}")
arcann_logger.critical(f"'{sander_emle_output_file}' failed. Check manually.")
del sander_emle_ouput, sander_emle_output_file, traj_file, model_deviation_filename

Expand Down Expand Up @@ -241,6 +244,7 @@ def main(
timings.append(np.average(np.asarray(ipi_time2, dtype="float32")))
del ipi_time, ipi_time2
else:
failed_explorations_list.append(f"{lammps_output_file.parent}")
arcann_logger.critical(f"'{ipi_output_file}' failed. Check manually.")
del ipi_output
del ipi_output_file
Expand Down Expand Up @@ -285,7 +289,10 @@ def main(
del timings, average_per_step, system_count

del system_auto, it_nnp, it_number

if failed_explorations_list:
string_list_to_textfile((current_path / "failed_explorations.txt"), failed_explorations_list, read_only=True)
arcann_logger.critical(f"Failed explorations are listed in 'failed_explorations.txt'.")

arcann_logger.info(f"-" * 88)
# Update the booleans in the exploration JSON
if (completed_count + skipped_count + forced_count) == (exploration_json["nnp_count"] * sum([exploration_json["systems_auto"][_]["traj_count"] for _ in exploration_json["systems_auto"]])):
Expand Down
6 changes: 3 additions & 3 deletions arcann_training/exploration/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: AGPL-3.0-only #
#----------------------------------------------------------------------------------------------------#
Created: 2022/01/01
Last modified: 2024/05/15
Last modified: 2024/05/17
"""

# Standard library modules
Expand Down Expand Up @@ -389,7 +389,7 @@ def main(
system_nb_steps = system_exp_time_ps / system_timestep_ps
# Auto value
else:
system_nb_steps = update_system_nb_steps_factor(previous_exploration_json, system_auto)
system_nb_steps = update_system_nb_steps_factor(previous_exploration_json, system_auto) / system_timestep_ps
# Update if over Max value
if system_nb_steps > system_max_exp_time_ps / system_timestep_ps:
system_nb_steps = system_max_exp_time_ps / system_timestep_ps
Expand Down Expand Up @@ -559,7 +559,7 @@ def main(
system_nb_steps = system_exp_time_ps / system_timestep_ps
# Auto value
else:
system_nb_steps *= update_system_nb_steps_factor(previous_exploration_json, system_auto)
system_nb_steps *= update_system_nb_steps_factor(previous_exploration_json, system_auto) / system_timestep_ps
# Update if over Max value
if system_nb_steps > (system_max_exp_time_ps / system_timestep_ps):
system_nb_steps = system_max_exp_time_ps / system_timestep_ps
Expand Down
3 changes: 2 additions & 1 deletion arcann_training/exploration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: AGPL-3.0-only #
#----------------------------------------------------------------------------------------------------#
Created: 2022/01/01
Last modified: 2024/05/15
Last modified: 2024/05/17
Functions
---------
Expand Down Expand Up @@ -761,6 +761,7 @@ def get_last_frame_number(model_deviation: np.ndarray, sigma_high_limit: float,
return last_frame


# TODO: Sould be renamed because it is not returning a factor or a number of steps but a time of simulation
# Unittested
@catch_errors_decorator
def update_system_nb_steps_factor(previous_json: Dict, system_auto_index: int) -> int:
Expand Down
10 changes: 5 additions & 5 deletions arcann_training/labeling/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: AGPL-3.0-only #
#----------------------------------------------------------------------------------------------------#
Created: 2022/01/01
Last modified: 2024/05/15
Last modified: 2024/05/26
"""

# Standard library modules
Expand Down Expand Up @@ -360,15 +360,15 @@ def main(
first_job_input_t = deepcopy(system_first_job_input)
first_job_input_t = replace_substring_in_string_list(first_job_input_t, "_R_PADDEDSTEP_", padded_labeling_step)
if labeling_program == "cp2k":
first_job_input_t = replace_substring_in_string_list(first_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[0][i] for i in [0, 4, 8]]]))
first_job_input_t = replace_substring_in_string_list(first_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[labeling_step][i] for i in [0, 4, 8]]]))

string_list_to_textfile(labeling_step_path / f"1_labeling_{padded_labeling_step}.inp", first_job_input_t)
del first_job_input_t

if labeling_program == "cp2k":
second_job_input_t = deepcopy(system_second_job_input)
second_job_input_t = replace_substring_in_string_list(second_job_input_t, "_R_PADDEDSTEP_", padded_labeling_step)
second_job_input_t = replace_substring_in_string_list(second_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[0][i] for i in [0, 4, 8]]]))
second_job_input_t = replace_substring_in_string_list(second_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[labeling_step][i] for i in [0, 4, 8]]]))

string_list_to_textfile(labeling_step_path / f"2_labeling_{padded_labeling_step}.inp", second_job_input_t)
del second_job_input_t
Expand Down Expand Up @@ -416,13 +416,13 @@ def main(

first_job_input_t = deepcopy(system_first_job_input)
first_job_input_t = replace_substring_in_string_list(first_job_input_t, "_R_PADDEDSTEP_", padded_labeling_step)
first_job_input_t = replace_substring_in_string_list(first_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[0][i] for i in [0, 4, 8]]]))
first_job_input_t = replace_substring_in_string_list(first_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[labeling_step][i] for i in [0, 4, 8]]]))
string_list_to_textfile(labeling_step_path / f"1_labeling_{padded_labeling_step}.inp", first_job_input_t)
del first_job_input_t
if labeling_program == "cp2k":
second_job_input_t = deepcopy(system_second_job_input)
second_job_input_t = replace_substring_in_string_list(second_job_input_t, "_R_PADDEDSTEP_", padded_labeling_step)
second_job_input_t = replace_substring_in_string_list(second_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[0][i] for i in [0, 4, 8]]]))
second_job_input_t = replace_substring_in_string_list(second_job_input_t, "_R_CELL_", " ".join([str(_) for _ in [cell_info[labeling_step][i] for i in [0, 4, 8]]]))
string_list_to_textfile(labeling_step_path / f"2_labeling_{padded_labeling_step}.inp", second_job_input_t)
del second_job_input_t

Expand Down
19 changes: 19 additions & 0 deletions tools/force_explorations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#----------------------------------------------------------------------------------------------------#
# ArcaNN: Automatic training of Reactive Chemical Architecture with Neural Networks #
# Copyright 2022-2024 ArcaNN developers group <https://github.com/arcann-chem> #
# #
# SPDX-License-Identifier: AGPL-3.0-only #
#----------------------------------------------------------------------------------------------------#
# Created: 2024/05/26
# Last modified: 2024/05/26
#----------------------------------------------

# Read the file line by line
while IFS= read -r directory; do
# Remove leading/trailing whitespaces
directory=$(echo "$directory" | xargs)

# Create the "force" file in the director
touch "$directory"/force && echo "touch ${directory}/force"
done < failed_explorations.txt

0 comments on commit 26065b9

Please sign in to comment.