def pre_we(self):
        starttime = time.time()
        segments = self.sim_manager.segments.values()
        bin_mapper = self.system.bin_mapper
        self.find_mappers()

        # For now, assume one wexploreMapper
        wexploreMapper = self.wexploreMappers[0]['base_mapper']

        final_pcoords = np.empty((len(segments), self.system.pcoord_ndim), dtype=self.system.pcoord_dtype)

        for iseg, segment in enumerate(segments):
            final_pcoords[iseg] = segment.pcoord[-1,:]

        hash_init = wexploreMapper.last_graph
        kwargs = {'add_bins': True, 'n_regions': self.system.n_regions}
        assignments = bin_mapper.assign(final_pcoords, **kwargs)

        # Re-assign segments to new bins if bin_mapper changes
        if wexploreMapper.last_graph != hash_init:
            # The mapper has updated; force an update to the system mapper.
            bin_mapper.refresh_mappers()
            self.target_counts()

            # Reset we_driver internal data structures.  This includes sending in the target states,
            # as the bins have changed (we also need to feed in the initial states).
            target_states = []
            tstates = self.system.tstates
            tstates_strio = cStringIO.StringIO('\n'.join(tstates).replace(',', ' '))
            target_states.extend(TargetState.states_from_file(tstates_strio, self.system.pcoord_dtype))
            initial_states = []
            self.data_manager.save_target_states(target_states)
            #self.sim_manager.report_target_states(target_states)
            for key,value in self.we_driver.avail_initial_states.iteritems():
                initial_states.append(value)
            self.we_driver.new_iteration(target_states=target_states, initial_states=initial_states)

            # Re-assign segments
            self.we_driver.assign(segments)

        # Reset target counts to account for new iteration.
        self.target_counts(coords=final_pcoords, startup=False)

        endtime = time.time()

        # Report level statistics
        s = 1
        westpa.rc.pstatus('--wexplore-stats--------------------')
        westpa.rc.pstatus('wallclock time: {:.3f} s'.format(endtime - starttime))
        westpa.rc.pstatus('')
        for li, level in enumerate(wexploreMapper.level_indices):
            s *= wexploreMapper.n_regions[li]
            westpa.rc.pstatus('Level {}: {} cells ({} max)'.format(li, len(level), s))
        westpa.rc.pstatus('------------------------------------')
        westpa.rc.pflush()
Exemple #2
0
system = westpa.rc.get_system_driver()
sim_manager = westpa.rc.get_sim_manager()
propagator = westpa.rc.get_propagator()
data_manager = westpa.rc.get_data_manager()
h5file = data_manager.we_h5filename

data_manager.system = system
we_driver = westpa.rc.get_we_driver()

with work_manager:
    if work_manager.is_master:    
        # Process target states
        target_states = []
        if args.tstate_file:
            target_states.extend(TargetState.states_from_file(args.tstate_file, system.pcoord_dtype))
        if args.tstates:
            tstates_strio = cStringIO.StringIO('\n'.join(args.tstates).replace(',', ' '))
            target_states.extend(TargetState.states_from_file(tstates_strio, system.pcoord_dtype))
            del tstates_strio
                    
        # Process basis states
        basis_states = []
        if args.bstate_file:
            basis_states.extend(BasisState.states_from_file(args.bstate_file))
        if args.bstates:
            for bstate_str in args.bstates:
                fields = bstate_str.split(',')
                label=fields[0]
                probability=float(fields[1])
                try:
Exemple #3
0
system = westpa.rc.get_system_driver()
sim_manager = westpa.rc.get_sim_manager()
propagator = westpa.rc.get_propagator()
data_manager = westpa.rc.get_data_manager()
h5file = data_manager.we_h5filename

data_manager.system = system
we_driver = westpa.rc.get_we_driver()

with work_manager:
    if work_manager.is_master:
        # Process target states
        target_states = []
        if args.tstate_file:
            target_states.extend(
                TargetState.states_from_file(args.tstate_file,
                                             system.pcoord_dtype))
        if args.tstates:
            tstates_strio = io.StringIO('\n'.join(args.tstates).replace(
                ',', ' '))
            target_states.extend(
                TargetState.states_from_file(tstates_strio,
                                             system.pcoord_dtype))
            del tstates_strio

        # Process basis states
        basis_states = []
        if args.bstate_file:
            basis_states.extend(BasisState.states_from_file(args.bstate_file))
        if args.bstates:
            for bstate_str in args.bstates:
                fields = bstate_str.split(',')
Exemple #4
0
         tprob = sum(bstate.probability for bstate in basis_states)
         if abs(1.0 - tprob) > len(basis_states) * EPS:
             pscale = 1/tprob
             log.warning('Basis state probabilities do not add to unity; rescaling by {:g}'.format(pscale))
             for bstate in basis_states:
                 bstate.probability *= pscale        
         
         # Assign progress coordinates to basis states
         sim_manager.get_bstate_pcoords(basis_states, n_iter)
         data_manager.create_ibstate_group(basis_states, n_iter)
         sim_manager.report_basis_states(basis_states)
         
     # Now handle target states
     target_states = []
     if args.tstate_file:
         target_states.extend(TargetState.states_from_file(args.tstate_file, system.pcoord_dtype))
     if args.tstates:
         tstates_strio = io.StringIO('\n'.join(args.tstates).replace(',', ' '))
         target_states.extend(TargetState.states_from_file(tstates_strio, system.pcoord_dtype))
         del tstates_strio
         
     if not target_states:
         westpa.rc.pstatus('No target states specified.')
     else:
         data_manager.save_target_states(target_states, n_iter)
         sim_manager.report_target_states(target_states)
         
     data_manager.update_iter_group_links(n_iter)
     
 else: # args.mode == 'append'
     if args.bstate_file or args.bstates: