Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions interatomic_potentials/configs/newtonnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# NewtonNet

[NewtonNet: a Newtonian message passing network for deep learning of interatomic potentials and forces](https://doi.org/10.1039/D2DD00008C)

## Abstract

NewtonNet is a Newtonian message-passing neural network for learning interatomic potentials and forces. It operates on atomic graphs with radial Bessel basis functions and polynomial cutoff envelopes. The architecture uses a sequence of interaction layers that update both atom-level and force-level representations, enabling accurate prediction of energies and atomic forces while maintaining energy conservation.

## Model

NewtonNet constructs a radius graph from atomic positions and computes pairwise radial basis features. Interaction layers iteratively refine atom representations using Newtonian message passing that preserves physical symmetries. Per-atom energies are summed for the total molecular energy, and forces are obtained as negative energy gradients with respect to positions.

## Training

```bash
# single-gpu training
python interatomic_potentials/train.py -c interatomic_potentials/configs/newtonnet/newtonnet_qm9_energy.yaml

# multi-gpu training
python -m paddle.distributed.launch --gpus="0,1,2,3" interatomic_potentials/train.py -c interatomic_potentials/configs/newtonnet/newtonnet_qm9_energy.yaml
```

## Validation

```bash
python interatomic_potentials/train.py -c interatomic_potentials/configs/newtonnet/newtonnet_qm9_energy.yaml Global.do_eval=True Global.do_train=False Global.do_test=False Trainer.pretrained_model_path='your model path(*.pdparams)'
```

## Testing

```bash
python interatomic_potentials/train.py -c interatomic_potentials/configs/newtonnet/newtonnet_qm9_energy.yaml Global.do_test=True Global.do_train=False Global.do_eval=False Trainer.pretrained_model_path='your model path(*.pdparams)'
```

## Citation

```
@article{haghighatlari2022newtonnet,
title={NewtonNet: a Newtonian message passing network for deep learning of interatomic potentials and forces},
author={Haghighatlari, Mojtaba and Li, Jie and Guan, Xingyi and Zhang, Oufan and Das, Akshaya and Stein, Christopher J and Heiber, Farnaz and Liu, Tiantian and Head-Gordon, Martin and Bertels, Luke and others},
journal={Digital Discovery},
volume={1},
number={3},
pages={333--343},
year={2022},
publisher={Royal Society of Chemistry}
}
```
89 changes: 89 additions & 0 deletions interatomic_potentials/configs/newtonnet/newtonnet_qm9_energy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Global:
do_train: True
do_eval: False
do_test: False

label_names: ['energy']

Trainer:
max_epochs: 300
seed: 42
output_dir: ./output/newtonnet_qm9_energy
save_freq: 50
log_freq: 20
start_eval_epoch: 1
eval_freq: 1
pretrained_model_path: null
pretrained_weight_name: null
resume_from_checkpoint: null
use_amp: False
amp_level: 'O1'
eval_with_no_grad: False
gradient_accumulation_steps: 1
best_metric_indicator: 'eval_metric'
name_for_best_metric: "energy"
greater_is_better: False
compute_metric_during_train: True
metric_strategy_during_eval: 'epoch'
use_visualdl: False
use_wandb: False
use_tensorboard: False

Model:
__class_name__: NewtonNet
__init_params__:
cutoff: 5.0
n_features: 128
n_basis: 20
n_interactions: 3
activation: swish
layer_norm: False
loss_type: mse_loss
force_loss_weight: 100.0
property_names: ${Global.label_names}

Optimizer:
__class_name__: Adam
__init_params__:
lr:
__class_name__: Cosine
__init_params__:
learning_rate: 5e-4
eta_min: 1e-6
by_epoch: False

Metric:
energy:
__class_name__: paddle.nn.L1Loss
__init_params__: {}

Dataset:
dataset:
__class_name__: QM9Dataset
__init_params__:
path: "./data/qm9"
property_names: ${Global.label_names}
num_workers: 4
use_shared_memory: False
split_dataset_ratio:
train: 0.8
val: 0.1
test: 0.1
train_sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: True
drop_last: False
batch_size: 32
val_sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: False
drop_last: False
batch_size: 32
test_sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: False
drop_last: False
batch_size: 32
107 changes: 107 additions & 0 deletions interatomic_potentials/configs/schnet/schnet_md17_ethanol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Global:
do_train: True
do_eval: True
do_test: False

label_names: ['energy']

graph_converter:
__class_name__: FindPointsInSpheres
__init_params__:
cutoff: 5.0

prim_eager_enabled: True


Trainer:
max_epochs: 500
seed: 42
output_dir: ./output/schnet_md17_ethanol
save_freq: 50
log_freq: 50

start_eval_epoch: 1
eval_freq: 5
pretrained_model_path: null
pretrained_weight_name: null
resume_from_checkpoint: null
use_amp: False
eval_with_no_grad: True
gradient_accumulation_steps: 1

best_metric_indicator: 'eval_metric'
name_for_best_metric: "energy"
greater_is_better: False


Model:
__class_name__: SchNet
__init_params__:
n_atom_basis: 64
n_interactions: 6
n_filters: 64
cutoff: 5.0
n_gaussians: 25
max_z: 100
readout: "sum"
property_names: ${Global.label_names}
data_mean: 0.0
data_std: 1.0
loss_type: "l1_loss"
compute_forces: False


Optimizer:
__class_name__: Adam
__init_params__:
lr:
__class_name__: Cosine
__init_params__:
learning_rate: 1e-4
eta_min: 1e-7
by_epoch: False


Metric:
energy:
__class_name__: IgnoreNanMetricWrapper
__init_params__:
__class_name__: paddle.nn.L1Loss
__init_params__: {}


Dataset:
train:
dataset:
__class_name__: MD17Dataset
__init_params__:
path: "./data/md17"
molecule: "ethanol"
property_names: ${Global.label_names}
build_graph_cfg: ${Global.graph_converter}
max_samples: 50000
num_workers: 4
use_shared_memory: False
sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: True
drop_last: False
batch_size: 64
val:
dataset:
__class_name__: MD17Dataset
__init_params__:
path: "./data/md17"
molecule: "ethanol"
property_names: ${Global.label_names}
build_graph_cfg: ${Global.graph_converter}
max_samples: 10000
num_workers: 4
use_shared_memory: False
sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: False
drop_last: False
batch_size: 64
109 changes: 109 additions & 0 deletions interatomic_potentials/configs/schnet/schnet_qm9_U0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Global:
do_train: True
do_eval: True
do_test: False

label_names: ['energy_U0']

graph_converter:
__class_name__: FindPointsInSpheres
__init_params__:
cutoff: 10.0

prim_eager_enabled: True


Trainer:
max_epochs: 200
seed: 42
output_dir: ./output/schnet_qm9_U0
save_freq: 20
log_freq: 50

start_eval_epoch: 1
eval_freq: 5
pretrained_model_path: null
pretrained_weight_name: null
resume_from_checkpoint: null
use_amp: False
eval_with_no_grad: True
gradient_accumulation_steps: 1

best_metric_indicator: 'eval_metric'
name_for_best_metric: "energy_U0"
greater_is_better: False


Model:
__class_name__: SchNet
__init_params__:
n_atom_basis: 128
n_interactions: 6
n_filters: 128
cutoff: 10.0
n_gaussians: 50
max_z: 100
readout: "sum"
property_names: ${Global.label_names}
data_mean: -76.1160
data_std: 10.3238
loss_type: "l1_loss"
compute_forces: False


Optimizer:
__class_name__: Adam
__init_params__:
lr:
__class_name__: Cosine
__init_params__:
learning_rate: 1e-4
eta_min: 1e-7
by_epoch: False


Metric:
energy_U0:
__class_name__: IgnoreNanMetricWrapper
__init_params__:
__class_name__: paddle.nn.L1Loss
__init_params__: {}


Dataset:
train:
dataset:
__class_name__: QM9Dataset
__init_params__:
path: "./data/qm9"
property_names: ${Global.label_names}
build_graph_cfg: ${Global.graph_converter}
cache_path: "./data/qm9"
overwrite: False
filter_unvalid: True
num_workers: 4
use_shared_memory: False
sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: True
drop_last: False
batch_size: 64
val:
dataset:
__class_name__: QM9Dataset
__init_params__:
path: "./data/qm9"
property_names: ${Global.label_names}
build_graph_cfg: ${Global.graph_converter}
cache_path: "./data/qm9"
overwrite: False
filter_unvalid: True
num_workers: 4
use_shared_memory: False
sampler:
__class_name__: BatchSampler
__init_params__:
shuffle: False
drop_last: False
batch_size: 64
Loading