Github repository for this toolbox
Multipolar Optical Forces Toolbox is a Python code that allows to calculate the optical forces, torques and electromagnetic fields of optical systems formed by focused Laguerre-Gaussian beams (linearly or circularly polarized) impinging on spherical particles.
By employing the multipolar expansion of the incident beam, the Mie scattering solution, and the integration of the Maxwell stress tensor, MOFT calculates the exact solution of the optical forces and torques up to a cutoff multipolar order (currently set to 30). The multipolar decomposition of the incident field used in this toolbox provides a unique solution for highly focused beams fulfilling Maxwell’s equations.
In addition to a set of modules that estimate various parameters of interest—such as the multipolar expansion of highly focused and displaced beams, Mie coefficients, and analytical expressions for optical forces and torques—this toolbox also includes the ready-to-use program OT_EQUILIBRIUM_POINT_ANALYSIS.py. This program, given a particle and a trapping beam, calculates the equilibrium position and all associated dynamical parameters for both on- and off-axis trapping conditions. Additionally, it calculates the multipolar expansion of the beam displaced at the equilibrium point of the trap and plots the electromagnetic fields.
This toolbox requires the following packages: numpy, matplotlib, scipy, tqdm and sympy.
Python must already be installed.
Installation of the Python environment:
git clone https://github.com/QNanoLab/MOFT.git
cd MOFT
pipenv install
pipenv install .
pipenv shell
Once the installation is done, you will be able to run the program OT_EQUILIBRIUM_POINT_ANALYSIS.py on this environment. You can edit the parameters of the spherical particle and the focused LG beam for this calculation.
For running in the command line:
python OT_EQUILIBRIUM_POINT_ANALYSIS.py --plot-forces --plot-fields
Note: Interaction with the plotted figures may not be available until the program completes all the calculations. Close every figure window to finish the program.
The default simulation parameters show the following figures:

For the moment, this toolbox is designed to be used only on Linux OS.
LGTools module that containing special functions based on multipolar decomposition of electromagnetic fields and Mie scattering theory, applied to Laguerre-Gaussian beams in the following submodules:
coefficients calculate the Beam Shape Coefficients for on- and off-focus Laguerre-Gaussian beams, as well as the Mie coefficients for spherical particles.forces analytically calculate the optical forces in the x, y, and z directions for optical systems with on- and off-axis configurations.torques analytically calculate the optical torques in the x, y, and z directions for optical systems with on- and off-axis configurations.vsh generate the Vector Spherical Harmonics (vsh) and the near- and far-field versions of the Well-defined Helicity Multipoles.beam, coordinates_converter, equilibrium_point_finders, multipolar_fields_forces_plots, and summation_of_multipoles.TRANSLATION_MATRICES contains precalculated displacement matrices to improve the speed of the multipole expansion for displaced beams. These matrices, which were precalculated for different displacements, can be iteratively combined and applied to the on-focus Beam Shape Coefficients to generate displaced beams.
OT_EQUILIBRIUM_POINT_ANALYSIS.py calculates the optical forces and torques at the equilibrium point of the optical trap.OT_EQUILIBRIUM_POINT_ANALYSIS.pyFor this purpose, the main program “OT_EQUILIBRIUM_POINT_ANALYSIS.py” must be run, where the following steps are taken:
Set show_force_plots and show_field_plots to True or False to control the display of plots.
Alternatively, if command line is used, these variables can be controlled by --plot-forces and --plot-fields.
WARNING!, show_field_plots = True uses a lot of memory. Adjust the value of the variable resolution to reduce the memory employed.
WARNING!, variable ncores (number of cores employed in the paralelization process) must be adjusted to computer’s resources.
This toolbox has been used to calculate the results discussed in an article that is currently in publication process. Soon this message is going to be updated with the DOI of the article.