Skip to content

hqqen/TDMS

 
 

Repository files navigation

Build and test MATLAB tests doc

TDMS

Warning This repository is a work in progress. The API will change without notice

Time-Domain Maxwell Solver

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.

Compilation

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 install

where 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 llvm

Usage

Once the executable has been compiled and installed, tdms should be in the PATH. Check that installation worked with

$ tdms -h

You can invoke it directly or call it from a MATLAB script. We recommend that beginners with MATLAB installed start with the demonstration MATLAB script.

To run the demonstration code

Move into directory examples/arc_01, launch MATLAB and run the MATLAB script:

run_pstd_bscan.m

This script will generate the input to the executable, run the executable and display sample output.

To run standalone

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 information

The 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).

Parallelism

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=4

Before calling the tdms executable.

Want to contribute?

We're very grateful for bug reports, feature requests and pull requests. Please see our contribution guidelines.

About

Time Domain Maxwell Solver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 77.6%
  • MATLAB 17.4%
  • Python 2.6%
  • CMake 1.2%
  • C 0.9%
  • TeX 0.3%