Inputs not yet validated. Runtimes are estimates. The README describes what to check in the outputs.
What you will learn
- How to substitute atoms at random with set type/fraction
- How to use a bond-order potential (pair_style bop)
- How composition shifts ultimate tensile strength
Set up
Set up LAMMPS. Download the potential files below and keep them next to the input.
python -m pip install numpy matplotlibFiles for this tutorial:
in.cdte.lmp— Nanowire tension input (x = 0 and 0.5)analyze.py— Stress–strain + UTSREADME.md— Potential and notes
How it works
Get the potential
The Cd–Te–Se BOP table from the LAMMPS potentials folder (see README).
Build two wires
Zinc-blende CdTe, then a copy with half the Te replaced by Se at random.
Stretch and compare
Same strain rate and temperature for both; the script reports each UTS.
Run it
lmp -in in.cdte.lmp -var x 0 -var out tension_x0.txt
lmp -in in.cdte.lmp -var x 0.5 -var out tension_x05.txt
python analyze.pyHow this differs from the paper
The paper swept Se content, compared zinc-blende and wurtzite wires in several orientations, and analyzed failure planes. It found strength and stiffness rising linearly with Se content. This tutorial runs two compositions in one orientation.
Full source
in.cdte.lmp (39 lines)
units metal
atom_style atomic
boundary f f p
variable T index 300
variable rate index 0.01
variable seed index 87287
timestep 0.001
variable x index 0.5
variable out index tension_x05.txt
lattice custom 6.482 a1 1 0 0 a2 0 1 0 a3 0 0 1 &
basis 0 0 0 basis 0 0.5 0.5 basis 0.5 0 0.5 basis 0.5 0.5 0 &
basis 0.25 0.25 0.25 basis 0.25 0.75 0.75 basis 0.75 0.25 0.75 basis 0.75 0.75 0.25
region box block -24 24 -24 24 -25.928 25.928 units box
create_box 3 box
region wire cylinder z 0 0 21 -25.928 25.928 units box
create_atoms 1 region wire basis 5 2 basis 6 2 basis 7 2 basis 8 2
mass 1 112.414
mass 2 127.60
mass 3 78.971
# Substitute on the Te sublattice only.
set type 2 type/fraction 3 ${x} ${seed}
pair_style bop
pair_coeff * * CdTeSe.bop.table Cd Te Se
comm_modify cutoff 15.0
neighbor 2 bin
minimize 1e-7 1e-7 200 2000
velocity all create ${T} ${seed} mom yes rot yes dist gaussian
fix thermostat all nvt temp ${T} ${T} 0.1
thermo 500
run 2000
# Freeze initial length and normalize global virial by the initial material volume.
variable L0 equal $(lz)
variable A0 equal 1385.44236
variable strain equal (lz-v_L0)/v_L0
variable stress equal -pzz*vol/(v_A0*v_L0)*0.0001
fix deform all deform 1 z erate ${rate} units box remap x
fix output all print 100 "${strain} ${stress}" file ${out} screen no title "# strain stress_GPa"
run 15000
analyze.py (36 lines)
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
CASES = [('tension_x0.txt','x = 0'),('tension_x05.txt','x = 0.5')]
fig, ax = plt.subplots()
found = 0
for filename, label in CASES:
path = Path(filename)
if not path.exists():
print(f"Missing output: {path}. Run the matching LAMMPS command first.")
continue
try:
data = np.loadtxt(path, comments="#", ndmin=2)
if data.shape[1] < 2 or data.shape[0] == 0:
print(f"{path}: expected strain and stress_GPa columns; skipping.")
continue
data = data[np.isfinite(data[:, :2]).all(axis=1)]
if not len(data):
print(f"{path}: no finite data rows; skipping.")
continue
except (ValueError, OSError) as exc:
print(f"Cannot read {path}: {exc}")
continue
strain, stress = data[:, 0], data[:, 1]
ax.plot(strain, stress, label=label); print(f"{label}: UTS = {stress.max():.4g} GPa")
found += 1
if found:
ax.set(xlabel="Engineering strain", ylabel="Engineering stress (GPa)")
ax.legend()
fig.tight_layout()
fig.savefig("stress_strain.png", dpi=200)
print("Saved stress_strain.png")
else:
print("No usable data; no figure written.")