optzer documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Advanced case

A bit advanced case than the simplest case is examples/02_pmd_LZP also in the github repository.

This example shows how to optimize parameters in interatomic potentials used in a molecular dynamics (MD) program pmd in nap package. A target materials is LiZr2(PO4)3, which is called LZP. The interatomic potentials for LZP here is Coulomb potential, Morse potential, and angular potential between a certain pairs and triplets. The pmd program performs MD simulation with the following files:

  • in.pmd — setting file for MD simulation
  • pmdini — atom configuration file containing cell information and atom positions
  • in.params.Coulomb — parameters in Coulomb potential
  • in.params.Morse — parameters in Morse potential
  • in.params.angular — parameters in angular potential

Thus, for example, the in.params.Morse file is written like this.

# cspi, cspj,    D,      alpha,  rmin
  Li    O     {D_Li-O:6.4f}   {alp_Li-O:6.4f}   {rmin_Li-O:6.4f}
  Zr    O     {D_Zr-O:6.4f}   {alp_Zr-O:6.4f}   {rmin_Zr-O:6.4f}
  P     O     {D_P-O:6.4f}   {alp_P-O:6.4f}   {rmin_P-O:6.4f}

This means that there are three pairs to be considered, and each pair (such as Li-O pair) has three parameters, D, alpha, and rmin. These parameters are to be optimized by the optzer program.

The optzer program requires the following files:

  • in.optzer
  • in.vars.optzer
  • data.ref.XXX — target properties; rdf, adf, and vol in this case.
  • subjob.sh

in.vars.optzer

  17
     1.1101     1.0000     1.2000      0.5000     2.0000  rho_Li
     1.2301     1.1000     1.3000      0.5000     2.0000  rho_Zr
     0.8188     0.8000     1.1000      0.5000     2.0000  rho_P
     0.9471     0.8000     1.1000      0.5000     2.0000  rho_O
     1.2634     0.8000     1.3000      0.1000     10.000  D_Li-O
     2.1151     2.0000     2.2000      0.5000     3.0000  alp_Li-O
     1.7612     1.7000     1.9000      1.0000     3.0000  rmin_Li-O
     2.6937     2.0000     3.0000      0.1000     10.000  D_Zr-O
     2.0818     1.9000     2.2000      0.5000     3.0000  alp_Zr-O
     1.9338     1.9000     2.0000      1.0000     3.0000  rmin_Zr-O
     4.6525     4.0000     5.0000      0.1000     10.000  D_P-O
     2.0667     1.9000     2.2000      0.5000     3.0000  alp_P-O
     1.4202     1.4000     1.6000      1.0000     3.0000  rmin_P-O
     2.3355     1.0000     3.0000      0.0000     5.0000  alp_Zr-O-O
     0.0000    -0.5000     0.5000     -0.5000     0.5000  gmm_Zr-O-O
     2.4300     1.0000     3.0000      0.0000     5.0000  alp_P-O-O
    -0.3330    -0.5000     0.5000     -0.5000     0.5000  gmm_P-O-O
  • There are 17 parameters to be optimized.
  • 1st column — initial guess of the parameters
  • 2nd and 3rd columns — lower and upper of soft limits
  • 4th and 5th columns — lower and upper of hard limits
  • 6th column — names of parameters, which correspond to the placeholder key in the above in.params.XXX file.

subjob.sh

During the optimization, there are several trial parameters generated (called individuals) and they are written to in.params.XXX files in subdir_### directories. This subjob.sh script will be used to perform pmd and subtasks in each subdir_### directories.

#!/bin/bash

#...copy filed required for pmd calculation
yes | cp ../in.pmd.* ../pmdini ./

#...cd to the directory and clean up
rm -f dump_* out.*

t0=`date +%s`

export OMP_NUM_THREADS=1

#...NpT MD
cp in.pmd.NpT in.pmd
pmd 2>&1 > out.pmd.NpT
# mpirun -np 1 ../../../pmd/pmd 2>&1 > out.pmd.NpT
head -n166 out.pmd.NpT
tail -n20 out.pmd.NpT
echo "NpT-MD done at" `date`
#...extract rdf, adf, vol and rename files
python ~/src/nap/nappy/rdf.py --fortran -d 0.05 -r 5.0 --gsmear=2 --skip=80 --specorder=Li,Zr,P,O --pairs=Li-O,Zr-O,P-O,Li-Li --out4fp -o data.pmd.rdf dump_* 2>&1
python ~/src/nap/nappy/adf.py --fortran --gsmear=2 --triplets=Zr-O-O,P-O-O --skip=80 --out4fp -o data.pmd.adf dump_* 2>&1
python ~/src/nap/nappy/vol_lat.py --skip=80 --out4fp --prefix data.pmd dump_* 2>&1
t1=`date +%s`
etime=`expr $t1 - $t0`
echo "subjob.sh took" $etime "sec, done at" `date`
  • First, copy all the necessary files to run pmd program, such as in.pmd and pmdini. (in.params.Coulomb, in.params.Morse, and in.params.angular are written by optzer)
  • Remove some junk files.
  • Perform pmd program.
  • Finally, extract rdf, adf, and vol by using some python programs, rdf.py, adf.py, and, vol_lat.py, respectively.

In each subdir_###, above subjobs are performed and data.pmd.rdf, data.pmd.adf, and data.pmd.vol files are generated. And then otpzer compares data in these files with those in data.ref.XXX files.