Skip to main content

Python package for designing gaussian laser beam propagation and transformation.

Project description

gbeampro

gbeampro is a small Python package for simulating Gaussian (TEM₀₀) laser beam propagation and transformations using the ABCD matrix method (q-parameter formalism).

demo

Installation

pip install gbeampro

Quick Start

from gbeampro import GaussBeam, Propagation, ThinLens, Interface, OpticalSystem

# Define a beam at its waist: 1064 nm, w₀=1 mm
beam = GaussBeam.from_waist(wl_um=1.064, w0_mm=1.0)

# Build an optical system
sys = (OpticalSystem()
       .add(Propagation(100))
       .add(ThinLens(f_mm=50))
       .add(Interface(n1=1.0, n2=1.5))
       .add(Propagation(30)))

# Print system layout and beam state at each element
print(sys)
print(sys.summary(beam))

# Trace the full caustic
traj = sys.trace(beam, dz=0.5)

API Reference

GaussBeam

Immutable Gaussian beam value object (frozen dataclass).

Parameter Description Unit
wl_um Wavelength µm
n Refractive index
z_mm z-coordinate of wavefront mm
R_mm Wavefront curvature radius (inf at waist) mm
w_mm Beam radius (1/e² intensity half-width) mm

Key properties: .q (complex q-parameter), .theta (divergence half-angle in rad).

Constructors

GaussBeam.from_waist(wl_um, w0_mm, z_mm=0.0, n=1.0)  # from beam waist
GaussBeam.from_q(wl_um, n, q, z_mm=0.0)               # from complex q-parameter

Optical Elements

Each element implements apply(beam) -> GaussBeam based on its ABCD matrix.

Class Parameters Description
Propagation(d_mm) d — distance (mm) Free-space propagation
ThinLens(f_mm) f — focal length (mm) Thin lens
Interface(n1, n2) n1, n2 — refractive indices Flat dielectric interface
InterfaceCurved(n1, n2, r_mm) r > 0 convex, r < 0 concave (mm) Curved dielectric interface
CurvedMirrorTan(r_mm, theta_deg) r — radius (mm), θ — angle of incidence (deg) Curved mirror, tangential
CurvedMirrorSag(r_mm, theta_deg) r — radius (mm), θ — angle of incidence (deg) Curved mirror, sagittal

Custom elements can be added by subclassing Element and implementing the matrix property.

OpticalSystem

sys = OpticalSystem().add(element1).add(element2)  # fluent API

sys.trace(beam, dz=0.01)   # -> list[GaussBeam], full caustic trajectory
str(sys)                   # element layout table
sys.summary(beam)          # beam state at each element + waist report

Analysis (gbeampro.analysis)

from gbeampro.analysis import find_waists, rayleigh_range, confocal_parameter

find_waists(trajectory)      # -> list[GaussBeam] at waist locations
rayleigh_range(beam)         # -> float, z_R (mm)
confocal_parameter(beam)     # -> float, 2*z_R (mm)

Plot (gbeampro.plot)

import gbeampro.plot as gplot

gplot.plot_caustic(trajectory, ax)              # w vs z
gplot.plot_system(sys, trajectory, ax,
                  label="beam", beam_kw={})     # caustic + element symbols

Multiple beams can be overlaid by calling plot_system on the same ax; each label gets a distinct color from the matplotlib color cycle.

Display Example

OpticalSystem
=========================================================
   #  Type                Parameters                z (mm)
---------------------------------------------------------
   0  --- input ---                                  0.000
   1  Propagation         d =  100.000 mm          100.000
   2  ThinLens            f =   50.000 mm          100.000
   3  Propagation         d =  100.000 mm          200.000
=========================================================
Total length: 200.000 mm  |  3 elements

OpticalSystem trace  [wl=1.064 um]
========================================================================
   #  Type                   z (mm)     w (um)      R (mm)   th (urad)
------------------------------------------------------------------------
   0  --- input ---           0.000    1000.00         inf      338.68
   1  Propagation           100.000    1000.57   8.728e+04      338.49
   2  ThinLens              100.000    1000.57  -5.003e+01      338.49
   3  Propagation           200.000    1000.00   5.000e+01      338.68
========================================================================
Beam waists:  z=150.500 mm (2w0=39.0 um)

Examples

License

See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gbeampro-2.0.0.tar.gz (428.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gbeampro-2.0.0-py3-none-any.whl (361.6 kB view details)

Uploaded Python 3

File details

Details for the file gbeampro-2.0.0.tar.gz.

File metadata

  • Download URL: gbeampro-2.0.0.tar.gz
  • Upload date:
  • Size: 428.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for gbeampro-2.0.0.tar.gz
Algorithm Hash digest
SHA256 45d62c76f64fbbf81a9f98485ead99e2347b1503765163581990778314675472
MD5 7cb645784a4d91473c5275ee539b9cd1
BLAKE2b-256 a15300008d305690a1249cdffb4659a23b32cf5d9db9d281300ffcc46e6b7e1a

See more details on using hashes here.

File details

Details for the file gbeampro-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: gbeampro-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 361.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for gbeampro-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 862b733fb700f3c2cf93a9753b49213a40099e60f75b9a25695fb166b1711732
MD5 78c35f0353c83e45dec743ffea9ca9f9
BLAKE2b-256 2ed4c9ac9a89daa79b9238b9b99b106529439bf7732cc24019256f5c5d94e6d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page