Skip to content

Commit

Permalink
Got rid of some merging errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomDefaultUser committed Jan 31, 2025
1 parent fcec2ac commit fbe13ca
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 29,312 deletions.
6,391 changes: 0 additions & 6,391 deletions examples/basic_ace/Be.pbe-n-rrkjus_psl.1.0.0.UPF

This file was deleted.

14 changes: 0 additions & 14 deletions examples/basic_ace/Be_snapshot0.data

This file was deleted.

4,958 changes: 0 additions & 4,958 deletions examples/basic_ace/Be_snapshot0.out

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp01Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp02Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp03Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp04Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp05Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp06Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp07Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp08Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp09Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp10Be_ldos.cube

This file was deleted.

1,628 changes: 0 additions & 1,628 deletions examples/basic_ace/cubes/tmp.pp11Be_ldos.cube

This file was deleted.

88 changes: 50 additions & 38 deletions mala/descriptors/ace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import mala.descriptors.wigner_coupling as wigner_coupling
import mala.descriptors.cg_coupling as cg_coupling


class ACE(Descriptor):
"""Class for calculation and parsing of bispectrum descriptors.
Expand Down Expand Up @@ -221,8 +222,8 @@ def __init__(self, parameters):
]

topfile = cg_coupling.__file__
top_dir = topfile.split('/cg')[0]
lib_path = '%s' % top_dir
top_dir = topfile.split("/cg")[0]
lib_path = "%s" % top_dir
self.lib_path = lib_path

self.Wigner_3j = self.init_wigner_3j(
Expand All @@ -236,24 +237,29 @@ def __init__(self, parameters):
self.ncols0 = 3
self.couplings = None

assert not self.parameters.ace_types_like_snap, "Using the same 'element' type for atoms and grid points is not permitted for standar d mala models"
if self.parameters.ace_types_like_snap and "G" in self.parameters.ace_elements:
raise Exception("for types_like_snap = True, you must remove the separate element type for grid points")

if len(self.parameters.ace_elements) != len(self.parameters.ace_reference_ens):
raise Exception("Reference ensemble must match length of element list!")
assert (
not self.parameters.ace_types_like_snap
), "Using the same 'element' type for atoms and grid points is not permitted for standar d mala models"
if (
self.parameters.ace_types_like_snap
and "G" in self.parameters.ace_elements
):
raise Exception(
"for types_like_snap = True, you must remove the separate element type for grid points"
)

if len(self.parameters.ace_elements) != len(
self.parameters.ace_reference_ens
):
raise Exception(
"Reference ensemble must match length of element list!"
)

@property
def data_name(self):
"""Get a string that describes the target (for e.g. metadata)."""
return "ACE"

@property
def feature_size(self):
"""Get the feature dimension of this data."""
return self.fingerprint_length

@staticmethod
def convert_units(array, in_units="None"):
"""
Expand Down Expand Up @@ -331,18 +337,17 @@ def __calculate_lammps(self, outdir, **kwargs):
keep_logs = kwargs.get("keep_logs", True)

lammps_format = "lammps-data"
self.lammps_temporary_input = os.path.join(
outdir, "lammps_input_" + self.calculation_timestamp + ".tmp"
)
self.setup_lammps_tmp_files("acegrid", outdir)

ase.io.write(
self.lammps_temporary_input, self.atoms, format=lammps_format
self._lammps_temporary_input, self._atoms, format=lammps_format
)

nx = self.grid_dimensions[0]
ny = self.grid_dimensions[1]
nz = self.grid_dimensions[2]

# calculate the coupling coefficients
# TODO: Save the coupling coefficients.
if self.couplings != None:
coupling_coeffs = self.couplings
else:
Expand All @@ -366,10 +371,6 @@ def __calculate_lammps(self, outdir, **kwargs):
"rcutfac": self.maxrc,
}

self.lammps_temporary_log = os.path.join(
outdir,
"lammps_acegrid_log_" + self.calculation_timestamp + ".tmp",
)
lmp = self._setup_lammps(nx, ny, nz, lammps_dict)

# An empty string means that the user wants to use the standard input.
Expand Down Expand Up @@ -433,9 +434,9 @@ def __calculate_lammps(self, outdir, **kwargs):
lammps_constants.LMP_STYLE_LOCAL,
lammps_constants.LMP_SIZE_COLS,
)
if ncols_local != self.fingerprint_length + 3:
self.fingerprint_length = ncols_local - 3
#raise Exception("Inconsistent number of features.")
if ncols_local != self.feature_size + 3:
self.feature_size = ncols_local - 3
# raise Exception("Inconsistent number of features.")

ace_descriptors_np = extract_compute_np(
lmp,
Expand Down Expand Up @@ -497,7 +498,7 @@ def calculate_coupling_coeffs(self):
lmbda
), "you must have rcutfac and lmbda defined for each bond type"

