Fintrace Tutorial
Fabry Perot Cavity
[1]:
from fintrace.model import FintraceModel
# Instantiation
model = FintraceModel()
gdict, cavities, detectors = model.build_from_yaml("fabryperot/fp_test.yaml", gtrace=True, verbose=True)
# Plotting the cavity with gtrace using a laser
model.gtrace_plot(gdict, finesse_cavities=cavities, finesse_detectors=detectors, render=True,
beam_origin='laser', grid=True, draw_width=True, savefile='fabryperot/fp_gtrace_laser',
img_res=600, power_threshold=1e-2)
# Plotting the cavity with gtrace using the defined cavity
model.gtrace_plot(gdict, finesse_cavities=cavities, finesse_detectors=detectors, render=True,
beam_origin='cavity', grid=True, draw_width=True, savefile='fabryperot/fp_gtrace_cavity',
img_res=600, power_threshold=1e-3)
# Plotting a cavity eigenmode beamtrace
model.trace_cavities(['all'], savepath='fabryperot/fp_trace')
Laser:
+-------+---------------+-------+--------------------------------------------+---------+-----------+
| Name | Position[m] | P [W] | q [m] | θ [deg] | λ [m] |
+-------+---------------+-------+--------------------------------------------+---------+-----------+
| Laser | [0.000 0.000] | 1.0 | [-0.00e+00+2.66e+01j, -0.00e+00+2.66e+01j] | 0.000 | 1.064e-06 |
+-------+---------------+-------+--------------------------------------------+---------+-----------+
Components:
+------+--------------+-----------+--------------+----------+-----+-----+------+---------+------+----------------------+------------+---------------+------------------+
| Name | Position [m] | AOI [deg] | diameter [m] | T | L | R | R_AR | θ [deg] | n | RoC [m] | RoC_AR [m] | thickness [m] | wedgeAngle [deg] |
+------+--------------+-----------+--------------+----------+-----+-----+------+---------+------+----------------------+------------+---------------+------------------+
| M1 | [0.25, 0.00] | 0 | 0.05 | 1.00e-01 | 0.0 | 0.9 | 0.0 | 0.00 | 1.45 | [2.55e-01, 2.55e-01] | [inf, inf] | 0.005 | 0.00 |
| M2 | [0.50, 0.00] | 0 | 0.05 | 1.00e-01 | 0.0 | 0.9 | 0.0 | 180.00 | 1.45 | [inf, inf] | [inf, inf] | 0.005 | 0.00 |
+------+--------------+-----------+--------------+----------+-----+-----+------+---------+------+----------------------+------------+---------------+------------------+
Cavities:
+------------+---------+----------+-----------+-----------------+----------------+----------+----------+----------+----------+---------------------+----------------------+----------------+
| Name | finesse | FSR [Hz] | FWHM [Hz] | Gouy (deg) | stability-m | Loss | f_p [Hz] | RTL[m] | τ [s] | TMS [Hz] | w0 [m] | z0 [m] |
+------------+---------+----------+-----------+-----------------+----------------+----------+----------+----------+----------+---------------------+----------------------+----------------+
| FabryPerot | 29.80 | 6.00e+08 | 2.01e+07 | [163.90,163.90] | [-0.96, -0.96] | 1.90e-01 | 1.01e+07 | 5.00e-01 | 1.58e-08 | [2.73e+08,2.73e+08] | [1.09e-04, 1.09e-04] | [-0.25, -0.25] |
+------------+---------+----------+-----------+-----------------+----------------+----------+----------+----------+----------+---------------------+----------------------+----------------+
Detectors:
+------+----------------+------------+
| Name | Position (m) | Omega (Hz) |
+------+----------------+------------+
| PD1 | [0.600, 0.000] | None |
+------+----------------+------------+
Rerun
Notice how the laser beam is not mode-matched to the cavity. Try adding the Match flag with the cavity name in the .yaml file to the Laser object, and rerunning the code. You should see now the cavity eigenmode and the beamtrace from the laser are identical.
Add Match: FabryPerot under the Laser key in fp_test.yaml.
Bowtie Cavity
Here we use the bowtie cavity example.
This section demonstrates more techniques with gtrace renderings, cavity beam tracing, arbitrary beam tracing, as well as integrating Finesse analyses.
Gtrace Rendering
Here is shown the difference between rendering the cavity eigenmode and rendering a non-sequential beam propagation from our laser source in the .yaml. The number of ghost beams traced in the non-sequential trace rendering is dependent on the power_threshold, such that we can get an estimate of what power those beams would contain. These are affected also by the transmission coefficients of the mirrors used in the model. This behavior is not observed in the cavity eigenmode rendering as
it is doing a sequential beam propagation, and stopping after a round trip.
Cavity Traces
The cavity tracing produces a plot showing the beam evolution through the cavities in the model (if we use the arg ['all']), otherwise it will only plot those traces specified in the list of desired cavities. With this cavity trace, we can examine the q-parameter and other values at any node in our cavity (i.e. the beamwidth at M3.fr1.i). Note, it will try to analyze the nodes in each of the cavities that are being traced; if a node is not in a cavity, a warning will be produced.
Beam Traces
The beam tracing produces a plot showing the beam evolution from the start and end nodes defined by the user. With this beam trace, we can examine the q-parameter and other values at any node in our path (i.e. the beamwidth at M3.fr1.i). Note, the user can also specify the input q-parameter to be propagated through the calculated path.
Finesse Actions
With photodiodes added to the model, the user can also utilize any of the Finesse actions like Xaxis to perform analyses like measuring transmitted and reflected power.
[5]:
# Instantiation
model = FintraceModel()
gdict, cavities, detectors = model.build_from_yaml("bowtie/bowtie_test.yaml", gtrace=True, verbose=True)
# Plotting the cavity with gtrace using a laser
model.gtrace_plot(gdict, finesse_cavities=cavities, finesse_detectors=detectors, render=True,
beam_origin='laser', grid=True, draw_width=True, savefile='bowtie/bowtie_gtrace_laser',
img_res=600, power_threshold=5e-2)
# Plotting the cavity with gtrace using the defined cavity
model.gtrace_plot(gdict, finesse_cavities=cavities, finesse_detectors=detectors, render=True,
beam_origin='cavity', grid=True, draw_width=True, savefile='bowtie/bowtie_gtrace_cavity',
img_res=600)
# Plotting a cavity eigenmode beamtrace
model.trace_cavities(['all'], savepath='bowtie/bowtie_trace', q_at=["M2.fr2.o" ,"M3.fr1.i"])
# Plotting beam between just M2 and M4
model.trace_beam(['Laser.fr.o', 'M4.fr1.i'], savepath='bowtie/bowtie_beam', plot=True)
# Now we can also do things in finesse like actions
from finesse.analysis.actions import Xaxis
import matplotlib.pyplot as plt
xaxis = Xaxis(model.M2.phi, mode='lin', start=0, stop=360,
steps=200)
sol = model.run(xaxis)
fig, axs = plt.subplots(1, 1, figsize=(10, 8))
axs.plot(sol.x[0], sol['PD1'], label='PD1')
axs.plot(sol.x[0], sol['PD2'], label='PD2')
axs.set_title("Power in PDs vs. M2 sweep")
axs.set_xlabel("M2 Phi [degrees]")
axs.set_ylabel("Power in PD [W]")
axs.legend()
plt.savefig("bowtie/power_sweep.png")
Laser:
+-------+---------------+-------+--------------------------------------------+-----------------+
| Name | Position[m] | P [W] | q [m] | normAngle [deg] |
+-------+---------------+-------+--------------------------------------------+-----------------+
| Laser | [0.000 0.000] | 1.0 | [-3.78e-01+4.58e-02j, -3.79e-01+1.47e-01j] | 0.000 |
+-------+---------------+-------+--------------------------------------------+-----------------+
Components:
+------+---------------+-----------+--------------+-----+-----------------+------+-----+------+----------------------+------------+---------------+----------+------------------+
| Name | Position [m] | AOI [deg] | diameter [m] | L | normAngle [deg] | n | R | R_AR | RoC [m] | RoC_AR [m] | thickness [m] | T | wedgeAngle [deg] |
+------+---------------+-----------+--------------+-----+-----------------+------+-----+------+----------------------+------------+---------------+----------+------------------+
| M1 | [0.25, 0.00] | 18.43 | 0.05 | 0.0 | 341.57 | 1.45 | 0.9 | 0.0 | [inf, inf] | [inf, inf] | 0.005 | 1.00e-01 | 0.00 |
| M2 | [0.50, 0.00] | 18.43 | 0.05 | 0.0 | 198.43 | 1.45 | 0.9 | 0.0 | [inf, inf] | [inf, inf] | 0.005 | 1.00e-01 | 0.00 |
| M3 | [0.30, -0.15] | 18.43 | 0.05 | 0.0 | 18.43 | 1.45 | 0.9 | 0.0 | [8.00e-01, 8.00e-01] | [inf, inf] | 0.005 | 1.00e-01 | 0.00 |
| M4 | [0.45, -0.15] | 18.43 | 0.05 | 0.0 | 161.57 | 1.45 | 0.9 | 0.0 | [8.00e-01, 8.00e-01] | [inf, inf] | 0.005 | 1.00e-01 | 0.00 |
+------+---------------+-----------+--------------+-----+-----------------+------+-----+------+----------------------+------------+---------------+----------+------------------+
Cavities:
+--------------+--------+---------+----------+-----------+------------------+--------------+----------+-----------+----------+------------------+---------------------+----------------------+--------------------+
| Name | Stable | finesse | FSR [Hz] | FWHM [Hz] | Gouy (deg) | g-factor | Loss | pole [Hz] | RTL[m] | Storage time [s] | TMS [Hz] | Waist Size [m] | Waist Position [m] |
+--------------+--------+---------+----------+-----------+------------------+--------------+----------+-----------+----------+------------------+---------------------+----------------------+--------------------+
| BowtieCavity | True | 14.9 | 3.33e+08 | 2.24e+07 | [168.84, 144.90] | [0.01, 0.09] | 3.44e-01 | 1.12e+07 | 9.00e-01 | 1.42e-08 | [1.56e+08,1.34e+08] | [1.25e-04, 2.23e-04] | [-0.12, -0.12] |
+--------------+--------+---------+----------+-----------+------------------+--------------+----------+-----------+----------+------------------+---------------------+----------------------+--------------------+
Detectors:
+------+----------------+------------+
| Name | Position (m) | Omega (Hz) |
+------+----------------+------------+
| PD1 | [0.200, 0.030] | None |
| PD2 | [0.600, 0.000] | None |
+------+----------------+------------+
q at M2.fr2.o in BowtieCavity:
+-----------+------------------------------+------------------------+---------------------+------------------------+--------------------+
| direction | q | w | RoC | w0 | Gouy [deg] |
+-----------+------------------------------+------------------------+---------------------+------------------------+--------------------+
| x | (0.125+0.04577811810927323j) | 0.00036208168992946934 | 0.14176508878101257 | 0.00012451590954265816 | 20.113990826581702 |
| y | (0.125+0.14745662020566086j) | 0.00029296538524936036 | 0.2989476387398121 | 0.00022347452113019917 | 49.71182425883252 |
+-----------+------------------------------+------------------------+---------------------+------------------------+--------------------+
q at M3.fr1.i in BowtieCavity:
+-----------+------------------------------+-----------------------+---------------------+------------------------+-------------------+
| direction | q | w | RoC | w0 | Gouy [deg] |
+-----------+------------------------------+-----------------------+---------------------+------------------------+-------------------+
| x | (0.375+0.04577811810927323j) | 0.001027567349523008 | 0.38058836292700415 | 0.00012451590954265816 | 6.959944497595886 |
| y | (0.375+0.14745662020566086j) | 0.0006106812260367766 | 0.43298254624660404 | 0.00022347452113019917 | 21.46562818212047 |
+-----------+------------------------------+-----------------------+---------------------+------------------------+-------------------+