gtrace: a Gaussian beam tracing package for Python
gtrace is a python package to trace the propagation of Gaussian beams among optical components such as mirrors and lenses. The features of gtrace include:
- Automatically track the Gaussian beam propagation, i.e. q-parameter change, using the ABCD matrix method.
- Reflection and refraction at interface surfaces are properly treated.
- Automatically track the optical distance traveled by a beam through dielectric media.
- Sequential or non-sequential trace modes are available.
- Exporting the results to DXF files
The main motivation behind the development of gtrace was to help the design of the optical layout for the KAGRA interferometer. The task is not so trivial because we had to satisfy many constraints at the same time. Manually placing mirrors on a CAD and adjusting the distances between the mirrors and their orientations was not an option. We needed a way to automatically adjust the optical layout with a computer to satisfy our requirements. In order to do this, we needed a tool to represent an optical layout convenient for computer processings. gtrace represents mirrors and beams as class objects in python. Then the propagation of the beams can be treated as interactions between the beams and the mirrors. This way, we can automate the optimization of the KAGRA optical layout.
The main ingredients of gtrace are mirrors and beams. A mirror is represented as an instance of Mirror class. You place mirrors in a 2D plane. You can set various properties of a mirror such as size, curvature, reflectivities, wedge angle etc. Then you launch a beam, an instance of GaussianBeam class, from a certain point in the 2D plane. As the beam hits mirrors, it is divided into several sub-beams, such as reflections and deflected beams. These newly generated beam objects are available to you for further propagation. In the non-sequential mode, these sub-beams are automatically propagated until one of the termination conditions is satisfied. The termination conditions include, not hitting any mirror, power is below a certain threshold and so on. At the end of the propagation, you will have a collection of beam objects generated by the collision with the mirrors. You can export the mirrors and the beams into a DXF file.
gtrace is at this moment limited to 2D optical layouts. This limitation might be lifted in the future.
gtrace is available from the Python Package Index (PyPI): https://pypi.org/project/gtrace/
You can install gtrace into your Python environment using the following command:
pip install gtrace
gtrace requires Python version 3. It is not compatible with Python 2.
gtrace also needs the following Python packages to be installed:
Recommended way to install gtrace from scratch
If you do not have Python installed on your computer, here is a recommended way to install gtrace from scratch.
Install Anaconda from here.
Make sure to download the Python 3 version.
- Create a conda environment for gtrace by the following command:
conda create -n gtrace python=3.6 numpy scipy traits pip
- Switch to the created environment
conda activate gtrace
- Install gtrace from pip
pip install gtrace
You may also want to install Jupyter to work with gtrace on Jupyter
conda install jupyter
Installing gtrace into the base environment
In the above method, you always have to activate the gtrace environment before using gtrace. If you don't want to do this every time, you can install gtrace into the base environment of Jupyter. In this case, after the installation of Anaconda, you do the following:
conda install numpy scipy traits pip pip install gtrace
Incomplete manual of gtrace can be found here: JGW-T1910679
gtrace generates results in DXF format, so that integration into the optical CAD model is easy. There are several ways to view DXF files for free. Here are some options.