diff options
author | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-02-21 17:16:22 -0700 |
---|---|---|
committer | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-02-21 17:16:22 -0700 |
commit | 96eade3b9f72c5d1fa5bae27ba82a2cd23e1e200 (patch) | |
tree | 9a15f21713e356a79702c97ca9819f9e6228c344 | |
parent | 7a83a6e48a7503848bf1a4abd448f7858dca71e0 (diff) |
Add nuclear charge
-rw-r--r-- | ml_exp/compound.py | 11 | ||||
-rw-r--r-- | ml_exp/data.py | 141 | ||||
-rw-r--r-- | ml_exp/read_qm7_data.py | 11 |
3 files changed, 163 insertions, 0 deletions
diff --git a/ml_exp/compound.py b/ml_exp/compound.py index 6fd46fc3a..cfa3e0322 100644 --- a/ml_exp/compound.py +++ b/ml_exp/compound.py @@ -21,13 +21,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import numpy as np +from ml_exp.data import NUCLEAR_CHARGE class Compound: def __init__(self, xyz=None): + # empty_array = np.asarray([], dtype=float) + self.n = None self.atoms = None + self.atoms_nc = None self.coordinates = None + self.energy = None + + self.coulomb_matrix = None + self.lennard_jones_matrix = None + self.bob = None if xyz is not None: self.read_xyz(xyz) @@ -42,10 +51,12 @@ class Compound: self.n = int(lines[0]) self.atoms = [] + self.atoms_nc = np.empty(self.n, dtype=int) self.coordinates = np.empty((self.n, 3), dtype=float) for i, atom in enumerate(lines[2:self.n + 2]): atom_d = atom.split() self.atoms.append(atom_d[0]) + self.atoms_nc[i] = NUCLEAR_CHARGE[atom_d[0]] self.coordinates[i] = np.asarray(atom_d[1:4], dtype=float) diff --git a/ml_exp/data.py b/ml_exp/data.py new file mode 100644 index 000000000..243aff168 --- /dev/null +++ b/ml_exp/data.py @@ -0,0 +1,141 @@ +"""MIT License + +Copyright (c) 2019 David Luevano Alvarado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" +NUCLEAR_CHARGE = { + 'H': 1, + 'He': 2, + 'Li': 3, + 'Be': 4, + 'B': 5, + 'C': 6, + 'N': 7, + 'O': 8, + 'F': 9, + 'Ne': 10, + 'Na': 11, + 'Mg': 12, + 'Al': 13, + 'Si': 14, + 'P': 15, + 'S': 16, + 'Cl': 17, + 'Ar': 18, + 'K': 19, + 'Ca': 20, + 'Sc': 21, + 'Ti': 22, + 'V': 23, + 'Cr': 24, + 'Mn': 25, + 'Fe': 26, + 'Co': 27, + 'Ni': 28, + 'Cu': 29, + 'Zn': 30, + 'Ga': 31, + 'Ge': 32, + 'As': 33, + 'Se': 34, + 'Br': 35, + 'Kr': 36, + 'Rb': 37, + 'Sr': 38, + 'Y': 39, + 'Zr': 40, + 'Nb': 41, + 'Mo': 42, + 'Tc': 43, + 'Ru': 44, + 'Rh': 45, + 'Pd': 46, + 'Ag': 47, + 'Cd': 48, + 'In': 49, + 'Sn': 50, + 'Sb': 51, + 'Te': 52, + 'I': 53, + 'Xe': 54, + 'Cs': 55, + 'Ba': 56, + 'La': 57, + 'Ce': 58, + 'Pr': 59, + 'Nd': 60, + 'Pm': 61, + 'Sm': 62, + 'Eu': 63, + 'Gd': 64, + 'Tb': 65, + 'Dy': 66, + 'Ho': 67, + 'Er': 68, + 'Tm': 69, + 'Yb': 70, + 'Lu': 71, + 'Hf': 72, + 'Ta': 73, + 'W': 74, + 'Re': 75, + 'Os': 76, + 'Ir': 77, + 'Pt': 78, + 'Au': 79, + 'Hg': 80, + 'Tl': 81, + 'Pb': 82, + 'Bi': 83, + 'Po': 84, + 'At': 85, + 'Rn': 86, + 'Fr': 87, + 'Ra': 88, + 'Ac': 89, + 'Th': 90, + 'Pa': 91, + 'U': 92, + 'Np': 93, + 'Pu': 94, + 'Am': 95, + 'Cm': 96, + 'Bk': 97, + 'Cf': 98, + 'Es': 99, + 'Fm': 100, + 'Md': 101, + 'No': 102, + 'Lr': 103, + 'Rf': 104, + 'Db': 105, + 'Sg': 106, + 'Bh': 107, + 'Hs': 108, + 'Mt': 109, + 'Ds ': 110, + 'Rg ': 111, + 'Cn ': 112, + 'Nh': 113, + 'Fl': 114, + 'Mc': 115, + 'Lv': 116, + 'Ts': 117, + 'Og': 118} diff --git a/ml_exp/read_qm7_data.py b/ml_exp/read_qm7_data.py index 81be05a17..63c48195c 100644 --- a/ml_exp/read_qm7_data.py +++ b/ml_exp/read_qm7_data.py @@ -49,6 +49,17 @@ def read_nc_data(data_path): return {line[2]: int(line[0]) for line in lines} +# For use in the rewriting of the code (from functional programming to object +# oriented programming-ish) +def print_nc(nc_data): + """ + Prints the nuclear charge data to the terminal. + nc_data: dict of nc. + """ + for key in nc_data.keys(): + print(f'\'{key}\': {nc_data[key]},') + + # 'hof_qm7.txt.txt' retrieved from # https://github.com/qmlcode/tutorial def read_db_data(zi_data, |