How to use the openpathsampling.ensemble.AllInXEnsemble function in openpathsampling

To help you get started, we’ve selected a few openpathsampling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpathsampling / openpathsampling / examples / alanine / ala_dipeptide_example.py View on Github external
We do this by using a special sequential ensemble for the sequence.
This path ensemble is particularly complex because we want to be sure that
the path we generate is in the ensemble we desire: this means that we can't
use PartOutXEnsemble as we typically do with TIS paths.
    """
    snapshot = engine.storage.snapshots.load(0)

    first_traj_ensemble = SequentialEnsemble([
        AllOutXEnsemble(stateA) | LengthEnsemble(0),
        AllInXEnsemble(stateA),
        (AllOutXEnsemble(stateA) & AllInXEnsemble(interface0)) | LengthEnsemble(0),
        AllInXEnsemble(interface0) | LengthEnsemble(0),
        AllOutXEnsemble(interface0),
        AllOutXEnsemble(stateA) | LengthEnsemble(0),
        AllInXEnsemble(stateA) & LengthEnsemble(1)
    ])

    interface0_ensemble = interface_set[0]
    print "start path generation (should not take more than a few minutes)"
    total_path = engine.generate(snapshot,
                                    [first_traj_ensemble.can_append])
    print "path generation complete"
    print
    print "Total trajectory length: ", len(total_path)
    segments = interface0_ensemble.split(total_path)
    print "Traj in first_traj_ensemble? (should be)", 
    print first_traj_ensemble(total_path)
    print "Traj in TIS ensemble? (probably not)", 
    print interface0_ensemble(total_path)
    print "Number of segments in TIS ensemble: ", len(segments)
    if len(segments):
github openpathsampling / openpathsampling / examples / alanine / ala_dipeptide_example.py View on Github external
We do this by using a special sequential ensemble for the sequence.
This path ensemble is particularly complex because we want to be sure that
the path we generate is in the ensemble we desire: this means that we can't
use PartOutXEnsemble as we typically do with TIS paths.
    """
    snapshot = engine.storage.snapshots.load(0)

    first_traj_ensemble = SequentialEnsemble([
        AllOutXEnsemble(stateA) | LengthEnsemble(0),
        AllInXEnsemble(stateA),
        (AllOutXEnsemble(stateA) & AllInXEnsemble(interface0)) | LengthEnsemble(0),
        AllInXEnsemble(interface0) | LengthEnsemble(0),
        AllOutXEnsemble(interface0),
        AllOutXEnsemble(stateA) | LengthEnsemble(0),
        AllInXEnsemble(stateA) & LengthEnsemble(1)
    ])

    interface0_ensemble = interface_set[0]
    print "start path generation (should not take more than a few minutes)"
    total_path = engine.generate(snapshot,
                                    [first_traj_ensemble.can_append])
    print "path generation complete"
    print
    print "Total trajectory length: ", len(total_path)
    segments = interface0_ensemble.split(total_path)
    print "Traj in first_traj_ensemble? (should be)", 
    print first_traj_ensemble(total_path)
    print "Traj in TIS ensemble? (probably not)", 
    print interface0_ensemble(total_path)
    print "Number of segments in TIS ensemble: ", len(segments)
    if len(segments):
github openpathsampling / openpathsampling / examples / alanine / ala_dipeptide_simple.py View on Github external
interface_set = ef.TISEnsembleSet(stateA, stateA | stateB, volume_set)
    for no, interface in enumerate(interface_set):
        # Give each interface a name
        interface.name = 'Interface '+str(no)
        # And save all of these
        engine.storage.ensembles.save()

    mover_set = mf.OneWayShootingSet(UniformSelector(), interface_set)

    snapshot = engine.storage.snapshots.load(0)
    
    first_traj_ensemble = SequentialEnsemble([
        AllOutXEnsemble(stateA) | LengthEnsemble(0),
        AllInXEnsemble(stateA),
        (AllOutXEnsemble(stateA) & AllInXEnsemble(interface0)) | LengthEnsemble(0),
        AllInXEnsemble(interface0) | LengthEnsemble(0),
        AllOutXEnsemble(interface0),
        AllOutXEnsemble(stateA) | LengthEnsemble(0),
        AllInXEnsemble(stateA) & LengthEnsemble(1)
    ])

    interface0_ensemble = interface_set[0]
    print "start path generation (should not take more than a few minutes)"
    total_path = engine.generate(snapshot,
                                    [first_traj_ensemble.can_append])
    print "path generation complete"
    print
    print "Total trajectory length: ", len(total_path)
    segments = interface0_ensemble.split(total_path)
    print "Traj in first_traj_ensemble? (should be)", 
    print first_traj_ensemble(total_path)
    print "Traj in TIS ensemble? (probably not)",
github openpathsampling / openpathsampling / openpathsampling / ensemble.py View on Github external
def StartXEnsemble(volume):
        """
        Construct an ensemble that starts (x[0]) in the specified volume

        Parameters
        ----------
        volume : :class:`openpathsampling.volume.Volume`
            The volume to start in

        Returns
        -------
        ensemble : :class:`openpathsampling.ensemble.Ensemble`
            The constructed Ensemble
        """
        return AllInXEnsemble(volume, 0)
