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