예제 #1
0
    def analyze_transition_duration(self, trajectory, stateA, stateB):
        """Analysis to obtain transition durations for given state.

        Parameters
        ----------
        trajectory : :class:`.Trajectory`
            trajectory to analyze
        stateA : :class:`.Volume`
            initial state volume for the transition
        stateB : :class:`.Volume`
            final state volume for the transition

        Returns
        -------
        :class:`.TrajectorySegmentContainer`
            transitions from `stateA` to `stateB` within `trajectory`
        """
        # we define the transitions ensemble just in case the transition is,
        # e.g., fixed path length TPS. We want flexible path length ensemble
        transition_ensemble = paths.SequentialEnsemble([
            paths.AllInXEnsemble(stateA) & paths.LengthEnsemble(1),
            paths.OptionalEnsemble( # optional to allow instantaneous hops
                paths.AllOutXEnsemble(stateA) & paths.AllOutXEnsemble(stateB)
            ),
            paths.AllInXEnsemble(stateB) & paths.LengthEnsemble(1)
        ])
        segments = [seg[1:-1] for seg in transition_ensemble.split(trajectory)]
        return TrajectorySegmentContainer(segments, self.dt)
예제 #2
0
    def __init__(self, transition, snapshot, storage=None, engine=None,
                 extra_interfaces=None, forbidden_states=None):
        super(FullBootstrapping, self).__init__(storage, engine)
        if extra_interfaces is None:
            extra_interfaces = list()

        if forbidden_states is None:
            forbidden_states = list()
        interface0 = transition.interfaces[0]
        ensemble0 = transition.ensembles[0]
        state = transition.stateA
        self.state = state
        self.first_traj_ensemble = paths.SequentialEnsemble([
            paths.OptionalEnsemble(paths.AllOutXEnsemble(state)),
            paths.AllInXEnsemble(state),
            paths.OptionalEnsemble(
                paths.AllOutXEnsemble(state) & paths.AllInXEnsemble(interface0)
            ),
            paths.OptionalEnsemble(paths.AllInXEnsemble(interface0)),
            paths.AllOutXEnsemble(interface0),
            paths.OptionalEnsemble(paths.AllOutXEnsemble(state)),
            paths.SingleFrameEnsemble(paths.AllInXEnsemble(state))
        ]) & paths.AllOutXEnsemble(paths.join_volumes(forbidden_states))

        self.extra_ensembles = [paths.TISEnsemble(transition.stateA,
                                                  transition.stateB, iface,
                                                  transition.orderparameter)
                                for iface in extra_interfaces
        ]

        self.transition_shooters = [
            paths.OneWayShootingMover(selector=paths.UniformSelector(), 
                                      ensemble=ens) 
            for ens in transition.ensembles
        ]

        self.extra_shooters = [
            paths.OneWayShootingMover(selector=paths.UniformSelector(), 
                                      ensemble=ens) 
            for ens in self.extra_ensembles
        ]
        self.snapshot = snapshot.copy()
        self.ensemble0 = ensemble0
        self.all_ensembles = transition.ensembles + self.extra_ensembles
        self.n_ensembles = len(self.all_ensembles)
        self.error_max_rounds = True
예제 #3
0
    def get_lifetime_segments(trajectory, from_vol, to_vol, forbidden=None,
                              padding=[0, -1]):
        """General script to get lifetimes.

        Lifetimes for a transition between volumes are used in several other
        calculations: obviously, the state lifetime, but also the flux
        through an interface. This is a generic function to calculate that.

        Parameters
        ----------
        trajectory : :class:`.Trajectory`
            trajectory to analyze
        from_vol : :class:`.Volume`
            the volume for which this represents the lifetime: the
            trajectory segments returned are associated with the lifetime of
            `from_vol`
        to_vol : :class:`.Volume`
            the volume which indicates the end of the lifetime: a frame in
            this volume means the trajectory is no longer associated with
            `from_vol`
        forbidden : :class:`.Volume`
            if a frame is in `forbidden`, it cannot be part of the lifetime
            of `from_vol`. This isn't needed in 2-state lifetime
            calculations; however, it is useful to exclude other states
            from a flux calculation
        padding : list
            adjusts which frames are returned as list indices. That is, the
            returned segments are `full_segment[padding[0]:padding[1]]`.
            The `full_segment`s are the segments from (and including) each
            first frame in `from_vol` (after a visit to `to_vol`) until (and
            including) the first frame in `to_vol`. To get the full segment
            as output, use `padding=[None, None]`. The default is to remove
            the final frame (`padding=[0, -1]`) so that it doesn't include
            the frame in `to_vol`.

        Returns
        -------
        list of :class:`.Trajectory`
            the frames from (and including) each first entry from `to_vol`
            into `from_vol` until (and including) the next entry into
            `to_vol`, with no frames in `forbidden`, and with frames removed
            from the ends according to `padding`
        """
        if forbidden is None:
            forbidden = paths.EmptyVolume()
        ensemble_BAB = paths.SequentialEnsemble([
            paths.LengthEnsemble(1) & paths.AllInXEnsemble(to_vol),
            paths.PartInXEnsemble(from_vol) & paths.AllOutXEnsemble(to_vol),
            paths.LengthEnsemble(1) & paths.AllInXEnsemble(to_vol)
        ]) & paths.AllOutXEnsemble(forbidden)
        ensemble_AB = paths.SequentialEnsemble([
            paths.LengthEnsemble(1) & paths.AllInXEnsemble(from_vol),
            paths.OptionalEnsemble(paths.AllOutXEnsemble(to_vol)),
            paths.LengthEnsemble(1) & paths.AllInXEnsemble(to_vol) 
        ])
        BAB_split = ensemble_BAB.split(trajectory)
        AB_split = [ensemble_AB.split(part)[0] for part in BAB_split]
        return [subtraj[padding[0]:padding[1]] for subtraj in AB_split]