diff options
author | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-02-21 18:13:33 -0700 |
---|---|---|
committer | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-02-21 18:13:33 -0700 |
commit | efaa8eeb58d8e19d32f94ec4e91ec794574dfd32 (patch) | |
tree | 02c5250412880b0d50aebd028e975902dd809c18 | |
parent | bb5e608f0ca6491e1abfd7fd25d2f28ff6c96e6b (diff) |
Coulomb matrix done, fix init
-rw-r--r-- | ml_exp/__init__.py | 27 | ||||
-rw-r--r-- | ml_exp/compound.py | 28 | ||||
-rw-r--r-- | ml_exp/representations.py | 10 |
3 files changed, 33 insertions, 32 deletions
diff --git a/ml_exp/__init__.py b/ml_exp/__init__.py index 06425f6a2..8e803b37e 100644 --- a/ml_exp/__init__.py +++ b/ml_exp/__init__.py @@ -20,29 +20,10 @@ 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. """ -from ml_exp.read_qm7_data import read_nc_data, read_db_data, read_qm7_data -from ml_exp.c_matrix import c_matrix, c_matrix_multiple -from ml_exp.lj_matrix import lj_matrix, lj_matrix_multiple -from ml_exp.frob_norm import frob_norm -from ml_exp.gauss_kernel import gauss_kernel -from ml_exp.cholesky_solve import cholesky_solve -from ml_exp.do_ml import do_ml -from ml_exp.parallel_create_matrices import parallel_create_matrices -from ml_exp.misc import plot_benchmarks - +from ml_exp.compound import Compound +from ml_exp.representations import coulomb_matrix # If somebody does "from package import *", this is what they will # be able to access: -__all__ = ['read_nc_data', - 'read_db_data', - 'read_qm7_data', - 'c_matrix', - 'c_matrix_multiple', - 'lj_matrix', - 'lj_matrix_multiple', - 'frob_norm', - 'gauss_kernel', - 'cholesky_solve', - 'do_ml', - 'parallel_create_matrices', - 'plot_benchmarks'] +__all__ = ['Compound', + 'coulomb_matrix'] diff --git a/ml_exp/compound.py b/ml_exp/compound.py index 9536767a7..3ea377826 100644 --- a/ml_exp/compound.py +++ b/ml_exp/compound.py @@ -22,10 +22,16 @@ SOFTWARE. """ import numpy as np from ml_exp.data import NUCLEAR_CHARGE +from ml_exp.representations import coulomb_matrix class Compound: - def __init__(self, xyz=None): + def __init__(self, + xyz=None): + """ + Initialization of the Compound. + xyz: (path to) the xyz file. + """ # empty_array = np.asarray([], dtype=float) self.n = None @@ -41,10 +47,24 @@ class Compound: if xyz is not None: self.read_xyz(xyz) - def gen_cm(self): - pass + def gen_cm(self, + size=23, + as_eig=True, + bohr_ru=False): + """ + Generate the Coulomb Matrix for the compund. + size: compound size. + as_eig: if the representation should be as the eigenvalues. + bhor_ru: if radius units should be in bohr's radius units. + """ + self.coulomb_matrix = coulomb_matrix(self.coordinates, + self.atoms_nc, + size=size, + as_eig=as_eig, + bhor_ru=bohr_ru) - def read_xyz(self, filename): + def read_xyz(self, + filename): """ Reads an xyz file and adds the corresponding data to the Compound. filename: (path to) the xyz file. diff --git a/ml_exp/representations.py b/ml_exp/representations.py index bbc538ae6..c503c310d 100644 --- a/ml_exp/representations.py +++ b/ml_exp/representations.py @@ -28,16 +28,16 @@ def coulomb_matrix(coords, nc, size=23, as_eig=True, - bohr_radius_units=False): + bhor_ru=False): """ Creates the Coulomb Matrix from the molecule data given. coords: compound coordinates. nc: nuclear charge data. size: compound size. - as_eig: if data should be returned as matrix or array of eigenvalues. - bohr_radius_units: if units should be in bohr's radius units. + as_eig: if the representation should be as the eigenvalues. + bhor_ru: if radius units should be in bohr's radius units. """ - if bohr_radius_units: + if bhor_ru: cr = 0.52917721067 else: cr = 1 @@ -54,7 +54,7 @@ def coulomb_matrix(coords, size = n nr = range(size) - cm = np.empty((size, size), dtype=float) + cm = np.zeros((size, size), dtype=float) # Actual calculation of the coulomb matrix. for i in nr: |