OF-DFT with Continuous-time Normalizing Flows
July 19, 2024 · View on GitHub
This repository contains the original implementation of the experiments for "Leveraging Normalizing Flows for Orbital-Free Density Functional Theory".
Sketch of the algorithm
In orbital-free density functional theory, the ground-state density is found by solving a constrained optimization problem,
where acts as the Lagrange multiplier associated with the normalization constraint on the total number of particles . These constraints, which enforce both positivity and normalization, ensure the attainment of physically valid solutions.
In this work, we present an alternative constraint-free approach to solve for the ground-state density by a continuous-time normalizing flow (NF) ansatz, allowing us to reframe the OF-DFT variational problem as a Lagrangian-free optimization problem for molecular densities in real space,
where we parameterize the electron density , where is a NF, this form is also referred to as the shape factor. The samples are drawn from the base distribution and transformed by,
For the one-dimensional simulations, the architecture of is a standard feed-forward neural network (NN),
where is a linear layer followed by an activation function, and is the number of layers. For this work, has 3 layers, each with 512 neurons, and the activation function. For the simulation in three dimensions, is parametrized by a permutation equivariant graph NN (GNN),
where is the atomic number of the -nucleus, encoded as a one-hot vector (), is the number of nucleus in the molecule, and is a feed-forward NN with $64\tanh$ activation function.
Results
We successfully replicate the electronic density for the one-dimensional Lithium hydride molecule with varying interatomic distances, as well as comprehensive simulations of hydrogen and water molecules, all conducted in Cartesian space.
Running the code
1-D
For Lithium hydride () molecule, simulations can be run in the following way,
python LiH.py
--epochs <number of iterations>
--bs <batch size>
--N <number of valence electrons>
--sched <learning rate schedule>
--R <interatomic distances>
--Z <atomic number>
The default functionals can be found in the directory ofdft_normflows.
| of for various inter-atomic distances. | The change of and during training. |
|---|---|
![]() | ![]() |
3-D
For water () and hydrogen () molecules, simulations can be run in the following way,
python H2_mol_ofdft_min.py
--epochs <number of iterations>
--bs <batch size>
--lr <initial learning rate>
--sched <learning rate schedule>
The default kinetic energy functional is the sum of the Thomas-Fermi and Weizsäcker, however, --kin <name> could be used to select others.
| Vector field for water's electronic density. | Vector field for benzene's electronic density. |
|---|---|
![]() | ![]() |
Dependencies
- DeepMind JAX Ecosystem 'JAX v0.4.23'
- Flax
- PySCF
This is a library that is currently being built.