#printout("global max cutoff (angstrom)", max(rcutfac))
# printout("global max cutoff (angstrom)", max(rcutfac))
rcinner = [0.0] * len(self.bonds)
drcinner = [0.0] * len(self.bonds)

Expand Down Expand Up @@ -535,9 +536,13 @@ def calculate_coupling_coeffs(self):
nus, limit_nus = self.calc_limit_nus()

if not self.parameters.ace_types_like_snap:
#NOTE to use unique ACE types for gridpoints, we must subtract off
# NOTE to use unique ACE types for gridpoints, we must subtract off
# dummy descriptor counts (for non-grid element types)
self.fingerprint_length = self.ncols0 + len(limit_nus) - (len(self.parameters.ace_elements)-1)
self.fingerprint_length = (
self.ncols0
+ len(limit_nus)
- (len(self.parameters.ace_elements) - 1)
)
# permutation symmetry adapted ACE labels
Apot = AcePot(
self.parameters.ace_elements,
Expand All @@ -558,7 +563,7 @@ def calculate_coupling_coeffs(self):
Apot.write_pot("coupling_coefficients")

# add case for full basis separately
#NOTE that this basis evaluates grid-atom and atom-atom descriptors that are not needed in the current implementation of MALA
# NOTE that this basis evaluates grid-atom and atom-atom descriptors that are not needed in the current implementation of MALA
elif self.parameters.ace_types_like_snap:
self.fingerprint_length = self.ncols0 + len(nus)
# permutation symmetry adapted ACE labels
Expand All @@ -578,7 +583,6 @@ def calculate_coupling_coeffs(self):
)
Apot.write_pot("coupling_coefficients")


def calc_limit_nus(self):
ranked_chem_nus = []
for ind, rank in enumerate(self.parameters.ace_ranks):
Expand Down Expand Up @@ -646,9 +650,9 @@ def calc_limit_nus(self):
if self.parameters.ace_padfunc:
for muii in musins:
limit_nus.append(byattyp["%d" % muii][0])
#printout(
# printout(
# "all basis functions", len(nus), "grid subset", len(limit_nus)
#)
# )

return nus, limit_nus

Expand Down Expand Up @@ -789,7 +793,7 @@ def wigner_3j(self, j1, m1, j2, m2, j3, m3):
def init_wigner_3j(self, lmax):
# returns dictionary of all cg coefficients to be used at a given value of lmax
try:
with open('%s/wig.pkl' % self.lib_path,'rb') as readinwig:
with open("%s/wig.pkl" % self.lib_path, "rb") as readinwig:
cg = pickle.load(readinwig)
except FileNotFoundError:
cg = {}
Expand All @@ -810,14 +814,14 @@ def init_wigner_3j(self, lmax):
cg[key] = self.wigner_3j(
l1, m1, l2, m2, l3, m3
)
with open('%s/wig.pkl' % self.lib_path,'wb') as writewig:
pickle.dump(cg,writewig)
with open("%s/wig.pkl" % self.lib_path, "wb") as writewig:
pickle.dump(cg, writewig)
return cg

def init_clebsch_gordan(self, lmax):
# returns dictionary of all cg coefficients to be used at a given value of lmax
try:
with open('%s/cg.pkl' % self.lib_path,'rb') as readincg:
with open("%s/cg.pkl" % self.lib_path, "rb") as readincg:
cg = pickle.load(readincg)
except FileNotFoundError:
cg = {}
Expand All @@ -838,9 +842,9 @@ def init_clebsch_gordan(self, lmax):
cg[key] = self.clebsch_gordan(
l1, m1, l2, m2, l3, m3
)
with open('%s/cg.pkl' % self.lib_path,'wb') as writecg:
with open("%s/cg.pkl" % self.lib_path, "wb") as writecg:
pickle.dump(cg, writecg)
#pickle.dump(cg,'cg.pkl')
# pickle.dump(cg,'cg.pkl')
return cg

def clebsch_gordan(self, j1, m1, j2, m2, j3, m3):
Expand Down Expand Up @@ -906,3 +910,11 @@ def clebsch_gordan(self, j1, m1, j2, m2, j3, m3):

else:
return 0.0

def _read_feature_dimension_from_json(self, json_dict):
nus, limit_nus = self.calc_limit_nus()

if self.parameters.descriptors_contain_xyz:
return len(limit_nus) - (len(self.parameters.ace_elements) - 1)
else:
return len(limit_nus) - (len(self.parameters.ace_elements) - 1) + 3
4 changes: 1 addition & 3 deletions mala/descriptors/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ def __new__(cls, params: Parameters = None):
if params.descriptors.descriptor_type == "ACE":
from mala.descriptors.ace import ACE

descriptors = super(Descriptor, ACE).__new__(
ACE
)
descriptors = super(Descriptor, ACE).__new__(ACE)

if params.descriptors.descriptor_type == "MinterpyDescriptors":
from mala.descriptors.minterpy_descriptors import (
Expand Down

0 comments on commit fbe13ca

Please sign in to comment.