@@ -581,9 +581,13 @@ def __init__(self, system, config):
581581
582582 # Make sure the selection is valid.
583583 if self ._config .gcmc_selection is not None :
584+ if isinstance (self ._system , list ):
585+ mols = self ._system [0 ]
586+ else :
587+ mols = self ._system
584588 try :
585589 atoms = _sr .mol .selection_to_atoms (
586- self . _system , self ._config .gcmc_selection
590+ mols , self ._config .gcmc_selection
587591 )
588592 except :
589593 msg = "Invalid 'gcmc_selection' value."
@@ -1175,12 +1179,14 @@ def _check_restart(self):
11751179 self ._restart_ghost_waters = []
11761180 # List to store the current positions.
11771181 self ._restart_positions = []
1178- _logger .info ("Removing existing ghost waters from GCMC checkpoint systems" )
1182+ _logger .info (
1183+ "Determining existing ghost waters from GCMC checkpoint systems"
1184+ )
11791185 for i , system in enumerate (systems ):
11801186 # Store the positions of all atoms.
11811187 self ._restart_positions .append (_sr .io .get_coords_array (system ))
11821188 if system is not None :
1183- # Remove the ghost waters from the system .
1189+ # Find and log the current ghost waters .
11841190 try :
11851191 # Get the water molecule indices.
11861192 waters = system .molecules ().find (system ["water" ].molecules ())
@@ -1195,14 +1201,16 @@ def _check_restart(self):
11951201 idxs .append (waters .index (index ))
11961202 self ._restart_ghost_waters .append (idxs )
11971203
1198- for mol in system ["property is_ghost_water" ].molecules ():
1199- _logger .debug (
1200- f"Removing ghost water molecule { mol .number ()} for { _lam_sym } ={ self ._lambda_values [i ]:.5f} "
1201- )
1202- system .remove (mol )
12031204 except :
12041205 pass
12051206
1207+ # Remove the additional GCMC waters from the end of the system.
1208+ for mol in system .molecules ()[- self ._config .gcmc_num_waters :]:
1209+ _logger .debug (
1210+ f"Removing GCMC water molecule { mol .number ()} for { _lam_sym } ={ self ._lambda_values [i ]:.5f} "
1211+ )
1212+ system .remove (mol )
1213+
12061214 return True , systems
12071215
12081216 @staticmethod
@@ -1265,6 +1273,9 @@ def _compare_configs(config1, config2):
12651273
12661274 if (v1 == None and v2 == False ) or (v2 == None and v1 == False ):
12671275 continue
1276+ # The GCMC frequency will be automaticall set if None.
1277+ elif key == "gcmc_frequency" and v1 is None :
1278+ continue
12681279 elif v1 != v2 :
12691280 raise ValueError (
12701281 f"{ key } has changed since the last run. This is not "
0 commit comments