[PYTHON] Try MD simulation with ANN potential using aenet and ASE

aenet (Atomic Energy Network) is a package for dealing with ANN (artificial neural network) interatomic potential. New ANN potentials can be constructed based on DFT calculations, and energy and forces can be predicted using learned potentials.

Since aenet provides an interface for ASE (Atomic Simulation Environment), which is a Python library for atomic simulation, it is possible to perform structural optimization and molecular dynamics simulation (MD) using ANN potential.

In this article, we will perform MD simulation of TiO 2 </ sub> using the learned ANN potential.

Installation

Build the aenet Python interface.

Execute make in each directory (lib, src, python3) of the project. There are multiple Makefiles (ifort vs. gfortran, mpi vs. serial, etc.) in the src directory. Select Makefile if necessary.

Please also refer to the README provided in each directory.

$ git clone https://github.com/atomisticnet/aenet.git
$ git checkout v2.0.4 #newest version
$ cd aenet/lib
$ make #Compile lib
$ cd ../src
$ make -f makefiles/Makefile.gfortran_serial lib #Compile src.Be sure to set the target to lib.
$ cd ../python3
$ python3 setup.py install --user #Compile the Python interface

If the gcc version when building lib or src and the gcc version when building the python interface do not match, the build will not work properly even if it is completed. I'm addicted to this.

Trained data

Trained data of TiO 2 </ sub> (aenet-example-02-TiO2-Chebyshev.tar.bz2) can be downloaded from Official Site is. This trained data is also used in this article.

In the following, the calculation is performed using the trained nn file in the `ʻaenet-example-02-TiO2-Chebyshev / 03-predict / set001`` directory.

Simple example

As the simplest example, let's calculate the energy of rutile type TiO 2 </ sub>.

from ase.spacegroup import crystal
from aenet.ase_calculator import ANNCalculator

TiO2_rutile =crystal(['Ti', 'O'], basis=[(0, 0, 0), (0.3, 0.3, 0.0)],
                     spacegroup=136, cellpar=[4.6, 2.95, 2.95, 90, 90, 90])
calc = ANNCalculator({'Ti':'Ti.15t-15t.nn', 'O':'O.15t-15t.nn'})
TiO2_rutile.set_calculator(calc)
e = TiO2_rutile.get_potential_energy()
print(f'energy: {e}')

The energy of the ANN potential could be calculated very easily.

benchmark

Let's measure the calculation time with a notebook PC. We created multiple supercells with different atomic numbers and plotted the time required for energy calculation for each.

aenet_fig1.png

MD simulation

Finally, let's perform MD simulation. Just replace the ASE Calculator with an ANN Calculator.

from ase import units
from ase.spacegroup import crystal
from ase.md.nvtberendsen import NVTBerendsen
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
from aenet.ase_calculator import ANNCalculator

dt = 2 * units.fs
temp = 300
nsteps = 400
taut = 20 * units.fs

TiO2_rutile =crystal(['Ti', 'O'], basis=[(0, 0, 0), (0.3, 0.3, 0.0)],
                     spacegroup=136, cellpar=[4.6, 2.95, 2.95, 90, 90, 90])
calc = ANNCalculator({'Ti':'Ti.15t-15t.nn', 'O':'O.15t-15t.nn'})
TiO2_rutile.set_calculator(calc)
MaxwellBoltzmannDistribution(TiO2_rutile, temp * units.kB)
dyn = NVTBerendsen(TiO2_rutile, dt, temp, taut=taut, trajectory='md.traj')
def myprint():
    print(f'time={dyn.get_time() / units.fs: 5.0f} fs ' + \
          f'T={TiO2_rutile.get_temperature(): 3.0f} K')
dyn.attach(myprint, interval=20)
dyn.run(nsteps)

aenet-ani.gif

reference

Recommended Posts

Try MD simulation with ANN potential using aenet and ASE
Try using PythonTex with Texpad.
Try using matplotlib with PyCharm
Try using pytest-Overview and Samples-
Play with ASE MD module
Try using folium with anaconda
Using Sessions and Reflections with SQLAlchemy
Try frequency control simulation with Python
Try using Python's networkx with AtCoder
Perform DFT calculation with ASE and GPAW
Try using the camera with Python's OpenCV
Let's try gRPC with Go and Docker
Try using Dropbox API v2 with Go
Try using Python with Google Cloud Functions
I'm using tox and Python 3.3 with Travis-CI
2D physics simulation with Box2d and wxPython
Try using S3 object upload and download with AWS SDK for Go v2