@@ -732,31 +732,58 @@ def getFrame(self, index):
732
732
# Create a copy of the existing system object.
733
733
old_system = self ._system .copy ()
734
734
735
- # Update the coordinates and velocities and return a mapping between
736
- # the molecule indices in the two systems.
737
- sire_system , mapping = _SireIO .updateCoordinatesAndVelocities (
738
- old_system ._sire_object ,
739
- new_system ._sire_object ,
740
- self ._mapping ,
741
- is_lambda1 ,
742
- self ._property_map ,
743
- self ._property_map ,
744
- )
735
+ if isinstance (self ._protocol , _Protocol ._FreeEnergyMixin ):
736
+ # Udpate the coordinates and velocities and return a mapping between
737
+ # the molecule indices in the two systems.
738
+ mapping = {
739
+ _SireMol .MolIdx (x ): _SireMol .MolIdx (x )
740
+ for x in range (0 , self ._squashed_system .nMolecules ())
741
+ }
742
+ (
743
+ self ._squashed_system ._sire_object ,
744
+ _ ,
745
+ ) = _SireIO .updateCoordinatesAndVelocities (
746
+ self ._squashed_system ._sire_object ,
747
+ new_system ._sire_object ,
748
+ mapping ,
749
+ is_lambda1 ,
750
+ self ._property_map ,
751
+ self ._property_map ,
752
+ )
753
+
754
+ # Update the unsquashed system based on the updated squashed system.
755
+ old_system = _unsquash (
756
+ old_system ,
757
+ self ._squashed_system ,
758
+ self ._mapping ,
759
+ explicit_dummies = self ._explicit_dummies ,
760
+ )
761
+
762
+ else :
763
+ # Update the coordinates and velocities and return a mapping between
764
+ # the molecule indices in the two systems.
765
+ sire_system , mapping = _SireIO .updateCoordinatesAndVelocities (
766
+ old_system ._sire_object ,
767
+ new_system ._sire_object ,
768
+ self ._mapping ,
769
+ is_lambda1 ,
770
+ self ._property_map ,
771
+ self ._property_map ,
772
+ )
745
773
746
- # Update the underlying Sire object.
747
- old_system ._sire_object = sire_system
774
+ # Update the underlying Sire object.
775
+ old_system ._sire_object = sire_system
748
776
749
- # Store the mapping between the MolIdx in both systems so we don't
750
- # need to recompute it next time.
751
- self ._mapping = mapping
777
+ # Store the mapping between the MolIdx in both systems so we don't
778
+ # need to recompute it next time.
779
+ self ._mapping = mapping
752
780
753
781
# Update the box information in the original system.
754
- if self ._has_box :
755
- if "space" in new_system ._sire_object .propertyKeys ():
756
- box = new_system ._sire_object .property ("space" )
757
- old_system ._sire_object .setProperty (
758
- self ._property_map .get ("space" , "space" ), box
759
- )
782
+ if "space" in new_system ._sire_object .propertyKeys ():
783
+ box = new_system ._sire_object .property ("space" )
784
+ old_system ._sire_object .setProperty (
785
+ self ._property_map .get ("space" , "space" ), box
786
+ )
760
787
761
788
return old_system
762
789
0 commit comments