Skip to content

Commit cde583b

Browse files
Merge pull request mala-project#649 from RandomDefaultUser/ace_docs
ACE documentation updates
2 parents 0e2839f + c42173f commit cde583b

9 files changed

Lines changed: 508 additions & 330 deletions

File tree

mala/descriptors/ace.py

Lines changed: 111 additions & 73 deletions
Large diffs are not rendered by default.

mala/descriptors/acelib/ace_potential.py

Lines changed: 68 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
22
ACE potential class.
33
4-
Computes the coupling coefficients. ACE_DOCS_MISSING: Why is this called
5-
"potential" - would this work as an actual ACE potential or is this just the
6-
expansion coefficients?
4+
It writes a .yace file (ACE potential file) that is readable by LAMMPS. When only the
5+
coupling coefficients are saved to the .yace file, this acts as a parameter
6+
file with which one can evaluate ACE descriptors.
77
"""
88

99
import itertools
@@ -16,49 +16,64 @@
1616

1717
class ACEPotential:
1818
"""
19-
Class for calculation of ACE coupling coefficients.
19+
Class to manage interface between ACE descriptor enumeration library and LAMMPS. By default, it will enumerate ACE descriptors according to the Permutation-adapted approach described in https://doi.org/10.1016/j.jcp.2024.113073.
2020
21-
ACE_DOCS_MISSING: Explain scope of class. I think we always assume PA
22-
basis, but I don't know what that is.
21+
However, there are options for assigning descriptor labels if desired, manually for example.
2322
23+
After enumerating descriptors, it assigns all relevant hyperparamters needed to evaluate the ACE descriptors in LAMMPS. It saves a .yace file needed to evaluate ACE descriptors in LAMMPS (containing coupling coefficients). It does this by writing an ACE potential file, readable by LAMNMPS, that contains only information to evaluate descriptors, not energy models.
24+
2425
Parameters
2526
----------
2627
elements : List
27-
List of elements (symbols)
28+
List of elements (symbols), including 'G' for the grid points. In ACE, all possible
29+
combinations of these elements determine the "bond types" spanned by the ACE chemical
30+
basis (the chemical basis is the delta function basis used in Drautz 2019). For
31+
example, the "bond types" resulting from all possible combinations of ['Al','G'] are
32+
determined with :code:`itertools.product()` in python. They are (Al,Al)(Al,G)(G,Al)(G,G).
33+
For mala, only those of type (G,X) are kept, (grid-atom interactions) and only a placeholder
34+
is kept for other interaction types.
2835
2936
reference_ens : List
30-
List of floats, has same dimensions as elements. ACE_DOCS_MISSING:
31-
What does it do?
37+
List of reference energies. (To be applied only for linear models) with a constant
38+
shift to the energy per element type. Values other than 0 not be necessary in MALA.
3239
3340
ranks : List
34-
ACE_DOCS_MISSING
41+
Orders of the expansion, referred to as `N` in Drautz 2019, of the
42+
descriptors to be enumerated
3543
3644
nmax: List
37-
ACE_DOCS_MISSING
45+
Maximum radial basis function index per descriptor rank
3846
3947
lmax: List
40-
ACE_DOCS_MISSING
48+
Maximum angular momentum number per descriptor rank (maximum angular function index)
4149
4250
nradbase : int
43-
ACE_DOCS_MISSING
51+
Maximum radial basis function index OVERALL: max(nmax) - in the future, may be used
52+
to define the number of g_k(r) comprising R_nl from Drautz 2019 radial basis.
4453
45-
rcut : float
46-
ACE_DOCS_MISSING
54+
rcut : float/list
55+
radial basis function cutoff per bond type. For example, if elements are ['Al','G']
56+
then rcut must be supplied for each:(Al,Al)(Al,G)(G,Al)(G,G)
4757
48-
lmbda : float
49-
ACE_DOCS_MISSING
58+
lmbda : float/list
59+
Exponential factor for scaled distance in Drautz 2019 used in the radial basis
60+
functions. As with the radial cutoff, lambda must be supplied per bond type. For
61+
example, if elements are ['Al','G'] then lambda must be supplied for
62+
each:(Al,Al)(Al,G)(G,Al)(G,G)
5063
5164
css : dict
52-
ACE_DOCS_MISSING
65+
Dictionary of coupling coefficients of the format: {rank:{l:{m:coupling_coefficient}}
5366
5467
rcutinner : List
55-
ACE_DOCS_MISSING
68+
Inner cutoff to turn on soft-core repulsions. This parameter should be 0.0 (OFF) for
69+
each bond type in MALA.
5670
5771
drcutinner : List
58-
ACE_DOCS_MISSING
72+
Parameter for soft-core repulsions. This parameter should not matter if rcutinner is
73+
0.0 (OFF) for each bond type in MALA.
5974
60-
lmin : int
61-
ACE_DOCS_MISSING
75+
lmin : int/list
76+
Lower bound on angular momentum quantum number per rank.
6277
6378
manual_labels : str
6479
File for loading labels. If not None, then labels will be loaded from
@@ -67,12 +82,17 @@ class ACEPotential:
6782
6883
**kwarg : dict
6984
Additional keyword arguments.
85+
86+
Returns
87+
-------
88+
ACEPotential : class
89+
Class containing ACE descriptor and hyperparamter info.
7090
"""
7191

7292
def __init__(
7393
self,
7494
elements,
75-
reference_ensemble,
95+
reference_energy,
7696
ranks,
7797
nmax,
7898
lmax,
@@ -89,15 +109,22 @@ def __init__(
89109
if kwargs is not None:
90110
self.__dict__.update(kwargs)
91111

92-
# ACE_DOCS_MISSING: Explain what all these variables do, at least
93-
# briefly, and give them more meaningful names.
112+
#NOTE Our unused variable names here match exactly what is in LAMMPS
113+
# I'm hesitant to change these to something else. We wont use them in MALA
114+
# and if people are really interested, they can find them in the lammps
115+
# source code directly
116+
#coupling coefficients (generalized Wigner symbols or Generalized Clebsch-Gordan coefficients)
94117
self.__global_ccs = css
95118
self.__global_ccs[1] = {"0": {tuple([]): {"0": 1.0}}}
96-
self.__E0 = reference_ensemble
119+
#0th-order expansion term in ACE (e.g., constant energy shift)
120+
self.__E0 = reference_energy
97121
self.__ranks = ranks
98122
self.__elements = elements
123+
#linear model coefficients
99124
self.__betas = None
125+
#descriptor labels in FitSNAP/LAMMPS format - as described elsewhere
100126
self.__nus = None
127+
#hyperparameters for ACE basis (relevant for density embeddings)
101128
self.__deltaSplineBins = 0.001
102129
self.__global_ndensity = 1
103130
self.__global_rhocut = 100000
@@ -195,17 +222,17 @@ def __init__(
195222

196223
def __set_embeddings(self, npoti="FinnisSinclair", FSparams=[1.0, 1.0]):
197224
"""
198-
Set embeddings.
225+
Set 'embeddings' in the .yace file for lammps. Some terms here control if a square-root embedding term is added.
199226
200-
ACE_DOCS_MISSING
227+
This should always be OFF for descriptor calculations in MALA.
201228
202229
Parameters
203230
----------
204231
npoti : str
205-
ACE_DOCS_MISSING
232+
paramter to specify descriptor type in LAMMPS
206233
207234
FSparams : List
208-
ACE_DOCS_MISSING
235+
parameters to specify embedding terms in LAMMPS
209236
"""
210237
# embeddings =dict()#OrderedDict() #{ind:None for ind in range(len(self.elements))}
211238
embeddings = {ind: None for ind in range(len(self.__elements))}
@@ -227,9 +254,12 @@ def __set_bonds(self):
227254

228255
def __set_bond_base(self):
229256
"""
230-
Set bond base.
257+
Set the per-bond radial basis parameters. The 'bonds' are determined based on the elements.
258+
259+
If the elements are ['Al','G'], the bonds may be determined with :code:`itertools.product()` in python. They are (Al,Al)(Al,G)(G,Al)(G,G).
231260
232-
ACE_DOCS_MISSING - what does that mean, what does this function do?
261+
Some hyperparameters must be specified per bond label shown here.
262+
233263
"""
234264
bondstrs = ["[%d, %d]" % (b[0], b[1]) for b in self.__bondlsts]
235265
bonds = {bondstr: None for bondstr in bondstrs}
@@ -312,17 +342,18 @@ def __set_bond_base(self):
312342

313343
def set_funcs(self, nulst=None, print_0s=True):
314344
"""
315-
Set functions.
316-
317-
ACE_DOCS_MISSING - what does this function do?
345+
Set ctilde 'functions' in the .yace file, used to calculate descriptors in lammps.
318346
319347
Parameters
320348
----------
321349
nulst : List
322-
List of nus ACE_DOCS_MISSING - what are those?
350+
List of nus, a.k.a. ACE descriptor labels to write to
351+
the .yace file.
323352
324353
print_0s : bool
325-
ACE_DOCS_MISSING - what does this do?
354+
Logical to include 0-valued descriptors, this should always
355+
be True in MALA as 0-valued descriptors only arise after
356+
training linear models with sparsifying solvers like LASSO
326357
"""
327358
if nulst is None:
328359
if self.__nus is not None:

mala/descriptors/acelib/clebsch_gordan_coupling.py

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,35 @@ def clebsch_gordan_coupling(
88
clebsch_gordan_coefficients, ldict, L_R=0, use_permutations=True
99
):
1010
"""
11-
Compute Clebsch-Gordan couplings for a given L_R.
11+
Compute generalized Clebsch-Gordan coefficients for a given L_R.
1212
13-
ACE_DOCS_MISSING: Clarify what this means, and also maybe the name,
14-
because I am not so sure about it (see ace.py).
13+
These are all defined according to the pairwise coupling scheme in Goff et al. 2024.
14+
15+
The approach to construct generalized Clebsch-Gordan coefficients is manually defined for each rank for pedagogical and clarity purposes.
1516
1617
Parameters
1718
----------
1819
clebsch_gordan_coefficients : dict
1920
Precomputed Clebsch-Gordan coefficients.
2021
2122
ldict : dict
22-
Dictionary of ranks and their corresponding L values.
23+
Dictionary of ranks and their corresponding l values.
2324
2425
L_R : int
25-
ACE_DOCS_MISSING
26+
Resultant angular momentum quantum number. This determines the equivariant
27+
character of the rank N descriptor after reduction. L_R=0 corresponds to
28+
a rotationally invariant feature, L_R=1 corresponds to a feature that
29+
transforms like a vector, L_R=2 a tensor, etc.
2630
2731
use_permutations : bool
28-
ACE_DOCS_MISSING
32+
Flag to consider permutations of l in generation of coupling coefficients.
2933
3034
Returns
3135
-------
3236
coupling : dict
33-
Clebsch-Gordan couplings.
37+
Generalized Clebsch-Gordan coefficients, {M_R:{rank:{l:{m:coupling_coefficient}}}
3438
"""
3539
# Define the functions for the individual ranks.
36-
# ACE_DOCS_MISSING Maybe we can briefly summarize what the differences
3740
# between the functions for the individual ranks are.
3841

3942
def _rank_1_tree(_clebsch_gordan_coefficients, _l, _L_R=0, _M_R=0):
@@ -46,18 +49,18 @@ def _rank_1_tree(_clebsch_gordan_coefficients, _l, _L_R=0, _M_R=0):
4649
Precomputed Clebsch-Gordan coefficients.
4750
4851
_l : List
49-
ACE_DOCS_MISSING
52+
list of angular momentum quantum numbers [l1]
5053
5154
_L_R : int
52-
ACE_DOCS_MISSING
55+
Resultant angular momentum quantum number. This determines the equivariant character of the rank N descriptor after reduction. L_R=0 corresponds to a rotationally invariant feature, L_R=1 corresponds to a feature that transforms like a vector, L_R=2 a tensor, etc.
5356
5457
_M_R : int
55-
ACE_DOCS_MISSING
58+
Resultant projection quantum number. This also determines the equivariant character of the rank N descriptor after reduction. M_R must obey -L_R <= M_R <= L_R.
5659
5760
Returns
5861
-------
5962
decomposed : dict
60-
Clebsch-Gordan couplings for rank 1.
63+
Generalized Clebsch-Gordan coefficient for rank 1
6164
"""
6265
mstrs = mala.descriptors.acelib.common_utils.get_ms(_l, _M_R)
6366
full_inter_tuples = [()]
@@ -94,18 +97,24 @@ def _rank_2_tree(_clebsch_gordan_coefficients, _l, _L_R=0, _M_R=0):
9497
Precomputed Clebsch-Gordan coefficients.
9598
9699
_l : List
97-
ACE_DOCS_MISSING
100+
list of angular momentum quantum numbers [l1,l2]
98101
99102
_L_R : int
100-
ACE_DOCS_MISSING
103+
Resultant angular momentum quantum number. This determines the equivariant
104+
character of the rank N descriptor after reduction. L_R=0 corresponds to
105+
a rotationally invariant feature, L_R=1 corresponds to a feature that
106+
transforms like a vector, L_R=2 a tensor, etc.
101107
102108
_M_R : int
103-
ACE_DOCS_MISSING
109+
Resultant projection quantum number. This also determines the equivariant
110+
character of the rank N descriptor after reduction. M_R must obey
111+
-L_R <= M_R <= L_R
104112
105113
Returns
106114
-------
107115
decomposed : dict
108-
Clebsch-Gordan couplings for rank 2.
116+
Generalized Clebsch-Gordan coefficients for rank 2
117+
109118
"""
110119
nodes, remainder = ace_coupling_utils.build_quick_tree(_l)
111120
node = nodes[0]
@@ -147,18 +156,23 @@ def _rank_3_tree(_clebsch_gordan_coefficients, _l, _L_R=0, _M_R=0):
147156
Precomputed Clebsch-Gordan coefficients.
148157
149158
_l : List
150-
ACE_DOCS_MISSING
159+
list of angular momentum quantum numbers [l1,l2,l3]
151160
152161
_L_R : int
153-
ACE_DOCS_MISSING
162+
Resultant angular momentum quantum number. This determines the equivariant
163+
character of the rank N descriptor after reduction. L_R=0 corresponds to
164+
a rotationally invariant feature, L_R=1 corresponds to a feature that
165+
transforms like a vector, L_R=2 a tensor, etc.
154166
155167
_M_R : int
156-
ACE_DOCS_MISSING
168+
Resultant projection quantum number. This also determines the equivariant
169+
character of the rank N descriptor after reduction. M_R must obey
170+
-L_R <= M_R <= L_R
157171
158172
Returns
159173
-------
160174
decomposed : dict
161-
Clebsch-Gordan couplings for rank 3.
175+
Generalized Clebsch-Gordan coefficients for rank 3
162176
"""
163177
full_inter_tuples = ace_coupling_utils.build_tree_for_l_intermediates(
164178
_l, L_R=_L_R
@@ -203,18 +217,23 @@ def _rank_4_tree(_clebsch_gordan_coefficients, _l, _L_R=0, _M_R=0):
203217
Precomputed Clebsch-Gordan coefficients.
204218
205219
_l : List
206-
ACE_DOCS_MISSING
220+
list of angular momentum quantum numbers [l1,l2,l3,l4]
207221
208222
_L_R : int
209-
ACE_DOCS_MISSING
223+
Resultant angular momentum quantum number. This determines the equivariant
224+
character of the rank N descriptor after reduction. L_R=0 corresponds to
225+
a rotationally invariant feature, L_R=1 corresponds to a feature that
226+
transforms like a vector, L_R=2 a tensor, etc.
210227
211228
_M_R : int
212-
ACE_DOCS_MISSING
229+
Resultant projection quantum number. This also determines the equivariant
230+
character of the rank N descriptor after reduction. M_R must obey
231+
-L_R <= M_R <= L_R
213232
214233
Returns
215234
-------
216235
decomposed : dict
217-
Clebsch-Gordan couplings for rank 4.
236+
Generalized Clebsch-Gordan coefficients for rank 4
218237
"""
219238
nodes, remainder = ace_coupling_utils.build_quick_tree(_l)
220239
mstrs = mala.descriptors.acelib.common_utils.get_ms(_l, _M_R)
@@ -266,6 +285,8 @@ def _rank_4_tree(_clebsch_gordan_coefficients, _l, _L_R=0, _M_R=0):
266285
ranks = list(ldict.keys())
267286
coupling = {M_R: {rank: {} for rank in ranks} for M_R in M_Rs}
268287

288+
#NOTE higher-rank couplings (to enable higher rank descriptors)
289+
# are available in FitSNAP
269290
for M_R in M_Rs:
270291
for rank in ranks:
271292
rnk = rank

0 commit comments

Comments
 (0)