T-matrix for Electromagnetic Radiation with Multiple Scatterers — a set of Fortran modules/routines and Python scripts for T-matrix-based calculations and analysis of light scattering by clusters of individual scatterers. The source code can be either (i) compiled as a standalone Fortran program, driven by keywords via an input file; or (ii) built as a Python library (dubbed PyTERMS) using F2Py.

Electromagnetic field (i.e. light) is expanded in the basis of vector spherical waves (VSWs), with the Bessel/Hankel functions computed using TOMS644 library (source included in TERMS). Determining the collective scattering amounts to either solving or inverting a large linear system, which is done using LAPACK. All the relevant LAPACK routines are included in TERMS, but it is recommended to link with your system installed BLAS/LAPACK at compilation stage, because it can enable multi-threading during runtime.

Features

  • Several solution schemes to compute the collective T-matrix and/or the scattered field coefficients for a given set of individual T-matrices, scatterer geometry, and incident field.
  • Built-in calculation of individual T-matrices for spherically symmetric, multi-layered scatterers using Mie theory.
  • Capability to import a more general individual T-matrix, e.g. for a spheroid, calculated using SMARTIES.
  • Evaluation of VSW expansions, and transformation of VSW coefficients under rotation or translation of the local coordinate system.
  • Calculation of far-field properties like optical cross-sections and activities.
  • Mapping of the scattered and incident fields outside each scatterer’s circumscribing sphere. The internal field can be mapped only for spherical scatterers described by Mie theory.

System requirements

  • Fortran 90 compiler.
  • Python environment with NumPy, Matplotlib, and F2Py (for PyTERMS).

Compilation

The src/ directory contains all the Fortran source code, which can be compiled from inside the ‘build’ directory by executing bash buildTERMS.sh from a Linux terminal with bash. Edit ‘buildTERMS.sh’ to specify a compiler other than GFortran. Cross platform compilation tools, such as cmake, will most likely be utilised later.

Utilities and examples

Some LaTeX-ed notes are in the doc/ directory, preliminary PyTERMS scripts are in pyterms/, and a selection of useful (Python) post-processing tools are in scripts/. Similarly, R scripts are packaged under R/, and can be loaded with library(terms) after installing this package locally.

Full-length studies (currently in progress) are in the studies/ directory; for simpler examples of use the vignettes/ directory contains more minimal illustrations of the different features of the program, as well as timing and convergence tests.

The docs/ directory is auto-generated by a script, and serves the published website accessible at http://nano-optics.ac.nz/terms.

The input file

When running the stand-alone executable, main input parameters are read from a plain text input file (line by line and from left to right). Each line is interpreted as a sentence and split into space-separated words. The first (left-most) word is interpreted as a keyword, and the subsequent words as arguments for that keyword. In each sentence, text from the first word starting with the hash character (#) is interpreted as a human-readable comment and thus ignored by the program. All the supported keywords and corresponding arguments are documented on this page. The order of keywords generally doesn’t matter, with just two exceptions: ModeAndScheme must be the first keyword, and Scatterers must be the last.