@@ -264,6 +264,19 @@ def make_compatible(system, fix_perturbable_zero_sigmas=False):
264264 new_bonds0 .set (idx0 , idx1 , p0 .function ())
265265 new_bonds1 .set (idx0 , idx1 , p1 .function ())
266266
267+ # Pass through unique terms that have no ghost in the state they exist in.
268+ for b_idx in bonds0_unique_idx .values ():
269+ p = bonds0 [b_idx ]
270+ a0 , a1 = p .atom0 (), p .atom1 ()
271+ if not _has_ghost (mol , [a0 , a1 ]):
272+ new_bonds0 .set (a0 , a1 , p .function ())
273+
274+ for b_idx in bonds1_unique_idx .values ():
275+ p = bonds1 [b_idx ]
276+ a0 , a1 = p .atom0 (), p .atom1 ()
277+ if not _has_ghost (mol , [a0 , a1 ], True ):
278+ new_bonds1 .set (a0 , a1 , p .function ())
279+
267280 # Set the new bonded terms.
268281 edit_mol = edit_mol .set_property ("bond0" , new_bonds0 ).molecule ()
269282 edit_mol = edit_mol .set_property ("bond1" , new_bonds1 ).molecule ()
@@ -366,6 +379,19 @@ def make_compatible(system, fix_perturbable_zero_sigmas=False):
366379 new_angles0 .set (idx0 , idx1 , idx2 , p0 .function ())
367380 new_angles1 .set (idx0 , idx1 , idx2 , p1 .function ())
368381
382+ # Pass through unique terms that have no ghost in the state they exist in.
383+ for a_idx in angles0_unique_idx .values ():
384+ p = angles0 [a_idx ]
385+ a0 , a1 , a2 = p .atom0 (), p .atom1 (), p .atom2 ()
386+ if not _has_ghost (mol , [a0 , a1 , a2 ]):
387+ new_angles0 .set (a0 , a1 , a2 , p .function ())
388+
389+ for a_idx in angles1_unique_idx .values ():
390+ p = angles1 [a_idx ]
391+ a0 , a1 , a2 = p .atom0 (), p .atom1 (), p .atom2 ()
392+ if not _has_ghost (mol , [a0 , a1 , a2 ], True ):
393+ new_angles1 .set (a0 , a1 , a2 , p .function ())
394+
369395 # Set the new angle terms.
370396 edit_mol = edit_mol .set_property ("angle0" , new_angles0 ).molecule ()
371397 edit_mol = edit_mol .set_property ("angle1" , new_angles1 ).molecule ()
@@ -479,6 +505,25 @@ def make_compatible(system, fix_perturbable_zero_sigmas=False):
479505 new_dihedrals0 .set (idx0 , idx1 , idx2 , idx3 , p0 .function ())
480506 new_dihedrals1 .set (idx0 , idx1 , idx2 , idx3 , p1 .function ())
481507
508+ # Pass through unique terms that have no ghost in the state they exist in.
509+ for d_idx in dihedrals0_unique_idx .values ():
510+ p = dihedrals0 [d_idx ]
511+ a0 = info .atom_idx (p .atom0 ())
512+ a1 = info .atom_idx (p .atom1 ())
513+ a2 = info .atom_idx (p .atom2 ())
514+ a3 = info .atom_idx (p .atom3 ())
515+ if not _has_ghost (mol , [a0 , a1 , a2 , a3 ]):
516+ new_dihedrals0 .set (a0 , a1 , a2 , a3 , p .function ())
517+
518+ for d_idx in dihedrals1_unique_idx .values ():
519+ p = dihedrals1 [d_idx ]
520+ a0 = info .atom_idx (p .atom0 ())
521+ a1 = info .atom_idx (p .atom1 ())
522+ a2 = info .atom_idx (p .atom2 ())
523+ a3 = info .atom_idx (p .atom3 ())
524+ if not _has_ghost (mol , [a0 , a1 , a2 , a3 ], True ):
525+ new_dihedrals1 .set (a0 , a1 , a2 , a3 , p .function ())
526+
482527 # Set the new dihedral terms.
483528 edit_mol = edit_mol .set_property ("dihedral0" , new_dihedrals0 ).molecule ()
484529 edit_mol = edit_mol .set_property ("dihedral1" , new_dihedrals1 ).molecule ()
@@ -605,6 +650,25 @@ def make_compatible(system, fix_perturbable_zero_sigmas=False):
605650 new_impropers0 .set (idx0 , idx1 , idx2 , idx3 , p0 .function ())
606651 new_impropers1 .set (idx0 , idx1 , idx2 , idx3 , p1 .function ())
607652
653+ # Pass through unique terms that have no ghost in the state they exist in.
654+ for i_idx in impropers0_unique_idx .values ():
655+ p = impropers0 [i_idx ]
656+ a0 = info .atom_idx (p .atom0 ())
657+ a1 = info .atom_idx (p .atom1 ())
658+ a2 = info .atom_idx (p .atom2 ())
659+ a3 = info .atom_idx (p .atom3 ())
660+ if not _has_ghost (mol , [a0 , a1 , a2 , a3 ]):
661+ new_impropers0 .set (a0 , a1 , a2 , a3 , p .function ())
662+
663+ for i_idx in impropers1_unique_idx .values ():
664+ p = impropers1 [i_idx ]
665+ a0 = info .atom_idx (p .atom0 ())
666+ a1 = info .atom_idx (p .atom1 ())
667+ a2 = info .atom_idx (p .atom2 ())
668+ a3 = info .atom_idx (p .atom3 ())
669+ if not _has_ghost (mol , [a0 , a1 , a2 , a3 ], True ):
670+ new_impropers1 .set (a0 , a1 , a2 , a3 , p .function ())
671+
608672 # Set the new improper terms.
609673 edit_mol = edit_mol .set_property ("improper0" , new_impropers0 ).molecule ()
610674 edit_mol = edit_mol .set_property ("improper1" , new_impropers1 ).molecule ()
0 commit comments