A Python library for computing the scattering properties of homogeneous nonspherical scatterers with the T-Matrix method.
Uses the T-Matrix code by M. I. Mishchenko and L. D. Travis.
This is repository adapted the original PyTMatrix code by Jussi Leinonen, which can be found here, to run with newer versions of python:
installation of the original code was buggy for python>3.6
, fully deprecated for python>3.12
and numpy>2
.
The code adaptations include:
- Migration from distutils to setuptools (setup.py rewritten)
- Migration of certain scipy functions to new names
- Optimization and vectorization of some computations
The installation instructions in the original pytmatrix library are outdated and do not work for recent python versions (python>3.6
).
The instructions below describe how to install the LTE-maintained fork of pyTMatrix, which is compatible with modern Python interpreters.
WARNING: Installing pyTMatrix directly via pip install git+https://github.com/ltelab/pytmatrix-lte.git
does not work at this time. We welcome contributions to enable this type of installation !
Make sure you have the GNU Fortran Compiler (gfortran
) and the Meson build system installed. You can install them via conda:
conda install -c conda-forge gfortran meson
Fork and clone the LTE-maintained pyTMatrix repository:
git clone https://github.com/<your-account>/pytmatrix-lte.git
Navigate into the cloned repository and install the package in editable mode:
cd pytmatrix-lte
pip install -e .
To confirm that everything was installed correctly, run the built-in test suite:
from pytmatrix.test import test_tmatrix
test_tmatrix.run_tests()
The software should now be installed and ready to use.
See the usage instructions in the original wiki.