dockonsurf / modules / screening.py @ f3d1e601
Historique | Voir | Annoter | Télécharger (2,55 ko)
1 |
import logging |
---|---|
2 |
import numpy as np |
3 |
import ase |
4 |
|
5 |
logger = logging.getLogger('DockOnSurf')
|
6 |
|
7 |
|
8 |
def get_atom_coords(atoms: ase.Atoms, ctrs_list): |
9 |
pass
|
10 |
|
11 |
|
12 |
def ads_euler(site, ctr, pts_angle, neigh_ctr): |
13 |
pass
|
14 |
|
15 |
|
16 |
def ads_chemcat(site, ctr, pts_angle): |
17 |
pass
|
18 |
|
19 |
|
20 |
def adsorb_confs(conf_list, surf, ads_ctrs, sites, algo, num_pts, neigh_ctrs): |
21 |
surf_ads_list = [] |
22 |
sites_coords = get_atom_coords(surf, sites) |
23 |
for conf in conf_list: |
24 |
molec_ctr_coords = get_atom_coords(conf, ads_ctrs) |
25 |
molec_neigh_coords = get_atom_coords(conf, neigh_ctrs) |
26 |
for site in sites_coords: |
27 |
for i, molec_ctr in enumerate(molec_ctr_coords): |
28 |
if algo == 'euler': |
29 |
surf_ads_list.append(ads_euler(site, molec_ctr, num_pts, |
30 |
molec_neigh_coords[i])) |
31 |
elif algo == 'chemcat': |
32 |
surf_ads_list.append(ads_chemcat(site, molec_ctr, num_pts)) |
33 |
return surf_ads_list
|
34 |
|
35 |
|
36 |
def run_screening(inp_vars): |
37 |
"""Carry out the screening of adsorbate coordinates on a surface
|
38 |
|
39 |
@param inp_vars: Calculation parameters from input file.
|
40 |
"""
|
41 |
import os |
42 |
import numpy as np |
43 |
from modules.formats import read_coords, read_energies, \ |
44 |
rdkit_mol_to_ase_atoms, adapt_format |
45 |
from modules.clustering import get_rmsd, clustering |
46 |
from modules.isolated import get_moments_of_inertia, get_neighbors |
47 |
from modules.calculation import run_calc |
48 |
|
49 |
if not os.path.isdir("isolated"): |
50 |
err = "'isolated' directory not found. It is needed in order to carry "
|
51 |
"out the screening of structures to be adsorbed"
|
52 |
logger.error(err) |
53 |
raise ValueError(err) |
54 |
|
55 |
conf_list = read_coords(inp_vars['code'], 'isolated', 'rdkit') |
56 |
# TODO Implement neighbors algorithm
|
57 |
# neigh_list = get_neighbors(conf_list[0], inp_vars['molec_ads_ctrs'])
|
58 |
conf_enrgs = read_energies(inp_vars['code'], 'isolated') |
59 |
mois = np.array([get_moments_of_inertia(conf)[0] for conf in conf_list]) |
60 |
rmsd_mtx = get_rmsd(conf_list) |
61 |
exemplars = clustering(rmsd_mtx) |
62 |
conf_list = [conf_list[idx] for idx in exemplars] |
63 |
conf_list = [rdkit_mol_to_ase_atoms(conf) for conf in conf_list] |
64 |
surf = adapt_format('ase', inp_vars['surf_file']) |
65 |
surf_ads_list = adsorb_confs(conf_list, surf, inp_vars['molec_ads_ctrs'],
|
66 |
inp_vars['sites'], inp_vars['ads_algo'], |
67 |
inp_vars['sample_points_per_angle'],
|
68 |
inp_vars['molec_neigh_ctrs'])
|
69 |
run_calc('screening', inp_vars, surf_ads_list)
|