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 input file is shown below:
element: ['Cu']
mass: [63.546]
calculations:
- mode: alchemy
temperature: [600]
pressure: [0]
lattice: [FCC]
repeat: [5, 5, 5]
state: [solid]
nsims: 1
md:
pair_style: [eam/fs, eam/alloy]
pair_coeff: ["* * ../potentials/Cu1.eam.fs Cu", "* * ../potentials/Cu01.eam.alloy Cu"]
timestep: 0.001
tdamp: 0.1
pdamp: 0.1
te: 10000
ts: 15000
queue:
scheduler: local
cores: 4
commands:
- conda activate calphy
The major change 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.43894689000222
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.2544935936478223
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.6934404836500425
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.6942301262722053
We can see that the directly calculation is in meV agreement with the upsampling calculations.