[docs]defunwrap_system(atoms:ase.Atoms,components:list[np.ndarray])->list[ase.Atom]:"""Molecules in a system which extend across periodic boundaries are mapped such that they are connected but dangle out of the cell. Mapping to the side where the fragment of molecule is closest to the cell center is preferred. Can be reversed by joining the returned molecules and calling the `atoms.wrap()` method. """molecules=[]forcomponentincomponents:mol=atoms[component].copy()ifatoms.calcisnotNone:results={"forces":atoms.get_forces()[component]}if"forces_uncertainty"inatoms.calc.results.keys():f_unc=atoms.calc.results["forces_uncertainty"][component]results["forces_uncertainty"]=f_uncif"forces_ensemble"inatoms.calc.results.keys():f_ens=atoms.calc.results["forces_ensemble"][component]results["forces_ensemble"]=f_ensmol.calc=SinglePointCalculator(mol,**results)edges=edges_from_atoms(mol)closest_atom=closest_atom_to_center(mol)unwrap(mol,edges,idx=closest_atom)molecules.append(mol)returnmolecules