Copyright (c) 2026 Y. del Castillo. All rights reserved.
For sensor-on-tip geometry and 3D positioning workflows under active development, see: esr-tip-haldane-magnetometry.
This repository implements the two-stage machine-learning method used as computational support for:
Y. del Castillo and J. Fernandez-Rossier, Probing spin fractionalization with electron spin resonance based on scanning tunneling microscopy, Phys. Rev. B 110, 045145 (2024). DOI: 10.1103/PhysRevB.110.045145.
Implementation updated to work with latest versions of the libraries.
The target is to identify spin-fractionalization signatures under lateral ESR sensing and quantify reconstruction precision with sparse magnetic measurements. The method reduces the number of required measurements compared with direct inversion, where one independent measurement is typically required per unknown spin variable.
The physical model in this folder follows the original in-plane setup used in the paper:
- chain and sensors are defined in the same plane (
z = 0), - sensing is lateral relative to the chain,
- coupling is treated with the scalar
1/r^3kernel used in the original method.
- Stage A (classification): discriminate Haldane-like profiles from non-Haldane magnetic patterns.
- Stage B (regression): reconstruct the spin profile
<S_i^z>from sparse sensor readout.
A second notebook is provided for in-plane training and inference with experimental inputs.
It is prepared to be used directly with measured data by replacing the CSV files in
dummy_experimental_data/:
spin_positions.csvsensor_locations.csvmeasurements.csvsample_truth.csv(optional, for benchmark checks)
Workflow:
- read spin and sensor coordinates from CSV (planar:
z=0), - adapt 100-spin reference profiles to the experimental chain length (
N >= 50) by removing central spins, - generate training data with interpolated beta values and declared experimental resolution,
- train the two-stage model with that geometry,
- infer Haldane probability, reconstructed profile,
M_total,M_left,M_right, and estimated beta from measured shifts.
TwoNN_pipeline.ipynb: idealized in-plane chains and synthetic sparse readout to validate the method concept in controlled conditions.Experimental_Measurement_Workflow.ipynb: experimental-ready in-plane workflow using user-provided geometry and measured shifts.src/twonn_pipeline.py: data validation, synthetic dataset generation, training, and evaluation.src/experimental_workflow.py: CSV loaders and in-plane inference utilities.data/spin_profiles.csv: reference spin profiles.data/DATA_SCHEMA.md: schema for reference profiles.dummy_experimental_data/: template CSV files for planar geometry and measured shifts.requirements.txt: Python dependencies.
Reference profiles (data/spin_profiles.csv):
- required column:
beta - spin columns:
spin_0, spin_1, ..., spin_N(contiguous, starting fromspin_0) - beta rows and chain length are inferred from the CSV
Experimental measurements (dummy_experimental_data/measurements.csv), recommended format:
sensor_loc, measured_shift_mhz- sensor indexing can be
1..Nsor0..Ns-1
From repository root:
python -m pip install -r requirements.txt jupyter notebook TwoNN_pipeline.ipynb
Experimental workflow:
jupyter notebook Experimental_Measurement_Workflow.ipynb
If you use this implementation or build directly on the method, please cite the original article:
@article{PhysRevB.110.045145, title = {Probing spin fractionalization with electron spin resonance based on scanning tunneling microscopy}, author = {del Castillo, Y. and Fern\'andez-Rossier, J.}, journal = {Phys. Rev. B}, volume = {110}, issue = {4}, pages = {045145}, numpages = {6}, year = {2024}, month = {Jul}, publisher = {American Physical Society}, doi = {10.1103/PhysRevB.110.045145}, url = {https://link.aps.org/doi/10.1103/PhysRevB.110.045145} }