def test_flux_no_dt(self): analyzer = paths.TrajectoryTransitionAnalysis(self.transition) flux_iface_traj_str = "aixixaiaxiixiaxaixbxbixiaaixiai" flux_traj = self._make_traj(flux_iface_traj_str) flux = analyzer.flux(trajectories=[flux_traj], state=self.stateA, interface=self.interfaceA0)
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)
def trajectory_transition_flux_dict(self, minus_steps): """ Main minus move-based flux analysis routine. Parameters ---------- minus_steps: list of :class:`.MCStep` steps that used the minus movers Returns ------- dict of {(:class:`.Volume, :class:`.Volume`): dict} keys are (state, interface); values are the result dict from :meth:`.TrajectoryTransitionAnalysis.analyze_flux` (keys are strings 'in' and 'out', mapping to :class:`.TrajectorySegmentContainer` with appropriate frames. """ # set up a few mappings that make it easier set up other things flux_pair_to_transition = { (trans.stateA, trans.interfaces[0]): trans for trans in self.network.sampling_transitions } flux_pair_to_minus_mover = {(m.minus_ensemble.state_vol, m.minus_ensemble.innermost_vol): m for m in self.minus_movers} minus_mover_to_flux_pair = { flux_pair_to_minus_mover[k]: k for k in flux_pair_to_minus_mover } flux_pair_to_minus_ensemble = { (minus_ens.state_vol, minus_ens.innermost_vol): minus_ens for minus_ens in self.network.minus_ensembles } # sanity checks -- only run once per analysis, so keep them in for pair in self.flux_pairs: assert pair in flux_pair_to_transition.keys() assert pair in flux_pair_to_minus_mover.keys() assert len(self.flux_pairs) == len(minus_mover_to_flux_pair) # organize the steps by mover used mover_to_steps = collections.defaultdict(list) for step in minus_steps: mover_to_steps[step.change.canonical.mover].append(step) # create the actual TrajectoryTransitionAnalysis objects to use transition_flux_calculators = { k: paths.TrajectoryTransitionAnalysis( transition=flux_pair_to_transition[k], dt=flux_pair_to_minus_mover[k].engine.snapshot_timestep) for k in self.flux_pairs } # do the analysis results = {} flux_pairs = self.progress(self.flux_pairs, desc="Flux") for flux_pair in flux_pairs: (state, innermost) = flux_pair mover = flux_pair_to_minus_mover[flux_pair] calculator = transition_flux_calculators[flux_pair] minus_ens = flux_pair_to_minus_ensemble[flux_pair] # TODO: this won't work for SR minus, I don't think # (but neither would our old version) trajectories = [ s.active[minus_ens].trajectory for s in mover_to_steps[mover] ] mover_trajs = self.progress(trajectories, leave=False) results[flux_pair] = calculator.analyze_flux( trajectories=mover_trajs, state=state, interface=innermost) return results