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.
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 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.
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.
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.
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)
Recommended Posts