-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CHGNet-matgl implementation #242
Changes from 250 commits
697c443
62693b2
f2ed897
a54ff6e
b865bbb
22d151f
1de8ef6
8300daa
e48095e
2a3cb4e
f4dad3b
1e41da9
3e8698e
1b4ade3
a12015e
bf47998
9480c05
5437861
0305df3
18c1eec
30d53dc
6fb24d0
b35e4c5
2415330
27a575b
57e5681
1061aec
374cbd0
382b835
16c7f29
f2e14de
8f70a1c
507074f
33a5a42
688b952
c4611cc
ee5a4e6
0b1c2a1
07ae295
e1b3593
5929716
27f458e
a4a4b9d
f29c837
10bdea9
0506078
77cbcc6
f566459
9e1e326
2cfbca8
63a895f
fa50dab
13e8319
971135e
9c1c741
644ea71
b02e307
4fa29fb
2546df5
013c8d6
bed14de
a97a65e
882da3a
2f31e23
aa765b2
7df9c0d
f913e0a
414c924
e2facd0
3794af0
b84f24c
2fb9855
92ad929
01f148b
4932972
5c3ae23
7c64f44
bdf89b0
9053ac9
24664fb
c524162
729207d
16c262c
0740986
d330699
a5032f7
22a2e4e
2320580
cd58dcf
dbd8fdf
9a99106
adae431
6265749
42baa27
fd76452
f86a51d
2a35a85
e74c425
55ad683
938f61b
2807de6
5553fe0
a91a789
eb369e1
987b94a
f19e913
80b53a5
e874067
f43c8ee
1fa36e3
d851d84
c228311
e6dcd03
ebbbb33
0225624
239488d
5f03aa9
fcbf03b
fc9efbe
1deadbf
3c15846
0e4e2a4
0132791
48061a1
1695d60
3192fd7
3d0a4a3
d62bdf4
ed9375d
efa77e5
31af30d
c1b6309
ac87ee5
fb7c31d
6193abc
9b37f34
3f775a3
429c89b
53bcc3a
95ae563
4f2d4da
386e3b5
31d14dd
f46f782
e462a8a
fa62f07
90e650a
5796ecf
64dfa09
9107a44
70909b0
fa0c2a4
7f80d40
714b8db
1d90eb1
e9ffc14
c0c188a
0fa1413
485ef21
0c5860a
f61d570
80c7b16
4d880f0
5b91b97
2505fd7
137391d
8089cf7
c846690
ab08f0d
ba6d7bf
2bd649c
8855677
c4a2a1a
a309278
13613c9
4b9ca21
3afd275
f53e570
1a5d64e
0dc540e
f1663cb
d59411e
221035f
0dfc26d
b2bffd0
71a339c
c1426dd
862adfe
23505ea
3fc132a
7ec7234
b5f5abf
f61379d
7d0f5a6
932d1b7
a5b0adc
0adcb01
14fcf86
cded08f
567557f
ae9156c
f2e739f
635b153
25bda3f
13766ba
a93dcb8
01e095f
c34aa9e
8c8dc38
7993f4f
8f930e7
2146dc2
8545e3a
368efbb
aa0dbe5
92c2e0b
0211e04
536ad8b
51b3a74
982e5e9
5a3f200
c15d5c2
2595c34
ec8e528
6404299
bfefe2b
f926e02
452f056
ad49c71
8257d8d
26fbd9a
00c7a6d
d6fce6d
27ca01c
a6f6088
7a5e3e5
8ab82c4
902b0e5
d7a9a31
e52de99
bcb71fd
340b9da
4a875e0
2c92d97
392cc03
4985006
a95c104
e035d1c
cc80907
49c5193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||
# Description | ||||||
|
||||||
This model is a CHGNet universal potential trained from the Materials Project trajectory (MPtrj) dataset | ||||||
that contains over 1.5 million structures with 89 elements. | ||||||
This Matgl implementation has slight modification from original pytorch implementation by adding directed edge updates. | ||||||
|
||||||
# Training dataset | ||||||
|
||||||
MPtrj-2022.9: Materials Project trajectory dataset that contains GGA and GGA+U static and relaxation calculations. | ||||||
- Train-Val-Test splitting with mp-id: 0.9 - 0.5 - 0.5 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For numerical ranges, consider using an en dash (–) instead of a hyphen (-) for improved readability. For example, "0.9–0.5–0.5" instead of "0.9 - 0.5 - 0.5". - 0.9 - 0.5 - 0.5
+ 0.9–0.5–0.5 Committable suggestion
Suggested change
|
||||||
- Train set size: 1419861 | ||||||
- Validation set size: 79719 | ||||||
- Test set size: 79182 | ||||||
|
||||||
# Performance metrics | ||||||
## Training and validation errors | ||||||
|
||||||
| partition | Energy (meV/atom) | Force (meV/A) | stress (GPa) | magmom (muB) | | ||||||
| ---------- | ----------------- | ------------- | ------------ | ------------ | | ||||||
| Train | 26.45 | 49 | 0.173 | 0.036 | | ||||||
| Validation | 30.31 | 70 | 0.297 | 0.037 | | ||||||
| Test | 30.80 | 66 | 0.296 | 0.038 | | ||||||
|
||||||
|
||||||
# References | ||||||
|
||||||
```txt | ||||||
Deng, B. et al. CHGNet as a pretrained universal neural network potential for charge-informed atomistic modelling. | ||||||
Nat. Mach. Intell. 1–11 (2023) doi:10.1038/s42256-023-00716-3. | ||||||
``` | ||||||
|
||||||
#### Date: 2023.12.1 | ||||||
#### Author: Bowen Deng |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"@class": "Potential", | ||
"@module": "matgl.apps.pes", | ||
"@model_version": 1, | ||
"metadata": null, | ||
"kwargs": { | ||
"model": { | ||
"@class": "CHGNet", | ||
"@module": "matgl.models._chgnet", | ||
"@model_version": 1, | ||
"init_args": { | ||
"element_types": null, | ||
"dim_state_feats": null, | ||
"non_linear_bond_embedding": false, | ||
"non_linear_angle_embedding": false, | ||
"cutoff": 6.0, | ||
"threebody_cutoff": 3.0, | ||
"cutoff_exponent": 5, | ||
"max_f": 32, | ||
"learn_basis": false, | ||
"num_blocks": 5, | ||
"shared_bond_weights": "both", | ||
"final_mlp_type": "mlp", | ||
"final_hidden_dims": [ | ||
128, | ||
128, | ||
128 | ||
], | ||
"final_dropout": 0.0, | ||
"pooling_operation": "sum", | ||
"readout_field": "atom_feat", | ||
"activation_type": "swish", | ||
"is_intensive": false, | ||
"num_targets": 1, | ||
"num_site_targets": 1, | ||
"task_type": "regression", | ||
"angle_update_hidden_dims": [], | ||
"atom_conv_hidden_dims": [ | ||
128 | ||
], | ||
"bond_conv_hidden_dims": [ | ||
128 | ||
], | ||
"bond_update_hidden_dims": [ | ||
128 | ||
], | ||
"conv_dropout": 0.0, | ||
"dim_angle_embedding": 128, | ||
"dim_atom_embedding": 128, | ||
"dim_bond_embedding": 128, | ||
"dim_state_embedding": null, | ||
"layer_bond_weights": null, | ||
"max_n": 63, | ||
"normalization": "layer", | ||
"normalize_hidden": false | ||
} | ||
}, | ||
"data_mean": "tensor(0.)", | ||
"data_std": "tensor(1.)", | ||
"element_refs": "tensor([ -3.4524, -0.2535, -3.1356, -3.5818, -7.5282, -8.2669, -7.7537,\n -8.3183, -5.6419, -0.0301, -1.9928, -1.5805, -4.3933, -6.2148,\n -6.3137, -5.6612, -3.6236, -0.0632, -1.7023, -3.7368, -6.8803,\n -9.4099, -9.5156, -9.5164, -9.0957, -7.9901, -6.4274, -5.5935,\n -3.3122, -0.8411, -3.2124, -4.8460, -4.6307, -4.8599, -3.1515,\n 0.8167, -1.5970, -3.4679, -7.7371, -9.5454, -10.5613, -9.9911,\n -6.7590, -8.2281, -7.0194, -5.0765, -1.8264, -0.3508, -2.5801,\n -3.9090, -4.0772, -3.8814, -2.4899, 3.0526, -2.2544, -3.9207,\n -7.2230, -7.4592, -6.5778, -6.7207, -5.1486, -6.7854, -11.7604,\n -16.2078, -6.4504, -6.4809, -6.3964, -6.3873, -6.3777, -2.8369,\n -6.4433, -10.6572, -12.3228, -11.8578, -10.5498, -9.1838, -8.1969,\n -6.0177, -2.7653, 0.6777, -1.6524, -3.1770, -3.3326, 0.0000,\n 0.0000, 0.0000, 0.0000, 0.0000, -4.2516, -9.0753, -10.3286,\n -12.5580, -12.7219, -14.3059])", | ||
"calc_forces": true, | ||
"calc_stresses": true, | ||
"calc_hessian": false, | ||
"calc_site_wise": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||
# Description | ||||||
|
||||||
This model is a CHGNet universal potential trained from the Materials Project trajectory (MPtrj) dataset | ||||||
that contains over 1.5 million structures with 89 elements. | ||||||
This Matgl implementation has slight modification from original pytorch implementation by adding directed edge updates. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace "pytorch" with "PyTorch" to adhere to the correct capitalization of the framework's name. - original pytorch implementation
+ original PyTorch implementation Committable suggestion
Suggested change
|
||||||
|
||||||
# Training dataset | ||||||
|
||||||
MPtrj-2022.9: Materials Project trajectory dataset that contains GGA and GGA+U static and relaxation calculations. | ||||||
- Train-Val-Test splitting with mp-id: 0.95 - 0.5 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For numerical ranges, consider using an en dash (–) instead of a hyphen (-) for improved readability. For example, "0.95–0.5" instead of "0.95 - 0.5". - 0.95 - 0.5
+ 0.95–0.5 Committable suggestion
Suggested change
|
||||||
- Train set size: 1499043 | ||||||
- Validation set size: 79719 | ||||||
- Test set size: 0 | ||||||
|
||||||
# Performance metrics | ||||||
## Training and validation errors | ||||||
|
||||||
| partition | Energy (meV/atom) | Force (meV/A) | stress (GPa) | magmom (muB) | | ||||||
| ---------- | ----------------- | ------------- | ------------ | ------------ | | ||||||
| Train | 25.6 | 47.6 | 0.177 | 0.017 | | ||||||
| Validation | 27.7 | 62.5 | 0.288 | 0.017 | | ||||||
|
||||||
|
||||||
# References | ||||||
|
||||||
```txt | ||||||
Deng, B. et al. CHGNet as a pretrained universal neural network potential for charge-informed atomistic modelling. | ||||||
Nat. Mach. Intell. 1–11 (2023) doi:10.1038/s42256-023-00716-3. | ||||||
``` | ||||||
|
||||||
#### Date: 2024.2.13 | ||||||
#### Author: Bowen Deng |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"@class": "Potential", | ||
"@module": "matgl.apps.pes", | ||
"@model_version": 2, | ||
"metadata": null, | ||
"kwargs": { | ||
"model": { | ||
"@class": "CHGNet", | ||
"@module": "matgl.models._chgnet", | ||
"@model_version": 1, | ||
"init_args": { | ||
"element_types": null, | ||
"dim_state_feats": null, | ||
"non_linear_bond_embedding": false, | ||
"non_linear_angle_embedding": false, | ||
"cutoff": 6.0, | ||
"threebody_cutoff": 3.0, | ||
"cutoff_exponent": 5, | ||
"max_f": 32, | ||
"learn_basis": false, | ||
"num_blocks": 5, | ||
"shared_bond_weights": "both", | ||
"final_mlp_type": "mlp", | ||
"final_hidden_dims": [ | ||
256, | ||
256, | ||
256 | ||
], | ||
"final_dropout": 0.0, | ||
"pooling_operation": "sum", | ||
"readout_field": "atom_feat", | ||
"activation_type": "swish", | ||
"is_intensive": false, | ||
"num_targets": 1, | ||
"num_site_targets": 1, | ||
"task_type": "regression", | ||
"angle_update_hidden_dims": [], | ||
"atom_conv_hidden_dims": [ | ||
256 | ||
], | ||
"bond_conv_hidden_dims": [ | ||
256 | ||
], | ||
"bond_update_hidden_dims": [ | ||
256 | ||
], | ||
"conv_dropout": 0.0, | ||
"dim_angle_embedding": 256, | ||
"dim_atom_embedding": 256, | ||
"dim_bond_embedding": 256, | ||
"dim_state_embedding": null, | ||
"layer_bond_weights": null, | ||
"max_n": 63, | ||
"normalization": "layer", | ||
"normalize_hidden": false | ||
} | ||
}, | ||
"data_mean": "tensor(0.)", | ||
"data_std": "tensor(1.)", | ||
"element_refs": "tensor([ -3.4524, -0.2535, -3.1356, -3.5818, -7.5282, -8.2669, -7.7537,\n -8.3183, -5.6419, -0.0301, -1.9928, -1.5805, -4.3933, -6.2148,\n -6.3137, -5.6612, -3.6236, -0.0632, -1.7023, -3.7368, -6.8803,\n -9.4099, -9.5156, -9.5164, -9.0957, -7.9901, -6.4274, -5.5935,\n -3.3122, -0.8411, -3.2124, -4.8460, -4.6307, -4.8599, -3.1515,\n 0.8167, -1.5970, -3.4679, -7.7371, -9.5454, -10.5613, -9.9911,\n -6.7590, -8.2281, -7.0194, -5.0765, -1.8264, -0.3508, -2.5801,\n -3.9090, -4.0772, -3.8814, -2.4899, 3.0526, -2.2544, -3.9207,\n -7.2230, -7.4592, -6.5778, -6.7207, -5.1486, -6.7854, -11.7604,\n -16.2078, -6.4504, -6.4809, -6.3964, -6.3873, -6.3777, -2.8369,\n -6.4433, -10.6572, -12.3228, -11.8578, -10.5498, -9.1838, -8.1969,\n -6.0177, -2.7653, 0.6777, -1.6524, -3.1770, -3.3326, 0.0000,\n 0.0000, 0.0000, 0.0000, 0.0000, -4.2516, -9.0753, -10.3286,\n -12.5580, -12.7219, -14.3059])", | ||
"calc_forces": true, | ||
"calc_stresses": true, | ||
"calc_hessian": false, | ||
"calc_site_wise": true, | ||
"debug_mode": false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ authors = [ | |
{ name = "Ji Qi", email = "[email protected]" }, | ||
{ name = "Santiago Miret", email = "[email protected]" }, | ||
{ name = "Eliott Liu", email = "[email protected]" }, | ||
{ name = "Bowen Deng", email = "[email protected]" }, | ||
{ name = "Luis Barroso-Luque", email = "[email protected]" }, | ||
{ name = "Shyue Ping Ong", email = "[email protected]" }, | ||
] | ||
description = "MatGL is a framework for graph deep learning for materials science." | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -122,7 +122,7 @@ def get_graph(self, atoms: Atoms) -> tuple[dgl.DGLGraph, torch.Tensor, list]: | |||||||||||||
class PESCalculator(Calculator): | ||||||||||||||
"""Potential calculator for ASE.""" | ||||||||||||||
|
||||||||||||||
implemented_properties = ("energy", "free_energy", "forces", "stress", "hessian") | ||||||||||||||
implemented_properties = ("energy", "free_energy", "forces", "stress", "hessian", "magmoms") | ||||||||||||||
|
||||||||||||||
def __init__( | ||||||||||||||
self, | ||||||||||||||
|
@@ -145,6 +145,7 @@ def __init__( | |||||||||||||
self.potential = potential | ||||||||||||||
self.compute_stress = potential.calc_stresses | ||||||||||||||
self.compute_hessian = potential.calc_hessian | ||||||||||||||
self.compute_magmoms = potential.calc_site_wise | ||||||||||||||
self.stress_weight = stress_weight | ||||||||||||||
self.state_attr = state_attr | ||||||||||||||
self.element_types = potential.model.element_types # type: ignore | ||||||||||||||
|
@@ -172,18 +173,20 @@ def calculate( | |||||||||||||
graph, lattice, state_attr_default = Atoms2Graph(self.element_types, self.cutoff).get_graph(atoms) | ||||||||||||||
# type: ignore | ||||||||||||||
if self.state_attr is not None: | ||||||||||||||
energies, forces, stresses, hessians = self.potential(graph, lattice, self.state_attr) | ||||||||||||||
calc_result = self.potential(graph, lattice, self.state_attr) | ||||||||||||||
else: | ||||||||||||||
energies, forces, stresses, hessians = self.potential(graph, lattice, state_attr_default) | ||||||||||||||
calc_result = self.potential(graph, lattice, state_attr_default) | ||||||||||||||
self.results.update( | ||||||||||||||
energy=energies.detach().cpu().numpy().item(), | ||||||||||||||
free_energy=energies.detach().cpu().numpy().item(), | ||||||||||||||
forces=forces.detach().cpu().numpy(), | ||||||||||||||
energy=calc_result[0].detach().cpu().numpy().item(), | ||||||||||||||
free_energy=calc_result[0].detach().cpu().numpy(), | ||||||||||||||
forces=calc_result[1].detach().cpu().numpy(), | ||||||||||||||
) | ||||||||||||||
if self.compute_stress: | ||||||||||||||
self.results.update(stress=stresses.detach().cpu().numpy() * self.stress_weight) | ||||||||||||||
self.results.update(stress=calc_result[2].detach().cpu().numpy() * self.stress_weight) | ||||||||||||||
if self.compute_hessian: | ||||||||||||||
self.results.update(hessian=hessians.detach().cpu().numpy()) | ||||||||||||||
self.results.update(hessian=calc_result[3].detach().cpu().numpy()) | ||||||||||||||
if self.compute_magmoms: | ||||||||||||||
self.results.update(magmoms=calc_result[4].detach().cpu().numpy()) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The update to the Consider adding a check or conversion to ensure the data type and shape are correct before updating the + if self.compute_magmoms:
+ magmoms = calc_result[4].detach().cpu().numpy()
+ # Ensure magmoms is in the expected format for ASE.
+ self.results.update(magmoms=magmoms) Committable suggestion
Suggested change
|
||||||||||||||
|
||||||||||||||
|
||||||||||||||
# for backward compatibility | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace "pytorch" with "PyTorch" to adhere to the correct capitalization of the framework's name.
Committable suggestion