def start_minimization(self, which_min): job = {} saddle_path = os.path.join(config.path_incomplete, self.finished_saddle_name) mode_file = open(os.path.join(saddle_path, "mode.dat")) mode = io.load_mode(mode_file) mode_file.close() reactant_file = open(os.path.join(saddle_path, "saddle.con")) reactant = io.loadcon(reactant_file) reactant_file.close() if which_min == "min2": mode = -mode reactant.r += config.process_search_minimization_offset*mode reactIO = StringIO.StringIO() io.savecon(reactIO, reactant) job['pos.con'] = reactIO ini_changes = [ ('Main', 'job', 'minimization') ] job['config.ini'] = io.modify_config(config.config_path, ini_changes) return job
def start_minimization(self, which_min): job = {} saddle_path = os.path.join(config.path_incomplete, self.finished_saddle_name) mode_file = open(os.path.join(saddle_path, "mode.dat")) mode = io.load_mode(mode_file) mode_file.close() reactant_file = open(os.path.join(saddle_path, "saddle.con")) reactant = io.loadcon(reactant_file) reactant_file.close() if which_min == "min2": mode = -mode reactant.r += config.process_search_minimization_offset * mode reactIO = StringIO.StringIO() io.savecon(reactIO, reactant) job['pos.con'] = reactIO ini_changes = [('Main', 'job', 'minimization')] job['config.ini'] = io.modify_config(config.config_path, ini_changes) return job
#!/usr/bin/env python import sys import numpy import pathfix import fileio as io m1 = io.load_mode(sys.argv[1]) m2 = io.load_mode(sys.argv[2]) print (m1 * m2).sum()
def add_process(self, result, superbasin=None): """ Adds a process to this State. """ state.State.add_process(self, result) self.set_good_saddle_count(self.get_good_saddle_count() + 1) resultdata = result[ "results"] #The information from the result.dat file if 'simulation_time' in resultdata: self.increment_time(resultdata['simulation_time'], resultdata['md_temperature']) # We may not already have the energy for this State. If not, it should be placed in the result data. if self.get_energy() is None: # This energy now defines the reference energy for the state self.set_energy(resultdata["potential_energy_reactant"]) reactant_energy = self.get_energy() # Calculate the forward barrier for this process, and abort if the energy is too high. oldlowest = self.get_lowest_barrier() barrier = resultdata["potential_energy_saddle"] - reactant_energy lowest = self.update_lowest_barrier(barrier) ediff = (barrier - lowest) - (self.statelist.kT * (self.statelist.thermal_window + self.statelist.max_thermal_window)) if ediff > 0.0: self.append_search_result(result, "barrier > max_thermal_window", superbasin) return None # Determine the number of processes in the process table that have a similar energy. id = self.find_repeat(result["saddle.con"], barrier) if id != None: self.append_search_result(result, "repeat-%d" % id, superbasin) self.procs[id]['repeats'] += 1 self.save_process_table() if result['type'] == "random" or result['type'] == "dynamics": self.inc_proc_random_count(id) # Do not increase repeats if we are currently in a # superbasin and the process does not lead out of it; # or if the process barrier is outside the thermanl # window. if id in self.get_relevant_procids(superbasin): self.inc_repeats() if 'simulation_time' in resultdata: current_time = self.get_time() logger.debug("event %3i found at time %f fs" % (id, current_time)) return None # This appears to be a unique process. # Check if the mode, reactant, saddle, and product are legit try: if 'mode' not in result: io.load_mode(result['mode.dat']) if 'reactant' not in result: io.loadcon(result['reactant.con']) if 'saddle' not in result: io.loadcon(result['saddle.con']) if 'product' not in result: io.loadcon(result['product.con']) except: logger.exception( "Mode, reactant, saddle, or product has incorrect format") return None # Reset the repeat count. self.reset_repeats() # Respond to finding a new lowest barrier. self.set_unique_saddle_count(self.get_unique_saddle_count() + 1) if barrier == lowest and barrier < oldlowest - self.statelist.epsilon_e: logger.info("Found new lowest barrier %f for state %i (type: %s)", lowest, self.number, result['type']) logger.info("Found new barrier %f for state %i (type: %s)", barrier, self.number, result['type']) # Update the search result table. self.append_search_result(result, "good-%d" % self.get_num_procs(), superbasin) # The id of this process is the number of processes. id = self.get_num_procs() if 'simulation_time' in resultdata: current_time = self.get_time() logger.debug("new event %3i found at time %f fs" % (id, current_time)) # Move the relevant files into the procdata directory. open(self.proc_reactant_path(id), 'w').writelines(result['reactant.con'].getvalue()) open(self.proc_mode_path(id), 'w').writelines(result['mode.dat'].getvalue()) open(self.proc_product_path(id), 'w').writelines(result['product.con'].getvalue()) open(self.proc_saddle_path(id), 'w').writelines(result['saddle.con'].getvalue()) open(self.proc_results_path(id), 'w').writelines(result['results.dat'].getvalue()) # Append this barrier to the process table (in memory and on disk). self.append_process_table( id=id, saddle_energy=resultdata["potential_energy_saddle"], prefactor=resultdata["prefactor_reactant_to_product"], product=-1, product_energy=resultdata["potential_energy_product"], product_prefactor=resultdata["prefactor_product_to_reactant"], barrier=barrier, rate=resultdata["prefactor_reactant_to_product"] * math.exp(-barrier / self.statelist.kT), repeats=0) # If this is a random search type, add this proc to the random proc dict. if result['type'] == "random" or result['type'] == "dynamics": self.inc_proc_random_count(id) # This was a unique process, so return the id. return id
def get_process_mode(self, id): return io.load_mode(self.proc_mode_path(id))
#!/usr/bin/env python import sys import numpy import pathfix import fileio as io m1 = io.load_mode(sys.argv[1]) m2 = io.load_mode(sys.argv[2]) print(m1 * m2).sum()