Skip to content

Commit

Permalink
Iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
charnley committed Feb 15, 2024
1 parent 5947c80 commit 5be2374
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 337 deletions.
46 changes: 23 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ format:

test:
${python} -m pytest -rs \
tests/test_acsf_linear_angles.py \
tests/test_acsf.py \
tests/test_arad.py \
tests/test_armp.py \
tests/test_compound.py \
tests/test_distance.py \
tests/test_energy_krr_atomic_cmat.py \
tests/test_energy_krr_bob.py \
tests/test_energy_krr_cmat.py \
tests/test_fchl_acsf_energy.py \
tests/test_fchl_acsf_forces.py \
tests/test_fchl_acsf.py \
tests/test_fchl_electric_field.py \
tests/test_fchl_force.py \
tests/test_fchl_scalar.py \
tests/test_kernel_derivatives.py \
tests/test_kernels.py \
tests/test_mrmp.py \
tests/test_neural_network.py \
tests/test_representations.py \
tests/test_slatm.py \
tests/test_solvers.py \
tests/test_symm_funct.py
tests/test_distance.py \
tests/test_kernels.py \
tests/test_representations.py \
tests/test_slatm.py \
tests/test_solvers.py
# tests/test_fchl_acsf.py
# tests/test_fchl_acsf_energy.py
# tests/test_fchl_acsf_forces.py \
# tests/test_fchl_electric_field.py \
# tests/test_fchl_force.py \
# tests/test_fchl_scalar.py
# REMOVE tests/test_acsf_linear_angles.py \
# REMOVE tests/test_acsf.py \
# tests/test_arad.py \
# REMOVE tests/test_armp.py \
# REMOVE tests/test_compound.py \
# integration tests/test_energy_krr_atomic_cmat.py \
# integration tests/test_energy_krr_bob.py \
# integration tests/test_energy_krr_cmat.py \
# tests/test_kernel_derivatives.py \
# REMOVE tests/test_mrmp.py \
# REMOVE tests/test_neural_network.py \
# REMOVE tests/test_symm_funct.py

types:
${python} -m monkeytype run $(which pytest) ./tests/
Expand Down
186 changes: 0 additions & 186 deletions src/qmllib/kernels/wrappers.py

This file was deleted.

26 changes: 14 additions & 12 deletions src/qmllib/representations/slatm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import itertools as itl
import itertools

import numpy as np
import scipy.spatial.distance as spatial_distance
Expand Down Expand Up @@ -50,15 +50,15 @@ def update_m(obj, ia, rcut=9.0, pbc=None):

n1s, n2s, n3s = nns

n123s_ = np.array(list(itl.product(n1s, n2s, n3s)))
n123s_ = np.array(list(itertools.product(n1s, n2s, n3s)))
n123s = []
for n123 in n123s_:
n123u = list(n123)
if n123u != [0, 0, 0]:
n123s.append(n123u)

nau = len(n123s)
n123s = np.array(n123s, np.float)
n123s = np.array(n123s, np.float64)

na = len(zs)
cia = coords[ia]
Expand Down Expand Up @@ -134,13 +134,14 @@ def get_sbop(
assert ia is not None, "#ERROR: plz specify `za and `ia "

if pbc != "000":
if rcut < 9.0:
raise ValueError()
assert iloc, "#ERROR: for periodic system, plz use atomic rpst"
zs, coords = update_m(obj, ia, rcut=rcut, pbc=pbc)
raise NotImplementedError("Periodic boundary conditions not implemented")
# if rcut < 9.0:
# raise ValueError()
# assert iloc, "#ERROR: for periodic system, plz use atomic rpst"
# zs, coords = update_m(obj, ia, rcut=rcut, pbc=pbc)

# after update of `m, the query atom `ia will become the first atom
ia = 0
# ia = 0

# bop potential distribution
r0 = 0.1
Expand Down Expand Up @@ -174,11 +175,12 @@ def get_sbot(
assert ia is not None, "#ERROR: plz specify `za and `ia "

if pbc != "000":
assert iloc, "#ERROR: for periodic system, plz use atomic rpst"
zs, coords = update_m(obj, ia, rcut=rcut, pbc=pbc)
raise NotImplementedError("Periodic boundary conditions not implemented")
# assert iloc, "#ERROR: for periodic system, plz use atomic rpst"
# zs, coords = update_m(obj, ia, rcut=rcut, pbc=pbc)

# after update of `m, the query atom `ia will become the first atom
ia = 0
# # after update of `m, the query atom `ia will become the first atom
# ia = 0

# for a normalized gaussian distribution, u should multiply this coeff
coeff = 1 / np.sqrt(2 * sigma**2 * np.pi) if normalize else 1.0
Expand Down
51 changes: 51 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
from pathlib import Path

import numpy as np

ASSETS = Path("./tests/assets")


def get_asize(list_of_atoms, pad):
"""TODO Anders what is asize"""

asize: dict[int, int] = dict()

# WHAT

for atoms in list_of_atoms:

unique_atoms, unique_counts = np.unique(atoms, return_counts=True)

for atom, count in zip(unique_atoms, unique_counts):

prev = asize.get(atom, None)

if prev is None:
asize[atom] = count + pad
continue

asize[atom] = max(asize[atom], count + pad)

# for key, value in mol.natypes.items():
# try:
# asize[key] = max(asize[key], value + pad)
# except KeyError:
# asize[key] = value + pad

return asize


def get_energies(filename: Path):
"""Returns a dictionary with heats of formation for each xyz-file."""

with open(filename, "r") as f:
lines = f.readlines()

energies = dict()

for line in lines:
tokens = line.split()

xyz_name = tokens[0]
hof = float(tokens[1])

energies[xyz_name] = hof

return energies
Loading

0 comments on commit 5be2374

Please sign in to comment.