Liquid Si - MLFF: Difference between revisions

From VASP Wiki
Line 168: Line 168:
=== Creating the liquid structure ===
=== Creating the liquid structure ===


We will start this example from a perfect super cell of crystalline silicon (fcc diamond structure) containing 64 atoms. The temperature is set to 2000 K so that when an MD is run the melting should occur relatively fast. We will do the melting with on-the-fly learning. This will greatly accelerate the melting since after some time most of the ab initio calculations are skipped and the very fast force fields take over. This calculation will be executed for 10000 steps with a step size of 3 fs.
We will start this example from a perfect super cell of crystalline silicon (fcc diamond structure) containing 64 atoms. The temperature is set to 2000 K so that when an MD is run the melting should occur relatively fast. We will do the melting with on-the-fly learning. This will greatly accelerate the melting since after some time most of the ab initio calculations are skipped and the very fast force field takes over. This calculation will be executed for 10000 steps with a step size of 3 fs.


Please run now the calculation.
Please run now the calculation.

Revision as of 10:21, 26 July 2019

Task

Generating a machine learning force field for liquid Si.

Input

POSCAR

  • In this example we start from a 64 atom super cell of diamond-fcc Si (the same as in this example: Liquid Si - Standard MD:
Si cubic diamond 2x2x2 super cell of conventional cell
     5.43090000000000
    2.00000000   0.00000000   0.00000000
    0.00000000   2.00000000   0.00000000
    0.00000000   0.00000000   2.00000000
   Si
   64
Direct
   0.00000000   0.00000000   0.00000000
   0.50000000   0.00000000   0.00000000
   0.00000000   0.50000000   0.00000000
   0.50000000   0.50000000   0.00000000
   0.00000000   0.00000000   0.50000000
   0.50000000   0.00000000   0.50000000
   0.00000000   0.50000000   0.50000000
   0.50000000   0.50000000   0.50000000
   0.37500000   0.12500000   0.37500000
   0.87500000   0.12500000   0.37500000
   0.37500000   0.62500000   0.37500000
   0.87500000   0.62500000   0.37500000
   0.37500000   0.12500000   0.87500000
   0.87500000   0.12500000   0.87500000
   0.37500000   0.62500000   0.87500000
   0.87500000   0.62500000   0.87500000
   0.00000000   0.25000000   0.25000000
   0.50000000   0.25000000   0.25000000
   0.00000000   0.75000000   0.25000000
   0.50000000   0.75000000   0.25000000
   0.00000000   0.25000000   0.75000000
   0.50000000   0.25000000   0.75000000
   0.00000000   0.75000000   0.75000000
   0.50000000   0.75000000   0.75000000
   0.37500000   0.37500000   0.12500000
   0.87500000   0.37500000   0.12500000
   0.37500000   0.87500000   0.12500000
   0.87500000   0.87500000   0.12500000
   0.37500000   0.37500000   0.62500000
   0.87500000   0.37500000   0.62500000
   0.37500000   0.87500000   0.62500000
   0.87500000   0.87500000   0.62500000
   0.25000000   0.00000000   0.25000000
   0.75000000   0.00000000   0.25000000
   0.25000000   0.50000000   0.25000000
   0.75000000   0.50000000   0.25000000
   0.25000000   0.00000000   0.75000000
   0.75000000   0.00000000   0.75000000 
   0.25000000   0.50000000   0.75000000
   0.75000000   0.50000000   0.75000000
   0.12500000   0.12500000   0.12500000
   0.62500000   0.12500000   0.12500000
   0.12500000   0.62500000   0.12500000
   0.62500000   0.62500000   0.12500000
   0.12500000   0.12500000   0.62500000
   0.62500000   0.12500000   0.62500000
   0.12500000   0.62500000   0.62500000
   0.62500000   0.62500000   0.62500000
   0.25000000   0.25000000   0.00000000
   0.75000000   0.25000000   0.00000000
   0.25000000   0.75000000   0.00000000
   0.75000000   0.75000000   0.00000000
   0.25000000   0.25000000   0.50000000
   0.75000000   0.25000000   0.50000000
   0.25000000   0.75000000   0.50000000
   0.75000000   0.75000000   0.50000000
   0.12500000   0.37500000   0.37500000
   0.62500000   0.37500000   0.37500000
   0.12500000   0.87500000   0.37500000
   0.62500000   0.87500000   0.37500000
   0.12500000   0.37500000   0.87500000
   0.62500000   0.37500000   0.87500000
   0.12500000   0.87500000   0.87500000
   0.62500000   0.87500000   0.87500000

KPOINTS

  • We will start with a single k point in this example:
K-Points
 0
Gamma
 1  1  1
 0  0  0

INCAR

#Basic parameters
ISMEAR = 0
SIGMA = 0.1
LREAL = Auto
PREC = FAST
ALGO = FAST
ISYM = -1
NELM = 100
EDIFF = 1E-4
LWAVE = .FALSE.
LCHARG = .FALSE.

#Parallelization of ab initio calculations
NCORE = 2

#MD
IBRION = 0
MDALGO = 2
ISIF = 2
SMASS = 1.0
TEBEG = 2000
NSW = 10000
POTIM = 3.0

#Machine learning paramters
ML_FF_LMLFF = .TRUE.
ML_FF_ISTART = 0
ML_FF_NWRITE = 2
ML_FF_EATOM = -.70128086E+00
  • The user should be familiar at this step how to run a basic molecular dynamics calculations. If not please go through the example here: Liquid Si - Standard MD.
  • Machine learning is switched on by setting the following tag: ML_FF_LMLFF=.TRUE..
  • By setting the tag ML_FF_ISTART to zero learning from scratch is selected.
  • The flag ML_FF_NWRITE=2 selects a more verbose output where the error on energies, forces and stress are output to the ML_LOGFILE file. This setting is very handy to check the accuracy of the force field.
  • The tag ML_FF_EATOM=-.70128086E+00 sets the atomic reference energy for each species. How to obtain that energy is explained below.

Calculation

Reference energy

Before the force field for liquid Si can be calculated, the atomic energy of a single Si atom in a large enough box has to be calculated. For that the following steps have to be done:

  • Create a new directory Si_ATOM by typing mkdir Si_ATOM and go to that directory cd Si_ATOM.
  • Create an INCAR file with the following parameters:
#Basic parameters
ISMEAR = 0
SIGMA = 0.1
LREAL = Auto
PREC = FAST
ALGO = FAST
ISYM = 0
NELM = 100
EDIFF = 1E-4
LWAVE = .FALSE.
LCHARG = .FALSE.
ISPIN = 2
  • Create a POSCAR file with a single atom in a large enough box (the box should be orthorombic to have enough degrees of freedom for electronic relaxation):
Si atom
     1.00090000000000
    12.00000000   0.00000000   0.00000000
     0.00000000  12.01000000   0.00000000
     0.00000000   0.00000000  12.02000000
   Si
   1
Direct
   0.00000000   0.00000000   0.00000000
  • Create a KPOINTS file with a single k point (or copy the one delivered with this example):
test
0 0 0
Gamma
 1 1 1
 0 0 0
  • Copy the POTCAR from the previous directory to this directory (cp ../POTCAR).
  • Run the calculation and look at the total energy in the OUTCAR file (or OSZICAR). AFter that switch back to the original directory. That energy will be used for the ML_FF_EATOM tag. If multiple atom types are present in the structure than this step has to be repeated for each atom type separately and the reference energies are provided as a list after the ML_FF_EATOM tag, where the ordering of the energies corresponds to the ordering of the elements in the POTCAR file.

Creating the liquid structure

We will start this example from a perfect super cell of crystalline silicon (fcc diamond structure) containing 64 atoms. The temperature is set to 2000 K so that when an MD is run the melting should occur relatively fast. We will do the melting with on-the-fly learning. This will greatly accelerate the melting since after some time most of the ab initio calculations are skipped and the very fast force field takes over. This calculation will be executed for 10000 steps with a step size of 3 fs.

Please run now the calculation.

After running the calculation we should obtain a fairly good liquid in the CONTCAR file.

As a side effect we have also learned a force field, but with maybe a quite bad trajectory at the beginning. Usually it is more systematic to learn on the pure structures. In our case this means to use the CONTCAR file obtained after the melting. Also the force field was only learned using a single k point. To obtain a better accuracy we will use more k points. So after this step we will start the learning from scratch using the CONTCAR obtained so and using more accurate parameters.

But before we do that we will take a look at the accuracy of the force obtained now.

The main output files for the machine learning are:

  • ML_LOGFILE: This contains the main output of the machine learning. Since we use ML_FF_NWRITE=2 the error on energy, forces and stress of the force field compared to ab initio is also written out on this file for every step.
  • ML_ABNCAR: This contains the ab initio data used for the learning. It will be needed for continuation runs as ML_ABCAR.
  • ML_FFNCAR: This contains the regression results (weights, parameters, etc.). It will be needed for continuation runs as ML_FFCAR.

In the ML_LOGFILE we will look for the last entry on the error of energy, forces and stress, Bayesian error and spilling factor, which should look similar to this (since we run a molecular dynamics calculation in parallel on different computers actual results can deviate a little):

====================================================================================================
     Information on error estimations
----------------------------------------------------------------------------------------------------
              Error in energy (eV atom^-1):     0.011371
             Error in force  (eV Angst^-1):     0.160309
                      Error in stress (kB):     2.387189
               Bayesian error (eV Angst-1):     0.142874    0.101240
                       Spilling factor (-):     0.006869    0.020000
====================================================================================================

The first entry of the Bayesian error is the estimated error from our model. The second entry is the error threshold. In our case it is newly determined during the calculations. The first and second entry for the spilling factor are the calculated spilling factor and the threshold, respectively. The threshold for the spilling factor is usually always kept constant during the calculations.

Download