Sampling in CNID#

In this tutorial, let us verify the computed CNID.

We do this by sampling the total energy of a system of Si(111)/SiC(0001) interface with displacing one crystal in the CNID.

import & prepare#

[1]:
!pip install git+https://github.com/nmdl-mizo/interface_master.git@develop
!mkdir -p cif_files
!curl https://raw.githubusercontent.com/nmdl-mizo/interface_master/develop/test_files/cif_files/Si_mp-149_conventional_standard.cif -o 'cif_files/Si_mp-149_conventional_standard.cif'
!curl https://raw.githubusercontent.com/nmdl-mizo/interface_master/develop/test_files/cif_files/SiC_mp-568656_conventional_standard.cif -o 'cif_files/SiC_mp-568656_conventional_standard.cif'
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/nmdl-mizo/interface_master.git@develop
  Cloning https://github.com/nmdl-mizo/interface_master.git (to revision develop) to /tmp/pip-req-build-lq_mn61j
  Running command git clone --filter=blob:none --quiet https://github.com/nmdl-mizo/interface_master.git /tmp/pip-req-build-lq_mn61j
  Resolved https://github.com/nmdl-mizo/interface_master.git to commit 2bdf96ed4835b036557ac18de82b4fa2afdabf24
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pymatgen in /home/vscode/.local/lib/python3.10/site-packages (from interfacemaster==1.1.1) (2023.1.30)
Requirement already satisfied: matplotlib in /home/vscode/.local/lib/python3.10/site-packages (from interfacemaster==1.1.1) (3.7.0)
Requirement already satisfied: gb_code in /home/vscode/.local/lib/python3.10/site-packages (from interfacemaster==1.1.1) (1.0.0)
Requirement already satisfied: numpy>=1.14.0 in /home/vscode/.local/lib/python3.10/site-packages (from gb_code->interfacemaster==1.1.1) (1.24.2)
Requirement already satisfied: pillow>=6.2.0 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (9.4.0)
Requirement already satisfied: fonttools>=4.22.0 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (4.38.0)
Requirement already satisfied: cycler>=0.10 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (0.11.0)
Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (23.0)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (2.8.2)
Requirement already satisfied: pyparsing>=2.3.1 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (3.0.9)
Requirement already satisfied: contourpy>=1.0.1 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (1.0.7)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (1.4.4)
Requirement already satisfied: pybtex in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (0.24.0)
Requirement already satisfied: sympy in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (1.11.1)
Requirement already satisfied: plotly>=4.5.0 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (5.13.0)
Requirement already satisfied: spglib>=2.0.2 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (2.0.2)
Requirement already satisfied: requests in /usr/local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (2.28.2)
Requirement already satisfied: tqdm in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (4.64.1)
Requirement already satisfied: networkx>=2.2 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (3.0)
Requirement already satisfied: palettable>=3.1.1 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (3.3.0)
Requirement already satisfied: pandas in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (1.5.3)
Requirement already satisfied: ruamel.yaml>=0.17.0 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (0.17.21)
Requirement already satisfied: tabulate in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (0.9.0)
Requirement already satisfied: mp-api>=0.27.3 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (0.30.10)
Requirement already satisfied: uncertainties>=3.1.4 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (3.1.7)
Requirement already satisfied: scipy>=1.5.0 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (1.10.1)
Requirement already satisfied: monty>=3.0.2 in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (2022.9.9)
Requirement already satisfied: emmet-core>=0.39.8 in /home/vscode/.local/lib/python3.10/site-packages (from mp-api>=0.27.3->pymatgen->interfacemaster==1.1.1) (0.44.0)
Requirement already satisfied: msgpack in /home/vscode/.local/lib/python3.10/site-packages (from mp-api>=0.27.3->pymatgen->interfacemaster==1.1.1) (1.0.4)
Requirement already satisfied: typing-extensions>=3.7.4.1 in /home/vscode/.local/lib/python3.10/site-packages (from mp-api>=0.27.3->pymatgen->interfacemaster==1.1.1) (4.5.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/site-packages (from mp-api>=0.27.3->pymatgen->interfacemaster==1.1.1) (65.5.1)
Requirement already satisfied: tenacity>=6.2.0 in /home/vscode/.local/lib/python3.10/site-packages (from plotly>=4.5.0->pymatgen->interfacemaster==1.1.1) (8.2.1)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib->interfacemaster==1.1.1) (1.16.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests->pymatgen->interfacemaster==1.1.1) (1.26.14)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests->pymatgen->interfacemaster==1.1.1) (2022.12.7)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages (from requests->pymatgen->interfacemaster==1.1.1) (3.0.1)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests->pymatgen->interfacemaster==1.1.1) (3.4)
Requirement already satisfied: ruamel.yaml.clib>=0.2.6 in /home/vscode/.local/lib/python3.10/site-packages (from ruamel.yaml>=0.17.0->pymatgen->interfacemaster==1.1.1) (0.2.7)
Requirement already satisfied: future in /home/vscode/.local/lib/python3.10/site-packages (from uncertainties>=3.1.4->pymatgen->interfacemaster==1.1.1) (0.18.3)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/site-packages (from pandas->pymatgen->interfacemaster==1.1.1) (2022.7.1)
Requirement already satisfied: PyYAML>=3.01 in /usr/local/lib/python3.10/site-packages (from pybtex->pymatgen->interfacemaster==1.1.1) (6.0)
Requirement already satisfied: latexcodec>=1.0.4 in /home/vscode/.local/lib/python3.10/site-packages (from pybtex->pymatgen->interfacemaster==1.1.1) (2.0.1)
Requirement already satisfied: mpmath>=0.19 in /home/vscode/.local/lib/python3.10/site-packages (from sympy->pymatgen->interfacemaster==1.1.1) (1.2.1)
Requirement already satisfied: pydantic>=1.10.2 in /home/vscode/.local/lib/python3.10/site-packages (from emmet-core>=0.39.8->mp-api>=0.27.3->pymatgen->interfacemaster==1.1.1) (1.10.5)

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1059  100  1059    0     0   1312      0 --:--:-- --:--:-- --:--:--  1310
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1685  100  1685    0     0   2252      0 --:--:-- --:--:-- --:--:--  2249

Again, making an two-D CSL interface following the previous tutorials#

[1]:
from interfacemaster.cellcalc import get_primitive_hkl, get_pri_vec_inplane, get_normal_index
from interfacemaster.interface_generator import core, convert_vector_index, write_trans_file
from numpy import array, dot, round, cross
from numpy.linalg import inv, det
[2]:
my_interface = core('cif_files/Si_mp-149_conventional_standard.cif',\
                    'cif_files/SiC_mp-568656_conventional_standard.cif')
Warning!, this programme will rewrite the POSCAR file in this dir!
/Users/jasonxie/.local/lib/python3.8/site-packages/pymatgen/io/cif.py:1121: UserWarning: Issues encountered while parsing CIF: Some fractional co-ordinates rounded to ideal values to avoid issues with finite precision.
  warnings.warn("Issues encountered while parsing CIF: %s" % "\n".join(self.warnings))
[3]:
hkl_1 = get_primitive_hkl([1,1,1], my_interface.conv_lattice_1, my_interface.lattice_1)
hkl_2 = get_primitive_hkl([0,0,1], my_interface.conv_lattice_2, my_interface.lattice_2)
[4]:
my_interface.parse_limit(du = 2e-2, S  = 2e-2, sgm1=50, sgm2=50, dd = 2e-2)

#Do searching!
my_interface.search_one_position_2D(hkl_1, hkl_2, theta_range = 180, \
                                    dtheta = 0.01, start = 15.21, integer_tol=1e-3)
Congrates, we found an appx CSL!

U1 =
[[ 1 -6]
 [-6  5]
 [ 5  1]]; sigma_1 = 54

U2 =
[[-3 -5]
 [-8  3]
 [ 0  0]]; sigma_2 = 49

D =
[[ 0.99590432  0.00730638 -0.0032107 ]
 [-0.0032107   0.99590432  0.00730638]
 [ 0.00730638 -0.0032107   0.99590432]]

axis = [-7.47674648 -7.47674648 -7.47674648] ; theta = 15.21

[5]:
dot(inv(my_interface.lattice_1), my_interface.CNID)
[5]:
array([[ 0.06122449,  0.10204082],
       [-0.16326531,  0.06122449],
       [ 0.10204082, -0.16326531]])
[6]:
my_interface.compute_bicrystal_two_D(hkl_1 = hkl_1, hkl_2=hkl_2, \
                                     normal_ortho = True,
                                     lim = 50, tol_ortho = 1e-2)
my_interface.get_bicrystal(two_D = True, xyz_1 = [1,1,1], xyz_2 = [1,1,1], filetype = 'LAMMPS', filename = 'atominfile', dp1 = 1.5)
cell 1:
[[-1  1 -6]
 [-1 -6  5]
 [-1  5  1]]
cell 2:
[[ 0 -3 -5]
 [ 0 -8  3]
 [-1  0  0]]

Generate LAMMPS commands to sampling system energy in the CNID#

The interface structure can be complex, especially when we can have a ‘triclinic’ cell.

Therefore, we provide some functions here to help you write some necessary input commands for LAMMPS.

Note that it is far more effective to do looping by LAMMPS’s looping variables than by generating many different atom files!

  1. Define regions & groups

[8]:
my_interface.define_lammps_regions(['right'],[11],['EDGE'])

You can see that here we generated a ‘blockfile’ file defining a ‘right’ group, which will be displaced during the simulation.

  1. Define translation variables

To verify the periodicity of CNID, we translate in a 2x2 expansion of CNID divided into a fine 50x50 grids (dont worry, this won’t take a long time :D)

[9]:
v1, v2 = 2*dot(my_interface.orient, my_interface.CNID).T
write_trans_file(v1,v2,50,50)

Here we generated a ‘paras’ file, including the looping variables and the translation variables which will be applied in the ‘displace_atoms’ command.

Now, put these two files in the ‘CNID_check’ folder and run LAMMPS in this folder!

After running LAMMPS, a ‘results’ file is generated with the energy map by RBT. Now we just show the results here.

[10]:
from numpy import loadtxt
dx, dy, dz, energy = loadtxt('LAMMPS_input_of_CNID_cheking/results', unpack = True)
[11]:
import matplotlib.pyplot as plt
[14]:
plt.scatter(dy, dz, c = energy, cmap = 'hot')
plt.colorbar()
[14]:
<matplotlib.colorbar.Colorbar at 0x7fb991429d60>
../_images/tutorials_Tutorial_Sampling_in_CNID_23_1.png

A 2*2 periodicity is confirmed