@@ -183,6 +183,10 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
183183 insert_element_task = os .path .join (path_to_work , "element.out" )
184184 if os .path .isfile (insert_element_task ):
185185 os .remove (insert_element_task )
186+ # Keep the task metadata present even when every generated
187+ # interstitial is rejected by a configuration filter.
188+ with open (insert_element_task , "w" ):
189+ pass
186190
187191 for ii in self .insert_ele :
188192 pre_vds = InterstitialGenerator ()
@@ -467,8 +471,11 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
467471 return task_list
468472
469473 def post_process (self , task_list ):
470- if True :
471- fin1 = open (os .path .join (task_list [0 ], ".." , "element.out" ))
474+ """Adjust generated LAMMPS atom types for interstitial tasks."""
475+ if not task_list :
476+ return
477+
478+ with open (os .path .join (task_list [0 ], ".." , "element.out" )) as fin1 :
472479 for ii in task_list :
473480 conf = os .path .join (ii , "conf.lmp" )
474481 inter = os .path .join (ii , "inter.json" )
@@ -492,7 +499,6 @@ def post_process(self, task_list):
492499 with open (conf , "w+" ) as fout :
493500 for jj in conf_line :
494501 print (jj , file = fout )
495- fin1 .close ()
496502
497503 def task_type (self ):
498504 return self .parameter ["type" ]
0 commit comments