Beispiel #1
0
def submit():
    parser = argparse.ArgumentParser(
        description="Submit task to yascheduler daemon")
    parser.add_argument('script')

    args = parser.parse_args()
    if not os.path.isfile(args.script):
        raise ValueError("Script parameter is not a file name")
    inputs = {}
    with open(args.script) as f:
        for l in f.readlines():
            try:
                k, v = l.split('=')
                inputs[k.strip()] = v.strip()
            except ValueError:
                pass
    config = ConfigParser()
    config.read(CONFIG_FILE)
    yac = Yascheduler(config)
    task_id = yac.queue_submit_task(
        inputs['LABEL'], {
            'structure': open(inputs['STRUCT']).read(),
            'input': open(inputs['INPUT']).read(),
            'local_folder': os.getcwd()
        })

    print("Successfully submitted task: {}".format(task_id))
    yac.connection.close()
                                     elem_pair,
                                     more_query_args=dict(lattices='cubic'))
    structures_by_sgn = {}

    for s in structures:
        structures_by_sgn.setdefault(s.info['spacegroup'].no, []).append(s)

    for sgn_cls in structures_by_sgn:

        if how_many and counter >= how_many: raise SystemExit

        # get structures with the minimal number of atoms and find one with the median cell vectors
        minimal_struct = min([len(s) for s in structures_by_sgn[sgn_cls]])
        cells = np.array([
            s.get_cell().reshape(9) for s in structures_by_sgn[sgn_cls]
            if len(s) == minimal_struct
        ])
        median_cell = np.median(cells, axis=0)
        median_idx = int(
            np.argmin(np.sum((cells - median_cell)**2, axis=1)**0.5))
        target_obj = structures_by_sgn[sgn_cls][median_idx]

        f34_input = Fort34([bs_repo[el] for el in elem_pair])
        struct_input = f34_input.from_ase(target_obj)
        struct_input = str(struct_input)
        setup_input = get_input(calc_setup['parameters']['crystal'], elem_pair,
                                bs_repo, target_obj.info['phase'])

        yac.queue_submit_task(target_obj.info['phase'],
                              dict(structure=struct_input, input=setup_input))
        counter += 1
Beispiel #3
0
work_folder = os.path.dirname(target)
setup_input = open(target).read()

try:
    sys.argv[2]
except IndexError:
    folder = None
    print('**To save calc in a local repo**')
else:
    folder = work_folder
    print('**To save calc in an input folder**')

if os.path.exists(os.path.join(work_folder, 'fort.34')):
    assert "EXTERNAL" in setup_input
    struct_input = open(os.path.join(work_folder, 'fort.34')).read()
else:
    assert "EXTERNAL" not in setup_input
    struct_input = "UNUSED"

label = setup_input.splitlines()[0]

config = ConfigParser()
config.read(CONFIG_FILE)
yac = Yascheduler(config)

result = yac.queue_submit_task(
    label, dict(structure=struct_input, input=setup_input,
                local_folder=folder))
print(label)
print(result)
Beispiel #4
0
try: symprec = float(sys.argv[2])
except: symprec = 3E-02 # NB needs tuning
print('symprec = %s' % symprec)

label = sys.argv[1].split(os.sep)[-1].split('.')[0] + \
    " " + spglib.get_spacegroup(ase_obj, symprec=symprec)

ase_obj, error = refine(ase_obj, accuracy=symprec, conventional_cell=True)
assert not error, error

yaconfig = ConfigParser()
yaconfig.read(CONFIG_FILE)
yac = Yascheduler(yaconfig)

calc_setup = get_template()
bs_repo = get_basis_sets(calc_setup['basis_family'])

#bs_repo_tzvp = get_basis_sets('./tzvp_RE')
#bs_repo_other = get_basis_sets('./hand_made_bs')
#bs_repo = {**bs_repo_tzvp , **bs_repo_other}

elements = list(set(ase_obj.get_chemical_symbols()))
f34_input = Fort34([bs_repo[el] for el in elements])
struct_input = str(f34_input.from_ase(ase_obj))
setup_input = get_input(calc_setup['parameters']['crystal'], elements, bs_repo, label)

result = yac.queue_submit_task(label, dict(structure=struct_input, input=setup_input))
print(label)
print(result)