tdms

Time Domain Maxwell Solver

https://github.com/ucl/tdms

Science Score: 75.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
    Organization ucl has institutional domain (www.ucl.ac.uk)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.9%) to scientific vocabulary

Keywords

matlab maxwell-equations maxwell-equations-solver physics time-domain

Keywords from Contributors

mesh interactive imaging network-simulation hacking particles embedded optim pde microscopy
Last synced: 6 months ago · JSON representation ·

Repository

Time Domain Maxwell Solver

Basic Info
Statistics
  • Stars: 12
  • Watchers: 4
  • Forks: 6
  • Open Issues: 41
  • Releases: 4
Topics
matlab maxwell-equations maxwell-equations-solver physics time-domain
Created about 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License Citation

README.md

TDMS · latest release license Build and test MATLAB tests codecov DOI

Time-Domain Maxwell Solver

TDMS, the Time Domain Maxwell Solver, is a hybrid C++ and MATLAB tool for simulating light propagation through a medium by solving Maxwell's equations. For further details about the method, please refer to the PDF documentation.

The normed z-component of the H field incident on a cylinder

Getting started

We don't ship binaries at the moment, so to use TDMS, it has to be compiled. It needs to be built against FFTW and MATLAB, which must be downloaded and installed first.

Linux prerequisite setup Assuming you don't already have them, you'll need a C++ compiler, CMake, OpenMP and FFTW. For Debian-based distributions this should be as simple as ```{sh} $ sudo apt install git gcc cmake libfftw3-dev libgomp1 ```
MacOS prerequisite setup On MacOS everything can be installed using [Homebrew](https://brew.sh): ```{sh} $ brew install cmake fftw llvm hdf5 ```
Windows prerequisite setup TDMS was developed - and extensively tested - on linux. Support for Windows is quite new and experimental (please [report](https://github.com/UCL/TDMS/issues/new/choose) any issues you encounter!). It might be more straightforward to use the [Windows subsystem for Linux (WSL2)](https://learn.microsoft.com/en-gb/windows/wsl/install), or set up an linux virtual machine. However, TDMS _can_ be compiled natively on Windows. This has been tested Windows 10 and 11, with PowerShell. Assuming you don't already have them, you'll need to download and install: * [MATLAB](https://www.mathworks.com/products/matlab.html), * [Visual Studio](https://visualstudio.microsoft.com/vs/community/) and **be sure to select the C++ developer kit**, * [CMake](https://cmake.org/download/), * and [FFTW](https://www.fftw.org/install/windows.html). You can check that the Visual Studio compiler was installed with: ```{pwsh} PS> MSBuild.exe -h ``` Potentially the simplest way to get FFTW is via [conda](https://anaconda.org/conda-forge/fftw): ```{pwsh} PS> conda install -c conda-forge fftw --yes ``` You'll need to ensure the paths to FFTW and MATLAB (the locations of `fftw3.dll` and `libmex.dll` respectively) are in the `env:Path`. These can be found, e.g. by ```{pwsh} PS> conda list fftw # assuming you installed via conda PS> which.exe MATLAB ``` Which should return something like `C:\Program Files (x86)\MATLAB\R20XXx\bin\matlab` and maybe `C:\ProgramData\envs\base\bin`. If you downloaded FFTW and created `fftw3.dll` with `lib.exe`, you just need to know where you saved it. You can append the paths: ```{pwsh} PS> $env:Path += ";C:\Program Files (x86)\MATLAB\R20XXx\bin\;C:\ < wherever fftw3.dll is >" ``` Which will help Windows locate `.dll` files later. For all following instructions, you'll have to substitute our mentions of ``tdms`` with ``tdms.exe`` and ``$`` is used to denote a command prompt which, in PowerShell, would look like ``PS>``
Even more Windows troubleshooting We've seen that in a fresh PowerShell window, Windows does not remember the location of the ``.dll`` files, so you may have to re-add them to the path, or copy them into the directory where TDMS was installed. TDMS typically installs to ``"C:\Program Files (x86)\tdms\bin\tdms.exe"``.


You'll need to download and install MATLAB, and take note where the headers are installed.

Installation

To compile and install, follow these steps:

{sh} $ git clone git@github.com:UCL/TDMS.git $ cd TDMS $ git checkout v1.0.2 # the stable version $ mkdir build; cd build $ cmake ../tdms \ $ # -DMatlab_ROOT_DIR=/usr/local/MATLAB/R20XXx/ \ $ # -DFFTW_ROOT=/usr/local/fftw3/ \ $ # -DCMAKE_INSTALL_PREFIX=$HOME/.local/ $ cmake --build . --target install --config Release

If CMake cannot find MATLAB, FFTW, or install to the default installation prefix, uncomment the relevant line(s) and modify the path(s) accordingly.

You can check that tdms was installed correctly and is in your PATH by running: {sh} $ tdms --help $ tdms --version in a new terminal.

How to run

You can run TDMS either directly or from a MATLAB script. For beginners, we recommend starting with the demonstration MATLAB script, which you can find in the examples/arc_01 directory. Move into this directory, launch MATLAB, and run the MATLAB script run_pstd_bscan.m. This script will generate the input to TDMS, run TDMS, and display sample output. There are comments explaining what it is doing, so you can follow along with what is being setup and created at each stage. We have also commented the input file arc_01_example_input.m that this script passes to iteratefdtd_matrix.m.

Troubleshooting We've seen that launching MATLAB on MacOS via the launcher (cmd + space) may not preserve the system `PATH`. ``` command not found: tdms ``` Assuming `tdms --help` works in a new terminal, try launching MATLAB _from_ that terminal. ```{sh} $ tdms --help $ /Applications/MATLAB_.app/bin/matlab ``` The MATLAB example scripts should then find `tdms`. If you still have problems, you can try hard-coding the full path to `tdms` into the MATLAB script. In a terminal run ```{sh} $ which tdms ``` Copy the full path (something like `/usr/local/bin/tdms`) into [`run_pstd_bscan.m`](https://github.com/UCL/TDMS/blob/main/examples/arc_01/run_pstd_bscan.m), replacing the ` 'tdms' ` text in the calls to the ``system()`` function.

MATLAB file version

In order to be readable by TDMS, files need to be saved in .mat (MATLAB file) version 7.3 or newer. This can be done by passing '-v7.3' to MATLAB's save command as the final argument, for example:

save('my_input_file.mat', 'my_input_var_1', 'my_input_var_2', ..., 'my_input_var_N', '-v7.3');

Or set v7.3 as the default in MATLAB's settings. ![](doc/assets/matlab-file-settings.png)

On the command line

If you want to run TDMS standalone at the command line, the basic operation is with two arguments: an input file containing simulation parameters, and an output file name. You can choose between two solver methods: finite-difference or pseudo-spectral, as well as two interpolation methods: cubic or bandlimited. These options can be selected by setting the corresponding flag variables in the input file. When tdms reads the input, it will verify if the input file contains a dataset that matches the names of these flags.

There are two flags available for configuration in the input file.

use_pstd - If not provided, or provided as false, then the default timestepping method of finite-differences (FDTD) will be used. - If present and set to true, then tdms will use the pseudo-spectral (PSTD) method when performing simulation timesteps.
use_bli - If not provided, or provided as false, then the default interpolation method of cubic interpolation will be used to obtain field values at the centres of Yee cells. - If present and set to true, then tdms will use bandlimited interpolation (BLI) when obtaining field values at Yee cell centres.

\note Typically bandlimited interpolation is superior to cubic interpolation when the extent of the Yee cell is of approximately the same order as, but slightly less than, one-sixth of the shortest wavelength of interest. Otherwise, cubic interpolation typically enjoys superior accuracy.

TDMS is parallelised with OpenMP. You can set the maximum number of threads using the OMP_NUM_THREADS environment variable before calling the TDMS executable. {sh} $ export OMP_NUM_THREADS=4 # for example

Citation

If you used TDMS in your research and found it helpful, please cite this work: 10.5281/zenodo.7950604.

BibTEX ```bibtex @software{tdms, author = {Munro, Peter and others}, license = {GPL-3.0}, title = {{TDMS - The Time-Domain Maxwell Solver}}, URL = {https://github.com/UCL/TDMS}, publisher = {Zenodo}, doi = {10.5281/zenodo.7950603} } ```
LaTeX ```tex \bibitem{tdms} P. Munro, et al \emph{TDMS - The Time-Domain Maxwell Solver}, \url{https://github.com/UCL/TDMS}, \href{https://doi.org/10.5281/zenodo.7950603}{10.5281/zenodo.7950603}. ```

Acknowledgements

The TDMS source code was released under a GPL-3.0 License as part of a joint project between University College London's Medical Physics and Biomedical Engineering and Centre for Advanced Research Computing with generous funding from the Royal Society.

medphys arc

Development of this software has previously benefited from funding from the Commonwealth Scholarships Commission, the Engineering and Physical Sciences Research Council, and the Australian Research Council.

Want to contribute?

We're grateful for bug reports, feature requests, and pull requests. Please see our contribution guidelines (we also have some developer documentation).

Owner

  • Name: University College London
  • Login: UCL
  • Kind: organization
  • Email: rc-softdev@ucl.ac.uk

Citation (CITATION.cff)

cff-version: 1.2.0
title: TDMS - The Time-Domain Maxwell Solver
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Peter
    family-names: Munro
    affiliation: University College London
    orcid: 'https://orcid.org/0000-0001-9306-3673'
  - given-names: Sam
    family-names: Cunliffe
    affiliation: University College London
    orcid: 'https://orcid.org/0000-0003-0167-8641'
  - given-names: Mosè
    family-names: Giordano
    orcid: 'https://orcid.org/0000-0002-7218-2873'
    affiliation: University College London
  - given-names: William
    family-names: Graham
    affiliation: University College London
    orcid: 'https://orcid.org/0000-0003-0058-263X'
  - given-names: Emmanouil
    family-names: Kriezis
    email: mkriezis@auth.gr
    affiliation: Aristotle University of Thessaloniki
    orcid: 'https://orcid.org/0000-0001-6407-2810'
  - given-names: Peter
    family-names: Török
    email: peter.torok@ntu.edu.sg
    affiliation: Nanyang Technological University
  - given-names: Tom
    family-names: Young
    affiliation: University College London
    orcid: 'https://orcid.org/0000-0002-8432-7769'
identifiers:
  - type: doi
    value: 10.5281/zenodo.7950603
repository-code: 'https://github.com/UCL/TDMS'
url: 'https://github-pages.ucl.ac.uk/TDMS'
keywords:
  - time-domain
  - maxwell-equations-solver
license: GPL-3.0

GitHub Events

Total
  • Issues event: 7
  • Delete event: 7
  • Issue comment event: 7
  • Push event: 34
  • Pull request review event: 10
  • Pull request review comment event: 3
  • Pull request event: 12
  • Fork event: 2
  • Create event: 8
Last Year
  • Issues event: 7
  • Delete event: 7
  • Issue comment event: 7
  • Push event: 34
  • Pull request review event: 10
  • Pull request review comment event: 3
  • Pull request event: 12
  • Fork event: 2
  • Create event: 8

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 198
  • Total Committers: 7
  • Avg Commits per committer: 28.286
  • Development Distribution Score (DDS): 0.545
Past Year
  • Commits: 4
  • Committers: 2
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.25
Top Committers
Name Email Commits
Sam Cunliffe s****e 90
Will Graham 3****1 59
Tom Young 3****1 36
Mosè Giordano m****e@g****g 6
David Stansby d****y@g****m 5
dependabot[bot] 4****] 1
Peter Munro 3****o 1
Committer Domains (Top 20 + Academic)
gnu.org: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 55
  • Total pull requests: 58
  • Average time to close issues: 2 months
  • Average time to close pull requests: 13 days
  • Total issue authors: 7
  • Total pull request authors: 7
  • Average comments per issue: 1.07
  • Average comments per pull request: 1.17
  • Merged pull requests: 48
  • Bot issues: 0
  • Bot pull requests: 6
Past Year
  • Issues: 4
  • Pull requests: 8
  • Average time to close issues: about 3 hours
  • Average time to close pull requests: about 2 hours
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 0.25
  • Average comments per pull request: 0.13
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 6
Top Authors
Issue Authors
  • t-young31 (36)
  • samcunliffe (10)
  • prmunro (3)
  • willGraham01 (3)
  • matt-graham (1)
  • tikitaka5188 (1)
  • giordano (1)
Pull Request Authors
  • t-young31 (29)
  • samcunliffe (12)
  • dependabot[bot] (6)
  • willGraham01 (6)
  • giordano (4)
  • prmunro (1)
  • dstansby (1)
Top Labels
Issue Labels
enhancement (27) from list (14) technical (13) testing (10) context required (8) documentation (6) bug (6) priority:1 (3) good first issue (3) priority:2 (2) wontfix (1) ux (1) housekeeping (1) upstream (1)
Pull Request Labels
technical (14) housekeeping (8) testing (6) enhancement (6) documentation (5) review required (2) opinions wanted (1) bug (1) upstream (1)

Dependencies

.github/workflows/doc.yml actions
  • actions/checkout v3 composite
  • stefanzweifel/git-auto-commit-action v4 composite
  • xu-cheng/latex-action v2 composite
.github/workflows/doxygen-gh-pages.yml actions
  • DenverCoder1/doxygen-github-pages-action v1.2.0 composite
.github/workflows/matlab_tests.yml actions
  • actions/checkout v3 composite
  • matlab-actions/run-command v1 composite
  • matlab-actions/setup-matlab v1.2.3 composite
tdms/tests/requirements.txt pypi
  • h5py * test
  • numpy * test
  • pytest * test
  • pytest-check * test
  • pyyaml * test
.github/workflows/ci.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • codecov/codecov-action v3 composite
  • conda-incubator/setup-miniconda v2 composite
  • matlab-actions/run-command v1 composite
  • matlab-actions/setup-matlab v1.2.3 composite
  • ucl/composite-actions/pre-commit v1 composite