Warning This repository is a work in progress. The API will change without notice
TDMS, the Time Domain Maxwell Solver, is a hybrid C++ and MATLAB tool for solving Maxwell's equations to simulate light propagation through a medium. See the pdf documentation for further details.
TDMS needs to be built against FFTW and MATLAB, thus both need to be downloaded and installed prior to compiling TDMS. Install with
$ cd tdms
$ mkdir build; cd build
$ cmake .. \
# -DMatlab_ROOT_DIR=/usr/local/MATLAB/R2019b/ \
# -DFFTW_ROOT=/usr/local/fftw3/ \
# -DCMAKE_INSTALL_PREFIX=$HOME/.local/ \
# -DBUILD_TESTING=ON
$ make installwhere lines need to be commented in and the paths modified if cmake cannot (1) find MATLAB, (2) find FFTW or (3) install to the default install prefix.
Mac specific instructions
To compile on a Mac an x86 compiler with libraries for OpenMP are required,
which can be installed using brew with brew install llvm
then (optionally) set the following cmake arguments
-DCMAKE_CXX_COMPILER=/Users/username/.local/homebrew/opt/llvm/bin/clang++
-DOMP_ROOT=/Users/username/.local/homebrew/opt/llvm/
-DCXX_ROOT=/Users/username/.local/homebrew/opt/llvm
On an ARM Mac install the x86 version of brew with
arch -x86_64 zsh
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install llvmOnce the executable has been compiled and installed, tdms should be in the
PATH. Check that installation worked with
$ tdms -hYou can invoke it directly or call it from a MATLAB script. We recommend that beginners with MATLAB installed start with the demonstration MATLAB script.
Move into directory examples/arc_01,
launch MATLAB and run the MATLAB script:
This script will generate the input to the executable, run the executable and display sample output.
You can also run tdms from the command line...
$ tdms --help
Usage:
tdms [options] infile outfile
tdms [options] infile gridfile outfile
Options:
-h: Display this help message
-fd, --finite-difference: Use the finite-difference solver, instead of the pseudo-spectral method.
-q: Quiet operation. Silence all logging
-m: Minimise output file size by not saving vertex and facet informationThe basic workflow is with two arguments, an input file as specified by
iterate_fdtd_matrix.m, and an output
file name to be created.
You can choose two possible solver methods: either pseudo-spectral time-domain
(PSTD, the default) or finite-difference (FDTD, with option
--finite-difference).
TDMS is parallelised with OpenMP. The
maximum number of threads can be set with the OMP_NUM_THREADS environment
variable. For example, to use 4 threads, in a bash shell, use:
$ export OMP_NUM_THREADS=4Before calling the tdms executable.
We're very grateful for bug reports, feature requests and pull requests. Please see our contribution guidelines.