A cantilever tip (radius R = 20 nm) is raster-scanned across a real 2D sample topography built from several Gaussian bumps plus a patch of elevated Hamaker constant (a stickier "material"). The same van der Waals + DMT elastic-contact force law and damped cantilever equation used in the flagship 3D AFM sim govern the dynamics here — m·z̈ = −k(z − zcmd) − c·ż + F(gap, A) — but now the sample height s(x,y) and stickiness A(x,y) vary with scan position instead of being fixed.
In Constant-Force mode a PI feedback loop continuously adjusts the piezo command zcmd to hold the measured tip–sample force at the setpoint Fset:
error = F(gap,A) − F_set
z_cmd += (Kp·error + Ki·∫error dt) · dt
Because the force law is monotonic in this repulsive DMT contact regime, holding force constant forces the gap to a near-constant equilibrium value — so the recorded zcmd trace is the topography, up to a fixed offset. That is exactly how a real constant-force (contact-mode) AFM builds an image: it never "measures height" directly, it measures the piezo command needed to keep pressing with the same force everywhere.
Switch to Constant-Height mode and the feedback loop is disabled — zcmd stays fixed and the image is built from the raw tip deflection instead. Because deflection is a nonlinear function of gap and depends on the local Hamaker constant A, the reconstruction is distorted, especially over the stickier patch — a real artifact of open-loop AFM imaging, visible by comparing the "Reconstructed" channel against "Ground Truth" once a scan finishes.
Note on timescale: a full raster scan is compressed roughly 20× so it completes in well under a minute — the force law, cantilever ODE and PI feedback above are exact and unscaled; only wall-clock playback speed is accelerated, the same way the 3D sim slows its dynamics down for visibility.
Fixed vs. the 3D sim: the 3D engine's DMT contact term used a common distance floor for both branches, which silently freezes the elastic push-back at a fixed value however deep the tip indents. Here the contact branch uses the true (possibly negative/overlapping) gap, so contact stiffness grows correctly with indentation — required for the feedback loop below to have a stable equilibrium at all.