Calculate GSFE

This script will use mdapy to calculate the generalized stacking fault energy directly

[1]:
import mdapy as mp
import polars as pl
from tqdm import tqdm
import numpy as np
import matplotlib.pyplot as plt
from mdapy import set_figure
mp.init()
[Taichi] version 1.7.0, llvm 15.0.1, commit 2fd24490, win, python 3.8.0
[Taichi] Starting on arch=x64
[2]:
mp.__version__
[2]:
'0.10.5'

Generate a FCC lattice with orientation x[11-2], y[1-10] and z[111]

[3]:
lattice_constant = 4.05
lattice_type = 'FCC'
[4]:
fcc = mp.LatticeMaker(lattice_constant, lattice_type, 10, 15, 10, crystalline_orientation=np.array([[1, 1, -2], [1, -1, 0], [1, 1, 1]]))
fcc.compute()
[5]:
system = mp.System(pos=fcc.pos, box=fcc.box)

Change boundary condition to free along z axis

[6]:
system.boundary[-1] = 0

Calculate the initial potential energy

[7]:
system.cal_energy_force('../../../example/Al_DFT.eam.alloy', ['Al'], max_neigh=150)
[8]:
pe0 = system.data['pe'].sum()
[9]:
move = (lattice_constant/6**0.5+0.2)/50
factor = system.box[0,0]* system.box[1,1]/16021.766200000002

Calculate the GSFE along [112] direction

[10]:
sfe = [0.]
for i in tqdm(range(1, 51)):
    newdata = system.data.with_columns(pl.when(pl.col('z')>35).then(pl.col('x')+move).otherwise(pl.col('x')).alias('x'))
    system.update_data(newdata,update_pos=True) # Move the upper part.
    system.wrap_pos() # Wrap the positions
    system.if_neigh = False # Make sure rebuild neighbor every time
    system.cal_energy_force('../../../example/Al_DFT.eam.alloy', ['Al'], max_neigh=150)
    sfe.append((system.data['pe'].sum()-pe0)/factor)
100%|██████████| 50/50 [00:03<00:00, 13.99it/s]

Plot the results

[11]:
fig, ax = set_figure(figsize=(10, 7), use_pltset=True)

plt.plot(np.arange(51)*move/(lattice_constant/6**0.5), sfe, 'o-')
plt.xlabel("Displacement along $<112>$ " + "$\mathregular{(a_0/\sqrt{6})}$")
plt.ylabel("SFE ($\mathregular{mJ/{m^2}}$)")
plt.text(0.47, 100, 'USF')
plt.text(0.97, 25, 'ISF')
[11]:
Text(0.97, 25, 'ISF')
../_images/gettingstarted_calculate_GSFE_17_1.png