CIS twinning - Approximate#

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/CIS-exp.cif -o 'cif_files/CIS-exp.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-wlbjf_9_
  Running command git clone --filter=blob:none --quiet https://github.com/nmdl-mizo/interface_master.git /tmp/pip-req-build-wlbjf_9_
  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: cycler>=0.10 in /home/vscode/.local/lib/python3.10/site-packages (from matplotlib->interfacemaster==1.1.1) (0.11.0)
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: 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: 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: 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: 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: 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: 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: 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: 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: sympy in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (1.11.1)
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: 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: 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: pandas in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (1.5.3)
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: 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: pybtex in /home/vscode/.local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (0.24.0)
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: 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: requests in /usr/local/lib/python3.10/site-packages (from pymatgen->interfacemaster==1.1.1) (2.28.2)
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: 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: 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: 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: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests->pymatgen->interfacemaster==1.1.1) (3.4)
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: 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: 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  1684  100  1684    0     0   5826      0 --:--:-- --:--:-- --:--:--  5826
[2]:
from interfacemaster.cellcalc import get_primitive_hkl
from interfacemaster.interface_generator import core, convert_vector_index
from numpy import array, dot, round, var, average
from numpy.linalg import inv

Define an interface core class#

Input two cif files.For GBs, input the same file; for interfaces, input two different files.

The first structure is non-changed while the second one can be deformed to form an approximate CSL

Please input files of CONVENTIONAL cells if you are not familiar with the indices in the primitive cell.

[2]:
my_interface = core('cif_files/CIS-exp.cif','cif_files/CIS-exp.cif')
Warning!, this programme will rewrite the POSCAR file in this dir!

Specify the rotation axis and searching parameters to find an approximate CSL#

Rotation axis should be expressed in the primitive cell frame, we can convert this.

For example we need an axis [2,-2,1] expressed in the conventional cell.

[3]:
axis = convert_vector_index(my_interface.conv_lattice_1, my_interface.lattice_1, [2,-2,1])
axis
[3]:
array([ 3., -1.,  2.])

For the meaning of searching parameters, please check the paper.

If you are making an exact CSL, please use the search_fixed() function setting ‘exact = True’

In this case we make a known twinning GB, which is an approximate CSL.

[5]:
my_interface.parse_limit(du = 1e-2, S  = 1e-2, sgm1=100, sgm2=100, dd = 1e-2)

#Do searching!
#We already know that there is a CSL by rotation 180 degrees
my_interface.search_one_position(axis,180,1,0.01)
[ 11.562  -11.562   11.6422]
Congrates, we found an appx CSL!

U1 =
[[ 0  1  1]
 [-1  1 -1]
 [-1  0  1]]; sigma_1 = 3

U2 =
[[ 0 -1  2]
 [ 1 -1  0]
 [ 1  0  1]]; sigma_2 = 3

D =
[[ 1.0030793  -0.0030793  -0.00611617]
 [-0.0030793   1.0030793   0.00611617]
 [ 0.00310066 -0.00310066  0.9938414 ]]

axis = [ 11.562  -11.562   11.6422] ; theta = 180.0

‘U1’, ‘U2’ are two sets of indices of the CSL in the two crystals’ frames, ‘D’ is the deformation applied to the crystal 2 to form an approximate CSL

As you can see, to form a twinning structure we need to deform the structure provided!

Convert the miller indices to be expressed in the primitive cell#

Now we need to specify the orientation of our interface, which is by giving a miller indices in expressed in the primitive cell.

[20]:
"""
The interface plane is the [1,-1,2] plane in the conventional cell and now we \
transform it into primitive cell
"""
hkl = get_primitive_hkl(array([1,-1,2]), my_interface.conv_lattice_1, my_interface.lattice_1)
hkl
[20]:
array([ 1, -1,  1])

Compute the indices of the two slabs to make bicrystal#

Now let’s compute the indices of the two slabs forming the interface If you want a near orthogonal bicrystal, please set ’orthogonal to yes, and adjust the lim & tol.

[21]:
my_interface.compute_bicrystal(hkl, normal_ortho = True, lim = 50, tol_ortho = 1e-2)
cell 1:
[[ 3  0  1]
 [-1 -1  1]
 [ 2 -1  0]]
cell 2:
[[ 3  0 -1]
 [-1  1 -1]
 [ 2  1  0]]

Here we obtained the two sets of indices to build a bicrystal

Make a bicrystal!#

You can adjust the bicrystal by 1. do expansion by set ‘xyz’ = [dimX, dimY, dimZ] 2. do RBT by ‘dzdy’ = a translation vector (please confine dzdy in the interface plane, for RBT in the normal, please use ‘dp1’ and ‘dp2’, to make vacuum in the interface use ‘dx’); 3. introduce vacuum in the interface by ‘dx’ = the distance spacing the two crystals 4. adjust the termination by ‘dp1’, ‘dp2’ = length of shift of the position of the termination from the interface into the bulk 5. introduce vacuum to make a surface in the end of the bicrystal by ‘vx’ = length of the vaccumn

default: xyz = [1,1,1] and others = 0

[7]:
my_interface.get_bicrystal(xyz_1 = [1,1,1], xyz_2 = [1,1,1])

Good! You have made a ‘POSCAR’ file of this bicrystal, we also generated two files named ‘cell_1.cif’ and ‘cell_2.cif’ providing the structure of the two slabs.

[8]:
#To sample the CNID, try
my_interface.sample_CNID(grid = [20,20], xyz_1 = [1,1,1], xyz_2 = [1,1,1])
CNID
[[ 0. -1.]
 [-1. -1.]
 [-1.  0.]]
making 400 files...
completed

Please check the generated ‘POSCAR.x.y’ files. The CNID here is expressed in the primitive cell’s frame. You can refer to the cartesian coordinates or in the conventional cell’s frame

[9]:
CNID_cartesian = round(my_interface.CNID,8)
CNID_cartesian
[9]:
array([[ 2.8905, -5.781 ],
       [-2.8905, -5.781 ],
       [-5.8211, -0.    ]])
[10]:
CNID_conv = round(dot(inv(my_interface.conv_lattice_1)\
                              , my_interface.CNID),8)
CNID_conv
[10]:
array([[ 0.5, -1. ],
       [-0.5, -1. ],
       [-0.5,  0. ]])