github openpathsampling / openpathsampling / openpathsampling / ensemble.py View on Github external
----------
        volume_a : :class:`openpathsampling.volume.Volume`
            The volume to start in 
        volume_b : :class:`openpathsampling.volume.Volume`
            The volume to end in 
        
        Returns
        -------
        ensemble : :class:`openpathsampling.ensemble.Ensemble`
            The constructed Ensemble
        '''        
        # TODO: this is actually only for flexible path length TPS now
        return SequentialEnsemble([
            SingleFrameEnsemble(AllInXEnsemble(volume_a)),
            AllOutXEnsemble(volume_a | volume_b),
            SingleFrameEnsemble(AllInXEnsemble(volume_b))
        ])
github openpathsampling / openpathsampling / openpathsampling / ensemble.py View on Github external
n_initial_states = len(initial_states)
        except TypeError:
            n_initial_states = 1
            initial_states = [initial_states]

        try:
            n_final_states = len(final_states)
        except TypeError:
            n_final_states = 1
            final_states = [final_states]

        volume_a = paths.volume.join_volumes(initial_states)
        volume_b = paths.volume.join_volumes(final_states)

        super(TISEnsemble, self).__init__([
            AllInXEnsemble(volume_a) & LengthEnsemble(1),
            AllOutXEnsemble(volume_a | volume_b) & PartOutXEnsemble(interface),
            AllInXEnsemble(volume_a | volume_b) & LengthEnsemble(1)
        ])

        self.initial_states = initial_states
        self.final_states = final_states
        self.interface = interface
#        self.name = interface.name
        self.orderparameter = orderparameter
github openpathsampling / openpathsampling / openpathsampling / ensemble.py View on Github external
self.state_vol = state_vol
        try:
            innermost_vols = list(innermost_vols)
        except TypeError:
            innermost_vols = [innermost_vols]

        self.innermost_vols = innermost_vols
        #self.innermost_vol = paths.volume.join_volumes(self.innermost_vols)
        self.innermost_vol = paths.FullVolume()
        for vol in self.innermost_vols:
            self.innermost_vol = self.innermost_vol & vol
        self.greedy = greedy
        inA = AllInXEnsemble(state_vol)
        outA = AllOutXEnsemble(state_vol)
        outX = AllOutXEnsemble(self.innermost_vol)
        inX = AllInXEnsemble(self.innermost_vol)
        leaveX = PartOutXEnsemble(self.innermost_vol)
        interstitial = outA & inX
        segment_ensembles = [paths.TISEnsemble(state_vol, state_vol, inner)
                             for inner in self.innermost_vols]

        self._segment_ensemble = join_ensembles(segment_ensembles)

        #interstitial = AllInXEnsemble(self.innermost_vol - state_vol)
        start = [
            SingleFrameEnsemble(inA),
            OptionalEnsemble(interstitial),
        ]
        loop = [
            outA & leaveX,
            inX # & hitA # redundant due to stop req for previous outA
        ]
github openpathsampling / openpathsampling / openpathsampling / ensemble.py View on Github external
def EndXEnsemble(volume):
        """
        Construct an ensemble that ends (x[-1]) in the specified volume

        Parameters
        ----------
        volume : :class:`openpathsampling.volume.Volume`
            The volume to end in

        Returns
        -------
        ensemble : :class:`openpathsampling.ensemble.Ensemble`
            The constructed Ensemble
        """
        return AllInXEnsemble(volume, -1)
github openpathsampling / openpathsampling / openpathsampling / attic / sandbox.py View on Github external
print op(tt[0])
        s = Snapshot(coordinates=tt[0].coordinates)
        print op(s)

        # Check if the trajectory goes from lambda < 0.06 to lambda >0.08 and back    
        print 'In ensemble'
        print tis(tt)
        
        en = ef.A2BEnsemble(lV, lV, True)
        print en(tt)

        en = AllInXEnsemble(lV, 0)
        print en(tt)

        en = AllInXEnsemble(lV, -1)
        print en(tt)

        en = AllOutXEnsemble(lV, slice(1,-1), lazy = False)
        print en(tt)

        storage.ensemble.save(en)

        bm = BackwardShootMover(
                selector = UniformSelector(),
                ensemble = tis
                )

        fm = ForwardShootMover(
                selector = UniformSelector(),
                ensemble = tis
                )
github openpathsampling / openpathsampling / openpathsampling / ensemble.py View on Github external
def EndXEnsemble(volume):
        '''
        Construct an ensemble that ends (x[-1]) in the specified volume
        
        Parameters
        ----------
        volume : :class:`openpathsampling.volume.Volume`
            The volume to end in 
        
        Returns
        -------
        ensemble : :class:`openpathsampling.ensemble.Ensemble`
            The constructed Ensemble
        '''        
        return AllInXEnsemble(volume, -1)