Skip to content

About

Measured reward for beam-driven crystallization in STEM.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reward_function

A measured reward for electron-beam-driven crystallization in the STEM, and an ALIGNN-FF knock-on simulation (a "twin") of the amorphous/crystalline Si interface that such a reward would be used to test.

The motivating question: how should an autonomous microscope be scored when it tries to crystallize a chosen region of an amorphous film with the beam, and can a machine-learned force field such as ALIGNN-FF predict whether a dosed region will crystallize?

Research code; the results below are preliminary and are stated with their limits.

Principle

The reward is computed only from what the microscope measures: a before frame, an after frame, the dosed window T, and the dose. A simulator proposes actions and is scored separately against the measured outcomes. It never enters the reward, so an agent cannot raise its score by exploiting the simulator.

$$ R=\frac{\Delta F_{\mathrm{coh}}-\lambda,A_{\mathrm{off}}/|T|-\mu,A_{\mathrm{lost}}/|T|}{\Phi}, \qquad F_{\mathrm{coh}}=\big\langle \mathbf{1}[\kappa>\kappa_0],e^{-(\theta/\theta_0)^2}\big\rangle_T $$

  • κ: orientation-free crystallinity (the lattice amplitude of the parent {111} g-vector pair, rotated through 180° with the maximum kept). Parent-referenced GPA alone reads a misoriented grain as amorphous.
  • θ: misorientation from the parent (GPA rotation below 5°, the orientation bank above).
  • ΔFcoh: after minus before, so crystal already present in T earns nothing.
  • Aoff: new crystal outside T and outside the corridor that epitaxial growth must cross; Alost: parent crystal that became amorphous; Φ: dose.
  • Frames are registered on band-passed amorphous speckle away from the dosed area, with its two halves registered independently as a check. Crystal is unusable for registration: at fine scale it matches at every lattice translation.

Layout

Path What it is
image.png The before/after Si regrowth figure used as the one real data point
reward/ The reward (reward.py), the real pair (run_si.py), planted controls (controls.py), and the distance-only baseline with its nested test (baseline.py)
reward/out/ Outputs of reward/run_all.sh
reward/twin/ ALIGNN-FF validation and the interface twin (Slurm workflow)
reward/twin/results/ Every result JSON from the runs reported below, plus the built interface
report/ Image analysis of image.png (grain_boundary_report.pdf) and the scripts that reproduce it

Running

Image analysis and reward (numpy, scipy, pillow, matplotlib, opencv-python; tested with numpy 2.2.6, scipy 1.16.3, pillow 12.0.0, matplotlib 3.10.1, opencv 4.12.0):

bash reward/run_all.sh image.png reward_out/      # reward, controls, baseline (~10 min)
bash report/scripts/run_all.sh image.png report_work/   # the report's analysis

