Révision 86cf3a38 modules/refinement.py
b/modules/refinement.py | ||
---|---|---|
1 |
import logging |
|
2 |
|
|
3 |
logger = logging.getLogger('DockOnSurf') |
|
4 |
|
|
5 |
|
|
6 |
def select_confs(orig_conf_list, energy_cutoff, code): |
|
7 |
"""From a list of atomic configurations selects the most stable ones. |
|
8 |
|
|
9 |
Given a list of ase.Atoms configurations and an energy cutoff, selects all |
|
10 |
the structures that have an energy at most the value of energy cutoff larger |
|
11 |
than the most stable one. |
|
12 |
@param orig_conf_list: The original list of atomic configurations |
|
13 |
@param energy_cutoff: The maximum energy above the most stable configuration |
|
14 |
@param code: the code used to carry out the screening of structures. |
|
15 |
@return: list of the the most stable configurations within the energy cutoff |
|
16 |
""" |
|
17 |
from copy import deepcopy |
|
18 |
from modules.formats import read_energies |
|
19 |
|
|
20 |
conf_list = deepcopy(orig_conf_list) |
|
21 |
selected_ids = [] |
|
22 |
conf_enrgs = read_energies(code, 'screening') * 27.2113845 # Ha to eV |
|
23 |
|
|
24 |
for i, conf in enumerate(conf_list): |
|
25 |
conf.info['energy'] = conf_enrgs[i] |
|
26 |
|
|
27 |
sorted_list = sorted(conf_list, key=lambda conf: conf.info['energy']) |
|
28 |
lowest_e = sorted_list[0].info['energy'] |
|
29 |
return [conf for conf in sorted_list |
|
30 |
if conf.info['energy'] < lowest_e + energy_cutoff] |
|
31 |
|
|
32 |
|
|
1 | 33 |
def run_refinement(inp_vars): |
2 |
pass |
|
34 |
"""Carries out the refinement of adsorbate-slab structures after screening. |
|
35 |
|
|
36 |
@param inp_vars: Calculation parameters from input file. |
|
37 |
""" |
|
38 |
import os |
|
39 |
from modules.formats import read_coords |
|
40 |
from modules.calculation import run_calc |
|
41 |
if not os.path.isdir("screening"): |
|
42 |
err = "'screening' directory not found. It is needed in order to carry " |
|
43 |
"out the refinement of structures to be adsorbed" |
|
44 |
logger.error(err) |
|
45 |
raise ValueError(err) |
|
46 |
|
|
47 |
conf_list = read_coords(inp_vars['code'], 'screening', 'ase') |
|
48 |
logger.info(f"Found {len(conf_list)} structures on screening directory.") |
|
49 |
selected_confs = select_confs(conf_list, inp_vars['energy_cutoff'], |
|
50 |
inp_vars['code']) |
|
51 |
run_calc('refinement', inp_vars, selected_confs) |
Formats disponibles : Unified diff