Skip to content

Commit 5ce256c

Browse files
authored
model_devi_clean_traj support int type (#583)
* model_devi_clean_traj support buffer * fix clean index * update readme
1 parent 7aec091 commit 5ce256c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ The bold notation of key (such aas **type_map**) means that it's a necessary key
557557
| model_devi_perc_candi_f | Float | 0.0 | See `model_devi_adapt_trust_lo`.|
558558
| model_devi_perc_candi_v | Float | 0.0 | See `model_devi_adapt_trust_lo`.|
559559
| model_devi_f_avg_relative | Boolean | False | Normalized the force model deviations by the RMS force magnitude along the trajectory. This key should not be used with `use_relative`. |
560-
| **model_devi_clean_traj** | Boolean | true | Deciding whether to clean traj folders in MD since they are too large. |
560+
| **model_devi_clean_traj** | Boolean or Int | true | If type of model_devi_clean_traj is boolean type then it denote whether to clean traj folders in MD since they are too large. If it is Int type, then the most recent n iterations of traj folders will be retained, others will be removed. |
561561
| **model_devi_nopbc** | Boolean | False | Assume open boundary condition in MD simulations. |
562562
| model_devi_activation_func | List of list of string | [["tanh","tanh"],["tanh","gelu"],["gelu","tanh"],["gelu","gelu"]] | Set activation functions for models, length of the List should be the same as `numb_models`, and two elements in the list of string respectively assign activation functions to the embedding and fitting nets within each model. *Backward compatibility*: the orginal "List of String" format is still supported, where embedding and fitting nets of one model use the same activation function, and the length of the List should be the same as `numb_models`|
563563
| **model_devi_jobs** | [<br/>{<br/>"sys_idx": [0], <br/>"temps": <br/>[100],<br/>"press":<br/>[1],<br/>"trj_freq":<br/>10,<br/>"nsteps":<br/> 1000,<br/> "ensembles": <br/> "nvt" <br />},<br />...<br />] | List of dict | Settings for exploration in `01.model_devi`. Each dict in the list corresponds to one iteration. The index of `model_devi_jobs` exactly accord with index of iterations |

dpgen/generator/run.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,15 +2840,24 @@ def post_fp (iter_index,
28402840
else :
28412841
raise RuntimeError ("unsupported fp style")
28422842
# clean traj
2843-
iter_name = make_iter_name(iter_index)
28442843
clean_traj = True
28452844
if 'model_devi_clean_traj' in jdata :
28462845
clean_traj = jdata['model_devi_clean_traj']
2847-
if clean_traj:
2848-
modd_path = os.path.join(iter_name, model_devi_name)
2846+
modd_path = None
2847+
if isinstance(clean_traj, bool):
2848+
iter_name = make_iter_name(iter_index)
2849+
if clean_traj:
2850+
modd_path = os.path.join(iter_name, model_devi_name)
2851+
elif isinstance(clean_traj, int):
2852+
clean_index = iter_index - clean_traj
2853+
if clean_index >= 0:
2854+
modd_path = os.path.join(make_iter_name(clean_index), model_devi_name)
2855+
if modd_path is not None:
28492856
md_trajs = glob.glob(os.path.join(modd_path, 'task*/traj'))
2850-
for ii in md_trajs :
2857+
for ii in md_trajs:
28512858
shutil.rmtree(ii)
2859+
2860+
28522861

28532862
def set_version(mdata):
28542863

0 commit comments

Comments
 (0)