Skip to content

Examples

Every example redraws a figure from a published paper. Each cell runs in your browser: press Run, change the code, run it again. The first run loads Python and optodraw, about 10 MB.

A simple ODMR microscope, after Babashah et al., SciPost Phys. Core 6, 065 (2023), Fig. 4
# A simple ODMR microscope, after Babashah et al., SciPost Phys. Core 6, 065 (2023), Fig. 4
from optodraw import Beam, BeamSplitter, Filter, Laser, Lens, Objective, Photodiode, Sample, Scene
from optodraw.layout import aim
scene = Scene(title="ODMR setup", platform="free_space")
scene.set_view_layout({"3d": {"spacing": "auto"}}) # 3D: room for every post; 1D and 2D stay compact
pump = scene.add(Laser(center=(-38, 0), wavelength=532, label="Laser (dichroic pumping)"))
side = scene.add(Laser(center=(-38, -25.8), wavelength=532, label="Laser (side pumping)"))
dichroic = scene.add(BeamSplitter(center=(0, 0), dichroic=True, cutoff_wavelength=600,
label="Dichroic mirror"))
objective = scene.add(Objective(center=(0, -13), angle=-90, label="Microscope objective"))
# turned to face the objective, on the XYZ micro positioner: a motion mark in 1D and 2D, the stages in 3D
sample = scene.add(Sample(center=(0, -26), angle=-90, label="Sample on XYZ stage", base_mount="xyz_stage"))
filt = scene.add(Filter(center=(0, 10), angle=90, label="IF filter"))
lens = scene.add(Lens(center=(0, 20), angle=90, label="Lens"))
pd = scene.add(Photodiode(center=(0, 31), angle=90, label="Photodetector"))
aim(dichroic, pump, objective)
for part in (dichroic, objective, sample, filt, lens, pd):
part.label_side = "right"
pump.label_side = side.label_side = "bottom"
# the green pump goes down and the red photoluminescence comes back up the same axis (drawn narrower)
scene.add(Beam.through(pump, dichroic, objective, (sample, "in"), wavelength=532, width=1.0))
scene.add(Beam.through(side, (sample, "side_in"), wavelength=532, width=1.0, opacity=0.45)) # the side-pumping option
scene.add(Beam.through((sample, "in"), objective, dichroic, filt, lens, pd, wavelength=690, width=0.45))
scene.fit_frame(margin=8)
scene
A simple ODMR microscope, after Babashah et al., SciPost Phys. Core 6, 065 (2023), Fig. 4 in 2D
A Bell-test bench for students, after Lahoz Sanz et al., EPJ Quantum Technol. 11, 86 (2024), Fig. 4
# A Bell-test bench for students, after Lahoz Sanz et al., EPJ Quantum Technol. 11, 86 (2024), Fig. 4
import math
from optodraw import (PBS, Beam, BeamDump, CoincidenceCounter, Computer, Filter, FiberCollimator,
HalfWavePlate, Laser, Lens, Mirror, PhotonCounter, Polarizer, QuarterWavePlate,
Scene, WedgePlate)
from optodraw.layout import aim
scene = Scene(title="Bell inequalities", platform="free_space")
scene.set_view_layout({"3d": {"spacing": "auto"}}) # 3D: room for every post; 1D and 2D stay compact
# photon production: the 405 nm pump folds on two mirrors into the BBO crystals (CR); the rest stops in BS
ld = scene.add(Laser(center=(-92, 33), wavelength=405, label="LD"))
fl = scene.add(Lens(center=(-77, 33), label="FL"))
bf = scene.add(Filter(center=(-69, 33), label="BF"))
hwp1 = scene.add(HalfWavePlate(center=(-57, 33), label="HWP(1)"))
lp = scene.add(Polarizer(center=(-45, 33), label="LP"))
mi1 = scene.add(Mirror(center=(-22, 33), label="MI"))
mi2 = scene.add(Mirror(center=(-63, 0), label="MI"))
hwp2 = scene.add(HalfWavePlate(center=(-33, 0), label="HWP(2)"))
cr = scene.add(WedgePlate(center=(-12, 0), label="CR"))
stop = scene.add(BeamDump(center=(100, 0), label="BS"))
aim(mi1, lp, mi2)
aim(mi2, mi1, hwp2)
scene.add(Beam.through(ld, fl, bf, hwp1, lp, mi1, mi2, hwp2, cr, stop, wavelength=405, width=0.5))
# photon detection: each 810 nm photon of a pair leaves CR at 13 degrees and meets wave plates and a PBS
# the four-channel detector (4CD) and the coincidence counter (CC) face left: the fibres come from the right
detector = scene.add(PhotonCounter(center=(37, 64), angle=180, channels=4, label="4CD"))
counter = scene.add(CoincidenceCounter(center=(-13, 64), angle=180, channels=4, label="CC"))
computer = scene.add(Computer(center=(-50, 70), label="Computer"))
for channel in range(1, 5):
scene.route((detector, f"pulse{channel}"), (counter, f"in{channel}"), kind="electrical", width=0.6)
scene.route((counter, "data"), (computer, "e1"), kind="electrical", width=1.0,
steps=[{"y": 52}, {"x": -72}, {"y": 70}])
for sign, arm in ((1, "a"), (-1, "b")):
tilt = sign * 13.0
along = lambda d: (-12 + d * math.cos(math.radians(tilt)), d * math.sin(math.radians(tilt))) # noqa: E731
plates = [scene.add(HalfWavePlate(center=along(29), angle=tilt, label="HWP(s)"))] if arm == "a" else []
plates += [scene.add(QuarterWavePlate(center=along(52), angle=tilt, label=f"QWP({arm})")),
scene.add(HalfWavePlate(center=along(65), angle=tilt, label=f"HWP({arm})")),
scene.add(Filter(center=along(77), angle=tilt, label="IR"))]
pbs = scene.add(PBS(center=along(90), angle=tilt, label="PBS"))
pbs.flip_vertical = arm == "b" # the lower PBS reflects down
p = pbs.transform.position
out = math.radians(tilt + sign * 90.0)
fc_t = scene.add(FiberCollimator(center=along(112), angle=180 + tilt, label="FC"))
fc_r = scene.add(FiberCollimator(center=(p.x + 20 * math.cos(out), p.y + 20 * math.sin(out)),
angle=math.degrees(out) + 180, label="FC"))
for part in plates + [pbs, fc_t, fc_r]:
part.label_side = "top" if arm == "a" else "bottom"
scene.add(Beam.through(cr, *plates, pbs, fc_t, wavelength=810, width=0.4))
scene.add(Beam.through(pbs, fc_r, wavelength=810, width=0.4))
# fibres loop round the outside to the detector, each in its own lane, as in the paper; none crosses
channels = {("a", "r"): 1, ("a", "t"): 2, ("b", "t"): 3, ("b", "r"): 4} # turned: 1 is the lowest
lanes = {("a", "r"): [{"y": 55}], ("a", "t"): [{"x": 122}, {"y": 61}],
("b", "t"): [{"x": 128}, {"y": 67}], ("b", "r"): [{"y": -62}, {"x": 134}, {"y": 73}]}
for fc, which in ((fc_t, "t"), (fc_r, "r")):
scene.route((fc, "in"), (detector, f"fiber{channels[arm, which]}"), kind="fiber", width=0.6,
path_type="smooth", steps=lanes[arm, which])
scene.fit_frame(margin=10)
scene
A Bell-test bench for students, after Lahoz Sanz et al., EPJ Quantum Technol. 11, 86 (2024), Fig. 4 in 2D
A 1x4 AWG demultiplexer, after Smit and van Dam, IEEE J. Sel. Top. Quantum Electron. 2, 236-250 (1996)
# A 1x4 AWG demultiplexer, after Smit and van Dam, IEEE J. Sel. Top. Quantum Electron. 2, 236-250 (1996)
from optodraw import AWG, OnChipPhotodetector, Scene, VerticalGratingCoupler
from optodraw.layout import chain_ports
scene = Scene(title="1x4 AWG demultiplexer", platform="on_chip")
gc = scene.add(VerticalGratingCoupler(center=(-195, -35), angle=180, label="in")) # centred on the frame
awg = scene.add(AWG(channel_count=4, array_count=8, label="AWG"))
chain_ports([(gc, "o1", awg, "i1")], gap=40.0, grid=0.0) # the AWG one gap after the coupler
# one detector per channel, on the pitch of a detector, with room for the fan-out
outputs = [awg.world_ports()[f"o{i}"].center for i in range(1, 5)]
pitch = 32.0
x = max(p.x for p in outputs) + 60.0 - OnChipPhotodetector().ports()["o1"].center.x
detectors = [scene.add(OnChipPhotodetector(center=(x, -35 + (i - 1.5) * pitch), label=f"PD{i + 1}"))
for i in range(4)]
scene.route((gc, "o1"), (awg, "i1"), kind="waveguide", path_type="smooth")
for i, pd in enumerate(detectors, start=1):
scene.route((awg, f"o{i}"), (pd, "o1"), kind="waveguide", path_type="smooth")
pd.label_side = "right"
scene.fit_frame(margin=10)
scene
A 1x4 AWG demultiplexer, after Smit and van Dam, IEEE J. Sel. Top. Quantum Electron. 2, 236-250 (1996) in 2D
Figure Page
Advanced LIGO, Abbott et al. 2016, Fig. 3 Get started
Instant structured illumination microscope, Curd et al. 2015, Fig. 1A Free-space benches
Its 8.9 times beam expander, traced Ray tracing
Coupled add-drop rings, Borghi et al. 2019, Fig. 1 Photonic chips
Silicon-organic hybrid modulator, Wolf et al. 2018, Fig. 1a Photonic chips
Balanced homodyne receiver, Yang et al. 2025, Fig. 3 Electronics

The redraws follow each figure’s layout and parts. They are schematics, not copies of the artwork; cite the paper for the science and optodraw for the drawing.

  • Babashah, H. et al. Optically detected magnetic resonance with an open source platform. SciPost Phys. Core 6, 065 (2023). doi:10.21468/SciPostPhysCore.6.4.065
  • Lahoz Sanz, A. et al. Undergraduate setup for measuring the Bell inequalities and performing quantum state tomography. EPJ Quantum Technol. 11, 86 (2024). doi:10.1140/epjqt/s40507-024-00298-y
  • Smit, M. K. and van Dam, C. PHASAR-based WDM-devices: principles, design and applications. IEEE J. Sel. Top. Quantum Electron. 2, 236-250 (1996). doi:10.1109/2944.577370