From 7257a4f8fb1d94a05c1c9c44c4dedfc6d0a986f2 Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 21:28:46 +0100 Subject: [PATCH 1/8] Added citations --- README.rst | 57 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index a02fe798..44bccf55 100644 --- a/README.rst +++ b/README.rst @@ -85,15 +85,60 @@ How to use How to cite =========== -.. code-block:: python +Please cite the representation that you are using accordingly. + +- **Implementation** + Toolkit for Quantum Chemistry Machine Learning, + https://github.com/qmlcode/qmllib, + +- **FCHL19** `generate_fchl19` + FCHL revisited: Faster and more accurate quantum machine learning, + Christensen, Bratholm, Faber, Lilienfeld, + J. Chem. Phys. 152, 044107 (2020), + https://doi.org/10.1063/1.5126701 + +- **FCHL18** `generate_fchl18` + Alchemical and structural distribution based representation for universal quantum machine learning + Faber, Christensen, Huang, Lilienfeld, + J. Chem. Phys. 148, 241717 (2018), + https://doi.org/10.1063/1.5020710 + +- **Columb Matrix** `generate_columnb_matrix_*` + Fast and Accurate Modeling of Molecular Atomization Energies with Machine Learning, + Rupp, Tkatchenko, Müller, Lilienfeld, + Phys. Rev. Lett. 108, 058301 (2012) + DOI: https://doi.org/10.1103/PhysRevLett.108.058301 + +- **Bag of Bonds (BoB)** `generate_bob` + Assessment and Validation of Machine Learning Methods for Predicting Molecular Atomization Energies, + Hansen, Montavon, Biegler, Fazli, Rupp, Scheffler, Lilienfeld, Tkatchenko, Müller, + J. Chem. Theory Comput. 2013, 9, 8, 3404–3419 + https://doi.org/10.1021/ct400195d + +- **SLATM** `generate_slatm` + Understanding molecular representations in machine learning: The role of uniqueness and target similarity, + Huang, Lilienfeld, + J. Chem. Phys. 145, 161102 (2016) + https://doi.org/10.1063/1.4964627 + +- **ACSF** `generate_acsf` + Atom-centered symmetry functions for constructing high-dimensional neural network potentials, + Behler, + J Chem Phys 21;134(7):074106 (2011) + https://doi.org/10.1063/1.3553717 + +- **AARAD** `generate_aarad` + Alchemical and structural distribution based representation for universal quantum machine learning + Faber, Christensen, Huang, Lilienfeld, + J. Chem. Phys. 148, 241717 (2018), + https://doi.org/10.1063/1.5020710 - raise NotImplementedError ========= What TODO ========= -* Setup ifort flags -* Setup based on FCC env variable or --global-option flags -* Find MKL from env (for example conda) -* Find what numpy has been linked too (lapack or mkl) +- Setup ifort flags +- Setup based on FCC env variable or --global-option flags +- Find MKL from env (for example conda) +- Find what numpy has been linked too (lapack or mkl) From 842afab033ab8177a333024390b68552296e279f Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 21:31:16 +0100 Subject: [PATCH 2/8] Format of readme --- README.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 44bccf55..1377dfd6 100644 --- a/README.rst +++ b/README.rst @@ -91,43 +91,43 @@ Please cite the representation that you are using accordingly. Toolkit for Quantum Chemistry Machine Learning, https://github.com/qmlcode/qmllib, -- **FCHL19** `generate_fchl19` +- **FCHL19** ``generate_fchl19`` FCHL revisited: Faster and more accurate quantum machine learning, Christensen, Bratholm, Faber, Lilienfeld, J. Chem. Phys. 152, 044107 (2020), https://doi.org/10.1063/1.5126701 -- **FCHL18** `generate_fchl18` +- **FCHL18** ``generate_fchl18`` Alchemical and structural distribution based representation for universal quantum machine learning Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), https://doi.org/10.1063/1.5020710 -- **Columb Matrix** `generate_columnb_matrix_*` +- **Columb Matrix** ``generate_columnb_matrix_*`` Fast and Accurate Modeling of Molecular Atomization Energies with Machine Learning, Rupp, Tkatchenko, Müller, Lilienfeld, Phys. Rev. Lett. 108, 058301 (2012) DOI: https://doi.org/10.1103/PhysRevLett.108.058301 -- **Bag of Bonds (BoB)** `generate_bob` +- **Bag of Bonds (BoB)** ``generate_bob`` Assessment and Validation of Machine Learning Methods for Predicting Molecular Atomization Energies, Hansen, Montavon, Biegler, Fazli, Rupp, Scheffler, Lilienfeld, Tkatchenko, Müller, J. Chem. Theory Comput. 2013, 9, 8, 3404–3419 https://doi.org/10.1021/ct400195d -- **SLATM** `generate_slatm` +- **SLATM** ``generate_slatm`` Understanding molecular representations in machine learning: The role of uniqueness and target similarity, Huang, Lilienfeld, J. Chem. Phys. 145, 161102 (2016) https://doi.org/10.1063/1.4964627 -- **ACSF** `generate_acsf` +- **ACSF** ``generate_acsf`` Atom-centered symmetry functions for constructing high-dimensional neural network potentials, Behler, J Chem Phys 21;134(7):074106 (2011) https://doi.org/10.1063/1.3553717 -- **AARAD** `generate_aarad` +- **AARAD** ``generate_aarad`` |br| Alchemical and structural distribution based representation for universal quantum machine learning Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), From 3f016e23670418cc83c2fc349d82c63b00a6cb38 Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 21:33:12 +0100 Subject: [PATCH 3/8] Format --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 1377dfd6..78c792ff 100644 --- a/README.rst +++ b/README.rst @@ -127,7 +127,7 @@ Please cite the representation that you are using accordingly. J Chem Phys 21;134(7):074106 (2011) https://doi.org/10.1063/1.3553717 -- **AARAD** ``generate_aarad`` |br| +- **AARAD** ``generate_aarad`` | Alchemical and structural distribution based representation for universal quantum machine learning Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), From 6596bf8258dd8943a7ec9f3c367e3032418c914e Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 21:33:40 +0100 Subject: [PATCH 4/8] Format --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 78c792ff..fe6e749f 100644 --- a/README.rst +++ b/README.rst @@ -127,8 +127,8 @@ Please cite the representation that you are using accordingly. J Chem Phys 21;134(7):074106 (2011) https://doi.org/10.1063/1.3553717 -- **AARAD** ``generate_aarad`` | - Alchemical and structural distribution based representation for universal quantum machine learning +- | **AARAD** ``generate_aarad`` + | Alchemical and structural distribution based representation for universal quantum machine learning Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), https://doi.org/10.1063/1.5020710 From d95cb23cadf066797b122f6f860630ec3d23771f Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 21:34:01 +0100 Subject: [PATCH 5/8] format --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index fe6e749f..8871381c 100644 --- a/README.rst +++ b/README.rst @@ -128,7 +128,7 @@ Please cite the representation that you are using accordingly. https://doi.org/10.1063/1.3553717 - | **AARAD** ``generate_aarad`` - | Alchemical and structural distribution based representation for universal quantum machine learning + Alchemical and structural distribution based representation for universal quantum machine learning Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), https://doi.org/10.1063/1.5020710 From 66699487c914cd3b777edce527f817a9cd09ccb4 Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 21:34:43 +0100 Subject: [PATCH 6/8] Format --- README.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 8871381c..bc9457b5 100644 --- a/README.rst +++ b/README.rst @@ -87,41 +87,41 @@ How to cite Please cite the representation that you are using accordingly. -- **Implementation** +- | **Implementation** Toolkit for Quantum Chemistry Machine Learning, https://github.com/qmlcode/qmllib, -- **FCHL19** ``generate_fchl19`` +- | **FCHL19** ``generate_fchl19`` FCHL revisited: Faster and more accurate quantum machine learning, Christensen, Bratholm, Faber, Lilienfeld, J. Chem. Phys. 152, 044107 (2020), https://doi.org/10.1063/1.5126701 -- **FCHL18** ``generate_fchl18`` +- | **FCHL18** ``generate_fchl18`` Alchemical and structural distribution based representation for universal quantum machine learning Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), https://doi.org/10.1063/1.5020710 -- **Columb Matrix** ``generate_columnb_matrix_*`` +- | **Columb Matrix** ``generate_columnb_matrix_*`` Fast and Accurate Modeling of Molecular Atomization Energies with Machine Learning, Rupp, Tkatchenko, Müller, Lilienfeld, Phys. Rev. Lett. 108, 058301 (2012) DOI: https://doi.org/10.1103/PhysRevLett.108.058301 -- **Bag of Bonds (BoB)** ``generate_bob`` +- | **Bag of Bonds (BoB)** ``generate_bob`` Assessment and Validation of Machine Learning Methods for Predicting Molecular Atomization Energies, Hansen, Montavon, Biegler, Fazli, Rupp, Scheffler, Lilienfeld, Tkatchenko, Müller, J. Chem. Theory Comput. 2013, 9, 8, 3404–3419 https://doi.org/10.1021/ct400195d -- **SLATM** ``generate_slatm`` +- | **SLATM** ``generate_slatm`` Understanding molecular representations in machine learning: The role of uniqueness and target similarity, Huang, Lilienfeld, J. Chem. Phys. 145, 161102 (2016) https://doi.org/10.1063/1.4964627 -- **ACSF** ``generate_acsf`` +- | **ACSF** ``generate_acsf`` Atom-centered symmetry functions for constructing high-dimensional neural network potentials, Behler, J Chem Phys 21;134(7):074106 (2011) From 7e9906aa22d06090f38201374d239ca6e4a8d634 Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Sun, 10 Nov 2024 22:49:06 +0100 Subject: [PATCH 7/8] Renamed interface to be consistent with cites --- src/qmllib/representations/__init__.py | 18 ++++++++++++- src/qmllib/representations/arad/arad.py | 2 +- .../fchl/fchl_representations.py | 12 ++++----- src/qmllib/representations/representations.py | 11 ++++---- tests/test_arad.py | 6 ++--- tests/test_energy_krr_atomic_cmat.py | 6 ++--- tests/test_fchl_acsf.py | 18 ++++++------- tests/test_fchl_acsf_energy.py | 4 +-- tests/test_fchl_acsf_forces.py | 4 +-- tests/test_fchl_electric_field.py | 24 ++++++++--------- tests/test_fchl_force.py | 14 +++++----- tests/test_fchl_scalar.py | 6 ++--- tests/test_representations.py | 26 +++++++++---------- 13 files changed, 84 insertions(+), 67 deletions(-) diff --git a/src/qmllib/representations/__init__.py b/src/qmllib/representations/__init__.py index 96ffda24..502572d3 100644 --- a/src/qmllib/representations/__init__.py +++ b/src/qmllib/representations/__init__.py @@ -1 +1,17 @@ -from .representations import * # noqa:F403 +from qmllib.representations.arad import generate_arad # noqa:403 +from qmllib.representations.fchl import ( # noqa:F403 + generate_fchl18, + generate_fchl18_displaced, + generate_fchl18_displaced_5point, + generate_fchl18_electric_field, +) +from qmllib.representations.representations import ( # noqa:F403 + generate_acsf, + generate_bob, + generate_coulomb_matrix, + generate_coulomb_matrix_atomic, + generate_coulomb_matrix_eigenvalue, + generate_fchl19, + generate_slatm, + get_slatm_mbtypes, +) diff --git a/src/qmllib/representations/arad/arad.py b/src/qmllib/representations/arad/arad.py index 221fa5c3..bebc6837 100644 --- a/src/qmllib/representations/arad/arad.py +++ b/src/qmllib/representations/arad/arad.py @@ -23,7 +23,7 @@ def getAngle(sp: ndarray, norms: ndarray) -> ndarray: return angles -def generate_arad_representation( +def generate_arad( coordinates: ndarray, nuclear_charges: ndarray, size: int = 23, cut_distance: float = 5.0 ) -> ndarray: """Generates a representation for the ARAD kernel module. diff --git a/src/qmllib/representations/fchl/fchl_representations.py b/src/qmllib/representations/fchl/fchl_representations.py index b951a7f5..39541047 100644 --- a/src/qmllib/representations/fchl/fchl_representations.py +++ b/src/qmllib/representations/fchl/fchl_representations.py @@ -5,7 +5,7 @@ from numpy import ndarray -def generate_representation( +def generate_fchl18( nuclear_charges: ndarray, coordinates: Union[ndarray, List[List[float]]], max_size: int = 23, @@ -84,7 +84,7 @@ def generate_representation( return M -def generate_displaced_representations( +def generate_fchl18_displaced( nuclear_charges, coordinates, max_size=23, neighbors=23, cut_distance=5.0, cell=None, dx=0.005 ): """Generates displaced representations for the FCHL kernel module. @@ -121,7 +121,7 @@ def generate_displaced_representations( displaced_coordinates = copy.deepcopy(coordinates) displaced_coordinates[i, xyz] += disp - rep = generate_representation( + rep = generate_fchl18( nuclear_charges, displaced_coordinates, max_size=size, @@ -135,7 +135,7 @@ def generate_displaced_representations( return reps -def generate_displaced_representations_5point( +def generate_fchl18_displaced_5point( nuclear_charges, coordinates, max_size=23, neighbors=23, cut_distance=5.0, cell=None, dx=0.005 ): """Generates displaced representations for the FCHL kernel module, using a 5-point stencil. @@ -172,7 +172,7 @@ def generate_displaced_representations_5point( displaced_coordinates = copy.deepcopy(coordinates) displaced_coordinates[i, xyz] += disp - rep = generate_representation( + rep = generate_fchl18( nuclear_charges, displaced_coordinates, max_size=size, @@ -186,7 +186,7 @@ def generate_displaced_representations_5point( return reps -def generate_representation_electric_field( +def generate_fchl18_electric_field( nuclear_charges: ndarray, coordinates: ndarray, fictitious_charges: Union[ndarray, List[float]] = "gasteiger", diff --git a/src/qmllib/representations/representations.py b/src/qmllib/representations/representations.py index 4da9f7f8..c65a3e4b 100644 --- a/src/qmllib/representations/representations.py +++ b/src/qmllib/representations/representations.py @@ -105,7 +105,7 @@ def generate_coulomb_matrix( raise SystemExit -def generate_atomic_coulomb_matrix( +def generate_coulomb_matrix_atomic( nuclear_charges: ndarray, coordinates: ndarray, size: int = 23, @@ -244,7 +244,7 @@ def generate_atomic_coulomb_matrix( raise SystemExit -def generate_eigenvalue_coulomb_matrix( +def generate_coulomb_matrix_eigenvalue( nuclear_charges: ndarray, coordinates: ndarray, size: int = 23 ) -> ndarray: """ Creates an eigenvalue Coulomb Matrix representation of a molecule. @@ -336,7 +336,7 @@ def generate_bob( def get_slatm_mbtypes(nuclear_charges: List[ndarray], pbc: str = "000") -> List[List[int64]]: """ Get the list of minimal types of many-body terms in a dataset. This resulting list - is necessary as input in the ``generate_slatm_representation()`` function. + is necessary as input in the ``generate_slatm()`` function. :param nuclear_charges: A list of the nuclear charges for each compound in the dataset. :type nuclear_charges: list of numpy arrays @@ -734,7 +734,7 @@ def generate_acsf( return rep, grad -def generate_fchl_acsf( +def generate_fchl19( nuclear_charges: ndarray, coordinates: ndarray, elements: List[int] = [1, 6, 7, 8, 16], @@ -753,9 +753,10 @@ def generate_fchl_acsf( gradients: bool = False, ) -> Union[Tuple[ndarray, ndarray], ndarray]: """ - FCHL-ACSF + https://pubs.aip.org/aip/jcp/article/152/4/044107/1064737/FCHL-revisited-Faster-and-more-accurate-quantum + Reasonable hyperparameters: Sigma ~ 21.0 diff --git a/tests/test_arad.py b/tests/test_arad.py index f3d123e9..de48b207 100644 --- a/tests/test_arad.py +++ b/tests/test_arad.py @@ -2,7 +2,7 @@ from conftest import ASSETS, get_energies from qmllib.representations.arad import ( - generate_arad_representation, + generate_arad, get_atomic_kernels_arad, get_atomic_symmetric_kernels_arad, get_global_kernels_arad, @@ -30,7 +30,7 @@ def test_arad(): properties.append(data[filename]) for coord, atoms in molecules: - rep = generate_arad_representation(coord, atoms) + rep = generate_arad(coord, atoms) representations.append(rep) representations = np.array(representations) @@ -73,7 +73,7 @@ def test_arad(): molid = 5 coordinates, atoms = molecules[molid] natoms = len(atoms) - X1 = generate_arad_representation(coordinates, atoms, size=natoms) + X1 = generate_arad(coordinates, atoms, size=natoms) XA = X1[:natoms] K_atomic_asymm = get_atomic_kernels_arad(XA, XA, sigmas) diff --git a/tests/test_energy_krr_atomic_cmat.py b/tests/test_energy_krr_atomic_cmat.py index a906e8cb..1fda7a4a 100644 --- a/tests/test_energy_krr_atomic_cmat.py +++ b/tests/test_energy_krr_atomic_cmat.py @@ -2,7 +2,7 @@ from conftest import ASSETS, get_energies, shuffle_arrays from qmllib.kernels import get_local_kernels_gaussian, get_local_kernels_laplacian -from qmllib.representations import generate_atomic_coulomb_matrix +from qmllib.representations import generate_coulomb_matrix_atomic from qmllib.solvers import cho_solve from qmllib.utils.xyz_format import read_xyz @@ -23,7 +23,7 @@ def test_krr_gaussian_local_cmat(): for filename in filenames: coord, atoms = read_xyz((ASSETS / "qm7" / filename).with_suffix(".xyz")) - representation = generate_atomic_coulomb_matrix(atoms, coord, size=23, sorting="row-norm") + representation = generate_coulomb_matrix_atomic(atoms, coord, size=23, sorting="row-norm") all_representations.append(representation) all_properties.append(data[filename]) @@ -106,7 +106,7 @@ def test_krr_laplacian_local_cmat(): for filename in filenames: coord, atoms = read_xyz((ASSETS / "qm7" / filename).with_suffix(".xyz")) - representation = generate_atomic_coulomb_matrix(atoms, coord, size=23, sorting="row-norm") + representation = generate_coulomb_matrix_atomic(atoms, coord, size=23, sorting="row-norm") all_representations.append(representation) all_properties.append(data[filename]) diff --git a/tests/test_fchl_acsf.py b/tests/test_fchl_acsf.py index 3e4bc648..fd830fef 100644 --- a/tests/test_fchl_acsf.py +++ b/tests/test_fchl_acsf.py @@ -7,7 +7,7 @@ import numpy as np from conftest import ASSETS -from qmllib.representations import generate_fchl_acsf +from qmllib.representations import generate_fchl19 from qmllib.utils.xyz_format import read_xyz np.set_printoptions(linewidth=666, edgeitems=10) @@ -20,7 +20,7 @@ def get_acsf_numgrad(coordinates, nuclear_charges, dx=1e-5): natoms = len(coordinates) true_coords = deepcopy(coordinates) - true_rep = generate_fchl_acsf(nuclear_charges, coordinates, gradients=False, **REP_PARAMS) + true_rep = generate_fchl19(nuclear_charges, coordinates, gradients=False, **REP_PARAMS) gradient = np.zeros((3, natoms, true_rep.shape[0], true_rep.shape[1])) @@ -30,25 +30,25 @@ def get_acsf_numgrad(coordinates, nuclear_charges, dx=1e-5): temp_coords = deepcopy(true_coords) temp_coords[n, xyz] = x + 2.0 * dx - (rep, grad) = generate_fchl_acsf( + (rep, grad) = generate_fchl19( nuclear_charges, temp_coords, gradients=True, **REP_PARAMS ) gradient[xyz, n] -= rep temp_coords[n, xyz] = x + dx - (rep, grad) = generate_fchl_acsf( + (rep, grad) = generate_fchl19( nuclear_charges, temp_coords, gradients=True, **REP_PARAMS ) gradient[xyz, n] += 8.0 * rep temp_coords[n, xyz] = x - dx - (rep, grad) = generate_fchl_acsf( + (rep, grad) = generate_fchl19( nuclear_charges, temp_coords, gradients=True, **REP_PARAMS ) gradient[xyz, n] -= 8.0 * rep temp_coords[n, xyz] = x - 2.0 * dx - (rep, grad) = generate_fchl_acsf( + (rep, grad) = generate_fchl19( nuclear_charges, temp_coords, gradients=True, **REP_PARAMS ) gradient[xyz, n] += rep @@ -66,11 +66,9 @@ def test_fchl_acsf(): coordinates, nuclear_charges = read_xyz(ASSETS / "qm7/0101.xyz") - (repa, anal_grad) = generate_fchl_acsf( - nuclear_charges, coordinates, gradients=True, **REP_PARAMS - ) + (repa, anal_grad) = generate_fchl19(nuclear_charges, coordinates, gradients=True, **REP_PARAMS) - repb = generate_fchl_acsf(nuclear_charges, coordinates, gradients=False, **REP_PARAMS) + repb = generate_fchl19(nuclear_charges, coordinates, gradients=False, **REP_PARAMS) assert np.allclose(repa, repb), "Error in FCHL-ACSF representation implementation" diff --git a/tests/test_fchl_acsf_energy.py b/tests/test_fchl_acsf_energy.py index bd61097b..93d5f8ef 100644 --- a/tests/test_fchl_acsf_energy.py +++ b/tests/test_fchl_acsf_energy.py @@ -2,7 +2,7 @@ from conftest import ASSETS, get_energies, shuffle_arrays from qmllib.kernels import get_local_kernel, get_local_symmetric_kernel -from qmllib.representations import generate_fchl_acsf +from qmllib.representations import generate_fchl19 from qmllib.solvers import cho_solve from qmllib.utils.xyz_format import read_xyz @@ -27,7 +27,7 @@ def test_energy(): # Associate a property (heat of formation) with the object all_properties.append(data[xyz_file]) - representation = generate_fchl_acsf(atoms, coord, gradients=False, pad=27) + representation = generate_fchl19(atoms, coord, gradients=False, pad=27) all_representations.append(representation) all_atoms.append(atoms) diff --git a/tests/test_fchl_acsf_forces.py b/tests/test_fchl_acsf_forces.py index 83c51c18..c973571a 100644 --- a/tests/test_fchl_acsf_forces.py +++ b/tests/test_fchl_acsf_forces.py @@ -12,7 +12,7 @@ get_gp_kernel, get_symmetric_gp_kernel, ) -from qmllib.representations import generate_fchl_acsf +from qmllib.representations import generate_fchl19 from qmllib.solvers import cho_solve, svd_solve np.set_printoptions(linewidth=999, edgeitems=10, suppress=True) @@ -59,7 +59,7 @@ def get_reps(df): energy = float(df["atomization_energy"][i]) - (x1, dx1) = generate_fchl_acsf(nuclear_charges, coordinates, gradients=True, pad=max_atoms) + (x1, dx1) = generate_fchl19(nuclear_charges, coordinates, gradients=True, pad=max_atoms) x.append(x1) f.append(force) diff --git a/tests/test_fchl_electric_field.py b/tests/test_fchl_electric_field.py index 760f75b1..f706dace 100644 --- a/tests/test_fchl_electric_field.py +++ b/tests/test_fchl_electric_field.py @@ -6,10 +6,12 @@ import pytest from scipy.linalg import lstsq +from qmllib.representations import ( + generate_fchl18, + generate_fchl18_displaced, + generate_fchl18_electric_field, +) from qmllib.representations.fchl import ( - generate_displaced_representations, - generate_representation, - generate_representation_electric_field, get_atomic_local_electric_field_gradient_kernels, get_atomic_local_gradient_kernels, get_atomic_local_kernels, @@ -148,11 +150,9 @@ def parse_csv(filename): # Coordinates (Angstrom) coords = np.array(ast.literal_eval(row[2])) - rep = generate_representation(nuclear_charges, coords, **REP_ARGS) - rep_gradient = generate_displaced_representations( - nuclear_charges, coords, dx=DX, **REP_ARGS - ) - rep_dipole = generate_representation_electric_field( + rep = generate_fchl18(nuclear_charges, coords, **REP_ARGS) + rep_gradient = generate_fchl18_displaced(nuclear_charges, coords, dx=DX, **REP_ARGS) + rep_dipole = generate_fchl18_electric_field( nuclear_charges, coords, fictitious_charges="Gasteiger", **REP_ARGS ) @@ -247,7 +247,7 @@ def test_generate_representation(): # Test with fictitious charges from a numpy array fic_charges1 = np.array([-0.41046649, 0.20523324, 0.20523324]) - rep1 = generate_representation_electric_field( + rep1 = generate_fchl18_electric_field( nuclear_charges, coords, fictitious_charges=fic_charges1, max_size=3 ) @@ -256,7 +256,7 @@ def test_generate_representation(): # Test with fictitious charges from a list fic_charges2 = [-0.41046649, 0.20523324, 0.20523324] - rep2 = generate_representation_electric_field( + rep2 = generate_fchl18_electric_field( nuclear_charges, coords, fictitious_charges=fic_charges2, max_size=3 ) @@ -368,7 +368,7 @@ def test_gaussian_process_field_dependent(): ang_rad = ang / 180.0 * np.pi field = np.array([np.cos(ang_rad), np.sin(ang_rad), 0.0]) * 0.001 - rep = generate_representation_electric_field( + rep = generate_fchl18_electric_field( nuclear_charges, coordinates, max_size=2, neighbors=2, cut_distance=1e6 ) fields.append(field) @@ -397,7 +397,7 @@ def test_gaussian_process_field_dependent(): field = np.array([np.cos(ang_rad), np.sin(ang_rad), 0.0]) * 0.001 - rep = generate_representation_electric_field( + rep = generate_fchl18_electric_field( nuclear_charges, coordinates, max_size=2, neighbors=2, cut_distance=1e6 ) diff --git a/tests/test_fchl_force.py b/tests/test_fchl_force.py index 98af0bab..a6e938ed 100644 --- a/tests/test_fchl_force.py +++ b/tests/test_fchl_force.py @@ -11,10 +11,12 @@ from conftest import ASSETS from scipy.linalg import lstsq +from qmllib.representations import ( + generate_fchl18, + generate_fchl18_displaced, + generate_fchl18_displaced_5point, +) from qmllib.representations.fchl import ( - generate_displaced_representations, - generate_displaced_representations_5point, - generate_representation, get_atomic_local_gradient_5point_kernels, get_atomic_local_gradient_kernels, get_atomic_local_kernels, @@ -85,15 +87,15 @@ def csv_to_molecular_reps(csv_filename, force_key="orca_forces", energy_key="orc force = np.array(ast.literal_eval(row[3])) energy = float(row[6]) - rep = generate_representation( + rep = generate_fchl18( coordinates, nuclear_charges, max_size=max_atoms, cut_distance=CUT_DISTANCE ) - disp_rep = generate_displaced_representations( + disp_rep = generate_fchl18_displaced( coordinates, nuclear_charges, max_size=max_atoms, cut_distance=CUT_DISTANCE, dx=DX ) - disp_rep5 = generate_displaced_representations_5point( + disp_rep5 = generate_fchl18_displaced_5point( coordinates, nuclear_charges, max_size=max_atoms, cut_distance=CUT_DISTANCE, dx=DX ) diff --git a/tests/test_fchl_scalar.py b/tests/test_fchl_scalar.py index d4779943..a0ea5e42 100644 --- a/tests/test_fchl_scalar.py +++ b/tests/test_fchl_scalar.py @@ -3,7 +3,7 @@ from scipy.special import binom, factorial, jn from qmllib.representations.fchl import ( - generate_representation, + generate_fchl18, get_atomic_kernels, get_atomic_symmetric_kernels, get_global_kernels, @@ -40,7 +40,7 @@ def _get_training_data(n_points, representation_options={}): # Associate a property (heat of formation) with the object all_properties.append(data[xyz_file]) - representation = generate_representation(atoms, coord, **_representation_options) + representation = generate_fchl18(atoms, coord, **_representation_options) assert ( representation.shape[0] == _representation_options["max_size"] @@ -453,7 +453,7 @@ def test_fchl_local_periodic(): X = np.array( [ - generate_representation( + generate_fchl18( nuclear_charges[i], fractional_coordinates[i], cell=cells[i], diff --git a/tests/test_representations.py b/tests/test_representations.py index 983f119a..5d5828c8 100644 --- a/tests/test_representations.py +++ b/tests/test_representations.py @@ -1,13 +1,13 @@ import numpy as np from conftest import ASSETS -from qmllib.representations.bob import get_asize -from qmllib.representations.representations import ( - generate_atomic_coulomb_matrix, +from qmllib.representations import ( generate_bob, generate_coulomb_matrix, - generate_eigenvalue_coulomb_matrix, + generate_coulomb_matrix_atomic, + generate_coulomb_matrix_eigenvalue, ) +from qmllib.representations.bob import get_asize from qmllib.utils.xyz_format import read_xyz @@ -92,7 +92,7 @@ def test_atomic_coulomb_matrix_distance(): # Generate coulomb matrix representation, sorted by distance representations = [] for coord, nuclear_charges in mols: - rep = generate_atomic_coulomb_matrix(nuclear_charges, coord, size=size, sorting="distance") + rep = generate_coulomb_matrix_atomic(nuclear_charges, coord, size=size, sorting="distance") representations.append(rep) X_test = np.concatenate([rep for rep in representations]) @@ -114,7 +114,7 @@ def test_atomic_coulomb_matrix_rownorm(): representations = [] for coord, nuclear_charges in mols: - rep = generate_atomic_coulomb_matrix(nuclear_charges, coord, size=size, sorting="row-norm") + rep = generate_coulomb_matrix_atomic(nuclear_charges, coord, size=size, sorting="row-norm") representations.append(rep) X_test = np.concatenate(representations) @@ -132,7 +132,7 @@ def test_atomic_coulomb_matrix_distance_softcut(): representations = [] for coord, nuclear_charges in mols: - rep = generate_atomic_coulomb_matrix( + rep = generate_coulomb_matrix_atomic( nuclear_charges, coord, size=size, @@ -161,7 +161,7 @@ def test_atomic_coulomb_matrix_rownorm_cut(): representations = [] for coord, nuclear_charges in mols: - rep = generate_atomic_coulomb_matrix( + rep = generate_coulomb_matrix_atomic( nuclear_charges, coord, size=size, @@ -188,9 +188,9 @@ def test_atomic_coulomb_matrix_twoatom_distance(): size = max(atoms.size for _, atoms in mols) + 1 for coord, nuclear_charges in mols: - rep = generate_atomic_coulomb_matrix(nuclear_charges, coord, size=size, sorting="distance") + rep = generate_coulomb_matrix_atomic(nuclear_charges, coord, size=size, sorting="distance") representation_subset = rep[1:3] - rep = generate_atomic_coulomb_matrix( + rep = generate_coulomb_matrix_atomic( nuclear_charges, coord, size=size, sorting="distance", indices=[1, 2] ) for i in range(2): @@ -213,9 +213,9 @@ def test_atomic_coulomb_matrix_twoatom_rownorm(): for coord, nuclear_charges in mols: - rep = generate_atomic_coulomb_matrix(nuclear_charges, coord, size=size, sorting="row-norm") + rep = generate_coulomb_matrix_atomic(nuclear_charges, coord, size=size, sorting="row-norm") representation_subset = rep[1:3] - rep = generate_atomic_coulomb_matrix( + rep = generate_coulomb_matrix_atomic( nuclear_charges, coord, size=size, sorting="row-norm", indices=[1, 2] ) for i in range(2): @@ -238,7 +238,7 @@ def test_eigenvalue_coulomb_matrix(): representations = [] for coord, nuclear_charges in mols: - rep = generate_eigenvalue_coulomb_matrix(nuclear_charges, coord, size=size) + rep = generate_coulomb_matrix_eigenvalue(nuclear_charges, coord, size=size) representations.append(rep) X_test = np.asarray(representations) From fbe6fbb3acf694e9f0e45873dc4c9331ff19926e Mon Sep 17 00:00:00 2001 From: Jimmy Charnley Kromann Date: Mon, 11 Nov 2024 16:24:09 +0100 Subject: [PATCH 8/8] Added comma --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index bc9457b5..ddd4f4c7 100644 --- a/README.rst +++ b/README.rst @@ -98,7 +98,7 @@ Please cite the representation that you are using accordingly. https://doi.org/10.1063/1.5126701 - | **FCHL18** ``generate_fchl18`` - Alchemical and structural distribution based representation for universal quantum machine learning + Alchemical and structural distribution based representation for universal quantum machine learning, Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), https://doi.org/10.1063/1.5020710 @@ -128,7 +128,7 @@ Please cite the representation that you are using accordingly. https://doi.org/10.1063/1.3553717 - | **AARAD** ``generate_aarad`` - Alchemical and structural distribution based representation for universal quantum machine learning + Alchemical and structural distribution based representation for universal quantum machine learning, Faber, Christensen, Huang, Lilienfeld, J. Chem. Phys. 148, 241717 (2018), https://doi.org/10.1063/1.5020710