Ejemplo n.º 1
0
tda_params = {'integral': '(acc2e=12)', 'tda': '(50-50)', 'guess': 'read'}
nmr_params = {'integral': '(acc2e=12)', 'guess': 'read', 'nmr': ''}

# define the rings used to calculate NICS
six_mem_a = [0, 1, 2, 3, 4, 5]
six_mem_b = [1, 2, 6, 7, 8, 9]
five_mem_a = [0, 1, 9, 13, 12]
five_mem_b = [2, 3, 10, 11, 6]

index = int(sys.argv[1])

# use absolute path so we don't loose track of the db when changing directory
db = TinyDB(os.path.abspath('structures.json'))
query = Query()
compound = db.get(query.index == index)
rin = GaussianInput.from_dict(compound['input'])
directory = rin.title


def calculate_properties(rin, directory):

    with cd(directory):

        # found that the relax often crashed or didn't finish, so will restart
        # the calculation in these cases
        try:
            rout = GaussianOutput('relax.log')
            if not rout.properly_terminated:
                logging.info('restarting {}'.format(directory))
                route = rout.route
                route['integral'] = '(acc2e=12)'
                'nicss_six_ring_below': nicss_six_ring_below,
                'nicss_five_ring_above': nicss_five_ring_above,
                'nicss_five_ring_below': nicss_five_ring_below,
                'nicst_six_ring_above': nicst_six_ring_above,
                'nicst_six_ring_below': nicst_six_ring_below,
                'nicst_five_ring_above': nicst_five_ring_above,
                'nicst_five_ring_below': nicst_five_ring_below}
    return data


data_to_write = []
db = TinyDB(os.path.join('..', 'data', 'structures.json'))
systems = list(db.all())
done = 0
for i, system in enumerate(systems):
    input_file = GaussianInput.from_dict(system['input'])
    directory = input_file.title
    tar_name = '{}.tar.gz'.format(directory)
    tar_file = os.path.abspath(os.path.join('..', 'data', 'calculations', tar_name))
    if os.path.isfile(tar_file):
        # extract the data in a temp directory to avoid clobbering any data
        with tempdir() as tmp_dir:
            shutil.copy(tar_file, tmp_dir)
            data = extract_data_from_tar_file(tar_name)
            if not data:
                print('{} did not finish correctly, skipping'.format(directory))
                continue
            data.update({'x_sub': system['x_sub'], 'y_sub': system['y_sub'],
                         'z_sub': system['z_sub'], 'nx': system['nx'],
                         'ny': system['ny'], 'title': system['title']})
            data_to_write.append(data)