Skip to content

Repository files navigation

Laser Pulse Simulator

An interactive simulator of the Fourier relationship between a laser pulse's spectrum, spectral phase, electric field, intensity, and instantaneous angular frequency. Quantities use arbitrary, internally consistent units.

Launch the simulator · Source · Feedback

Plots and controls

  • Spectrum and phase: Gaussian spectral intensity S(ω), or a custom spectrum edited by dragging red points. The Gaussian bandwidth is the FWHM of intensity, and field amplitude is A(ω) = √S(ω).
  • Individual waves: always seven illustrative cosine waves, evenly spaced across the intensity FWHM. Each wave has a matching angular-frequency label on its left. Dots and arrows above and below the rows indicate the rest of the spectrum; the upper marker is omitted when the lowest displayed wave sits at zero frequency, since no spectrum lies below it. Custom spectra use the span between the outermost half-maximum crossings; gaps within that span may produce flat rows.
  • Electric field: E(t), with optional positive and negative amplitude envelopes.
  • Pulse intensity: |F(t)|², with an optional instantaneous E(t)² trace. The measured intensity FWHM is printed under the plot, taken from the outermost half-maximum crossings of the plotted |F(t)|² and interpolated between samples; when the pulse runs past the time limits the value is reported as a lower bound. For a slowly varying envelope, the cycle average of E(t)² is |F(t)|²/2; the physical intensity conversion factor is omitted.
  • Instantaneous angular frequency: ωinst(t), with a reference line at ω₀. Frequency is undefined at field zeros and hidden in weak tails.
  • Plot limits: a compact panel below the parameter controls sets frequency minimum/maximum and the shared time range. Frequency defaults to 1–12, with a minimum permitted view limit of 0. The central-frequency slider follows those bounds while preserving the current value if it is outside the view. The integral retains its full spectrum, including frequencies below the view, and custom data are preserved.
  • Auto time: enabled initially. Fit the current pulse when the frequency limits or central value change. Bandwidth, phase, and display controls leave the time view fixed, so changes to the pulse remain easy to compare. The fitted window spans about ten intensity FWHM of the pulse, centered on it: the outermost half-maximum crossings of |F(t)|² are located numerically, interpolating between samples, and their separation and midpoint set the view. Structure below half maximum — TOD satellites, sinc sidelobes, far chirped tails — can therefore lie outside it. Re-enabling auto time or resetting the limits also requests a fresh fit. Uncheck auto time to restore editable manual limits (initially −20–20). Later phase or bandwidth changes can move the pulse outside the frozen view; a fresh fit includes those changes. The corner-brackets fit button in the E(t) panel applies the same fit on demand for the current settings; with auto time off, the fitted range becomes the manual range.
  • Open-ended parameter inputs: type any finite phase value, nonnegative central frequency, or positive bandwidth. If the value falls outside its slider's range, the slider expands around it. Values already inside the range leave the slider limits unchanged, and typed precision is preserved. Changing the central-frequency number box also recenters the frequency plot and updates its limit inputs, preserving the current frequency span and the minimum view limit of 0.

Custom spectra persist across mode switches and view changes. On first use, the custom spectrum is seeded from the current Gaussian, including its tails. A shape-preserving cubic Hermite curve passes through its points, stays nonnegative, and has continuous first derivatives. Interior derivatives use the PCHIP weighted harmonic mean; the two outer slopes are zero. The plotted spectrum, integrated field, spectral centroid, and FWHM all use this same curve. The spectrum is zero outside its editable endpoints. Fit spectrum fits its domain subject to the frequency view minimum of 0. The custom auto-center is the intensity-weighted spectral centroid; disabling it lets ω₀ set the phase reference manually.

Numerical model

The complex field and spectral phase are

F(t) = ∫₀∞ √S(ω) exp[iΦ(ω) − iωt] dω / (2π)
E(t) = Re F(t)
I(t) ∝ |F(t)|²
Φ(ω) = c₀ + c₁(ω − ω₀) + ½c₂(ω − ω₀)² + ⅙c₃(ω − ω₀)³
ωinst(t) = −Im[F′(t) / F(t)]

Positive c₁ delays the pulse. c₂ is GDD and c₃ is TOD, including the Taylor-series factorials. Frequencies below zero are excluded; a broad Gaussian centered near zero therefore has a truncated spectrum.

pulse-math.js integrates independently of the display waves and frequency view:

  • Include the full nonnegative spectrum wherever A(ω) is at least 10⁻⁴ of its peak amplitude. Gaussian tails are bounded analytically; custom intervals are clipped at the same relative threshold.
  • Use composite Simpson quadrature with a base mesh of about 2,000 intervals across the retained frequency span, refining for phase variation across the time window and omitting empty regions. Quadrature weights include dω/(2π), so increasing the sample count does not increase field amplitude.
  • Compute F′ analytically with frequency-weighted samples, avoiding phase unwrapping and finite-difference errors. Hide ωinst where intensity is at most 10⁻⁶ of the transform-limited peak for the same retained spectrum. This reference does not depend on the selected time window.
  • Resolve the highest E(t)² oscillations with at least 16 time samples per cycle. Very large time ranges are capped at the time-sample limit and undersample the carrier rather than refusing to plot; limits are 65,536 spectral samples, 20,001 time samples, and 80 million sample pairs per update.

The phase-derivative calculation follows the instantaneous-frequency identity in Julius O. Smith's Spectral Audio Signal Processing, with a minus sign for the exp(−iωt) convention used here.

Run and verify

Open visualphase.html in a browser, or serve this directory with a static web server. Chart.js loads from its CDN. The shared /header.css, /footer.css, and /layout.js assets are supplied by the parent VisuPhy site and are optional for local simulation.

The numerical tests require Node.js 18 or later and no installed packages:

node --test tests/pulse-math.test.js

Tests compare against analytic Gaussian and sinc pulses, check the Gaussian time-bandwidth product and chirp sign, verify phase invariance and energy conservation, and cover custom support, empty spectra, positive-frequency truncation, and convergence at large GDD/TOD. They also check cubic continuity, nonnegative interpolation without overshoot, centroid/FWHM consistency, cutoff crossings, and automatic fitting of narrow, chirped, high-carrier-frequency, and custom pulses.

Credits

Originally created by Hussein-Tofaili, maintained under VisuPhy, and licensed under the MIT License.

About

A qualitative web-based simulator for visualizing laser pulse formation and the effects of spectral phase. Uses arbitrary units for conceptual understanding.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages