# \[ANN\] JuliaPhysics/ABCDMatrixOptics.jl - Ray Transfer Matrix Analysis

**URL:** <https://discourse.julialang.org/t/ann-juliaphysics-abcdmatrixoptics-jl-ray-transfer-matrix-analysis/104107>\
**Category:** Package Announcements\
**Tags:** physics, optics\
**Created:** [September 21, 2023, 1:35pm UTC](https://discourse.julialang.org/t/ann-juliaphysics-abcdmatrixoptics-jl-ray-transfer-matrix-analysis/104107 "2023-09-21T13:35:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [September 21, 2023, 1:35pm UTC](https://discourse.julialang.org/t/ann-juliaphysics-abcdmatrixoptics-jl-ray-transfer-matrix-analysis/104107/1 "2023-09-21T13:35:13Z")

</div>

Hi all,

[ABCDMatrixOptics.jl](https://github.com/JuliaPhysics/ABCDMatrixOptics.jl) is small package which implements linear tracing of simple optical systems based on the [Ray transfer matrix analysis](https://en.wikipedia.org/wiki/Ray_transfer_matrix_analysis).  
The convention of the optical elements is identical to those on Wikipedia. So far we allow most standard optical elements and geometric and Gaussian beams.  
It evolved from the [ABCDBeamTrace.jl](https://github.com/ngedwin98/ABCDBeamTrace.jl) and should match its features.

## Simple Example

```julia-auto
using ABCDMatrixOptics

# create needed optical elements
f1 = FreeSpace(200)
l1 = ThinLens(200.0)
f12 = FreeSpace(200 + 400)
l2 = ThinLens(400.0)
f2 = FreeSpace(400)

# simple, single ray
beam = GeometricBeam(w=10.0, k=0.1)

# create optical system
# it's built from left to right.
M = [f1, l1, f12, l2, f2]

# apply the system to the beam
# The matrices are evaluates as f2 * l2 * f12 * l1 * f1 * beam
# * is syntactic sugar for propagate
beam_p = M * beam

# GaussianBeam
red_beam = GaussianBeam(w0=5e-3)
blue_beam = GaussianBeam(w0=5e-3, λ=405e-9)

using Plots

plot(M, red_beam)
plot!(M, blue_beam)

```

 ![plot(1)](https://global.discourse-cdn.com/julialang/original/3X/2/7/27d3eeeed52172284fad8f6eb0f334be4c4fdbd1.png)

This package evolved as a [community effort](https://github.com/ngedwin98/ABCDBeamTrace.jl/issues/12) so feel free to submit PRs 🙂  
Also I strongly believe, we should add more Physics related packages to [JuliaPhysics](https://github.com/JuliaPhysics) to increase visibility!

Best,

Felix

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [November 8, 2024, 2:24pm UTC](https://discourse.julialang.org/t/ann-juliaphysics-abcdmatrixoptics-jl-ray-transfer-matrix-analysis/104107/2 "2024-11-08T14:24:58Z")

</div>

Today I added support to also plot `GeometricBeam`s.

If anyone is more familiar with plotting we could also add support for Makie plotting. And some sort of displaying the lens would be great.

PR are welcome 🙂
