def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--charge', type=int, default=0, help='charge') parser.add_argument('-m', '--multiplicity', type=int, default=1, help='multiplicity') parser.add_argument('--scftype', type=str, default='rhf', choices=['rhf', 'uhf'], help='SCF type (rhf/uhf)') parser.add_argument("input_file", metavar='file', type=str, help='input coordinate file') parser.add_argument('--scan', type=int, nargs=2, help='scan between two atoms') parser.add_argument('--cycle', type=int, default=350, help='maximum number of optimization cycles') args = parser.parse_args() from Molecule import Molecule mol = Molecule.from_xyz(args.input_file) method_args = { 'charge': args.charge, 'multiplicity': args.multiplicity, 'scftype': args.scftype, 'software': 'xtb' } Xtb(mol, method_args) import optimiser print('optimising') optimiser.optimise(mol, method_args) if args.scan: pass
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--charge', type=int, default=0, help='charge') parser.add_argument('-m', '--multiplicity', type=int, default=1, help='multiplicity') parser.add_argument('--scftype', type=str, default='rhf', choices=['rhf', 'uhf'], help='SCF type (rhf/uhf)') parser.add_argument("input_file", metavar='file', type=str, help='input coordinate file') parser.add_argument('-o', '--opt', action='store_true', help='optimize') parser.add_argument('-g', '--gamma', type=float, default=0.0, help='optimize') parser.add_argument('--cycle', type=int, default=350, help='maximum number of optimization cycles') parser.add_argument('-f1', nargs='+', type=int, help='atoms in the first fragment') parser.add_argument('-f2', nargs='+', type=int, help='atoms in the second fragment') args = parser.parse_args() from Molecule import Molecule mol = Molecule.from_xyz(args.input_file) mol.fragments = [args.f1, args.f2] method_args = { 'charge': args.charge, 'multiplicity': args.multiplicity, 'scftype': args.scftype, 'software': 'turbomole' } Turbomole(mol, method_args) if args.opt: import optimiser turbomole_logger.info('optimising') optimiser.optimise(mol, method_args, args.gamma) else: make_coord(mol.atoms_list, mol.coordinates) prepare_control(charge=method_args['charge'], multiplicity=method_args['multiplicity']) turbomole_logger.info('created input file')
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('-s', type=int, required=True, nargs=2, help='scan between two atoms') parser.add_argument('-c', '--charge', type=int, default=0, help='charge') parser.add_argument('-m', '--multiplicity', type=int, default=1, help='multiplicity') parser.add_argument('--scftype', type=str, default= 'rhf', choices= ['rhf', 'uhf'], help='SCF type (rhf/uhf)') parser.add_argument("input_file", metavar='file', type=str, help='input coordinate file') parser.add_argument('-o', '--opt', action='store_true', help='optimize') args = parser.parse_args() from Molecule import Molecule mol = Molecule.from_xyz(args.input_file) method_args = { 'charge': args.charge, 'multiplicity': args.multiplicity, 'scftype': args.scftype, 'software': 'orca' } a, b = args.s coordinates = mol.coordinates import numpy as np start_dist = np.linalg.norm(coordinates[a] - coordinates[b]) final_distance = mol.covalent_radius[a] + mol.covalent_radius[b] step = int(abs(final_distance - start_dist)*10) c_k = '\n!ScanTS\n% geom scan B '+str(a)+' '+str(b)+ '= '+ str(start_dist)\ + ', ' + str(final_distance) + ', ' + str(step) + ' end end\n' geometry = Orca(mol, method_args, custom_keyword=c_k) if args.opt: import optimiser print('optimising') optimiser.optimise(mol, method_args, 0.0, custom_keyword=c_k) else: print('created input file')
def add_one(aggregate_id, seeds, monomer, hm_orientations, method): """ :type aggregate_id str :type seeds list of Molecules :type monomer Molecule.Molecule :type hm_orientations int how many orientations :type method dict containing charge, multiplicity, software """ if check_stop_signal(): print("Function: add_one") return StopIteration print(' There are', len(seeds), 'seed molecules') cwd = os.getcwd() dict_of_optimized_molecules = {} for seed_count, each_seed in enumerate(seeds): if check_stop_signal(): print("Function: add_one") return print(' Seed: {}'.format(seed_count)) seed_id = "{:03d}".format(seed_count) seeds_home = 'seed_' + seed_id file_manager.make_directories(seeds_home) os.chdir(seeds_home) each_seed.mol_to_xyz('seed.xyz') monomer.mol_to_xyz('monomer.xyz') mol_id = '{0}_{1}'.format(seed_id, aggregate_id) all_orientations = tabu.generate_orientations(mol_id, seeds[seed_count], monomer, hm_orientations) for name, molecule in sorted(all_orientations.items(), key=operator.itemgetter(0)): o_status = optimise(molecule, method) if o_status is True: print(" E(%10s): %12.7f" % (name, molecule.energy)) dict_of_optimized_molecules[name] = molecule else: print(' Optimisation failed:', name, 'will be discarded') os.chdir(cwd) if len(dict_of_optimized_molecules) < 2: return list(dict_of_optimized_molecules.values()) print(" Clustering") selected_seeds = clustering.choose_geometries(dict_of_optimized_molecules) file_manager.make_directories('selected') for each_file in selected_seeds.values(): xyz_file = 'seed_' + each_file.name[ 4:7] + '/result_' + each_file.name + '.xyz' shutil.copy(xyz_file, 'selected/') return list(selected_seeds.values())
def evolve( self, renderedModels ): """renderedModels: [(fitness, surface, model)]""" self.models_ = optimiser.optimise( self.targetSurface_, renderedModels )
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('-N', type=int, required=True, help='number of points/configurations') parser.add_argument('-mpt', action='store_true', help='generate random points on the surface of a unit ' 'sphere') parser.add_argument('-mmc', action='store_true', help='generate N configurations of two molecules') parser.add_argument('-mcm', action='store_true', help='generate a composite molecule with seed and N ' 'monomers') parser.add_argument('-i', type=str, nargs=2, dest='file', help="two molecules, seed and monomer, " "in xyz file format") parser.add_argument('-method', choices=['random', 'rotating', 'uniform'], help="method for generating points") parser.add_argument( '-spr', type=str, help="create a molecules from N atoms of given elememts") parser.add_argument('-best', type=int, nargs=2, help="create the best orientation with lowest a b " "distance") args = parser.parse_args() print(args) tabu_logger.debug(args) N = args.N if args.file: from Molecule import Molecule seed = Molecule.from_xyz(args.file[0]) monomer = Molecule.from_xyz(args.file[1]) else: seed = None monomer = None if args.method == 'rotating': if args.file and monomer.number_of_atoms == 1: pts = rotating_octants(N, angle_tabu=False) else: pts = rotating_octants(N, angle_tabu=True) elif args.method == 'random': pts = make_random_points_and_angles(N) elif args.method == 'uniform': pts = uniformly_distributed_points(N) else: print('using default method: random') pts = make_random_points_and_angles(N) if args.mpt: plot_points(pts) if args.mmc: orientations = generate_orientations_from_points_and_angles( seed, monomer, pts) for i, each_orientation in enumerate(orientations): each_orientation.mol_to_xyz('mol' + str(i) + '.xyz') if args.mcm: import optimiser method_args = { 'charge': 0, 'multiplicity': 1, 'scftype': 'rhf', 'software': 'xtb' } for i in range(128): result = generate_composite_molecule(seed, monomer, pts) result.title = "trial_" + str(i).zfill(3) optimiser.optimise(result, method_args, 0.0) result.mol_to_xyz('result_' + str(i).zfill(3) + '.xyz') if args.spr: import scipy.spatial.distance as sdist from Molecule import Molecule from atomic_data import atomic_numbers, covalent_radii radii = covalent_radii[atomic_numbers[args.spr.capitalize()]] pts = pts[:, :3] factor = pts / 10 while np.min(sdist.pdist(pts)) < 2 * radii: pts += factor atoms = [args.spr for _ in range(N)] result = Molecule(atoms, pts) result.mol_to_xyz('mol.xyz') if args.best: a = args.best[0] b = seed.number_of_atoms + args.best[1] generate_guess_for_bonding('xxx', seed, monomer, a, b, N)
def main(): args = argument_parse() method_args = { 'charge': args.charge, 'multiplicity': args.multiplicity, 'scftype': args.scftype, 'software': args.software } N = args.hm_orientations size_of_aggregate = args.aggregate_size minimum_gamma = args.gmin maximum_gamma = args.gmax input_files = args.input_files input_molecules = setup_molecules(input_files) if args.aggregate: if size_of_aggregate is None: print('For an Aggregation run ' 'specify the aggregate size ' '(number of monomers to be added) ' 'using the argument\n -as <integer>') sys.exit() if N is None: print("For aggregation, specify how many orientations" "are to be used, by the argument\n" "-N <number of orientations>") if len(input_molecules) == 1: input_molecules.append(copy.copy(input_molecules[0])) monomer = input_molecules[-1] seeds = input_molecules[:-1] t1 = time.clock() aggregator.aggregate(seeds, monomer, aggregate_size=size_of_aggregate, hm_orientations=N, method=method_args) print('Time:', time.clock() - t1) if args.react: if len(input_molecules) == 1: print('Reactor requires at least two molecules') sys.exit() if minimum_gamma is None or maximum_gamma is None: print('For a Reactor run specify the ' 'values of gamma_min and gamma_max using \n' '-gmin <integer> -gmax <integer>') sys.exit() if N is None: print("For aggregation, specify how many orientations" "are to be used, by the argument\n" "-N <number of orientations>") t1 = time.clock() reactor.react(input_molecules[0], input_molecules[1], gamma_min=minimum_gamma, gamma_max=maximum_gamma, hm_orientations=N, method=method_args) print('Time:', time.clock() - t1) return if args.optimize: import csv with open('energy.csv', 'w') as csvfile: writer = csv.writer(csvfile) writer.writerow(["Name", "Energy"]) for each_mol in input_molecules: status = optimise(each_mol, method_args) if status is True: writer.writerow([each_mol.name, each_mol.energy]) else: writer.writerow([each_mol.name, None])
def add_one1(aggregate_id1, aggregate_id2, seeds1, seeds2, hm_orientations, method): """ """ seeds2 = seeds2[0] if check_stop_signal(): aggregator_logger.info("Function: add_one") return StopIteration aggregator_logger.info(' There are {} seed molecules'.format(len(seeds1))) cwd = os.getcwd() list_of_optimized_molecules = [] for seed_count, each_seed in enumerate(seeds1): if check_stop_signal(): print("Function: add_one") return print(' Seed: {}'.format(seed_count)) seed_id = "{:03d}".format(seed_count) seeds_home = 'seed_' + seed_id file_manager.make_directories(seeds_home) os.chdir(seeds_home) each_seed.mol_to_xyz('seed.xyz') seeds2.mol_to_xyz('monomer.xyz') mol_id = '{0}_{1}_{2}'.format(seed_id, aggregate_id1, aggregate_id2) all_orientations = tabu.generate_orientations(mol_id, seeds1[seed_count], seeds2, hm_orientations) not_converged = all_orientations[:] converged = [] for i in range(10): aggregator_logger.info( "Round %d of block optimizations with %d molecules" % (i + 1, len(not_converged))) if len(not_converged) == 0: break status_list = [ optimise(each_mol, method, max_cycles=350, convergence='loose') for each_mol in not_converged ] converged = [ n for n, s in zip(not_converged, status_list) if s is True ] list_of_optimized_molecules.extend(converged) not_converged = [ n for n, s in zip(not_converged, status_list) if s == 'CycleExceeded' ] not_converged = clustering.remove_similar(not_converged) os.chdir(cwd) print(list_of_optimized_molecules) if len(list_of_optimized_molecules) < 2: return list_of_optimized_molecules print(" Clustering") selected_seeds = clustering.choose_geometries(list_of_optimized_molecules) file_manager.make_directories('selected') for each_file in selected_seeds: status = optimise(each_file, method, max_cycles=350, convergence='normal') if status is True: xyz_file = 'seed_' + each_file.name[ 4: 7] + '/job_' + each_file.name + '/result_' + each_file.name + '.xyz' shutil.copy(xyz_file, 'selected/') else: selected_seeds.remove(each_file) return selected_seeds
#it0 = np.where(time >= t0)[0][0] #ite = np.where(time >= te)[0][0] it0 = 1 ite = -1 opti_choice = get_choice( 0, 1, "Enter 0 for direct filtering or 1 for optimisation: ") if opti_choice == 0: #s_r, s_q = [5, 0.2], [0.1, 0.5] # Default SDs for the R and Q matrices are the optimised ones from the average of four flights s_r, s_q = [11.44823232, 0.160505051], [0.0275, 0.183080808] else: # Run the optimisation script to find the best SDs for the specified flight s_r, s_q, error = optimiser.optimise(time, rssi_unf, gt, gt_rel, fnumber=sim_case, sim=(sim_choice == 1)) print("Running the Kalman Filter...") # x_filter = ["x_rel", "y_rel", "vx", "vy", "vx_other", "vy_other", "psi", "psi_other", "z_rel"] x_filter, d_g, d_f, d_unf, b_g, b_f, vel_g, vel_f, rssi_f = filter.kalman_filter( time, rssi_unf, gt, gt_rel, s_r=s_r, s_q=s_q) # Getting correlation between noise in range and different parameters noise = d_unf - d_f print("Correlations with noise:") corre_range = get_correlation(noise, d_f, "range") # Noise in range and range corre_vel = get_correlation(noise, vel_f, "velocity") # Noise in range and velocity corre_bearing = get_correlation(noise, b_f,
def main(): args = argument_parse() if args.verbosity == 0: logger.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(name)-12s %(filename)s %(funcName)s ' '%(lineno)d %(levelname)-8s: %(message)s') elif args.verbosity == 1: formatter = logging.Formatter('%(message)s') logger.setLevel(logging.INFO) elif args.verbosity == 2: formatter = logging.Formatter('%(message)s') logger.setLevel(logging.WARNING) elif args.verbosity == 3: formatter = logging.Formatter('%(message)s') logger.setLevel(logging.ERROR) elif args.verbosity == 4: formatter = logging.Formatter('%(message)s') logger.setLevel(logging.CRITICAL) else: formatter = logging.Formatter('%(message)s') logger.setLevel(logging.CRITICAL) handler.setFormatter(formatter) logger.addHandler(handler) logger.info('Starting PyAR at %s in %s' % (datetime.datetime.now(), os.getcwd())) logger.debug('Logging level is %d' % args.verbosity) logger.debug('Parsed arguments %s' % args) method_args = { 'charge': args.charge, 'multiplicity': args.multiplicity, 'scftype': args.scftype, 'software': args.software } logger.info('Charge: %s' % method_args['charge']) logger.info('Multiplicity: %s' % method_args['multiplicity']) logger.info('SCF Type: %s' % method_args['scftype']) logger.info('QM Software: %s' % method_args['software']) how_many_orientations = args.hm_orientations logger.info('%s orientations will be used' % how_many_orientations) input_molecules = setup_molecules(args.input_files) if args.site is None: site = None proximity_factor = 2.3 else: site = args.site proximity_factor = 2.3 if args.aggregate: size_of_aggregate = args.aggregate_size if size_of_aggregate is None: logger.error('For an Aggregation run ' 'specify the aggregate size ' '(number of monomers to be added) ' 'using the argument\n -as <integer>') sys.exit('Missing arguments: -as #') if how_many_orientations is None: logger.error("For aggregation, specify how many orientations" "are to be used, by the argument\n" "-number_of_orientations <number of orientations>") sys.exit('Missing arguments: -N #') if len(input_molecules) == 1: print('Provide at least two files') sys.exit('Missing arguments: Provide at least two files') else: monomer = input_molecules[-1] seeds = input_molecules[:-1] t1 = time.clock() aggregator.aggregate(seeds, monomer, aggregate_size=size_of_aggregate, hm_orientations=how_many_orientations, method=method_args) logger.info('Total Time: {}'.format(time.clock() - t1)) if args.react: minimum_gamma = args.gmin maximum_gamma = args.gmax if len(input_molecules) == 1: logger.error('Reactor requires at least two molecules') sys.exit('Missing arguments: provide at least two molecules') if minimum_gamma is None or maximum_gamma is None: logger.error('For a Reactor run specify the ' 'values of gamma_min and gamma_max using \n' '-gmin <integer> -gmax <integer>') sys.exit('missing arguments: -gmin <integer> -gmax <integer>') if how_many_orientations is None: logger.error("For reaction, specify how many orientations" "are to be used, by the argument\n" "-number_of_orientations <number of orientations>") sys.exit('Missing argumetns: -N #') if site is not None: site = [site[0], input_molecules[0].number_of_atoms + site[1]] t1 = time.clock() number_of_orientations = int(how_many_orientations) reactor.react(input_molecules[0], input_molecules[1], gamma_min=minimum_gamma, gamma_max=maximum_gamma, hm_orientations=number_of_orientations, method=method_args, site=site, proximity_factor=proximity_factor) logger.info('Total run time: {}'.format(time.clock() - t1)) return if args.optimize: if args.gamma: gamma = args.gamma else: gamma = 0.0 list_of_optimized_molecules = optimiser.bulk_optimize( input_molecules, method_args, gamma) if len(list_of_optimized_molecules) == 0: print('no optimized molecules') energy_dict = {n.name: n.energy for n in input_molecules} write_csv_file('energy.csv', energy_dict) from data_analysis import clustering clustering_results = clustering.choose_geometries( list_of_optimized_molecules) logger.info(clustering_results) if args.makebond: a = args.makebond[0] b = input_molecules[0].number_of_atoms + args.makebond[1] if how_many_orientations is None: logger.error("For aggregation, specify how many orientations" "are to be used, by the argument\n" "-N <number of orientations>") sys.exit('Missing arguments: -N #') molecules = tabu.generate_guess_for_bonding( 'abc', input_molecules[0], input_molecules[1], a, b, int(number_of_orientations)) for each_molecule in molecules: coordinates = each_molecule.coordinates start_dist = np.linalg.norm(coordinates[a] - coordinates[b]) final_distance = each_molecule.covalent_radius[a] + \ each_molecule.covalent_radius[b] step = int(abs(final_distance - start_dist) * 10) if args.software == 'orca': c_k = '\n!ScanTS\n% geom scan B ' + str(a) + ' ' + str(b) +\ '= ' + str(start_dist) + ', ' + str(final_distance) + \ ', ' + str(step) + ' end end\n' optimiser.optimise(each_molecule, method_args, 0.0, custom_keyword=c_k) else: print('Optimization with %s is not implemented yet' % args.software)
# -*- coding: utf-8 -*- """ The script produces the results in the case where background is included. It calculates the values of tau and the fraction of the background in the signal at the minimum of the NLL. It then calculates their respective errors by method of changing the NLL by 0.5 units. """ import dataRead import fit import optimiser import numpy as np a = optimiser.optimise() a.dualOptimiserGradient() # finds minimum tau and a. a.ErrorHalfNLLBackground( ) # finds errors in tau and a by chaning NLL by 0.5 units
def optimize_all(gamma_id, gamma, orientations_to_optimize, product_dir, method): cwd = os.getcwd() table_of_optimized_molecules = {} for job_key, this_molecule in sorted(orientations_to_optimize.items(), key=operator.itemgetter(0)): print(' Orientation:', job_key) o_key = u"_{}".format(job_key[-8:]) orientations_home = 'orientation' + o_key file_manager.make_directories(orientations_home) os.chdir(orientations_home) na, nb = [len(i) for i in this_molecule.fragments] fragment.make_fragment_file(na, nb) job_name = gamma_id + o_key this_molecule.name = job_name print(' Optimizing', this_molecule.name, ':') start_xyz_file_name = 'trial_' + this_molecule.name + '.xyz' this_molecule.mol_to_xyz(start_xyz_file_name) start_inchi = interface.babel.make_inchi_string_from_xyz( start_xyz_file_name) start_smile = interface.babel.make_smile_string_from_xyz( start_xyz_file_name) status = optimise(this_molecule, method, gamma=gamma) this_molecule.name = job_name print(' job completed') if status is True or status == 'converged' or status == 'cycle_exceeded': print(" E(%s): %12.7f" % (job_name, this_molecule.energy)) if this_molecule.is_bonded() is True: print( " The fragments have close contracts. Going for relaxation" ) this_molecule.mol_to_xyz('trial_relax.xyz') this_molecule.name = 'relax' status = optimise(this_molecule, method) this_molecule.name = job_name if status is True: current_inchi = interface.babel.make_inchi_string_from_xyz( 'result_relax.xyz') current_smile = interface.babel.make_smile_string_from_xyz( 'result_relax.xyz') print(' geometry relaxed') print( "Checking for product formation with SMILE and InChi strings" ) print("Start SMILE:", start_smile, "Current SMILE:", current_smile) print("Start InChi:", start_inchi, "Current InChi:", current_inchi) if start_inchi != current_inchi or start_smile != current_smile: table_of_product_molecules[job_name] = this_molecule print( " The geometry is different from the stating structure." ) print(" Checking if this is a (new) products") if current_inchi not in table_of_product_inchi_strings.values( ): if current_smile not in table_of_product_smile_strings.values( ): print(" New Product! Saving") table_of_product_inchi_strings[ job_name] = current_inchi table_of_product_smile_strings[ job_name] = current_smile table_of_product_molecules[ job_name] = this_molecule table_of_product_keys_inchis[ job_name] = current_inchi shutil.copy( 'result_relax.xyz', product_dir + '/' + job_name + '.xyz') os.chdir(cwd) continue else: print("SMILE matches") os.chdir(cwd) continue else: print("InChi matches") os.chdir(cwd) continue else: table_of_optimized_molecules[job_name] = this_molecule print( job_name, 'is added to the table to optimize with higher gamma' ) else: table_of_optimized_molecules[job_name] = this_molecule print(job_name, 'no close contacts found') print(job_name, 'is added to the table to optimize with higher gamma') os.chdir(cwd) sys.stdout.flush() return table_of_optimized_molecules
def optimize_all(gamma_id, gamma, orientations_to_optimize, product_dir, method): cwd = os.getcwd() table_of_optimized_molecules = [] for this_molecule in orientations_to_optimize: job_key = this_molecule.name reactor_logger.info(' Orientation: {}'.format(job_key)) o_key = "_{}".format(job_key[-8:]) orientations_home = 'orientation' + o_key file_manager.make_directories(orientations_home) os.chdir(orientations_home) job_name = gamma_id + o_key this_molecule.name = job_name reactor_logger.info('Optimizing {}'.format(this_molecule.name)) start_xyz_file_name = 'trial_' + this_molecule.name + '.xyz' this_molecule.mol_to_xyz(start_xyz_file_name) start_inchi = interface.babel.make_inchi_string_from_xyz( start_xyz_file_name) start_smile = interface.babel.make_smile_string_from_xyz( start_xyz_file_name) status = optimise(this_molecule, method, gamma=gamma) before_relax = copy.copy(this_molecule) this_molecule.name = job_name reactor_logger.info('... completed') if status is True or status == 'converged' or status == 'cycle_exceeded': reactor_logger.info(" E({}): {:12.7f}".format( job_name, this_molecule.energy)) if this_molecule.is_bonded(): reactor_logger.info( "The fragments have close contracts. Going for relaxation") this_molecule.mol_to_xyz('trial_relax.xyz') this_molecule.name = 'relax' status = optimise(this_molecule, method) this_molecule.name = job_name if status is True or status == 'converged': this_molecule.mol_to_xyz('result_relax.xyz') current_inchi = interface.babel.make_inchi_string_from_xyz( 'result_relax.xyz') current_smile = interface.babel.make_smile_string_from_xyz( 'result_relax.xyz') reactor_logger.info('geometry relaxed') reactor_logger.info( "Checking for product formation with SMILE and InChi strings" ) reactor_logger.info( "Start SMILE: {} Current SMILE: {}".format( start_smile, current_smile)) reactor_logger.info( "Start InChi: {} Current InChi: {}".format( start_inchi, current_inchi)) if start_inchi != current_inchi or start_smile != current_smile: saved_products[job_name] = this_molecule reactor_logger.info(" The geometry is different " "from the stating structure.") reactor_logger.info( " Checking if this is a (new)" " products") if current_inchi not in saved_inchi_strings.values() and \ current_smile not in saved_smile_strings.values(): reactor_logger.info(" New Product! Saving") saved_inchi_strings[job_name] = current_inchi saved_smile_strings[job_name] = current_smile saved_products[job_name] = this_molecule shutil.copy('result_relax.xyz', product_dir + '/' + job_name + '.xyz') os.chdir(cwd) continue else: reactor_logger.info("Both strings matches with " "those of already saved " "products. Discarded") os.chdir(cwd) continue else: table_of_optimized_molecules.append(before_relax) reactor_logger.info('{} is added to the table to ' 'optimize with higher ' 'gamma'.format(job_name)) elif status == 'cycle_exceeded': table_of_optimized_molecules.append(before_relax) reactor_logger.info('{} is added to the table to optimize ' 'with higher gamma'.format(job_name)) else: table_of_optimized_molecules.append(this_molecule) reactor_logger.info(' no close contacts found') reactor_logger.info( ' {} is added to the table to ' 'optimize with higher gamma'.format(job_name)) os.chdir(cwd) sys.stdout.flush() return table_of_optimized_molecules
except RuntimeError as err: sys.exit(err) if args.convertto == 'whitespace': for stmt in program: print(stmt.towhitespace(), end='') elif args.convertto == 'printable': for stmt in program: print(stmt.toprintable()) elif args.convertto == 'assembly': for stmt in program: print(stmt.toassembly()) elif args.convertto == 'python': print(topython(program)) elif args.convertto == 'optimised': print(optimise(program)) elif args.run == 'python': try: exec(topython(program)) except SystemExit: pass elif args.run == 'optimised': try: exec(optimise(program)) except SystemExit: pass else: themachine = machine(program) while themachine.step(): pass