Downloads
Latest version of the lab [.tgz]Matlab code [.tgz]
Name of the course | Online | Lecture | Exercises | Lab |
---|---|---|---|---|
Electromagnetic Simulation Lab | ✓ | ✗ | ✗ | ✓ |
Preliminary Courses/Knowledge:
Recommended Preliminary Courses:
Follow-on courses:
Programming laboratory for students with interest in electromagnetic simulation and a background in programming with C/C++ and/or CUDA.
The course is a guided laboratory without lectures and as such well suited for student projects. Participants need some equipment to complete the course successfully, i.e. laptop or desktop computer with Ubuntu Linux and optionally a graphics card that supports NVIDIA CUDA.
The course records consists of a programming environment including a library with pre-compiled reference codes. The environment is available for download on this page including detailed documentation and manpage. The environment allow students to automatically verify their program results for correctness. The environment requires no maintenance as function prototypes are provided.
The course is offered in a virtual classroom. Students attend from the campus or from home on their individual preferences. The course barrier-free.
Students work on a given optical system, e.g. grating filter, to minimize run times while maintaining computational correctness. Grades are awarded on behalf of the correctness and complexity of the implemented algorithm as well as on program run times. The environment automatically checks for correctness and reports on run times. In case of run time improvements students are asked to explain their approach in a short essay, presentation and discussion.
Since the reference codes provide detailed reports on performance and correctness and utilize optimized algorithms for single-core microprocessors ([pdf],[pdf]) as well as massively parallel graphics engines (GPUs), the programming environment is very well suited for performance comparison. Students are encouraged to outperform the existing codes. Have fun!
Cuda-Version | 2D/3D |
CPU/GPU |
scalar/vectorial |
Version | Archive |
---|---|---|---|---|---|
9.1 | ✓/✓ |
✓/✓ |
✓/✓ |
3.00 | [.tgz] |
The programming environment is self-developed and non-commercial. It is allowed to use the code under the CC BY-NC-SA license agreement [w3].
CUDA 10.xx on Ubuntu 20.xx LTS has recently shown compile issues with options '-Ofast' and '-ffinite-math-only'. Please read the documentation below in case of problems.
The tar-archive in the table above provides a C/C++ programming environment for Ubuntu-Linux 16.04, 18.04 and 20.xx with CUDA version 9.x for nvcc and CUDA libraries to perform a self-paced programming laboratory. It allows students to implement 2D or 3D Fourier-based electromagnetic propagation methods for scalar or vector waves on a CPU or GPU. The environment compares the results against the results from reference codes and reports success if errors are below 0.1 per mil per spatial sample.
The tar-archive includes a pre-compiled library with reference codes for scalar and vector BPM and WPM on CPU and GPU. Student codes will be linked against this library and trainees run simulations from pre-defined adaptable configuration files to verify the results. The programming environment reports on run-time and memory usage for CPU and GPU devices. Course participants first implement the basic algorithms and then improve code efficiency by advanced programming techniques, e.g. dynamic programming, multi-threading for a given optical system to simulate. Students select the algorithms, programming method and device as appropriate for their level of expertise. Thereby participants work at their level of complexity to master the course successfully.
Download and extract the tar achive.
$ tar xvfz UDPMLAB_Vx.xx.tgz
The host system needs support for fftw and gcc for CPU runs and nvcc for GPU runs. In case of GPU runs, the shared library libcufft7.5.so or libcufft9.1.so has to be available on the host system. LD_LIBRARY_PATH needs to be set properly to pick the libcufft shared library. libcufft is only needed if GPU runs shall be performed!
$# this is just a comment
$ dpkg -i libcufft9.1_9.1.85-0ubuntu1_amd64.deb # install package
$ dpkg --contents libcufft9.1_9.1.85-0ubuntu1_amd64.deb # not needed but nice to know
$ dpkg -l # not needed but nice to know
If the cufft library is not available on your system and cannot be installed to the official system directory, get the library from the internet and extract it into a user subdirectory, e.g. the ./lib directory of the tar-archive. Then add the path to the environment variable LD_LIBRARY_PATH.
$# this is just a comment
$ dpkg -x libcufft9.1_9.1.85-0ubuntu1_amd64.deb ./lib # extract package to ./lib
$ export LD_LIBRARY_PATH =../lib:$LD_LIBRARY_PATH
Alternatively but maybe not the best choice due to side effects, redirect the installation to a local working directory.
$ dpkg -i --instdir=YOUR_DIR libcufft9.1_9.1.85-0ubuntu1_amd64.deb # install package to ./lib
$ find YOUR_DIR -name "*cufft*.so" -print # find LIBCUFFT_PATH to shared library
$ export LD_LIBRARY_PATH = LIBCUFFT_PATH:$LD_LIBRARY_PATH
The reference code in the package has been compiled with libcufft7.5 and libcufft9.1. If libcufft cannot be installed at all, user code will compile but errors will occur at runtime for GPU runs, i.e. option '-g'. CPU runs are not be affected. In this case, option '-g' cannot be applied.
In some rare cases, versions of nvcc and lubcufft does not match and linker errors occur, e.g. undefined reference to `cudaSetupArgument'. In such cases, versions of nvcc and libcufft need to be aligned.
./bin$ nvcc --version # Cuda compilation tools, release 9.1, V9.1.85
./bin$ ldd ./pm # libcufft.so.9.1 => /usr/lib/x86_64-linux-gnu/libcufft.so.9.1
The programming environment supports the following options.
./bin$ ./pm --help
prints the manpage.
./bin$ cd ..
./$ make
./$ cd bin
./bin$./pm -p -c -t -i wguide.txt
./pm -p -i wguide.cfg
and supports the following options To start a simulation on your CPU and compare against the CPU reference code, invoke the simulator as follows./pm -p -c -i wguide.cfg
For more examples click here.
[global]
nx = 48
ny = 48
nz = 96
x = 4000
y = 4000
z = 8000
method = vwpm
scale = nm
evanescent = 1
[/global]
Gaussian beam | Plane wave | User-defined |
[wave] |
[wave] |
[wave] layer-sections are under work and will be available soon. |
Homogeneous medium | Lens | Waveguide | Taper | 2D Grating |
[layer] |
[layer] |
[layer] |
[layer] |
[layer] |
[flux]
do_evanescent_like_propagating=0
do_theta_90 = 1
do_tolerance = 0
do_trim = 0
do_verbose = 0
do_skip_evanescent_modes_from_manual_override = 0
do_eflux_from_h = 0
do_limit_nyquist = 1
do_limit_modes = 0
modes = 20
do_mode_map_report = 0
do_mode_map_summary = 1
do_filter_field = 0
do_filter_system = 1
do_flux_report = 1
do_divd = 0
do_divd_report = 0
do_divd_summary = 1
do_spectrum_report = 0
do_spectrum_summary = 1
[/flux]