def __init__(self, cv, minvals, maxvals, period_min=None,
              period_max=None, intersect_with=None):
     volume_func = lambda minv, maxv: paths.PeriodicCVDefinedVolume(
         cv, minv, maxv, period_min, period_max
     )
     self.period_min = period_min
     self.period_max = period_max
     super(PeriodicVolumeInterfaceSet, self).__init__(cv, minvals,
                                                      maxvals,
                                                      intersect_with,
                                                      volume_func)
Beispiel #2
0
    def from_dict(cls, dct):
        interface_set = cls.__new__(cls)

        interface_set._load_from_dict(dct)
        interface_set.period_min = dct['period_min']
        interface_set.period_max = dct['period_max']
        volume_func = lambda minv, maxv: paths.PeriodicCVDefinedVolume(
            interface_set.cv, minv, maxv, interface_set.period_min,
            interface_set.period_max)
        super(InterfaceSet, interface_set).__init__()
        interface_set._set_volume_func(volume_func)
        return interface_set
 def test_new_interface(self):
     new_iface = self.increasing_set.new_interface(-140)
     expected = paths.PeriodicCVDefinedVolume(self.cv, 0.0, -140, -180, 180)
     assert_equal(new_iface, expected)
# In[6]:


# define the CVs
psi = paths.MDTrajFunctionCV("psi", md.compute_dihedrals, template.topology, indices=[[6,8,14,16]])
phi = paths.MDTrajFunctionCV("phi", md.compute_dihedrals, template.topology, indices=[[4,6,8,14]])


# In[7]:


# define the states
deg = 180.0/np.pi
C_7eq = (
    paths.PeriodicCVDefinedVolume(phi, lambda_min=-180/deg, lambda_max=0/deg, 
                                  period_min=-np.pi, period_max=np.pi) &
    paths.PeriodicCVDefinedVolume(psi, lambda_min=100/deg, lambda_max=200/deg,
                                  period_min=-np.pi, period_max=np.pi)
).named("C_7eq")
# similarly, without bothering with the labels:
alpha_R = (paths.PeriodicCVDefinedVolume(phi, -180/deg, 0/deg, -np.pi, np.pi) &
           paths.PeriodicCVDefinedVolume(psi, -100/deg, 0/deg, -np.pi, np.pi)).named("alpha_R")


# ## Getting a first trajectory
# 
# The idea here is a little subtle, but it makes nice use of our generalized path ensemble idea.
# 
# We want a path which contains at least one frame in each state. The question is, what ensemble can we use to create such a trajectory?
# 
# The first obvious thought would be `goal_ensemble = PartInXEnsemble(stateA) & PartInXEnsemble(stateB)` (which can, of course, be further generalized to more states). However, while that *is* the ensemble we want to eventually satisfy, we can't use its `can_append` to create it, because its `can_append` always returns `True`: the trajectory will go on forever!