Datasets:

ArXiv:
License:
siyuanliuseed commited on
Commit
38ad8a5
·
1 Parent(s): e319285

first release

Browse files
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ 👋 Hi, everyone!
3
+ <br>
4
+ We are <b>ByteDance Seed team.</b>
5
+ </div>
6
+
7
+ <p align="center">
8
+ You can get to know us better through the following channels👇
9
+ <br>
10
+ <a href="https://seed.bytedance.com/">
11
+ <img src="https://img.shields.io/badge/Website-%231e37ff?style=for-the-badge&logo=bytedance&logoColor=white"></a>
12
+ <a href="https://github.com/user-attachments/assets/5793e67c-79bb-4a59-811a-fcc7ed510bd4">
13
+ <img src="https://img.shields.io/badge/WeChat-07C160?style=for-the-badge&logo=wechat&logoColor=white"></a>
14
+ <a href="https://www.xiaohongshu.com/user/profile/668e7e15000000000303157d?xsec_token=ABl2-aqekpytY6A8TuxjrwnZskU-6BsMRE_ufQQaSAvjc%3D&xsec_source=pc_search">
15
+ <img src="https://img.shields.io/badge/Xiaohongshu-%23FF2442?style=for-the-badge&logo=xiaohongshu&logoColor=white"></a>
16
+ <a href="https://www.zhihu.com/org/dou-bao-da-mo-xing-tuan-dui/">
17
+ <img src="https://img.shields.io/badge/zhihu-%230084FF?style=for-the-badge&logo=zhihu&logoColor=white"></a>
18
+ </p>
19
+
20
+ ![seed logo](https://github.com/user-attachments/assets/c42e675e-497c-4508-8bb9-093ad4d1f216)
21
+
22
+
23
+ # Towards A Universally Transferable Acceleration Method for Density Functional Theory
24
+ Zhe Liu, Yuyan Ni, Zhichen Pu, Qiming Sun, Siyuan Liu & Wen Yan
25
+
26
+ https://arxiv.org/abs/2509.25724
27
+
28
+ # TL;DR
29
+
30
+ We propose a framework for accelerating DFT calculations.
31
+
32
+ We train E(3)-equivariant neural networks to predict the expansion coefficients of the electron density in an auxiliary basis, and use the prediction to construct an initial guess for the SCF process. This approach exhibits superior transferability in various aspects.
33
+
34
+ # Contents
35
+
36
+ The repo currently contains the following contents:
37
+
38
+ * The full SCFbench dataset.
39
+ * The data pipeline for the SCFbench dataset.
40
+ * The PyTorch `nn.Module` of the species-wise linear layer for the prediction of the electron density coefficients.
41
+ * The NequIP model architecture with the species-wise linear layer.
42
+ * Example code for computing the density coefficients from a density matrix.
43
+
44
+ We will also release the following items soon:
45
+
46
+ * The training code for models.
47
+ * The full evaluation code.
48
+
49
+
50
+ # Requirements
51
+
52
+ * torch
53
+ * e3nn
54
+ * pyscf
55
+ * lmdb
56
+ * numpy>1.26
57
+ * nequip (if you want to use the NequIP model)
58
+
59
+
60
+ # Dataset Usage
61
+
62
+ The sample dataset contains the `main` dataset (the dataset for training, validation and in-distribution testing) and the `ood-test` dataset.
63
+
64
+ Each dataset contains several `parts`, each of which corresponds to a specific piece of information. The parts are:
65
+
66
+ * `base`: the basic information of the molecule, including atomic numbers, coordinates, etc.
67
+ * `dm`: the density matrix of the molecule.
68
+ * `fock`: the Hamiltonian (fock) matrix of the molecule.
69
+ * `auxdensity.denfit`: the density coefficients on def2-universal-jfit.
70
+ * `auxdensity.denfit.etb2.0`: the density coefficients on the ETB basis of def2-svp with $\beta=2.0$.
71
+ * `auxdensity.denfit.etb1.5`: the density coefficients on the ETB basis of def2-svp with $\beta=1.5$.
72
+
73
+ Example:
74
+
75
+ ```python
76
+ from dataset import SCFBenchDataset
77
+
78
+ # Loading base info (atomic numbers, coordinates, etc.), density matrix, Hamiltonian (fock) matrix and the density coefficients on def2-universal-jfit.
79
+ parts_to_load = ['base', 'dm', 'fock', 'auxdensity.denfit']
80
+ dataset = SCFBenchDataset(data_root='dataset/main', parts_to_load=parts_to_load)
81
+ dataset[0].keys()
82
+
83
+ # Loading the base info and the density coefficients on the ETB basis of def2-svp with $\beta=1.5$.
84
+ parts_to_load = ['base', 'auxdensity.denfit.etb1.5']
85
+ dataset = SCFBenchDataset(data_root='dataset/ood-test', parts_to_load=parts_to_load, auxbasis='etb:def2-svp:1.5')
86
+ dataset[0].keys()
87
+
88
+ # for the raw data, use the underlying dataset
89
+ dataset.dataset[0].keys()
90
+ ```
91
+
92
+ # Citing SCFbench
93
+ If you use SCFbench in your research, please cite:
94
+ ```latex
95
+ @misc{liu2025universallytransferableaccelerationmethod,
96
+ title={Towards A Universally Transferable Acceleration Method for Density Functional Theory},
97
+ author={Zhe Liu and Yuyan Ni and Zhichen Pu and Qiming Sun and Siyuan Liu and Wen Yan},
98
+ year={2025},
99
+ eprint={2509.25724},
100
+ archivePrefix={arXiv},
101
+ primaryClass={physics.chem-ph},
102
+ url={https://arxiv.org/abs/2509.25724},
103
+ }
104
+ ```
105
+
106
+
107
+ ## License
108
+
109
+ Models are licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
110
+
111
+ The dataset is a derivative of [ChEMBL](https://www.ebi.ac.uk/chembl/), used under [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/).
112
+
113
+ Our modified version, the SCFbench dataset, is also licensed under [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/).
114
+
115
+ ## About [ByteDance Seed Team](https://seed.bytedance.com/)
116
+
117
+ Founded in 2023, ByteDance Seed Team is dedicated to crafting the industry's most advanced AI foundation models. The team aspires to become a world-class research team and make significant contributions to the advancement of science and society.
dataset.py ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import os
5
+ import lmdb
6
+ import pickle
7
+
8
+ from functools import lru_cache
9
+
10
+ import numpy as np
11
+
12
+ import torch
13
+ from torch.utils.data import Dataset
14
+
15
+ from gto import (
16
+ element_to_atomic_number,
17
+ GTOBasis,
18
+ GTOAuxDensityHelper,
19
+ GTOProductBasisHelper,
20
+ )
21
+
22
+
23
+ def compute_edge_index(coords, r_max, remove_self_loops=True):
24
+ from scipy.spatial import distance_matrix
25
+
26
+ dist = distance_matrix(coords, coords)
27
+ edge_index = np.stack(np.nonzero(dist < r_max), axis=0)
28
+ if remove_self_loops:
29
+ edge_index = edge_index[:, edge_index[0] != edge_index[1]]
30
+ return edge_index
31
+
32
+
33
+ class ShardedLMDBDataset(Dataset):
34
+ def __init__(self, data_root: str):
35
+ super().__init__()
36
+ self.data_root = data_root
37
+ if os.path.isfile(os.path.join(data_root, "data.lmdb")):
38
+ self.shards = ["."]
39
+ else:
40
+ self.shards = sorted(os.listdir(data_root))
41
+ envs = self.get_envs()
42
+ self.env_lengths = [env.stat()["entries"] for env in envs]
43
+ self.env_boundaries = np.cumsum(self.env_lengths)
44
+ self.len = self.env_boundaries[-1]
45
+
46
+ self.envs = None # postpone env intitialization until ddp is intitialized
47
+
48
+ def get_envs(self):
49
+ return [
50
+ lmdb.Environment(
51
+ os.path.join(self.data_root, shard, "data.lmdb"),
52
+ map_size=(1024**3) * 256,
53
+ subdir=False,
54
+ readonly=True,
55
+ readahead=True,
56
+ meminit=False,
57
+ lock=False,
58
+ )
59
+ for shard in self.shards
60
+ ]
61
+
62
+ def __len__(self):
63
+ return self.len
64
+
65
+ def __getitem__(self, index: int):
66
+ if self.envs is None:
67
+ self.envs = self.get_envs()
68
+ if index < 0 or index >= self.len:
69
+ raise IndexError
70
+ env_idx = np.searchsorted(self.env_boundaries, index, "right")
71
+ data_idx = index - (self.env_boundaries[env_idx - 1] if env_idx != 0 else 0)
72
+ x = pickle.loads(
73
+ self.envs[env_idx].begin(write=False).get(f"{data_idx}".encode())
74
+ )
75
+ return x
76
+
77
+
78
+ class MultipartLMDBDataset(Dataset):
79
+ def __init__(self, data_root: str, parts_to_load: list[str] = ["base"]):
80
+ super().__init__()
81
+ self.data_root = data_root
82
+ self.subdatasets = {
83
+ part: ShardedLMDBDataset(os.path.join(data_root, part))
84
+ for part in parts_to_load
85
+ }
86
+ self.len = len(next(iter(self.subdatasets.values())))
87
+ assert all(
88
+ len(subdataset) == self.len for subdataset in self.subdatasets.values()
89
+ )
90
+
91
+ def __len__(self):
92
+ return self.len
93
+
94
+ def __getitem__(self, index: int):
95
+ ret = {}
96
+ for part, subdataset in self.subdatasets.items():
97
+ ret.update(subdataset[index])
98
+ return ret
99
+
100
+
101
+ class SCFBenchDataset(Dataset):
102
+ """
103
+ Unit assumption:
104
+ atomic coordinates: angstrom
105
+ multipole moments: atomic unit
106
+ auxdensity: atomic unit
107
+ dm: atomic unit
108
+ fock: atomic unit
109
+ """
110
+
111
+ def __init__(
112
+ self,
113
+ data_root,
114
+ r_max=5.0,
115
+ type_names=["H", "C", "N", "O", "F", "P", "S"],
116
+ remove_self_loops=True,
117
+ parts_to_load=["base", "dm", "fock", "auxdensity.denfit"],
118
+ aobasis="def2-svp",
119
+ auxbasis="def2-universal-jfit",
120
+ use_denfit_ovlp=False,
121
+ ):
122
+ super().__init__()
123
+
124
+ self.data_root = data_root
125
+ self.parts_to_load = parts_to_load
126
+
127
+ self.dataset = MultipartLMDBDataset(
128
+ self.data_root, parts_to_load=self.parts_to_load
129
+ )
130
+
131
+ self.type_names = type_names
132
+ self.atom_numbers = [element_to_atomic_number[e] for e in self.type_names]
133
+ self.atom_number_to_index = {z: i for i, z in enumerate(self.atom_numbers)}
134
+
135
+ self.data_r_max = r_max
136
+ self.remove_self_loops = remove_self_loops
137
+
138
+ assert sum(["auxdensity" in p for p in parts_to_load]) <= 1, (
139
+ "Only one kind of auxdensity can be loaded."
140
+ )
141
+
142
+ if any(p.startswith("auxdensity") for p in parts_to_load):
143
+ self.auxbasis = GTOBasis.from_basis_name(auxbasis, elements=type_names)
144
+ self.use_denfit_ovlp = use_denfit_ovlp
145
+
146
+ if "dm" in parts_to_load or "fock" in parts_to_load or "mo" in parts_to_load:
147
+ self.aobasis = GTOBasis.from_basis_name(aobasis, elements=type_names)
148
+ self.ao_prod_basis = GTOProductBasisHelper(self.aobasis)
149
+
150
+ def __len__(self):
151
+ return len(self.dataset)
152
+
153
+ @lru_cache(maxsize=16)
154
+ def __getitem__(self, idx):
155
+ d = self.dataset[idx].copy()
156
+
157
+ d["atom_coords"] = d["atom_coords"]
158
+
159
+ d["edge_index"] = compute_edge_index(
160
+ d["atom_coords"], self.data_r_max, self.remove_self_loops
161
+ )
162
+
163
+ ret = {
164
+ "z": torch.LongTensor(
165
+ [self.atom_number_to_index[n] for n in d["atom_number"]]
166
+ ),
167
+ "pos": torch.FloatTensor(d["atom_coords"]),
168
+ "net_charge": torch.LongTensor([int(d["net_charge"])]),
169
+ "spin": torch.LongTensor([int(d["spin"])]),
170
+ "edge_index": torch.LongTensor(d["edge_index"]),
171
+ }
172
+
173
+ if any(p.startswith("auxdensity") for p in self.parts_to_load):
174
+ if self.use_denfit_ovlp:
175
+ auxdensity_key = "aux_density_denfit_ovlp"
176
+ else:
177
+ auxdensity_key = (
178
+ "aux_density_jfit"
179
+ if "auxdensity.jfit" in self.parts_to_load
180
+ else "aux_density_denfit"
181
+ )
182
+ gtoaux = GTOAuxDensityHelper(d["atom_number"], self.auxbasis)
183
+ auxdensity_by_element = gtoaux.split_ao_by_elements(
184
+ gtoaux.transform_from_pyscf_to_std(d[auxdensity_key])
185
+ )
186
+ ret.update(
187
+ {
188
+ "auxdensity": {
189
+ k: torch.FloatTensor(t)
190
+ for k, t in auxdensity_by_element.items()
191
+ },
192
+ "species_indices": {
193
+ k: torch.IntTensor(t)
194
+ for k, t in gtoaux.atom_indices_by_element.items()
195
+ },
196
+ }
197
+ )
198
+
199
+ if "dm" in self.parts_to_load:
200
+ (
201
+ dm_diag_blocks,
202
+ dm_diag_masks,
203
+ dm_tril_blocks,
204
+ dm_tril_masks,
205
+ dm_tril_edge_index,
206
+ ) = self.ao_prod_basis.split_matrix_to_padded_blocks(
207
+ d["atom_number"],
208
+ self.ao_prod_basis.transform_from_pyscf_to_std(
209
+ d["atom_number"], d["density_matrix"]
210
+ ),
211
+ )
212
+ ret.update(
213
+ {
214
+ "dm_diag_blocks": torch.FloatTensor(dm_diag_blocks),
215
+ "dm_diag_masks": torch.BoolTensor(dm_diag_masks),
216
+ "dm_tril_blocks": torch.FloatTensor(dm_tril_blocks),
217
+ "dm_tril_masks": torch.BoolTensor(dm_tril_masks),
218
+ "dm_tril_edge_index": torch.IntTensor(dm_tril_edge_index),
219
+ }
220
+ )
221
+
222
+ if "fock" in self.parts_to_load:
223
+ (
224
+ fock_diag_blocks,
225
+ fock_diag_masks,
226
+ fock_tril_blocks,
227
+ fock_tril_masks,
228
+ fock_tril_edge_index,
229
+ ) = self.ao_prod_basis.split_matrix_to_padded_blocks(
230
+ d["atom_number"],
231
+ self.ao_prod_basis.transform_from_pyscf_to_std(
232
+ d["atom_number"], d["fock"]
233
+ ),
234
+ )
235
+ ret.update(
236
+ {
237
+ "fock_diag_blocks": torch.FloatTensor(fock_diag_blocks),
238
+ "fock_diag_masks": torch.BoolTensor(fock_diag_masks),
239
+ "fock_tril_blocks": torch.FloatTensor(fock_tril_blocks),
240
+ "fock_tril_masks": torch.BoolTensor(fock_tril_masks),
241
+ "fock_tril_edge_index": torch.IntTensor(fock_tril_edge_index),
242
+ }
243
+ )
244
+
245
+ return ret
dataset/LICENSE.txt ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Creative Commons Legal Code
2
+
3
+ Attribution-ShareAlike 3.0 Unported
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
10
+ DAMAGES RESULTING FROM ITS USE.
11
+
12
+ License
13
+
14
+ THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
15
+ COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
16
+ COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
17
+ AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
18
+
19
+ BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
20
+ TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
21
+ BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
22
+ CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
23
+ CONDITIONS.
24
+
25
+ 1. Definitions
26
+
27
+ a. "Adaptation" means a work based upon the Work, or upon the Work and
28
+ other pre-existing works, such as a translation, adaptation,
29
+ derivative work, arrangement of music or other alterations of a
30
+ literary or artistic work, or phonogram or performance and includes
31
+ cinematographic adaptations or any other form in which the Work may be
32
+ recast, transformed, or adapted including in any form recognizably
33
+ derived from the original, except that a work that constitutes a
34
+ Collection will not be considered an Adaptation for the purpose of
35
+ this License. For the avoidance of doubt, where the Work is a musical
36
+ work, performance or phonogram, the synchronization of the Work in
37
+ timed-relation with a moving image ("synching") will be considered an
38
+ Adaptation for the purpose of this License.
39
+ b. "Collection" means a collection of literary or artistic works, such as
40
+ encyclopedias and anthologies, or performances, phonograms or
41
+ broadcasts, or other works or subject matter other than works listed
42
+ in Section 1(f) below, which, by reason of the selection and
43
+ arrangement of their contents, constitute intellectual creations, in
44
+ which the Work is included in its entirety in unmodified form along
45
+ with one or more other contributions, each constituting separate and
46
+ independent works in themselves, which together are assembled into a
47
+ collective whole. A work that constitutes a Collection will not be
48
+ considered an Adaptation (as defined below) for the purposes of this
49
+ License.
50
+ c. "Creative Commons Compatible License" means a license that is listed
51
+ at https://creativecommons.org/compatiblelicenses that has been
52
+ approved by Creative Commons as being essentially equivalent to this
53
+ License, including, at a minimum, because that license: (i) contains
54
+ terms that have the same purpose, meaning and effect as the License
55
+ Elements of this License; and, (ii) explicitly permits the relicensing
56
+ of adaptations of works made available under that license under this
57
+ License or a Creative Commons jurisdiction license with the same
58
+ License Elements as this License.
59
+ d. "Distribute" means to make available to the public the original and
60
+ copies of the Work or Adaptation, as appropriate, through sale or
61
+ other transfer of ownership.
62
+ e. "License Elements" means the following high-level license attributes
63
+ as selected by Licensor and indicated in the title of this License:
64
+ Attribution, ShareAlike.
65
+ f. "Licensor" means the individual, individuals, entity or entities that
66
+ offer(s) the Work under the terms of this License.
67
+ g. "Original Author" means, in the case of a literary or artistic work,
68
+ the individual, individuals, entity or entities who created the Work
69
+ or if no individual or entity can be identified, the publisher; and in
70
+ addition (i) in the case of a performance the actors, singers,
71
+ musicians, dancers, and other persons who act, sing, deliver, declaim,
72
+ play in, interpret or otherwise perform literary or artistic works or
73
+ expressions of folklore; (ii) in the case of a phonogram the producer
74
+ being the person or legal entity who first fixes the sounds of a
75
+ performance or other sounds; and, (iii) in the case of broadcasts, the
76
+ organization that transmits the broadcast.
77
+ h. "Work" means the literary and/or artistic work offered under the terms
78
+ of this License including without limitation any production in the
79
+ literary, scientific and artistic domain, whatever may be the mode or
80
+ form of its expression including digital form, such as a book,
81
+ pamphlet and other writing; a lecture, address, sermon or other work
82
+ of the same nature; a dramatic or dramatico-musical work; a
83
+ choreographic work or entertainment in dumb show; a musical
84
+ composition with or without words; a cinematographic work to which are
85
+ assimilated works expressed by a process analogous to cinematography;
86
+ a work of drawing, painting, architecture, sculpture, engraving or
87
+ lithography; a photographic work to which are assimilated works
88
+ expressed by a process analogous to photography; a work of applied
89
+ art; an illustration, map, plan, sketch or three-dimensional work
90
+ relative to geography, topography, architecture or science; a
91
+ performance; a broadcast; a phonogram; a compilation of data to the
92
+ extent it is protected as a copyrightable work; or a work performed by
93
+ a variety or circus performer to the extent it is not otherwise
94
+ considered a literary or artistic work.
95
+ i. "You" means an individual or entity exercising rights under this
96
+ License who has not previously violated the terms of this License with
97
+ respect to the Work, or who has received express permission from the
98
+ Licensor to exercise rights under this License despite a previous
99
+ violation.
100
+ j. "Publicly Perform" means to perform public recitations of the Work and
101
+ to communicate to the public those public recitations, by any means or
102
+ process, including by wire or wireless means or public digital
103
+ performances; to make available to the public Works in such a way that
104
+ members of the public may access these Works from a place and at a
105
+ place individually chosen by them; to perform the Work to the public
106
+ by any means or process and the communication to the public of the
107
+ performances of the Work, including by public digital performance; to
108
+ broadcast and rebroadcast the Work by any means including signs,
109
+ sounds or images.
110
+ k. "Reproduce" means to make copies of the Work by any means including
111
+ without limitation by sound or visual recordings and the right of
112
+ fixation and reproducing fixations of the Work, including storage of a
113
+ protected performance or phonogram in digital form or other electronic
114
+ medium.
115
+
116
+ 2. Fair Dealing Rights. Nothing in this License is intended to reduce,
117
+ limit, or restrict any uses free from copyright or rights arising from
118
+ limitations or exceptions that are provided for in connection with the
119
+ copyright protection under copyright law or other applicable laws.
120
+
121
+ 3. License Grant. Subject to the terms and conditions of this License,
122
+ Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
123
+ perpetual (for the duration of the applicable copyright) license to
124
+ exercise the rights in the Work as stated below:
125
+
126
+ a. to Reproduce the Work, to incorporate the Work into one or more
127
+ Collections, and to Reproduce the Work as incorporated in the
128
+ Collections;
129
+ b. to create and Reproduce Adaptations provided that any such Adaptation,
130
+ including any translation in any medium, takes reasonable steps to
131
+ clearly label, demarcate or otherwise identify that changes were made
132
+ to the original Work. For example, a translation could be marked "The
133
+ original work was translated from English to Spanish," or a
134
+ modification could indicate "The original work has been modified.";
135
+ c. to Distribute and Publicly Perform the Work including as incorporated
136
+ in Collections; and,
137
+ d. to Distribute and Publicly Perform Adaptations.
138
+ e. For the avoidance of doubt:
139
+
140
+ i. Non-waivable Compulsory License Schemes. In those jurisdictions in
141
+ which the right to collect royalties through any statutory or
142
+ compulsory licensing scheme cannot be waived, the Licensor
143
+ reserves the exclusive right to collect such royalties for any
144
+ exercise by You of the rights granted under this License;
145
+ ii. Waivable Compulsory License Schemes. In those jurisdictions in
146
+ which the right to collect royalties through any statutory or
147
+ compulsory licensing scheme can be waived, the Licensor waives the
148
+ exclusive right to collect such royalties for any exercise by You
149
+ of the rights granted under this License; and,
150
+ iii. Voluntary License Schemes. The Licensor waives the right to
151
+ collect royalties, whether individually or, in the event that the
152
+ Licensor is a member of a collecting society that administers
153
+ voluntary licensing schemes, via that society, from any exercise
154
+ by You of the rights granted under this License.
155
+
156
+ The above rights may be exercised in all media and formats whether now
157
+ known or hereafter devised. The above rights include the right to make
158
+ such modifications as are technically necessary to exercise the rights in
159
+ other media and formats. Subject to Section 8(f), all rights not expressly
160
+ granted by Licensor are hereby reserved.
161
+
162
+ 4. Restrictions. The license granted in Section 3 above is expressly made
163
+ subject to and limited by the following restrictions:
164
+
165
+ a. You may Distribute or Publicly Perform the Work only under the terms
166
+ of this License. You must include a copy of, or the Uniform Resource
167
+ Identifier (URI) for, this License with every copy of the Work You
168
+ Distribute or Publicly Perform. You may not offer or impose any terms
169
+ on the Work that restrict the terms of this License or the ability of
170
+ the recipient of the Work to exercise the rights granted to that
171
+ recipient under the terms of the License. You may not sublicense the
172
+ Work. You must keep intact all notices that refer to this License and
173
+ to the disclaimer of warranties with every copy of the Work You
174
+ Distribute or Publicly Perform. When You Distribute or Publicly
175
+ Perform the Work, You may not impose any effective technological
176
+ measures on the Work that restrict the ability of a recipient of the
177
+ Work from You to exercise the rights granted to that recipient under
178
+ the terms of the License. This Section 4(a) applies to the Work as
179
+ incorporated in a Collection, but this does not require the Collection
180
+ apart from the Work itself to be made subject to the terms of this
181
+ License. If You create a Collection, upon notice from any Licensor You
182
+ must, to the extent practicable, remove from the Collection any credit
183
+ as required by Section 4(c), as requested. If You create an
184
+ Adaptation, upon notice from any Licensor You must, to the extent
185
+ practicable, remove from the Adaptation any credit as required by
186
+ Section 4(c), as requested.
187
+ b. You may Distribute or Publicly Perform an Adaptation only under the
188
+ terms of: (i) this License; (ii) a later version of this License with
189
+ the same License Elements as this License; (iii) a Creative Commons
190
+ jurisdiction license (either this or a later license version) that
191
+ contains the same License Elements as this License (e.g.,
192
+ Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible
193
+ License. If you license the Adaptation under one of the licenses
194
+ mentioned in (iv), you must comply with the terms of that license. If
195
+ you license the Adaptation under the terms of any of the licenses
196
+ mentioned in (i), (ii) or (iii) (the "Applicable License"), you must
197
+ comply with the terms of the Applicable License generally and the
198
+ following provisions: (I) You must include a copy of, or the URI for,
199
+ the Applicable License with every copy of each Adaptation You
200
+ Distribute or Publicly Perform; (II) You may not offer or impose any
201
+ terms on the Adaptation that restrict the terms of the Applicable
202
+ License or the ability of the recipient of the Adaptation to exercise
203
+ the rights granted to that recipient under the terms of the Applicable
204
+ License; (III) You must keep intact all notices that refer to the
205
+ Applicable License and to the disclaimer of warranties with every copy
206
+ of the Work as included in the Adaptation You Distribute or Publicly
207
+ Perform; (IV) when You Distribute or Publicly Perform the Adaptation,
208
+ You may not impose any effective technological measures on the
209
+ Adaptation that restrict the ability of a recipient of the Adaptation
210
+ from You to exercise the rights granted to that recipient under the
211
+ terms of the Applicable License. This Section 4(b) applies to the
212
+ Adaptation as incorporated in a Collection, but this does not require
213
+ the Collection apart from the Adaptation itself to be made subject to
214
+ the terms of the Applicable License.
215
+ c. If You Distribute, or Publicly Perform the Work or any Adaptations or
216
+ Collections, You must, unless a request has been made pursuant to
217
+ Section 4(a), keep intact all copyright notices for the Work and
218
+ provide, reasonable to the medium or means You are utilizing: (i) the
219
+ name of the Original Author (or pseudonym, if applicable) if supplied,
220
+ and/or if the Original Author and/or Licensor designate another party
221
+ or parties (e.g., a sponsor institute, publishing entity, journal) for
222
+ attribution ("Attribution Parties") in Licensor's copyright notice,
223
+ terms of service or by other reasonable means, the name of such party
224
+ or parties; (ii) the title of the Work if supplied; (iii) to the
225
+ extent reasonably practicable, the URI, if any, that Licensor
226
+ specifies to be associated with the Work, unless such URI does not
227
+ refer to the copyright notice or licensing information for the Work;
228
+ and (iv) , consistent with Ssection 3(b), in the case of an
229
+ Adaptation, a credit identifying the use of the Work in the Adaptation
230
+ (e.g., "French translation of the Work by Original Author," or
231
+ "Screenplay based on original Work by Original Author"). The credit
232
+ required by this Section 4(c) may be implemented in any reasonable
233
+ manner; provided, however, that in the case of a Adaptation or
234
+ Collection, at a minimum such credit will appear, if a credit for all
235
+ contributing authors of the Adaptation or Collection appears, then as
236
+ part of these credits and in a manner at least as prominent as the
237
+ credits for the other contributing authors. For the avoidance of
238
+ doubt, You may only use the credit required by this Section for the
239
+ purpose of attribution in the manner set out above and, by exercising
240
+ Your rights under this License, You may not implicitly or explicitly
241
+ assert or imply any connection with, sponsorship or endorsement by the
242
+ Original Author, Licensor and/or Attribution Parties, as appropriate,
243
+ of You or Your use of the Work, without the separate, express prior
244
+ written permission of the Original Author, Licensor and/or Attribution
245
+ Parties.
246
+ d. Except as otherwise agreed in writing by the Licensor or as may be
247
+ otherwise permitted by applicable law, if You Reproduce, Distribute or
248
+ Publicly Perform the Work either by itself or as part of any
249
+ Adaptations or Collections, You must not distort, mutilate, modify or
250
+ take other derogatory action in relation to the Work which would be
251
+ prejudicial to the Original Author's honor or reputation. Licensor
252
+ agrees that in those jurisdictions (e.g. Japan), in which any exercise
253
+ of the right granted in Section 3(b) of this License (the right to
254
+ make Adaptations) would be deemed to be a distortion, mutilation,
255
+ modification or other derogatory action prejudicial to the Original
256
+ Author's honor and reputation, the Licensor will waive or not assert,
257
+ as appropriate, this Section, to the fullest extent permitted by the
258
+ applicable national law, to enable You to reasonably exercise Your
259
+ right under Section 3(b) of this License (right to make Adaptations)
260
+ but not otherwise.
261
+
262
+ 5. Representations, Warranties and Disclaimer
263
+
264
+ UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
265
+ OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
266
+ KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
267
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
268
+ FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
269
+ LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
270
+ WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
271
+ OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
272
+
273
+ 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
274
+ LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
275
+ ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
276
+ ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
277
+ BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
278
+
279
+ 7. Termination
280
+
281
+ a. This License and the rights granted hereunder will terminate
282
+ automatically upon any breach by You of the terms of this License.
283
+ Individuals or entities who have received Adaptations or Collections
284
+ from You under this License, however, will not have their licenses
285
+ terminated provided such individuals or entities remain in full
286
+ compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
287
+ survive any termination of this License.
288
+ b. Subject to the above terms and conditions, the license granted here is
289
+ perpetual (for the duration of the applicable copyright in the Work).
290
+ Notwithstanding the above, Licensor reserves the right to release the
291
+ Work under different license terms or to stop distributing the Work at
292
+ any time; provided, however that any such election will not serve to
293
+ withdraw this License (or any other license that has been, or is
294
+ required to be, granted under the terms of this License), and this
295
+ License will continue in full force and effect unless terminated as
296
+ stated above.
297
+
298
+ 8. Miscellaneous
299
+
300
+ a. Each time You Distribute or Publicly Perform the Work or a Collection,
301
+ the Licensor offers to the recipient a license to the Work on the same
302
+ terms and conditions as the license granted to You under this License.
303
+ b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
304
+ offers to the recipient a license to the original Work on the same
305
+ terms and conditions as the license granted to You under this License.
306
+ c. If any provision of this License is invalid or unenforceable under
307
+ applicable law, it shall not affect the validity or enforceability of
308
+ the remainder of the terms of this License, and without further action
309
+ by the parties to this agreement, such provision shall be reformed to
310
+ the minimum extent necessary to make such provision valid and
311
+ enforceable.
312
+ d. No term or provision of this License shall be deemed waived and no
313
+ breach consented to unless such waiver or consent shall be in writing
314
+ and signed by the party to be charged with such waiver or consent.
315
+ e. This License constitutes the entire agreement between the parties with
316
+ respect to the Work licensed here. There are no understandings,
317
+ agreements or representations with respect to the Work not specified
318
+ here. Licensor shall not be bound by any additional provisions that
319
+ may appear in any communication from You. This License may not be
320
+ modified without the mutual written agreement of the Licensor and You.
321
+ f. The rights granted under, and the subject matter referenced, in this
322
+ License were drafted utilizing the terminology of the Berne Convention
323
+ for the Protection of Literary and Artistic Works (as amended on
324
+ September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
325
+ Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
326
+ and the Universal Copyright Convention (as revised on July 24, 1971).
327
+ These rights and subject matter take effect in the relevant
328
+ jurisdiction in which the License terms are sought to be enforced
329
+ according to the corresponding provisions of the implementation of
330
+ those treaty provisions in the applicable national law. If the
331
+ standard suite of rights granted under applicable copyright law
332
+ includes additional rights not granted under this License, such
333
+ additional rights are deemed to be included in the License; this
334
+ License is not intended to restrict the license of any rights under
335
+ applicable law.
336
+
337
+
338
+ Creative Commons Notice
339
+
340
+ Creative Commons is not a party to this License, and makes no warranty
341
+ whatsoever in connection with the Work. Creative Commons will not be
342
+ liable to You or any party on any legal theory for any damages
343
+ whatsoever, including without limitation any general, special,
344
+ incidental or consequential damages arising in connection to this
345
+ license. Notwithstanding the foregoing two (2) sentences, if Creative
346
+ Commons has expressly identified itself as the Licensor hereunder, it
347
+ shall have all rights and obligations of Licensor.
348
+
349
+ Except for the limited purpose of indicating to the public that the
350
+ Work is licensed under the CCPL, Creative Commons does not authorize
351
+ the use by either party of the trademark "Creative Commons" or any
352
+ related trademark or logo of Creative Commons without the prior
353
+ written consent of Creative Commons. Any permitted use will be in
354
+ compliance with Creative Commons' then-current trademark usage
355
+ guidelines, as may be published on its website or otherwise made
356
+ available upon request from time to time. For the avoidance of doubt,
357
+ this trademark restriction does not form part of the License.
358
+
359
+ Creative Commons may be contacted at https://creativecommons.org/.
dataset/README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ 👋 Hi, everyone!
3
+ <br>
4
+ We are <b>ByteDance Seed team.</b>
5
+ </div>
6
+
7
+ <p align="center">
8
+ You can get to know us better through the following channels👇
9
+ <br>
10
+ <a href="https://seed.bytedance.com/">
11
+ <img src="https://img.shields.io/badge/Website-%231e37ff?style=for-the-badge&logo=bytedance&logoColor=white"></a>
12
+ <a href="https://github.com/user-attachments/assets/5793e67c-79bb-4a59-811a-fcc7ed510bd4">
13
+ <img src="https://img.shields.io/badge/WeChat-07C160?style=for-the-badge&logo=wechat&logoColor=white"></a>
14
+ <a href="https://www.xiaohongshu.com/user/profile/668e7e15000000000303157d?xsec_token=ABl2-aqekpytY6A8TuxjrwnZskU-6BsMRE_ufQQaSAvjc%3D&xsec_source=pc_search">
15
+ <img src="https://img.shields.io/badge/Xiaohongshu-%23FF2442?style=for-the-badge&logo=xiaohongshu&logoColor=white"></a>
16
+ <a href="https://www.zhihu.com/org/dou-bao-da-mo-xing-tuan-dui/">
17
+ <img src="https://img.shields.io/badge/zhihu-%230084FF?style=for-the-badge&logo=zhihu&logoColor=white"></a>
18
+ </p>
19
+
20
+ ![seed logo](https://github.com/user-attachments/assets/c42e675e-497c-4508-8bb9-093ad4d1f216)
21
+
22
+
23
+ # Towards A Universally Transferable Acceleration Method for Density Functional Theory
24
+ Zhe Liu, Yuyan Ni, Zhichen Pu, Qiming Sun, Siyuan Liu & Wen Yan
25
+
26
+ https://arxiv.org/abs/2509.25724
27
+
28
+ # Citing SCFBench
29
+ If you use SCFBench in your research, please cite:
30
+ ```latex
31
+ @misc{liu2025universallytransferableaccelerationmethod,
32
+ title={Towards A Universally Transferable Acceleration Method for Density Functional Theory},
33
+ author={Zhe Liu and Yuyan Ni and Zhichen Pu and Qiming Sun and Siyuan Liu and Wen Yan},
34
+ year={2025},
35
+ eprint={2509.25724},
36
+ archivePrefix={arXiv},
37
+ primaryClass={physics.chem-ph},
38
+ url={https://arxiv.org/abs/2509.25724},
39
+ }
40
+ ```
41
+
42
+
43
+ ## License
44
+
45
+ The dataset is a derivative of [ChEMBL](https://www.ebi.ac.uk/chembl/), used under [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/).
46
+
47
+ Our modified version, the SCFBench dataset, is also licensed under [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/).
48
+
49
+ ## About [ByteDance Seed Team](https://seed.bytedance.com/)
50
+
51
+ Founded in 2023, ByteDance Seed Team is dedicated to crafting the industry's most advanced AI foundation models. The team aspires to become a world-class research team and make significant contributions to the advancement of science and society.
dataset/main/auxdensity.denfit.etb1.5/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d1e2ff545fb684cd41e88cfac91e58556fed6bd2a615713a30ca5e8f8099d1c
3
+ size 1733136384
dataset/main/auxdensity.denfit.etb2.0/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:934d9ac292edcafc8c8c3ea7e8b7e2f6a44e6c016d8ca9ca5b39737cfceca2e5
3
+ size 1081253888
dataset/main/auxdensity.denfit/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:661d34a6e0e4937558c5b35934bd1a3c9544d1f9321f3cb6e2443b491cf74c17
3
+ size 507383808
dataset/main/base/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0fb6a7b9c25549934baf1187d03dd1234ed2f56f5485a21b7e1baac991eddc1
3
+ size 144449536
dataset/main/dm/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9cceaafd47a83195b6d5a4ad6151ff6ee5ee0423f6fb4f9af2d6e7eeb7553af
3
+ size 5826564096
dataset/main/fock/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb6c66476edc382940bac4db00b6ccafe60a2c7d410def574dccedfbfc56a45a
3
+ size 11557953536
dataset/ood-test/auxdensity.denfit.etb1.5/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12dac3be3a16b41a36065d553b123a04909714e0fcb56931f5ff40bb3b70048e
3
+ size 93360128
dataset/ood-test/auxdensity.denfit.etb2.0/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c5c5090caec500b62458871cdbdd4e6456c08f04c93c26a404b4de0bc4f7f90
3
+ size 56635392
dataset/ood-test/auxdensity.denfit/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4449dbc48b3341b9a99c8689dffec3d95f9fadbf1f05413f5446495cb1d0e1fe
3
+ size 28024832
dataset/ood-test/base/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f22a95ff7333f8a6bfa079d0bb619400736cc9f331317ee3fcb1278a7bc0471
3
+ size 4329472
dataset/ood-test/dm/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:955f4535408ccfb30fb645e12547dde560a9a75d043212567e844a6dbb2294af
3
+ size 779104256
dataset/ood-test/fock/data.lmdb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:400dfb50d64e935f652c2f4943ce46ec4bf9fc32c4ce49efa5e989dd6b7bbf20
3
+ size 1555718144
dm_to_density_example.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import numpy as np
5
+ import pyscf
6
+ import pyscf.df
7
+
8
+ from dataset import MultipartLMDBDataset
9
+
10
+ BASIS = "def2-svp"
11
+ AUXBASIS = "def2-universal-jfit"
12
+
13
+
14
+ def get_rho_auxbasis_denfit(features):
15
+ nums = features["atom_number"]
16
+ coords = features["atom_coords"]
17
+ charge = int(features["net_charge"])
18
+ spin = int(features["spin"])
19
+ dm = features["density_matrix"]
20
+
21
+ mol = pyscf.M(
22
+ atom=list(zip(nums.tolist(), coords.tolist())),
23
+ unit="angstrom",
24
+ basis=BASIS,
25
+ charge=charge,
26
+ spin=spin,
27
+ )
28
+ auxmol = pyscf.df.addons.make_auxmol(mol, auxbasis=AUXBASIS)
29
+
30
+ ints_3c1e = pyscf.df.incore.aux_e2(mol, auxmol, intor="int3c1e")
31
+ aux_vec = np.linalg.solve(
32
+ auxmol.intor("int1e_ovlp"), np.einsum("ij,ijp->p", dm, ints_3c1e)
33
+ )
34
+
35
+ return {"aux_density_denfit": aux_vec}
36
+
37
+
38
+ def main():
39
+ dataset = MultipartLMDBDataset("dataset/main", parts_to_load=["base", "dm"])
40
+ d = dataset[0]
41
+ density_coeffs_dict = get_rho_auxbasis_denfit(d)
42
+ print(density_coeffs_dict["aux_density_denfit"])
43
+
44
+
45
+ if __name__ == "__main__":
46
+ main()
gto.py ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from functools import lru_cache
5
+
6
+ import numpy as np
7
+ import pyscf
8
+ from pyscf.data.elements import (
9
+ NUC as element_to_atomic_number,
10
+ ELEMENTS as atomic_number_to_element,
11
+ )
12
+
13
+ import torch
14
+ from e3nn import o3
15
+
16
+
17
+ def build_irreps_from_mol(mol):
18
+ parity = lambda l: "e" if l % 2 == 0 else "o"
19
+ irreps = o3.Irreps(
20
+ "+".join(f"{l}{parity(l)}" for l in map(mol.bas_angular, range(mol.nbas)))
21
+ )
22
+ return irreps
23
+
24
+
25
+ def ref_etb(aobasis, beta, atom_type_names):
26
+ charges = [element_to_atomic_number[element] for element in atom_type_names]
27
+ spin = sum(charges) % 2
28
+ coords = np.zeros((len(charges), 3))
29
+ reference_mol = pyscf.M(atom=list(zip(charges, coords)), basis=aobasis, spin=spin)
30
+ basis = pyscf.df.aug_etb(reference_mol, beta)
31
+ return basis
32
+
33
+
34
+ def parse_basis_name(basis_name, atom_type_names):
35
+ if basis_name.startswith("etb:"):
36
+ # example: etb:def2-svp:1.5
37
+ _, aobasis, beta = basis_name.split(":")
38
+ return ref_etb(aobasis, float(beta), atom_type_names)
39
+ else:
40
+ return basis_name
41
+
42
+
43
+ def per_element_irreps_from_basis_name(basis_name, elements):
44
+ basis = parse_basis_name(basis_name, elements)
45
+ per_element_irreps = {}
46
+ if isinstance(basis, str):
47
+ for e in elements:
48
+ z = element_to_atomic_number[e]
49
+ if z % 2 != 0:
50
+ spin = 1
51
+ else:
52
+ spin = 0
53
+ mol = pyscf.M(atom=[[z, [0, 0, 0]]], basis=basis_name, charge=0, spin=spin)
54
+ per_element_irreps[e] = build_irreps_from_mol(mol)
55
+ return per_element_irreps
56
+ else:
57
+ parity = lambda l: "e" if l % 2 == 0 else "o"
58
+ irrep_from_item = lambda item: f"1x{item[0]}{parity(item[0])}"
59
+ for e in elements:
60
+ per_element_irreps[e] = o3.Irreps(
61
+ "+".join(irrep_from_item(i) for i in basis[e])
62
+ )
63
+ return per_element_irreps
64
+
65
+
66
+ @lru_cache(maxsize=16)
67
+ def pyscf_to_standard_perm_D_for_single_irrep(l, p, dtype=torch.float32):
68
+ if l == 1:
69
+ return torch.tensor([[0, 1, 0], [0, 0, 1], [1, 0, 0]], dtype=dtype)
70
+ else:
71
+ return torch.eye(2 * l + 1, dtype=dtype)
72
+
73
+
74
+ @lru_cache(maxsize=32)
75
+ def e3nn_change_of_coord_D_for_single_irrep(l, p, dtype=torch.float32):
76
+ cod = torch.tensor(
77
+ [
78
+ # this specifies the change of basis yzx -> xyz
79
+ [0.0, 0.0, 1.0],
80
+ [1.0, 0.0, 0.0],
81
+ [0.0, 1.0, 0.0],
82
+ ],
83
+ dtype=dtype,
84
+ )
85
+ irreps = o3.Irreps([(1, (l, p))])
86
+ return irreps.D_from_matrix(cod)
87
+
88
+
89
+ @lru_cache(maxsize=32)
90
+ def pyscf_to_e3nn_D_for_single_irrep(l, p, dtype=torch.float32):
91
+ pyscf_to_std = pyscf_to_standard_perm_D_for_single_irrep(l, p, dtype=dtype)
92
+ cod_D = e3nn_change_of_coord_D_for_single_irrep(l, p, dtype=dtype)
93
+ return pyscf_to_std @ cod_D
94
+
95
+
96
+ def e3nn_change_of_coord_D(irreps, dtype=torch.float32):
97
+ perm = torch.block_diag(
98
+ *[
99
+ e3nn_change_of_coord_D_for_single_irrep(
100
+ orbital.ir.l, orbital.ir.p, dtype=dtype
101
+ )
102
+ for orbital in irreps
103
+ ]
104
+ )
105
+ return perm
106
+
107
+
108
+ def pyscf_to_standard_perm_D(atomic_orbital_irreps, dtype=torch.float32):
109
+ perm = torch.block_diag(
110
+ *[
111
+ pyscf_to_standard_perm_D_for_single_irrep(
112
+ orbital.ir.l, orbital.ir.p, dtype=dtype
113
+ )
114
+ for orbital in atomic_orbital_irreps
115
+ ]
116
+ )
117
+ return perm.to(dtype=dtype)
118
+
119
+
120
+ def get_pyscf_to_e3nn_D(atomic_orbital_irreps, dtype=torch.float32):
121
+ total_D = torch.block_diag(
122
+ *[
123
+ pyscf_to_e3nn_D_for_single_irrep(orbital.ir.l, orbital.ir.p, dtype=dtype)
124
+ for orbital in atomic_orbital_irreps
125
+ ]
126
+ )
127
+ return total_D
128
+
129
+
130
+ def transform_from_pyscf_to_std_fast_1d(irreps, array: np.ndarray):
131
+ # only the l=1 orbitals need to be transformed: xyz -> yzx
132
+ assert array.shape[0] == irreps.dim
133
+ ret = array.copy()
134
+ start = 0
135
+ for orbital in irreps:
136
+ if orbital.ir.l == 1:
137
+ for _ in range(orbital.mul):
138
+ ret[start : start + 3] = np.roll(ret[start : start + 3], -1, axis=0)
139
+ start += 3
140
+ else:
141
+ start += orbital.dim
142
+ return ret
143
+
144
+
145
+ def transform_from_std_to_pyscf_fast_1d(irreps, array: np.ndarray):
146
+ # only the l=1 orbitals need to be transformed: xyz -> yzx
147
+ assert array.shape[0] == irreps.dim
148
+ ret = array.copy()
149
+ start = 0
150
+ for orbital in irreps:
151
+ if orbital.ir.l == 1:
152
+ for _ in range(orbital.mul):
153
+ ret[start : start + 3] = np.roll(ret[start : start + 3], 1, axis=0)
154
+ start += 3
155
+ else:
156
+ start += orbital.dim
157
+ return ret
158
+
159
+
160
+ def transform_from_pyscf_to_std_fast_2d(irreps, matrix: np.ndarray):
161
+ assert matrix.shape[0] == matrix.shape[1] == irreps.dim
162
+ ret = matrix.copy()
163
+ start = 0
164
+ for orbital in irreps:
165
+ if orbital.ir.l == 1:
166
+ for _ in range(orbital.mul):
167
+ ret[start : start + 3, :] = np.roll(
168
+ ret[start : start + 3, :], -1, axis=0
169
+ )
170
+ ret[:, start : start + 3] = np.roll(
171
+ ret[:, start : start + 3], -1, axis=1
172
+ )
173
+ start += 3
174
+ else:
175
+ start += orbital.dim
176
+ return ret
177
+
178
+
179
+ def transform_from_std_to_pyscf_fast_2d(irreps, matrix: np.ndarray):
180
+ assert matrix.shape[0] == matrix.shape[1] == irreps.dim
181
+ ret = matrix.copy()
182
+ start = 0
183
+ for orbital in irreps:
184
+ if orbital.ir.l == 1:
185
+ for _ in range(orbital.mul):
186
+ ret[start : start + 3, :] = np.roll(
187
+ ret[start : start + 3, :], 1, axis=0
188
+ )
189
+ ret[:, start : start + 3] = np.roll(
190
+ ret[:, start : start + 3], 1, axis=1
191
+ )
192
+ start += 3
193
+ else:
194
+ start += orbital.dim
195
+ return ret
196
+
197
+
198
+ class GTOBasis:
199
+ per_element_irreps: dict[str, o3.Irreps]
200
+ per_element_numel: dict[str, int]
201
+ allowed_elements: list[str]
202
+ allowed_atomic_numbers: list[int]
203
+
204
+ def __init__(self, per_element_irreps: dict[str, str]):
205
+ self.per_element_irreps = {}
206
+ self.per_element_numel = {}
207
+ self.allowed_elements = []
208
+ self.allowed_atomic_numbers = []
209
+
210
+ for elem, irstr in per_element_irreps.items():
211
+ irreps = o3.Irreps(irstr)
212
+ self.per_element_irreps[elem] = irreps
213
+ self.per_element_numel[elem] = irreps.dim
214
+ self.allowed_elements.append(elem)
215
+ self.allowed_atomic_numbers.append(element_to_atomic_number[elem])
216
+
217
+ @classmethod
218
+ def from_basis_name(cls, basis_name, elements: list[str]):
219
+ per_element_irreps = per_element_irreps_from_basis_name(basis_name, elements)
220
+ return cls(per_element_irreps=per_element_irreps)
221
+
222
+ def irreps_for_mol(self, atom_types: list[int]):
223
+ atom_elements = [atomic_number_to_element[z] for z in atom_types]
224
+ atomic_orbital_irreps = o3.Irreps(
225
+ "+".join(str(self.per_element_irreps[e]) for e in atom_elements)
226
+ )
227
+ return atomic_orbital_irreps
228
+
229
+
230
+ class GTOProductBasisHelper:
231
+ basis: GTOBasis
232
+ padded_irrep: o3.Irreps
233
+ per_element_mask: dict[str, np.ndarray]
234
+
235
+ def __init__(self, basis: GTOBasis):
236
+ self.basis = basis
237
+
238
+ maxl = max(basis.per_element_irreps[e].lmax for e in basis.allowed_elements)
239
+ parity = lambda l: "e" if l % 2 == 0 else "o"
240
+ ls = list(range(maxl + 1))
241
+ l_irreps = [f"{l}{parity(l)}" for l in ls]
242
+
243
+ per_element_irrep_mul = {
244
+ e: list(basis.per_element_irreps[e].count(l_ir) for l_ir in l_irreps)
245
+ for e in basis.allowed_elements
246
+ }
247
+
248
+ max_mul = list(
249
+ max(per_element_irrep_mul[e][l] for e in basis.allowed_elements) for l in ls
250
+ )
251
+ max_irreps = "+".join(f"{mul}x{l_ir}" for mul, l_ir in zip(max_mul, l_irreps))
252
+ self.padded_irrep = o3.Irreps(max_irreps)
253
+
254
+ self.per_element_mask = {}
255
+ for e in self.basis.allowed_elements:
256
+ self.per_element_mask[e] = np.zeros(self.padded_irrep.dim, dtype=bool)
257
+ element_irreps = basis.per_element_irreps[e]
258
+ for l, l_ir, lslice in zip(ls, l_irreps, self.padded_irrep.slices()):
259
+ mul = element_irreps.count(l_ir)
260
+ l_dim = 2 * l + 1
261
+ valid_slice = slice(lslice.start, lslice.start + mul * l_dim)
262
+ self.per_element_mask[e][valid_slice] = True
263
+
264
+ def transform_from_pyscf_to_std(self, atom_types: list[int], matrix: np.ndarray):
265
+ # only the l=1 orbitals need to be transformed: xyz -> yzx
266
+ atomic_orbital_irreps = self.basis.irreps_for_mol(atom_types)
267
+ return transform_from_pyscf_to_std_fast_2d(atomic_orbital_irreps, matrix)
268
+
269
+ def transform_from_std_to_pyscf(self, atom_types: list[int], matrix: np.ndarray):
270
+ # only the l=1 orbitals need to be transformed: xyz -> yzx
271
+ atomic_orbital_irreps = self.basis.irreps_for_mol(atom_types)
272
+ return transform_from_std_to_pyscf_fast_2d(atomic_orbital_irreps, matrix)
273
+
274
+ def split_matrix_to_padded_blocks(
275
+ self,
276
+ atom_types: list[int],
277
+ matrix: np.ndarray,
278
+ ) -> tuple[np.ndarray, np.ndarray]:
279
+ atom_types = np.array(atom_types, dtype=np.int32)
280
+ natom = len(atom_types)
281
+ atom_elements = [atomic_number_to_element[z] for z in atom_types]
282
+ atom_dims = [self.basis.per_element_numel[e] for e in atom_elements]
283
+ atom_starts = [0] + np.cumsum(atom_dims).tolist()[:-1]
284
+
285
+ diag_blocks = np.zeros(
286
+ (natom, self.padded_irrep.dim, self.padded_irrep.dim), dtype=matrix.dtype
287
+ )
288
+ diag_masks = np.zeros(
289
+ (natom, self.padded_irrep.dim, self.padded_irrep.dim), dtype=bool
290
+ )
291
+ tril_blocks = np.zeros(
292
+ (natom * (natom - 1) // 2, self.padded_irrep.dim, self.padded_irrep.dim),
293
+ dtype=matrix.dtype,
294
+ )
295
+ tril_masks = np.zeros(
296
+ (natom * (natom - 1) // 2, self.padded_irrep.dim, self.padded_irrep.dim),
297
+ dtype=bool,
298
+ )
299
+ tril_edge_index = np.zeros((2, (natom * (natom - 1) // 2)), dtype=np.int64)
300
+
301
+ for i in range(natom):
302
+ mask_i = self.per_element_mask[atom_elements[i]]
303
+ slice_i = slice(atom_starts[i], atom_starts[i] + atom_dims[i])
304
+ block = matrix[slice_i, slice_i]
305
+ diag_masks[i] = mask_i[:, None] & mask_i[None, :]
306
+ diag_blocks[i, diag_masks[i]] = block.reshape(-1)
307
+
308
+ iblock = 0
309
+ for i in range(0, natom):
310
+ mask_i = self.per_element_mask[atom_elements[i]]
311
+ slice_i = slice(atom_starts[i], atom_starts[i] + atom_dims[i])
312
+ for j in range(0, i): # lower triangle
313
+ mask_j = self.per_element_mask[atom_elements[j]]
314
+ slice_j = slice(atom_starts[j], atom_starts[j] + atom_dims[j])
315
+ tril_masks[iblock, mask_i[:, None] & mask_j[None, :]] = True
316
+ tril_blocks[iblock, tril_masks[iblock]] = matrix[
317
+ slice_i, slice_j
318
+ ].reshape(-1)
319
+ tril_edge_index[0, iblock] = i
320
+ tril_edge_index[1, iblock] = j
321
+ iblock += 1
322
+
323
+ return diag_blocks, diag_masks, tril_blocks, tril_masks, tril_edge_index
324
+
325
+ def assemble_matrix_from_padded_blocks(
326
+ self,
327
+ atom_types: list[int],
328
+ padded_diag_blocks: list[np.ndarray],
329
+ padded_tril_blocks: list[np.ndarray], # in lower triangular order
330
+ ) -> np.ndarray:
331
+ atom_types = np.array(atom_types, dtype=np.int32)
332
+ natom = len(atom_types)
333
+ atom_elements = [atomic_number_to_element[z] for z in atom_types]
334
+ atom_dims = [self.basis.per_element_numel[e] for e in atom_elements]
335
+ atom_starts = [0] + np.cumsum(atom_dims).tolist()[:-1]
336
+
337
+ nao = sum(self.basis.per_element_numel[e] for e in atom_elements)
338
+ matrix = np.zeros((nao, nao), dtype=padded_diag_blocks[0].dtype)
339
+
340
+ for i in range(natom):
341
+ slice_i = slice(atom_starts[i], atom_starts[i] + atom_dims[i])
342
+ mask_i = self.per_element_mask[atom_elements[i]]
343
+ block = padded_diag_blocks[i][mask_i][:, mask_i]
344
+ matrix[slice_i, slice_i] = block
345
+
346
+ iblock = 0
347
+ for i in range(0, natom):
348
+ mask_i = self.per_element_mask[atom_elements[i]]
349
+ slice_i = slice(atom_starts[i], atom_starts[i] + atom_dims[i])
350
+ for j in range(0, i): # lower triangle
351
+ mask_j = self.per_element_mask[atom_elements[j]]
352
+ slice_j = slice(atom_starts[j], atom_starts[j] + atom_dims[j])
353
+ block = padded_tril_blocks[iblock][mask_i][:, mask_j]
354
+ matrix[slice_i, slice_j] = block
355
+ matrix[slice_j, slice_i] = block.T
356
+ iblock += 1
357
+
358
+ return matrix
359
+
360
+
361
+ class GTOAuxDensityHelper:
362
+ atom_types: list[int]
363
+ basis: GTOBasis
364
+ atomic_orbital_irreps: o3.Irreps
365
+ atomic_orbital_masks_by_element: dict[str, np.ndarray]
366
+ atom_indices_by_element: dict[str, np.ndarray]
367
+
368
+ def __init__(self, atom_types: list[int], basis: GTOBasis):
369
+ self.atom_types = np.array(atom_types, dtype=np.int32)
370
+ atom_elements = [atomic_number_to_element[z] for z in self.atom_types]
371
+ self.basis = basis
372
+ self.atomic_orbital_irreps = self.basis.irreps_for_mol(self.atom_types)
373
+
374
+ mask = np.concatenate(
375
+ [
376
+ [z] * basis.per_element_numel[e]
377
+ for e, z in zip(atom_elements, self.atom_types)
378
+ ]
379
+ )
380
+ self.atomic_orbital_masks_by_element = {
381
+ e: mask == z
382
+ for e, z in zip(basis.allowed_elements, basis.allowed_atomic_numbers)
383
+ }
384
+ self.atom_indices_by_element = {
385
+ e: np.nonzero(atom_types == z)[0]
386
+ for e, z in zip(basis.allowed_elements, basis.allowed_atomic_numbers)
387
+ }
388
+
389
+ def transform_from_pyscf_to_std(self, array: np.ndarray):
390
+ return transform_from_pyscf_to_std_fast_1d(self.atomic_orbital_irreps, array)
391
+
392
+ def transform_from_std_to_pyscf(self, array: np.ndarray):
393
+ return transform_from_std_to_pyscf_fast_1d(self.atomic_orbital_irreps, array)
394
+
395
+ def split_ao_by_elements(self, array: np.ndarray):
396
+ splitted = {
397
+ e: array[self.atomic_orbital_masks_by_element[e]].reshape(
398
+ -1, self.basis.per_element_numel[e]
399
+ )
400
+ for e in self.basis.allowed_elements
401
+ }
402
+ assert sum(len(v) for v in splitted.values()) == len(self.atom_types)
403
+ assert sum(v.size for v in splitted.values()) == self.atomic_orbital_irreps.dim
404
+ return splitted
405
+
406
+ def assemble_ao_from_per_element_arrays(self, splitted: dict[str, np.ndarray]):
407
+ dtype = next(iter(splitted.values())).dtype
408
+ array = np.zeros(self.atomic_orbital_irreps.dim, dtype=dtype)
409
+ for z, mask in self.atomic_orbital_masks_by_element.items():
410
+ array[mask] = splitted[z].reshape(-1)
411
+ return array
modules.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import torch
5
+ import torch.nn as nn
6
+
7
+ from e3nn import o3
8
+
9
+ from nequip.data import AtomicDataDict
10
+ from nequip.nn import GraphModuleMixin
11
+
12
+ from gto import GTOBasis
13
+
14
+
15
+ class AuxdensityHead(nn.Module):
16
+ def __init__(
17
+ self,
18
+ irreps_in: str | o3.Irreps,
19
+ type_names: list[str],
20
+ biases: bool = False,
21
+ auxbasis: str = "def2-universal-jfit",
22
+ ):
23
+ super().__init__()
24
+ self.auxbasis = GTOBasis.from_basis_name(auxbasis, elements=type_names)
25
+ self.species_list = list(self.auxbasis.per_element_irreps.keys())
26
+ self.per_species_modules = nn.ModuleDict(
27
+ {
28
+ species: o3.Linear(
29
+ irreps_in=irreps_in, irreps_out=irreps_out, biases=biases
30
+ )
31
+ for species, irreps_out in self.auxbasis.per_element_irreps.items()
32
+ }
33
+ )
34
+
35
+ def forward(
36
+ self, atom_features: torch.Tensor, species_indices: dict[str, torch.Tensor]
37
+ ):
38
+ outputs = {}
39
+ for species in self.species_list:
40
+ outputs[species] = self.per_species_modules[species](
41
+ atom_features[species_indices[species]]
42
+ )
43
+ return outputs
44
+
45
+
46
+ class AuxdensityHeadForNequip(GraphModuleMixin, torch.nn.Module):
47
+ def __init__(
48
+ self,
49
+ type_names: list[str],
50
+ auxbasis: str = "def2-universal-jfit",
51
+ field: str = AtomicDataDict.NODE_FEATURES_KEY,
52
+ out_field: str | None = None,
53
+ biases: bool = True,
54
+ irreps_in: str | o3.Irreps = None,
55
+ ):
56
+ super().__init__()
57
+ self.field = field
58
+ out_field = out_field if out_field is not None else field
59
+ self.out_field = out_field
60
+
61
+ self._init_irreps(
62
+ irreps_in=irreps_in,
63
+ required_irreps_in=[field],
64
+ # we do not init irreps_out here because this module should be the final layer
65
+ )
66
+ self.layer = AuxdensityHead(
67
+ irreps_in=irreps_in[field],
68
+ type_names=type_names,
69
+ auxbasis=auxbasis,
70
+ biases=biases,
71
+ )
72
+
73
+ def forward(self, data):
74
+ data[self.out_field] = self.layer(data[self.field], data["species_indices"])
75
+ return data
nequip_model.py ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2021 The President and Fellows of Harvard College
2
+ # Copyright (c) 2025 The NequIP Developers
3
+ # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates
4
+ # SPDX-License-Identifier: MIT
5
+ #
6
+ # This file has been modified by ByteDance Ltd. and/or its affiliates on 2025-09-01.
7
+ #
8
+ # Original file was released under MIT, with the full license text
9
+ # available at https://github.com/mir-group/nequip/blob/main/LICENSE.
10
+ #
11
+ # This modified file is released under the same license.
12
+
13
+ import warnings
14
+ from typing import Sequence, Optional, Callable, Any
15
+
16
+ import math
17
+
18
+ import torch
19
+ import torch.nn as nn
20
+ from e3nn import o3
21
+ from e3nn.util.jit import compile_mode
22
+ from nequip.nn import GraphModuleMixin
23
+ from nequip.nn.utils import with_edge_vectors_
24
+
25
+ from nequip.data import AtomicDataDict
26
+ from nequip.nn import (
27
+ SequentialGraphNetwork,
28
+ ConvNetLayer,
29
+ ApplyFactor,
30
+ )
31
+ from nequip.nn.embedding import (
32
+ EdgeLengthNormalizer,
33
+ BesselEdgeLengthEncoding,
34
+ PolynomialCutoff,
35
+ NodeTypeEmbed,
36
+ )
37
+
38
+ from modules import AuxdensityHeadForNequip
39
+
40
+ @compile_mode("script")
41
+ class SphericalHarmonicEdgeAttrs(GraphModuleMixin, torch.nn.Module):
42
+ """Construct edge attrs as spherical harmonic projections of edge vectors.
43
+
44
+ Parameters follow ``e3nn.o3.spherical_harmonics``.
45
+
46
+ Args:
47
+ irreps_edge_sh (int, str, or o3.Irreps): if int, will be treated as lmax for o3.Irreps.spherical_harmonics(lmax)
48
+ edge_sh_normalization (str): the normalization scheme to use
49
+ edge_sh_normalize (bool, default: True): whether to normalize the spherical harmonics
50
+ out_field (str, default: AtomicDataDict.EDGE_ATTRS_KEY: data/irreps field
51
+ """
52
+
53
+ out_field: str
54
+
55
+ def __init__(
56
+ self,
57
+ irreps_edge_sh: int | str | o3.Irreps,
58
+ component_order: str = 'e3nn',
59
+ edge_sh_normalization: str = "component",
60
+ edge_sh_normalize: bool = True,
61
+ irreps_in=None,
62
+ out_field: str = AtomicDataDict.EDGE_ATTRS_KEY,
63
+ ):
64
+ super().__init__()
65
+ self.out_field = out_field
66
+
67
+ if isinstance(irreps_edge_sh, int):
68
+ self.irreps_edge_sh = o3.Irreps.spherical_harmonics(irreps_edge_sh)
69
+ else:
70
+ self.irreps_edge_sh = o3.Irreps(irreps_edge_sh)
71
+ self._init_irreps(
72
+ irreps_in=irreps_in,
73
+ irreps_out={out_field: self.irreps_edge_sh},
74
+ )
75
+ self.sh = o3.SphericalHarmonics(
76
+ self.irreps_edge_sh, edge_sh_normalize, edge_sh_normalization
77
+ )
78
+ # i.e. `model_dtype`
79
+ self._output_dtype = torch.get_default_dtype()
80
+
81
+ assert component_order in ['e3nn', 'std'], "component_order must be 'e3nn' or 'std'"
82
+ self.component_order = component_order
83
+
84
+ def forward(self, data: AtomicDataDict.Type) -> AtomicDataDict.Type:
85
+ data = with_edge_vectors_(data, with_lengths=False)
86
+ edge_vec = data[AtomicDataDict.EDGE_VECTORS_KEY]
87
+ if self.component_order == 'std':
88
+ edge_vec = edge_vec[:, [1, 2, 0]]
89
+ edge_sh = self.sh(edge_vec)
90
+ data[self.out_field] = edge_sh.to(self._output_dtype)
91
+ return data
92
+
93
+
94
+ class NequipArch(nn.Module):
95
+ def __init__(
96
+ self,
97
+ r_max: float,
98
+ type_names: Sequence[str],
99
+ # convnet params
100
+ radial_mlp_depth: Sequence[int],
101
+ radial_mlp_width: Sequence[int],
102
+ feature_irreps_hidden: Sequence[str | o3.Irreps],
103
+ # irreps and dims
104
+ irreps_edge_sh: int | str | o3.Irreps,
105
+ type_embed_num_features: int,
106
+ # edge length encoding
107
+ per_edge_type_cutoff: Optional[dict[str, float | dict[str, float]]] = None,
108
+ num_bessels: int = 8,
109
+ bessel_trainable: bool = False,
110
+ polynomial_cutoff_p: int = 6,
111
+ # edge sum normalization
112
+ avg_num_neighbors: Optional[float] = None,
113
+ # == things that generally shouldn't be changed ==
114
+ # convnet
115
+ convnet_resnet: bool = False,
116
+ convnet_nonlinearity_type: str = "gate",
117
+ convnet_nonlinearity_scalars: dict[int, Callable] = {"e": "silu", "o": "tanh"},
118
+ convnet_nonlinearity_gates: dict[int, Callable] = {"e": "silu", "o": "tanh"},
119
+ task_head_specs: dict[str, Any] = {},
120
+ auxbasis: str = "def2-universal-jfit",
121
+ ):
122
+ super().__init__()
123
+
124
+ self.type_names = type_names
125
+
126
+ # === sanity checks and warnings ===
127
+ assert all(tn.isalnum() for tn in type_names), (
128
+ "`type_names` must contain only alphanumeric characters"
129
+ )
130
+
131
+ # require every convnet layer to be specified explicitly in a list
132
+ # infer num_layers from the list size
133
+ assert (
134
+ len(radial_mlp_depth) == len(radial_mlp_width) == len(feature_irreps_hidden)
135
+ ), (
136
+ f"radial_mlp_depth: {radial_mlp_depth}, radial_mlp_width: {radial_mlp_width}, feature_irreps_hidden: {feature_irreps_hidden} should all have the same length"
137
+ )
138
+ num_layers = len(radial_mlp_depth)
139
+
140
+ if avg_num_neighbors is None:
141
+ warnings.warn(
142
+ "Found `avg_num_neighbors=None` -- it is recommended to set `avg_num_neighbors` for normalization and better numerics during training."
143
+ )
144
+
145
+ # === encode and embed features ===
146
+ # == edge tensor embedding ==
147
+ spharm = SphericalHarmonicEdgeAttrs(
148
+ irreps_edge_sh=irreps_edge_sh,
149
+ component_order="std",
150
+ )
151
+ # == edge scalar embedding ==
152
+ edge_norm = EdgeLengthNormalizer(
153
+ r_max=r_max,
154
+ type_names=type_names,
155
+ per_edge_type_cutoff=per_edge_type_cutoff,
156
+ irreps_in=spharm.irreps_out,
157
+ )
158
+ bessel_encode = BesselEdgeLengthEncoding(
159
+ num_bessels=num_bessels,
160
+ trainable=bessel_trainable,
161
+ cutoff=PolynomialCutoff(polynomial_cutoff_p),
162
+ edge_invariant_field=AtomicDataDict.EDGE_EMBEDDING_KEY,
163
+ irreps_in=edge_norm.irreps_out,
164
+ )
165
+ # for backwards compatibility of NequIP's bessel encoding
166
+ factor = ApplyFactor(
167
+ in_field=AtomicDataDict.EDGE_EMBEDDING_KEY,
168
+ factor=(2 * math.pi) / (r_max * r_max),
169
+ irreps_in=bessel_encode.irreps_out,
170
+ )
171
+ # == node scalar embedding ==
172
+ type_embed = NodeTypeEmbed(
173
+ type_names=type_names,
174
+ num_features=type_embed_num_features,
175
+ irreps_in=factor.irreps_out,
176
+ )
177
+ modules = {
178
+ "spharm": spharm,
179
+ "edge_norm": edge_norm,
180
+ "bessel_encode": bessel_encode,
181
+ "factor": factor,
182
+ "type_embed": type_embed,
183
+ }
184
+ prev_irreps_out = type_embed.irreps_out
185
+
186
+ # === convnet layers ===
187
+ for layer_i in range(num_layers):
188
+ current_convnet = ConvNetLayer(
189
+ irreps_in=prev_irreps_out,
190
+ feature_irreps_hidden=feature_irreps_hidden[layer_i],
191
+ convolution_kwargs={
192
+ "radial_mlp_depth": radial_mlp_depth[layer_i],
193
+ "radial_mlp_width": radial_mlp_width[layer_i],
194
+ "avg_num_neighbors": avg_num_neighbors,
195
+ # to ensure isolated atom limit
196
+ "use_sc": layer_i != 0,
197
+ },
198
+ resnet=(layer_i != 0) and convnet_resnet,
199
+ nonlinearity_type=convnet_nonlinearity_type,
200
+ nonlinearity_scalars=convnet_nonlinearity_scalars,
201
+ nonlinearity_gates=convnet_nonlinearity_gates,
202
+ )
203
+ prev_irreps_out = current_convnet.irreps_out
204
+ modules.update({f"layer{layer_i}_convnet": current_convnet})
205
+
206
+ # === assemble in SequentialGraphNetwork ===
207
+ self.backbone = SequentialGraphNetwork(modules)
208
+
209
+ # === readout ===
210
+ self.backbone_irreps_out = prev_irreps_out
211
+ self.task_head = SequentialGraphNetwork(
212
+ {
213
+ "auxdensity_atom_readout": AuxdensityHeadForNequip(
214
+ type_names=self.type_names,
215
+ auxbasis=auxbasis,
216
+ field=AtomicDataDict.NODE_FEATURES_KEY,
217
+ out_field="output:auxdensity",
218
+ biases=True,
219
+ irreps_in=self.backbone_irreps_out,
220
+ ),
221
+ }
222
+ )
223
+
224
+ def convert_inputs(self, inputs):
225
+ ret = inputs.copy()
226
+ ret.update(
227
+ {
228
+ AtomicDataDict.ATOM_TYPE_KEY: inputs["z"],
229
+ AtomicDataDict.POSITIONS_KEY: inputs["pos"],
230
+ AtomicDataDict.EDGE_INDEX_KEY: inputs["edge_index"],
231
+ }
232
+ )
233
+ return ret
234
+
235
+ def forward(self, data):
236
+ data = self.convert_inputs(data)
237
+ data = self.backbone(data)
238
+ data = self.task_head(data)
239
+ return data
240
+
241
+
242
+ def nequip_simple_builder(
243
+ num_layers: int = 4,
244
+ l_max: int = 1,
245
+ parity: bool = True,
246
+ num_features: int = 32,
247
+ radial_mlp_depth: int = 2,
248
+ radial_mlp_width: int = 64,
249
+ **kwargs,
250
+ ) -> nn.Module:
251
+ irreps_edge_sh = repr(
252
+ o3.Irreps.spherical_harmonics(lmax=l_max, p=-1 if parity else 1)
253
+ )
254
+ feature_irreps_hidden = repr(
255
+ o3.Irreps(
256
+ [
257
+ (num_features, (l, p))
258
+ for p in ((1, -1) if parity else (1,))
259
+ for l in range(l_max + 1)
260
+ ]
261
+ )
262
+ )
263
+ feature_irreps_hidden_list = [feature_irreps_hidden] * (num_layers - 1)
264
+ radial_mlp_depth_list = [radial_mlp_depth] * num_layers
265
+ radial_mlp_width_list = [radial_mlp_width] * num_layers
266
+
267
+ feature_irreps_hidden_list += [feature_irreps_hidden]
268
+
269
+ model = NequipArch(
270
+ irreps_edge_sh=irreps_edge_sh,
271
+ type_embed_num_features=num_features,
272
+ feature_irreps_hidden=feature_irreps_hidden_list,
273
+ radial_mlp_depth=radial_mlp_depth_list,
274
+ radial_mlp_width=radial_mlp_width_list,
275
+ **kwargs,
276
+ )
277
+ return model
278
+
279
+
280
+ if __name__ == "__main__":
281
+ model = nequip_simple_builder(r_max=5.0, type_names=["H", "C", "N", "O", "F", "P", "S"])
282
+ from dataset import SCFBenchDataset
283
+ dataset = SCFBenchDataset("dataset/main", parts_to_load=["base", "auxdensity.denfit"])
284
+ print(model(dataset[0])['output:auxdensity'])
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy>1.16,<2.0
2
+ lmdb
3
+ torch
4
+ e3nn
5
+ nequip