Interactive 2D visualization of an optical tweezer for a transparent dielectric particle.
The project combines two complementary views of the same optical-tweezer system:
- geometric ray tracing through a circular particle, used to show how rays bend at the particle boundary;
- a normalized Rayleigh-style force model, used to display the gradient force, radiation-pressure force, and their vector sum.
The goal is educational rather than metrological: the application is designed to show the direction, balance, and qualitative scaling of the main optical forces in a focused-beam tweezer.
- Interactive Matplotlib GUI with sliders for particle position, beam width, particle radius, refractive indices, lens position, lens width, and focal distance.
- Optional Gaussian beam profile.
- Optional focusing lens.
- Ray tracing through a circular dielectric particle using Snell's law.
- Total internal reflection markers.
- Separate force arrows for:
- gradient force,
F_grad; - radiation-pressure force, displayed as
F_рас; - total force,
F_Σ.
- gradient force,
- Numeric force readout in normalized units.
Requirements:
- Python 3.10 or newer;
- NumPy;
- Matplotlib.
Install dependencies:
pip install numpy matplotlibRun the demo:
python optical_tweezer_demo.py.
├── optical_tweezer_demo.py # Entry point and compatibility exports
└── optical_tweezer
├── __init__.py
├── app.py # Matplotlib UI and scene rendering
├── config.py # Simulation and visualization constants
├── geometry.py # Vector geometry, reflection, refraction
├── optics.py # Ray tracing through the particle
└── physics.py # Rayleigh-style force model
An optical tweezer confines microscopic particles with a strongly focused laser beam. Light carries momentum. When a particle refracts, reflects, scatters, or absorbs light, the momentum of the electromagnetic field changes; the particle receives the opposite momentum change.
The modern single-beam optical tweezer was developed from the radiation-pressure experiments of Arthur Ashkin. The central idea is that a tightly focused beam can create a restoring force near the focus. For a dielectric particle with refractive index higher than that of the surrounding medium, the particle is pulled toward the region of higher optical intensity.
Optical tweezers are used for:
- manipulation of dielectric microspheres;
- single-cell and organelle manipulation;
- force spectroscopy in biophysics;
- DNA, RNA, and protein mechanics;
- colloidal physics;
- calibration of microscopic forces in the pico-newton range.
The gradient force appears because a polarizable particle in a non-uniform optical field is pulled toward higher intensity. For a dielectric particle with n_particle > n_medium, this force points approximately toward the beam focus or the beam axis.
In the Rayleigh limit, where the particle radius is much smaller than the wavelength, the induced dipole approximation gives:
F_grad ∝ alpha * grad(|E|^2)
Since optical intensity is proportional to the squared electric-field amplitude,
I ∝ |E|^2
the model can be written qualitatively as:
F_grad ∝ alpha * grad(I)
For a small dielectric sphere, the polarizability scales as:
alpha ∝ R^3 * (m^2 - 1) / (m^2 + 2)
m = n_particle / n_medium
The implementation therefore uses the normalized form:
F_grad = C_grad * n_medium * R^3 * K * grad(I)
K = (m^2 - 1) / (m^2 + 2)
where C_grad is a visualization gain.
The radiation-pressure force is the forward push from the optical momentum flux. In a simple picture, photons carry momentum along the direction of beam propagation. Scattering and momentum transfer produce a force in that direction.
In the Rayleigh regime, the scattering contribution scales strongly with particle size and refractive-index contrast:
F_rad ∝ I * sigma_scat * k_hat
sigma_scat ∝ R^6 * K^2
K = (m^2 - 1) / (m^2 + 2)
The implementation uses:
F_rad = C_rad * n_medium * R^6 * K^2 * I * k_hat
where:
C_radis a visualization gain;Iis the local normalized intensity;k_hatis the local propagation direction, currently downward in the plotted coordinate system.
In the UI this component is displayed as F_рас.
The displayed total force is:
F_total = F_grad + F_rad
This is the green F_Σ arrow in the visualization.
The horizontal component mainly comes from the transverse intensity gradient. If the particle is shifted sideways from the beam axis, the intensity is different across the particle. For n_particle > n_medium, the gradient force tends to pull the particle back toward the optical axis.
The vertical component is the competition between:
- axial gradient force, which can pull the particle toward the focus;
- radiation pressure, which pushes the particle along the beam propagation direction.
In a stable single-beam tweezer, the beam must be focused strongly enough for the axial gradient force to overcome radiation pressure near the focus. This is why optical tweezers typically use high numerical-aperture objectives.
In real experiments, vertical force balance may also include gravity and buoyancy:
F_g,eff = (rho_particle - rho_medium) * V * g
Those terms are not included in the current code.
Without the lens, the code supports two transverse profiles:
Uniform beam: I = 1
Gaussian beam: I(x) = exp(-2x^2 / d^2)
For the focused mode, the code uses a simplified Gaussian-focus model around the focal point. The waist is estimated from an effective numerical aperture:
NA_eff = aperture / sqrt(aperture^2 + focal_distance^2)
and the beam waist is estimated as:
w0 ≈ wavelength / (pi * NA_eff)
The local intensity is then approximated by the paraxial Gaussian-beam form:
I(x, z) = 1 / q * exp(-2x^2 / (w0^2 q))
q = 1 + (z / z_R)^2
z_R = pi * w0^2 / wavelength
The gradient force is computed from the spatial gradient of this normalized intensity.
The ray-tracing part of the application is independent from the force formula. It is used to visualize how rays bend through the particle.
The particle is represented as a 2D circle. Each ray:
- intersects the circle boundary;
- refracts into the particle using Snell's law;
- propagates inside the particle;
- refracts back into the medium;
- reflects internally if total internal reflection occurs.
The vector form of Snell's law is implemented in optical_tweezer/geometry.py. Total internal reflection is detected when the transmitted direction is not physically real.
This is a compact educational model. It intentionally omits several effects needed for quantitative optical-tweezer simulation:
- no full Maxwell-equation solution;
- no Mie scattering;
- no Fresnel reflection/transmission coefficients in the force model;
- no absorption or heating;
- no Brownian motion;
- no viscous drag;
- no gravity or buoyancy in the displayed force;
- no hydrodynamic wall corrections;
- no calibration to SI units;
- 2D geometry instead of a full 3D optical field.
The force values are normalized. They should be interpreted as relative visualization values, not pico-newton predictions.
x0: horizontal particle displacement.d: beam half-width parameter.R: particle radius.n_ч: particle refractive index.n_ср: surrounding medium refractive index.L до линзы: distance from particle plane to lens.w линзы: lens half-width.f фокус: focal distance.
The checkboxes enable:
- Gaussian intensity profile;
- focusing lens.
The gradient force does not scale with the raw difference n_particle - n_medium. In this model it scales with:
n_medium * (m^2 - 1) / (m^2 + 2)
m = n_particle / n_medium
The radiation-pressure force scales with the square of the contrast factor:
n_medium * ((m^2 - 1) / (m^2 + 2))^2
Therefore radiation pressure can grow faster than the gradient component as refractive-index contrast increases.