Example 07: Upsampling calculations#
In this example, upsampling calculations which can be used to switch a system between two different interatomic potentials is illustrated.
The major change in the input file is that both pair_style
and pair_coeff
keywords have two arguments. These are the two potentials between which the transformation will be carried out.
The first potential is a Finnis-Sinclair (FS) potential for copper:
The second potential is an EAM:
If we know the free energy of the FS potential at a given temperature, we can calculate the free energy of the EAM through upsampling calculations. Upsampling calculations generally need only much less switching time, thus is quite useful in the case of expensive interatomic potentials, such as machine learning potentials.
We start by calculating the free energy of the FS potential. The input file is available at pot1/input-fe.yaml
. As usual, the calculation can be run using calphy -i input-fe.yaml
. We can now load the report.yaml
file and check the free energy.
[1]:
import yaml
import numpy as np
[2]:
with open('pot1/fe-FCC-600-0/report.yaml', 'r') as fin:
pot1 = yaml.safe_load(fin)
[3]:
pot1['results']['free_energy']
[3]:
-3.4389380251304913
Now we can transform FS to EAM potential (see input file above). After running the calculation, we can check the free energy of this alchemical transformation.
[4]:
with open('alchemy-FCC-600-0/report.yaml', 'r') as fin:
alchemy = yaml.safe_load(fin)
[5]:
alchemy['results']['free_energy']
[5]:
-0.25451608590151586
The free energy of the EAM potential, \(F_\mathrm{EAM} = F_\mathrm{FS} + F_\mathrm{upsampling}\)
[6]:
pot1['results']['free_energy']+alchemy['results']['free_energy']
[6]:
-3.693454111032007
We can verify this calculation by directly computing the free energy of the EAM potential. The input file is available at pot2/input-fe.yaml
.
[7]:
with open('pot2/fe-FCC-600-0/report.yaml', 'r') as fin:
pot2 = yaml.safe_load(fin)
[8]:
pot2['results']['free_energy']
[8]:
-3.6923377327832667
We can see that the directly calculation is in meV agreement with the upsampling calculations.