synth_afm.simulator
The simulator module provides the high-level AFMSimulator class, which coordinates the
height-mapping kernels, scanning lag, noise, and substrate tilt into a single, easy-to-use interface.
AFMSimulator
High-level simulator for generating HS-AFM images and movies.
Source code in synth_afm/simulator.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
Methods:
scan(positions, radii=None, use_tip_dilation=True, key=None)
Generates a height map for the given atomic positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
Array
|
(N, 3) atomic coordinates. |
required |
radii
|
Optional[Array]
|
(N,) atomic radii. If None, uses default 1.7A (Carbon). |
None
|
use_tip_dilation
|
bool
|
If True, uses the realistic tip-dilation kernel. |
True
|
key
|
Optional[Array]
|
PRNG key for noise generation. |
None
|
Source code in synth_afm/simulator.py
scan_movie(trajectory, radii=None, frames_per_second=10.0, trajectory_dt=None, use_tip_dilation=True, key=None)
Generates a movie of HS-AFM images from a coordinate trajectory. Simulates scanning lag by sampling different time-steps for each line. Uses jax.lax.scan for memory-efficient iteration over frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory
|
Array
|
(T, N, 3) atomic coordinates over time. |
required |
radii
|
Optional[Array]
|
(N,) atomic radii. |
None
|
frames_per_second
|
float
|
Nominal scan rate (FPS). |
10.0
|
trajectory_dt
|
Optional[float]
|
Time between trajectory steps (seconds). If None, assumes 1.0 / FPS. |
None
|
use_tip_dilation
|
bool
|
Whether to use the realistic tip model. |
True
|
key
|
Optional[Array]
|
PRNG key for noise generation. |
None
|
Returns:
| Type | Description |
|---|---|
Array
|
(T, H, W) array of height maps. |
Source code in synth_afm/simulator.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
compute_force_map(positions, radii, z_heights, k_cantilever=0.1)
Experimental: Computes a force map (deflection) based on tip-sample repulsion.
This uses a simplified Hookean elastic model where the tip acts as a linear spring. The force is proportional to the compression depth (sample_height - z_heights) multiplied by the cantilever stiffness (k_cantilever). Returns force in arbitrary units (or pN if heights are in nm and k is in N/m, depending on provided constants).