Skip to content

Commit 2b0e24a

Browse files
Changed some parameter names and added To-Dos together with James
Co-authored-by: James M. Goff <goffjimmy1@gmail.com>
1 parent b88bb4b commit 2b0e24a

6 files changed

Lines changed: 101 additions & 69 deletions

File tree

docs/source/advanced_usage/descriptors.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ with code such as this
149149
150150
parameters.descriptors.descriptor_type = "ACE"
151151
parameters.descriptors.ace_cutoff = 5.8
152-
parameters.descriptors.ace_ranks = [1, 2, 3]
153-
parameters.descriptors.ace_lmax = [0, 1, 1]
154-
parameters.descriptors.ace_nmax = [1, 1, 1]
155-
parameters.descriptors.ace_lmin = [0, 0, 0]
152+
parameters.descriptors.ace_included_expansion_ranks = [1, 2, 3]
153+
parameters.descriptors.ace_maximum_l_per_rank = [0, 1, 1]
154+
parameters.descriptors.ace_maximum_n_per_rank = [1, 1, 1]
155+
parameters.descriptors.ace_minimum_l_per_rank = [0, 0, 0]
156156
157157
ACE descriptors will be used in your processing/training/testing scripts.
158158
ACE_DOCS_MISSING: Describe what the parameters mean/how to best tune them.

examples/advanced/ex11_preprocess_ace_descriptors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
parameters = mala.Parameters()
3131
# Bispectrum parameters.
3232
parameters.descriptors.descriptor_type = "ACE"
33-
parameters.descriptors.ace_cutoff = 5.8
34-
parameters.descriptors.ace_ranks = [1, 2, 3]
35-
parameters.descriptors.ace_lmax = [0, 1, 1]
36-
parameters.descriptors.ace_nmax = [1, 1, 1]
37-
parameters.descriptors.ace_lmin = [0, 0, 0]
33+
parameters.descriptors.ace_cutoff_factor = 5.8
34+
parameters.descriptors.ace_included_expansion_ranks = [1, 2, 3]
35+
parameters.descriptors.ace_maximum_l_per_rank = [0, 1, 1]
36+
parameters.descriptors.ace_maximum_n_per_rank = [1, 1, 1]
37+
parameters.descriptors.ace_minimum_l_per_rank = [0, 0, 0]
3838

3939
####################
4040
# 2. ADDING DATA FOR DATA CONVERSION

mala/common/parameters.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -470,35 +470,35 @@ class ParametersDescriptors(ParametersBase):
470470
WILL BE DEPRECATED IN MALA v1.4.0 - polynomial degree for minterpy
471471
descriptor calculation.
472472
473-
ace_ranks : list
473+
ace_included_expansion_ranks : list
474474
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
475475
how to best communicate to users how to set this.
476476
477-
ace_nmax : list
477+
ace_maximum_n_per_rank : list
478478
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
479479
how to best communicate to users how to set this.
480480
481-
ace_lmax : list
481+
ace_maximum_l_per_rank : list
482482
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
483483
how to best communicate to users how to set this.
484484
485-
ace_lmin : list
485+
ace_minimum_l_per_rank : list
486486
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
487487
how to best communicate to users how to set this.
488488
489489
ace_nshell : list
490490
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
491491
how to best communicate to users how to set this.
492492
493-
ace_apply_shift : list
493+
ace_balance_cutoff_radii_for_elements : list
494494
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
495495
how to best communicate to users how to set this.
496496
497-
ace_metal_max : list
497+
ace_larger_cutoff_for_metals : list
498498
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
499499
how to best communicate to users how to set this.
500500
501-
ace_use_vdw : list
501+
ace_use_maximum_cutoff_per_element : list
502502
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
503503
how to best communicate to users how to set this.
504504
@@ -508,11 +508,11 @@ class ParametersDescriptors(ParametersBase):
508508
ace_M_R : list
509509
ACE_DOCS_MISSING: I am not sure how to set this.
510510
511-
ace_coupling_type : str
511+
ace_coupling_coefficients_type : str
512512
Coupling type used for reduction of spherical harmonic products.
513513
Can be "clebsch_gordan" or "wigner_3j".
514514
515-
ace_reduction_coefficients_lmax : int
515+
ace_coupling_coefficients_maximum_l : int
516516
ACE_DOCS_MISSING: I think I know what this does, but I am not sure
517517
how to best communicate to users how to set this.
518518
"""
@@ -556,24 +556,38 @@ def __init__(self):
556556
# Everything pertaining to the ACE descriptors.
557557
self.ace_cutoff = None
558558

559-
self.ace_ranks = [1, 2, 3]
560-
self.ace_nmax = [6, 2, 2]
561-
self.ace_lmax = [0, 2, 2]
562-
self.ace_lmin = [0, 0, 0]
559+
# Many body orders
560+
self.ace_included_expansion_ranks = [1, 2, 3]
561+
self.ace_maximum_n_per_rank = [6, 2, 2]
562+
self.ace_maximum_l_per_rank = [0, 2, 2]
563+
self.ace_minimum_l_per_rank = [0, 0, 0]
563564

564565
# Flavors/extra options for the ACE descriptors.
566+
# TODO: This will become ace_cutoff, and the default should be 2.0!
565567
self.ace_nshell = 2.0
566-
self.ace_apply_shift = False
567-
self.ace_metal_max = True
568-
self.ace_use_vdw = False
569568

570-
# ???
569+
self.ace_balance_cutoff_radii_for_elements = False
570+
self.ace_larger_cutoff_for_metals = True
571+
572+
# TODO: Based on VdW radii
573+
self.ace_use_maximum_cutoff_per_element = False
574+
575+
# TODO: Move that into the ace.py class. Rename them, also they are
576+
# always 0 for now
577+
# Equivariance options for the ACE descriptors.
578+
# L_R: Transformation characteristics of the descriptor
579+
# (0: scalar, 1: vector, 2: tensor, etc.)
580+
# M_R: Selects which transformation within the subclass of
581+
# transformations selected by L_R.
571582
self.ace_L_R = 0
572583
self.ace_M_R = 0
573584

574585
# Other value could be "wigner3j".
575-
self.ace_coupling_type = "clebsch_gordan"
576-
self.ace_reduction_coefficients_lmax = 12
586+
self.ace_coupling_coefficients_type = "clebsch_gordan"
587+
588+
# TODO: Implement a check in the ace.py class, so that symbols
589+
# are recomputed if a larger lmax is requested.
590+
self.ace_coupling_coefficients_maximum_l = 12
577591

578592
@property
579593
def use_z_splitting(self):

mala/descriptors/ace.py

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, parameters):
4343

4444
# Initialize a dictionary with ionic radii (in Angstrom).
4545
# and a list containing all elements which are considered metals.
46-
self._ionic_radii, self._metal_list = self.__init_element_lists()
46+
self._atomic_radii, self._metal_list = self.__init_element_lists()
4747

4848
# Initialize several arrays that are computed using
4949
# nested for-loops but can be reused.
@@ -52,15 +52,15 @@ def __init__(self, parameters):
5252
# If a pkl file is detected, the array is loaded from the pkl file,
5353
# otherwise it is computed and saved to a pkl file.
5454
# The arrays are used within the ACE descriptor calculation.
55-
# Which arrays are actually needed depends on which type of coefficients
56-
# are used for the ACE descriptor calculation.
57-
if self.parameters.ace_coupling_type == "wigner3j":
55+
# Which arrays are actually needed depends on which type of
56+
# coefficients are used for the ACE descriptor calculation.
57+
if self.parameters.ace_coupling_coefficients_type == "wigner3j":
5858
self.__precomputed_wigner_3j = self.__init_wigner_3j(
59-
self.parameters.ace_reduction_coefficients_lmax
59+
self.parameters.ace_coupling_coefficients_maximum_l
6060
)
61-
if self.parameters.ace_coupling_type == "clebsch_gordan":
61+
if self.parameters.ace_coupling_coefficients_type == "clebsch_gordan":
6262
self.__precomputed_clebsch_gordan = self.__init_clebsch_gordan(
63-
self.parameters.ace_reduction_coefficients_lmax
63+
self.parameters.ace_coupling_coefficients_maximum_l
6464
)
6565

6666
# File which holds the coupling coefficients.
@@ -71,6 +71,8 @@ def __init__(self, parameters):
7171
# Will get filled once the atoms object has been loaded.
7272
# ACE_DOCS_MISSING: What do these do?
7373
self.__ace_mumax = None
74+
75+
# Comment WHY this is always zero.
7476
self.__ace_reference_ensemble = None
7577

7678
# Will get filled during calculation of coupling coefficients.
@@ -92,9 +94,12 @@ def __init__(self, parameters):
9294

9395
# Consistency checks for the ACE settings.
9496
if (
95-
len(self.parameters.ace_ranks) != len(self.parameters.ace_lmax)
96-
or len(self.parameters.ace_ranks) != len(self.parameters.ace_nmax)
97-
or len(self.parameters.ace_ranks) != len(self.parameters.ace_lmin)
97+
len(self.parameters.ace_included_expansion_ranks)
98+
!= len(self.parameters.ace_maximum_l_per_rank)
99+
or len(self.parameters.ace_included_expansion_ranks)
100+
!= len(self.parameters.ace_maximum_n_per_rank)
101+
or len(self.parameters.ace_included_expansion_ranks)
102+
!= len(self.parameters.ace_minimum_l_per_rank)
98103
):
99104
raise Exception(
100105
"ACE ranks, lmax, nmax, and lmin must have the same length"
@@ -240,6 +245,10 @@ def __calculate_lammps(self, outdir, **kwargs):
240245

241246
# Check the cutoff radius, i.e., compare that the user choice
242247
# is not too small compared to those requird by ACE.
248+
249+
# TODO: Not self.parameters.ace_cutoff will be passed to LAMMPS,
250+
# but rather self._maximum_cutoff_factor.
251+
# It is only used for the pair_style command in the LAMMPS input file.
243252
if self.parameters.ace_cutoff < self._maximum_cutoff_factor:
244253
printout(
245254
"One or more automatically generated ACE cutoff radii is "
@@ -422,6 +431,8 @@ def _calculate_bonds_and_cutoff(self):
422431
lmb_default,
423432
) = self.__default_settings()
424433

434+
# TODO: Scale _cutoff_factors by * self.parameters.ace_cutoff
435+
# Make self.parameters.ace_cutoff 1.0 by default
425436
self._cutoff_factors = [float(k) for k in rc_default.split()[2:]]
426437
self._maximum_cutoff_factor = np.max(self._cutoff_factors)
427438
self.__lambdas = [float(k) for k in lmb_default.split()[2:]]
@@ -463,7 +474,8 @@ def _calculate_coupling_coeffs(self):
463474
ldict = {
464475
ranki: li
465476
for ranki, li in zip(
466-
self.parameters.ace_ranks, self.parameters.ace_lmax
477+
self.parameters.ace_included_expansion_ranks,
478+
self.parameters.ace_maximum_l_per_rank,
467479
)
468480
}
469481

@@ -472,14 +484,16 @@ def _calculate_coupling_coeffs(self):
472484
# used for the reduction of the spherical harmonics products.
473485
# So maybe "reduction coefficients" or something?
474486
# Or is this really the "coupling type"?
475-
if self.parameters.ace_coupling_type == "wigner3j":
487+
if self.parameters.ace_coupling_coefficients_type == "wigner3j":
476488
ccs = wigner_coupling.wigner_3j_coupling(
477489
self.__precomputed_wigner_3j,
478490
ldict,
479491
L_R=self.parameters.ace_L_R,
480492
)
481493

482-
elif self.parameters.ace_coupling_type == "clebsch_gordan":
494+
elif (
495+
self.parameters.ace_coupling_coefficients_type == "clebsch_gordan"
496+
):
483497
ccs = cg_coupling.clebsch_gordan_coupling(
484498
self.__precomputed_clebsch_gordan,
485499
ldict,
@@ -489,7 +503,7 @@ def _calculate_coupling_coeffs(self):
489503
else:
490504
raise Exception(
491505
"Coupling type "
492-
+ str(self.parameters.ace_coupling_type)
506+
+ str(self.parameters.ace_coupling_coefficients_type)
493507
+ " not recongised"
494508
)
495509

@@ -498,16 +512,16 @@ def _calculate_coupling_coeffs(self):
498512
Apot = ACEPotential(
499513
element_list,
500514
self.__ace_reference_ensemble,
501-
self.parameters.ace_ranks,
502-
self.parameters.ace_nmax,
503-
self.parameters.ace_lmax,
504-
max(self.parameters.ace_nmax),
515+
self.parameters.ace_included_expansion_ranks,
516+
self.parameters.ace_maximum_n_per_rank,
517+
self.parameters.ace_maximum_l_per_rank,
518+
max(self.parameters.ace_maximum_n_per_rank),
505519
self._cutoff_factors,
506520
self.__lambdas,
507521
ccs[self.parameters.ace_M_R],
508522
rcutinner=rcinner,
509523
drcutinner=drcinner,
510-
lmin=self.parameters.ace_lmin,
524+
lmin=self.parameters.ace_minimum_l_per_rank,
511525
)
512526

513527
# ACE_DOCS_MISSING: What does this function do?
@@ -535,14 +549,16 @@ def __calculate_limit_nus(self):
535549
# ACE_DOCS_MISSING: Add maybe a general outline of what is being
536550
# done here.
537551
ranked_chem_nus = []
538-
for ind, rank in enumerate(self.parameters.ace_ranks):
552+
for ind, rank in enumerate(
553+
self.parameters.ace_included_expansion_ranks
554+
):
539555
rank = int(rank)
540556
PA_lammps = ace_coupling_utils.compute_pa_labels_raw(
541557
rank,
542-
int(self.parameters.ace_nmax[ind]),
543-
int(self.parameters.ace_lmax[ind]),
558+
int(self.parameters.ace_maximum_n_per_rank[ind]),
559+
int(self.parameters.ace_maximum_l_per_rank[ind]),
544560
int(self.__ace_mumax),
545-
lmin=int(self.parameters.ace_lmin[ind]),
561+
lmin=int(self.parameters.ace_minimum_l_per_rank[ind]),
546562
)
547563
ranked_chem_nus.append(PA_lammps)
548564

@@ -613,7 +629,7 @@ def __default_settings(self):
613629
rc_range = {bp: None for bp in self.__bonds}
614630
rin_def = {bp: None for bp in self.__bonds}
615631
rc_def = {bp: None for bp in self.__bonds}
616-
fac_per_elem = {key: 0.5 for key in list(self._ionic_radii.keys())}
632+
fac_per_elem = {key: 0.5 for key in list(self._atomic_radii.keys())}
617633
fac_per_elem_sub = {
618634
"H": 0.61,
619635
"Be": 0.52,
@@ -642,7 +658,7 @@ def __default_settings(self):
642658
# if apply_shift:
643659
for bond in self.__bonds:
644660
if rc_def[bond] != max(rc_def.values()):
645-
if self.parameters.ace_apply_shift:
661+
if self.parameters.ace_balance_cutoff_radii_for_elements:
646662
rc_def[bond] = rc_def[bond] + shift # *nshell
647663
else:
648664
rc_def[bond] = rc_def[bond] # *nshell
@@ -687,7 +703,7 @@ def __default_cutoff_factors(self, elms):
687703
atnum1 = ase.data.atomic_numbers["Au"]
688704
covr1 = ase.data.covalent_radii[atnum1]
689705
vdwr1 = ase.data.vdw_radii[atnum1]
690-
ionr1 = self._ionic_radii[elm1]
706+
ionr1 = self._atomic_radii[elm1]
691707
if np.isnan(vdwr1):
692708
printout(
693709
"NOTE: using dummy VDW radius of 2* covalent radius for %s"
@@ -700,15 +716,15 @@ def __default_cutoff_factors(self, elms):
700716
atnum2 = ase.data.atomic_numbers["Au"]
701717
covr2 = ase.data.covalent_radii[atnum2]
702718
vdwr2 = ase.data.vdw_radii[atnum2]
703-
ionr2 = self._ionic_radii[elm2]
719+
ionr2 = self._atomic_radii[elm2]
704720
if np.isnan(vdwr2):
705721
printout(
706722
"NOTE: using dummy VDW radius of 2* covalent radius for %s"
707723
% elm2
708724
)
709725
vdwr2 = 2 * covr2
710726
minbond = ionr1 + ionr2
711-
if self.parameters.ace_metal_max:
727+
if self.parameters.ace_larger_cutoff_for_metals:
712728
if elm1 not in self._metal_list and elm2 not in self._metal_list:
713729
maxbond = vdwr1 + vdwr2
714730
elif elm1 in self._metal_list and elm2 not in self._metal_list:
@@ -725,7 +741,7 @@ def __default_cutoff_factors(self, elms):
725741
# by default, return the ionic bond length * number of bonds for
726742
# minimum
727743
returnmin = minbond
728-
if self.parameters.ace_use_vdw:
744+
if self.parameters.ace_use_maximum_cutoff_per_element:
729745
# return vdw bond length if requested
730746
returnmax = maxbond
731747
else:
@@ -890,7 +906,7 @@ def __init_element_arrays(self):
890906
@staticmethod
891907
def __init_element_lists():
892908
"""
893-
Initialize a dictionary with ionic radii and list of metals.
909+
Initialize a dictionary with atomic radii and list of metals.
894910
895911
This function initializes a dictionary with ionic radii (in
896912
Angstrom) and a list containing all elements which are considered
@@ -901,7 +917,7 @@ def __init_element_lists():
901917
902918
Returns
903919
-------
904-
ionic_radii : dict
920+
atomic_radii : dict
905921
Dictionary with ionic radii.
906922
907923
metal_list : List
@@ -916,13 +932,13 @@ def __init_element_lists():
916932
# These ionic (actually, atomic radii) are taken from mendeleev.
917933
# In the original implementation of the ACE class, these were
918934
# hardcoded, now we get them automatically from mendeleev.
919-
ionic_radii = element_info.to_dict()["atomic_radius"]
920-
ionic_radii = {key: v / 100 for (key, v) in ionic_radii.items()}
921-
ionic_radii["G"] = 1.35
935+
atomic_radii = element_info.to_dict()["atomic_radius"]
936+
atomic_radii = {key: v / 100 for (key, v) in atomic_radii.items()}
937+
atomic_radii["G"] = 1.35
922938

923939
# The metal list that was originally here only contains elements up to
924940
# the 13th group (I am not sure why, e.g., Al is excluded).
925-
# Additionally, only _some_ Lanthanoids and Actininoids were included,
941+
# Additionally, only _some_ Lanthanoids and Actinoids were included,
926942
# but that may be due to the list having been outdated, since the old
927943
# name for Db (Ha) had been used. The code here now includes all
928944
# elements up to group 13 (minus H) and all Lanthanoids and
@@ -938,7 +954,7 @@ def __init_element_lists():
938954
metal_list = list(set(main_groups + actininoids_lanthanoids))
939955
metal_list.remove("H")
940956

941-
return ionic_radii, metal_list
957+
return atomic_radii, metal_list
942958

943959
@staticmethod
944960
def _clebsch_gordan(j1, m1, j2, m2, j3, m3):

0 commit comments

Comments
 (0)