From 39e46e82b9809ae1f6270471f625396b6898bba9 Mon Sep 17 00:00:00 2001 From: Andreas Lynge Vishart Date: Wed, 24 Sep 2025 09:19:55 +0200 Subject: [PATCH 1/2] Reintroduce last structure(s) trajectory file --- catlearn/_version.py | 2 +- catlearn/activelearning/activelearning.py | 24 +++++++++++++++++---- catlearn/activelearning/adsorption.py | 11 ++++++++-- catlearn/activelearning/local.py | 11 ++++++++-- catlearn/activelearning/mlgo.py | 11 ++++++++-- catlearn/activelearning/mlneb.py | 11 ++++++++-- catlearn/activelearning/randomadsorption.py | 11 ++++++++-- 7 files changed, 66 insertions(+), 15 deletions(-) diff --git a/catlearn/_version.py b/catlearn/_version.py index 64809e13..020205b7 100644 --- a/catlearn/_version.py +++ b/catlearn/_version.py @@ -1,3 +1,3 @@ -__version__ = "7.2.0" +__version__ = "7.2.1" __all__ = ["__version__"] diff --git a/catlearn/activelearning/activelearning.py b/catlearn/activelearning/activelearning.py index 56075d26..ae00a834 100644 --- a/catlearn/activelearning/activelearning.py +++ b/catlearn/activelearning/activelearning.py @@ -62,6 +62,7 @@ def __init__( pred_evaluated="predicted_evaluated.traj", converged_trajectory="converged.traj", initial_traj="initial_struc.traj", + last_traj=None, tabletxt="ml_summary.txt", timetxt="ml_time.txt", prev_calculations=None, @@ -187,14 +188,18 @@ def __init__( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str (optional) Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -267,6 +272,7 @@ def __init__( pred_evaluated=pred_evaluated, converged_trajectory=converged_trajectory, initial_traj=initial_traj, + last_traj=last_traj, tabletxt=tabletxt, timetxt=timetxt, seed=seed, @@ -856,6 +862,7 @@ def update_arguments( pred_evaluated=None, converged_trajectory=None, initial_traj=None, + last_traj=None, tabletxt=None, timetxt=None, seed=None, @@ -978,14 +985,18 @@ def update_arguments( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str (optional) Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -1101,6 +1112,8 @@ def update_arguments( self.converged_trajectory = converged_trajectory if initial_traj is not None or not hasattr(self, "initial_traj"): self.initial_traj = initial_traj + if last_traj is not None or not hasattr(self, "last_traj"): + self.last_traj = last_traj if tabletxt is not None: self.tabletxt = str(tabletxt) elif not hasattr(self, "tabletxt"): @@ -1198,6 +1211,8 @@ def run_method( self.structures = self.get_structures() # Write atoms to trajectory self.save_trajectory(self.trajectory, self.structures, mode=self.mode) + # Write atoms to last_traj trajectory + self.save_trajectory(self.last_traj, self.structures, mode="w") return method_converged def initiate_structure(self, step=1, **kwargs): @@ -2118,6 +2133,7 @@ def get_arguments(self): pred_evaluated=self.pred_evaluated, converged_trajectory=self.converged_trajectory, initial_traj=self.initial_traj, + last_traj=self.last_traj, tabletxt=self.tabletxt, timetxt=self.timetxt, seed=self.seed, diff --git a/catlearn/activelearning/adsorption.py b/catlearn/activelearning/adsorption.py index fb7e3cc9..e74b9459 100644 --- a/catlearn/activelearning/adsorption.py +++ b/catlearn/activelearning/adsorption.py @@ -53,6 +53,7 @@ def __init__( pred_evaluated="predicted_evaluated.traj", converged_trajectory="converged.traj", initial_traj="initial_struc.traj", + last_traj=None, tabletxt="ml_summary.txt", timetxt="ml_time.txt", prev_calculations=None, @@ -193,14 +194,18 @@ def __init__( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -272,6 +277,7 @@ def __init__( pred_evaluated=pred_evaluated, converged_trajectory=converged_trajectory, initial_traj=initial_traj, + last_traj=last_traj, tabletxt=tabletxt, timetxt=timetxt, prev_calculations=prev_calculations, @@ -458,6 +464,7 @@ def get_arguments(self): pred_evaluated=self.pred_evaluated, converged_trajectory=self.converged_trajectory, initial_traj=self.initial_traj, + last_traj=self.last_traj, tabletxt=self.tabletxt, timetxt=self.timetxt, seed=self.seed, diff --git a/catlearn/activelearning/local.py b/catlearn/activelearning/local.py index 2ecf1771..1b21c324 100644 --- a/catlearn/activelearning/local.py +++ b/catlearn/activelearning/local.py @@ -48,6 +48,7 @@ def __init__( pred_evaluated="predicted_evaluated.traj", converged_trajectory="converged.traj", initial_traj="initial_struc.traj", + last_traj=None, tabletxt="ml_summary.txt", timetxt="ml_time.txt", prev_calculations=None, @@ -177,14 +178,18 @@ def __init__( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -252,6 +257,7 @@ def __init__( pred_evaluated=pred_evaluated, converged_trajectory=converged_trajectory, initial_traj=initial_traj, + last_traj=last_traj, tabletxt=tabletxt, timetxt=timetxt, prev_calculations=prev_calculations, @@ -361,6 +367,7 @@ def get_arguments(self): pred_evaluated=self.pred_evaluated, converged_trajectory=self.converged_trajectory, initial_traj=self.initial_traj, + last_traj=self.last_traj, tabletxt=self.tabletxt, timetxt=self.timetxt, seed=self.seed, diff --git a/catlearn/activelearning/mlgo.py b/catlearn/activelearning/mlgo.py index 473cfdb9..2984038a 100644 --- a/catlearn/activelearning/mlgo.py +++ b/catlearn/activelearning/mlgo.py @@ -63,6 +63,7 @@ def __init__( pred_evaluated="predicted_evaluated.traj", converged_trajectory="converged.traj", initial_traj="initial_struc.traj", + last_traj=None, tabletxt="ml_summary.txt", timetxt="ml_time.txt", prev_calculations=None, @@ -231,14 +232,18 @@ def __init__( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -307,6 +312,7 @@ def __init__( pred_evaluated=pred_evaluated, converged_trajectory=converged_trajectory, initial_traj=initial_traj, + last_traj=last_traj, tabletxt=tabletxt, timetxt=timetxt, prev_calculations=None, @@ -592,6 +598,7 @@ def get_arguments(self): pred_evaluated=self.pred_evaluated, converged_trajectory=self.converged_trajectory, initial_traj=self.initial_traj, + last_traj=self.last_traj, tabletxt=self.tabletxt, timetxt=self.timetxt, seed=self.seed, diff --git a/catlearn/activelearning/mlneb.py b/catlearn/activelearning/mlneb.py index a913181f..087ba11b 100644 --- a/catlearn/activelearning/mlneb.py +++ b/catlearn/activelearning/mlneb.py @@ -57,6 +57,7 @@ def __init__( pred_evaluated="predicted_evaluated.traj", converged_trajectory="converged.traj", initial_traj="initial_struc.traj", + last_traj=None, tabletxt="ml_summary.txt", timetxt="ml_time.txt", prev_calculations=None, @@ -229,14 +230,18 @@ def __init__( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -315,6 +320,7 @@ def __init__( pred_evaluated=pred_evaluated, converged_trajectory=converged_trajectory, initial_traj=initial_traj, + last_traj=last_traj, tabletxt=tabletxt, timetxt=timetxt, prev_calculations=self.prev_calculations, @@ -528,6 +534,7 @@ def get_arguments(self): pred_evaluated=self.pred_evaluated, converged_trajectory=self.converged_trajectory, initial_traj=self.initial_traj, + last_traj=self.last_traj, tabletxt=self.tabletxt, timetxt=self.timetxt, seed=self.seed, diff --git a/catlearn/activelearning/randomadsorption.py b/catlearn/activelearning/randomadsorption.py index cac02c51..b4165ef7 100644 --- a/catlearn/activelearning/randomadsorption.py +++ b/catlearn/activelearning/randomadsorption.py @@ -63,6 +63,7 @@ def __init__( pred_evaluated="predicted_evaluated.traj", converged_trajectory="converged.traj", initial_traj="initial_struc.traj", + last_traj=None, tabletxt="ml_summary.txt", timetxt="ml_time.txt", prev_calculations=None, @@ -228,14 +229,18 @@ def __init__( training data with predicted properties. If pred_evaluated is None, then the predicted data is not saved. - converged_trajectory: str or TrajectoryWriter instance + converged_trajectory: str or TrajectoryWriter instance (optional) Trajectory filename to store the converged structure(s). Or the TrajectoryWriter instance to store the converged structure(s). - initial_traj: str or TrajectoryWriter instance + initial_traj: str or TrajectoryWriter instance (optional) Trajectory filename to store the initial structure(s). Or the TrajectoryWriter instance to store the initial structure(s). + last_traj: str or TrajectoryWriter instance (optional) + Trajectory filename to store the last structure(s). + Or the TrajectoryWriter instance to store the last + structure(s). tabletxt: str Name of the .txt file where the summary table is printed. It is not saved to the file if tabletxt=None. @@ -316,6 +321,7 @@ def __init__( pred_evaluated=pred_evaluated, converged_trajectory=converged_trajectory, initial_traj=initial_traj, + last_traj=last_traj, tabletxt=tabletxt, timetxt=timetxt, prev_calculations=prev_calculations, @@ -496,6 +502,7 @@ def get_arguments(self): pred_evaluated=self.pred_evaluated, converged_trajectory=self.converged_trajectory, initial_traj=self.initial_traj, + last_traj=self.last_traj, tabletxt=self.tabletxt, timetxt=self.timetxt, seed=self.seed, From 4eec9afd70378302c18e1a07cf87595af20a5ae2 Mon Sep 17 00:00:00 2001 From: Andreas Lynge Vishart Date: Tue, 30 Sep 2025 16:02:16 +0200 Subject: [PATCH 2/2] Change in README --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 562bcab2..b833dc65 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,18 @@ CalLearn uses ASE to handle atomic systems and the calculator interface to calcu You can install CatLearn by downloading it from GitHub as: ```shell -$ git clone --single-branch --branch activelearning https://github.com/avishart/CatLearn -$ pip install -e CatLearn/. +git clone --single-branch --branch activelearning https://github.com/avishart/CatLearn +pip install -e CatLearn/. ``` You can also install CatLearn directly from GitHub: ```shell -$ pip install git@github.com:avishart/CatLearn.git@activelearning +pip install git+https://github.com/avishart/CatLearn.git@activelearning ``` However, it is recommended to install a specific tag to ensure it is a stable version: ```shell -$ pip install git+https://github.com/avishart/CatLearn.git@v.x.x.x +pip install git+https://github.com/avishart/CatLearn.git@v.x.x.x ``` The dependency of ASE has only been thoroughly tested up to version 3.26.0. @@ -74,7 +74,7 @@ dyn.run( fmax=0.05, max_unc=0.30, steps=100, - ml_steps=1000, + ml_steps=500, ) ``` @@ -117,7 +117,7 @@ mlneb = MLNEB( start_without_ci=True, reuse_ci_path=True, save_memory=False, - parallel_run=False, + parallel_run=True, local_opt=FIRE, local_opt_kwargs={}, use_restart=True, @@ -129,7 +129,7 @@ mlneb.run( fmax=0.05, max_unc=0.30, steps=100, - ml_steps=1000, + ml_steps=500, ) ```