The twin needs ALIGNN ≥ 2026.11.2 (pip install alignn; https://github.com/atomgptlab/alignn), whose pure-PyTorch force-field model code is identical to what the runs below used and whose registry lists the same four checkpoints that fetch_models.sh downloads, plus ASE ≥ 3.26. It runs on a CPU for smoke tests (--small) and on GPUs through Slurm. validate.sbatch expects a work folder holding code/ (the contents of reward/twin/), models/, and an ALIGNN source copy in alignn_src/ (or set ALIGNN_SRC); set PY to the Python of an environment with ALIGNN.

bash code/fetch_models.sh models          # four checkpoints, MD5-verified
bash code/make_tasks.sh                   # Stage A (quick checks) and B (thresholds, a-Si)
sbatch --array=1-5 --export=ALL,TASKS=tasks_A.txt code/validate.sbatch
sbatch --array=1-20%4 --export=ALL,TASKS=tasks_B.txt code/validate.sbatch
bash code/make_tasks_C.sh alignn_ff_omat24_1m   # Stage C: build the interface, recoil grid
sbatch --array=1 --export=ALL,TASKS=tasks_C1.txt code/validate.sbatch
sbatch --array=1-28%4 --export=ALL,TASKS=tasks_C2.txt code/validate.sbatch
python code/summarize.py results
python code/predict_rate.py results alignn_ff_omat24_1m     # front advance vs. voltage
python code/plot_twin.py results alignn_ff_omat24_1m twin.png

python code/predict_rate.py selftest checks the knock-on cross-section, the integration, the error propagation, and the pooling rules.

Results so far

The one real pair. The growth front stops 0.26 nm short of the 0.74 nm window, so ΔFcoh = 0; 89% of the new crystal lies in the window or the corridor. Planted controls show that a 0.74 nm window is below what the measurement can resolve: windows need about 2 nm or more in the growth direction.

Scoring a twin. Compared directly with a distance-only baseline, a twin that knows only the distance curve "wins" in up to 30% of simulated 10-window campaigns. The nested test (the twin's logit, residualized on distance, must improve the held-out Brier score by ≥ 0.005 with a paired sign-flip test at p < 0.025) has 0% false positives for distance-only twins and ≤ 1% for noise.

Is ALIGNN-FF fit to be the twin? Of four pure-PyTorch checkpoints (OMat24, MPtrj, MatPES-PBE, MatPES-r²SCAN), all make acceptable a-Si, but only OMat24 passes a displacement-threshold screen (minimum Ed 12.0 eV; the others 5.0–9.5 eV). Against DFT-MD (Holmström et al. 2008), OMat24 matches both ⟨111⟩ thresholds but is about 8 eV too soft along ⟨100⟩. No current checkpoint conserves energy: each has a hard 3.5 Å three-body cutoff, and the energy jumps by 0.17–0.24 eV whenever a pair crosses it.

The interface twin (OMat24, 320 recoils). Interface normal [001], beam along [110] in the interface plane; 1,280 atoms, half melt-quenched onto a fixed crystal template. Each recoil gets energy T at the knock-on angle for 200 kV, runs 1 ps, and is relaxed; the outcome is the net number of atoms that join the parent lattice. All no-kick controls give exactly 0. Net atoms per recoil (mean ± s.e.):

depth from interface 0.5 eV 1 eV 2 eV 4 eV 8 eV 16 eV
−2 Å (crystal) 0 0 0 0 −0.10 ± 0.28 −1.10 ± 0.52
0 Å 0 0 +0.20 ± 0.20 +0.20 ± 0.20 −0.55 ± 0.43 −1.45 ± 0.73
+2 Å (a-Si) 0 0 +0.10 ± 0.10 +0.30 ± 0.52 −0.40 ± 0.22 −0.35 ± 0.26
+4 Å (a-Si) 0 +0.10 ± 0.10 −0.20 ± 0.20 −0.10 ± 0.18 +0.10 ± 0.38 −0.25 ± 0.34

Integrated over the McKinley–Feshbach knock-on cross-section, the predicted front advance per 10⁷ e⁻/Ų is +14 ± 14 nm at 60 kV, +11 ± 12 at 80, +1.3 ± 6.7 at 200, and −0.6 ± 5.6 at 300. No voltage differs from zero. At 0.5–4 eV, which covers 91–98% of knock-on events, only 14 of 160 recoils changed anything, so the low-voltage values rest on a few rare events. Other limits: all 100 recoils checked (8 and 16 eV) end 0.7–4.9 eV higher in energy than they started, from the cutoff jumps; at 16 eV a third of recoils change atoms at the damped cell faces; and 1 ps captures only prompt events, not defect migration or ionization. The natural next steps are to kick every interface site systematically at 0.5–4 eV and to use a force field with a smooth cutoff.

The image itself (report/). No grain boundary is detected: the figure shows a crystalline/amorphous interface and an epitaxial regrown pillar 6.9–7.5 nm long from the original interface, with a real tilt of about 0.5°.

Data

image.png: Si regrowth before/after figure, provided by Professor Choudhary. It has no scale bar; the analysis takes the scale (0.0525 nm/px) from the Si lattice.

References

  • K. Holmström, A. Kuronen, K. Nordlund, Phys. Rev. B 78, 045202 (2008): DFT-MD threshold displacement energies in Si.
  • K. Choudhary et al., Digital Discovery 2, 346 (2023): ALIGNN-FF.
  • W. A. McKinley Jr., H. Feshbach, Phys. Rev. 74, 1759 (1948): knock-on cross-section.
  • J. F. Ziegler, J. P. Biersack, U. Littmark, The Stopping and Range of Ions in Solids (Pergamon, 1985): ZBL screened-Coulomb potential.

License

MIT; see LICENSE. The force-field checkpoints downloaded by fetch_models.sh are not part of this repository and keep their own licenses.

About

Measured reward for beam-driven crystallization in STEM.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages