def from_state_pairs(cls, state_pairs): sampling = [] transitions = {} for (initial, final) in state_pairs: if len(sampling) == 1: sampling[0].add_transition(initial, final) elif len(sampling) == 0: sampling = [paths.TPSTransition(initial, final)] else: raise RuntimeError( "More than one sampling transition for TPS?") transitions[(initial, final)] = paths.TPSTransition(initial, final) network = cls.__new__(cls) super(cls, network).__init__() network._sampling_transitions = sampling network.transitions = transitions return network
def __init__(self, initial_states, final_states): super(TPSNetwork, self).__init__() try: iter(initial_states) except TypeError: initial_states = [initial_states] try: iter(final_states) except TypeError: final_states = [final_states] all_initial = paths.join_volumes(initial_states) all_initial.name = "|".join([v.name for v in initial_states]) all_final = paths.join_volumes(final_states) all_final.name = "|".join([v.name for v in final_states]) self._sampling_transitions = [ paths.TPSTransition(all_initial, all_final) ] self.transitions = { (initial, final): paths.TPSTransition(initial, final) for (initial, final) in itertools.product(initial_states, final_states) if initial != final }
def setup(self): op = paths.FunctionCV("Id", lambda snap: snap.coordinates[0][0]) vol1 = paths.CVDefinedVolume(op, 0.1, 0.5) vol2 = paths.CVDefinedVolume(op, -0.1, 0.7) vol3 = paths.CVDefinedVolume(op, 2.0, 2.5) self.stateA = vol1 self.stateB = vol3 self.interfaceA0 = vol2 self.stateX = ~vol1 & ~vol3 transition = paths.TPSTransition(self.stateA, self.stateB) self.analyzer = paths.TrajectoryTransitionAnalysis(transition, dt=0.1) self.traj_str = "aaaxaxxbxaxababaxbbbbbxxxxxxa" # frame numbers "0 5 0 5 0 5 8" self.trajectory = self._make_traj(self.traj_str)