diff --git a/feflow/utils/hybrid_topology.py b/feflow/utils/hybrid_topology.py index 188125d1..35decf7c 100644 --- a/feflow/utils/hybrid_topology.py +++ b/feflow/utils/hybrid_topology.py @@ -2698,14 +2698,17 @@ def _create_hybrid_topology(self): # In the first instance, create a list of necessary atoms from # both old & new Topologies atom_list = [] + # iterate once over the topologies for speed + old_topology_atoms = list(self._old_topology.atoms()) + new_topology_atoms = list(self._new_topology.atoms()) for pidx in range(self.hybrid_system.getNumParticles()): if pidx in self._hybrid_to_old_map: idx = self._hybrid_to_old_map[pidx] - atom_list.append(list(self._old_topology.atoms())[idx]) + atom_list.append(old_topology_atoms[idx]) else: idx = self._hybrid_to_new_map[pidx] - atom_list.append(list(self._new_topology.atoms())[idx]) + atom_list.append(new_topology_atoms[idx]) # Now we loop over the atoms and add them in alongside chains & resids