Skip to content
RichardLiuCodingPublic

About

Scanning Probe Microscopy Simulator based on Python

Resources

Stars

9 stars

Watchers

2 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spmsimu -- Simulator of Scanning Probe Microscopy

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.

1. Installation

1-1. Quick installation

pip install spmsimu

To get started, please see the examples in the "SpmSimu -- Tutorial 101.ipynb" notebook located in spmsimu/notebooks folder.

2. Generate ground-truth patterns and tip shapes

In spmsimu package, we offer three ground-truth patterns for SPM scan simulation:

  1. Checkerboard pattern
  2. Spiral pattern
  3. Atomic lattice with cubic structure
  4. 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 pattern

checkerboard = generate_pattern(nx=256, ny=256, pattern='checkerboard', num=10, show=True)

image

Spiral pattern

spiral = generate_pattern(nx=256, ny=256, pattern='spiral', num=10, turns=5, show=True)

image

Atomic lattice

atomic = generate_pattern(nx=256, ny=256, pattern='atomic', num=10, show=True)

image

Real topography maps

image This one is included in the spmsimu/notebooks folder as an example.

Ideal tip shape -- single sharp tip

tip_ideal = generate_tip_kernel(kernel_size=50, wx=5, wy=5)

image

Double tip

tip_double = generate_doubletip_kernel(kernel_size=kernel_size, offset=offset,tip1=[wx1, wy1, amp1], tip2=[wx2, wy2, amp2])

image

Simulate realistic scans

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.

Scan with ideal 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)

image

In an ideal scan, the trace and retrace match each other well:

image

Scan with too slow z-speed or too fast scan speed -- parachutting effect

# 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:

image

Here the trace and retrace scans don't agree with each other:

image

Scan with too large I Gain -- unstable/oscillatory PI loop

# 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)

image

image

Other uses of the package

Double tip effect

image

Tip change event

image

About

Scanning Probe Microscopy Simulator based on Python

Resources

Stars

9 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages