Scanning Probe Microscopy (SPM) simulator based on Python.
It simulates realistic SPM scans based on ground-truth patterns or user-input images. This simulator emulates effects of most of controlling parameters so it can be used as a training tool for new SPM operators.
It also serves as a playground for testing machine learning based automation algorithms as the results can be validated through real SPM experiments.
pip install spmsimuTo get started, please see the examples in the "SpmSimu -- Tutorial 101.ipynb" notebook located in spmsimu/notebooks folder.
In spmsimu package, we offer three ground-truth patterns for SPM scan simulation:
- Checkerboard pattern
- Spiral pattern
- Atomic lattice with cubic structure
- We also allow users to use their custom patterns or real topography maps as ground-truth patterns.
We also provide functions to generate single tip with different size and double tip with different separation, relative height, and sizes of each tip.
checkerboard = generate_pattern(nx=256, ny=256, pattern='checkerboard', num=10, show=True)spiral = generate_pattern(nx=256, ny=256, pattern='spiral', num=10, turns=5, show=True)atomic = generate_pattern(nx=256, ny=256, pattern='atomic', num=10, show=True)
This one is included in the spmsimu/notebooks folder as an example.
tip_ideal = generate_tip_kernel(kernel_size=50, wx=5, wy=5)tip_double = generate_doubletip_kernel(kernel_size=kernel_size, offset=offset,tip1=[wx1, wy1, amp1], tip2=[wx2, wy2, amp2])In the scan() function, there are following parameters can be tuned:
Input:
image - ndarray: ground truth 1D or 2D image profile
kernel - ndarray: tip shape kernel
drive - float: the drive amplitude (free-air amplitude)
setpoint - float: setpoint amplitude (setpoint tip-sample distance in the simulator)
P - float: proportional gain in PID
I - float: integral gain in PID
length - int: the number of pixels in "memory" of PID algorithm
z_speed - float: the extend/retrace speed of the z piezo
scan_speed - float: the xy movement speed of the tip
phase - boolean: if true, a corresponding phase map is generated along with the height map
retrace - boolean: if true, both trace and retrace maps will be generated
Output:
Realistic scan image generated based on ground truth image, tip shape kernel, and scanning parameters.traces = scan(image=checkerboard, kernel=tip_ideal, drive=0.5, setpoint=0.2,
P=1, I=1e-2, z_speed=0.1, scan_speed=1, phase=True, retrace=True)In an ideal scan, the trace and retrace match each other well:
# Here we have decreased the z_speed from 1e-1 to 1e-2:
traces = scan(image=checkerboard, kernel=tip_ideal, drive=0.5, setpoint=0.2,
P=1, I=1e-2, z_speed=1e-2, scan_speed=1, phase=True, retrace=True)When the scan speed is too fast, the PI loop is not fast enough to respond to the fast change of sample height. As a result, we'll observe the parachutting effect:
Here the trace and retrace scans don't agree with each other:
# Here we have decreased the I Gain from 1e-2 to 1:
traces = scan(image=checkerboard, kernel=tip_ideal, drive=0.5, setpoint=0.2,
P=1, I=1, z_speed=1e-1, scan_speed=1, phase=True, retrace=True)











