Inputs not yet validated. Runtimes are estimates. The README describes what to check in the outputs.
What you will learn
- How fix deposit builds a film
- How cooling rate enters a printing simulation
- How to test a deposited film
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.deposition.lmp— Deposition, cooling, tensionanalyze.py— Stress–strain comparisonREADME.md— Notes and link to the original repository
How it works
Deposit
Three batches of 300 atoms land on a small substrate, with the alloy composition assigned at random.
Cool
Two copies cool at 10 and 100 K/ps.
Test
Tension along the periodic in-plane direction; analyze.py overlays both curves.
Run it
lmp -in in.deposition.lmp -var cool 10 -var out tension_10.txt
lmp -in in.deposition.lmp -var cool 100 -var out tension_100.txt
python analyze.pyHow this differs from the paper
The conference study used an embedded-atom method potential in LAMMPS. It pulled a bar cut from the solidified layer along [001]. This smaller example stretches the deposited material in the plane of the substrate.
Full source
in.deposition.lmp (59 lines)
in.deposition.lmp
units metal
atom_style atomic
boundary p p f
variable T index 300
variable rate index 0.01
variable seed index 87287
variable cool index 10
variable out index tension_10.txt
timestep 0.001
lattice fcc 3.52
region box block 0 28.16 0 28.16 0 65 units box
create_box 3 box
region substrate block 0 28.16 0 28.16 0 21.12 units box
create_atoms 1 region substrate
mass 1 58.6934
mass 2 51.9961
mass 3 55.845
pair_style eam/alloy
pair_coeff * * FeNiCr.eam.alloy Ni Cr Fe
neighbor 2 bin
minimize 1e-7 1e-7 200 2000
velocity all create 1000 ${seed} mom yes rot yes dist gaussian
# Add three sequential batches at increasing heights; each batch is a thin source layer.
fix integration all nve
fix bath all langevin 1000 1000 0.1 ${seed}
thermo 1000
thermo_modify lost error
region layer1 block 0 28.16 0 28.16 29 35 units box
region layer2 block 0 28.16 0 28.16 34 40 units box
region layer3 block 0 28.16 0 28.16 39 45 units box
fix dep all deposit 300 1 10 ${seed} region layer1 near 2.2 attempt 50 vz -1.0 -0.5 units box
run 3000
unfix dep
fix dep all deposit 300 1 10 ${seed} region layer2 near 2.2 attempt 50 vz -1.0 -0.5 units box
run 3000
unfix dep
fix dep all deposit 300 1 10 ${seed} region layer3 near 2.2 attempt 50 vz -1.0 -0.5 units box
run 3000
unfix dep
unfix bath
# Randomize the final deposit and substrate to the intended alloy fractions.
set type 1 type/fraction 2 0.21 ${seed}
variable seed2 equal v_seed+17
set type 1 type/fraction 3 0.2405063291 ${seed2}
fix bath all langevin 1000 ${T} 0.1 ${seed}
variable nquench equal ceil((1000-v_T)/(v_cool*0.001))
run ${nquench}
unfix bath
fix bath all langevin ${T} ${T} 0.1 ${seed}
run 2000
# Periodic x loading; pxx includes the vacuum, so normalize by a defined initial slab height.
variable L0 equal $(lx)
variable V0 equal $(lx*ly*30.0)
variable strain equal (lx-v_L0)/v_L0
variable stress equal -pxx*vol/v_V0*0.0001
fix deform all deform 1 x erate ${rate} remap x units box
fix output all print 100 "${strain} ${stress}" file ${out} screen no title "# strain stress_GPa"
run 15000
analyze.py (36 lines)
analyze.py
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
CASES = [('tension_10.txt','10 K/ps'),('tension_100.txt','100 K/ps')]
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)
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.")