Getting Started

This guide will help you get your first band structure calculation running in under 5 minutes.

Installation

using Pkg
Pkg.add("PhoXonic")
Pkg.add("Plots")  # For plotting

Your First Calculation: 2D Photonic Crystal

See also: examples/101_triangular_rods.jl

Let's compute the band structure of a 2D photonic crystal with dielectric rods in a triangular lattice.

Step 1: Define the Structure

A triangular lattice photonic crystal with dielectric rods (ε = 12) in air.

using PhoXonic

# Create triangular (hexagonal) lattice with period a = 1
lat = hexagonal_lattice(1.0)

# Define materials
air = Dielectric(1.0)
rod = Dielectric(12.0)  # High dielectric (e.g., GaAs or Si)

# Geometry: air background with dielectric rod at center
geo = Geometry(lat, air, [(Circle([0.0, 0.0], 0.2), rod)])

Step 2: Create Solver and Compute Bands

# Create solver for TM polarization
solver = Solver(TMWave(), geo, (64, 64); cutoff=7)

# Define k-path: Γ → M → K → Γ
kpath = simple_kpath_hexagonal(; a=1.0, npoints=30)

# Compute band structure
bands = compute_bands(solver, kpath; bands=1:8)

Parameters:

  • (64, 64): Grid resolution for discretizing the unit cell
  • cutoff=7: Number of reciprocal lattice vectors included (higher = more accurate but slower)

The returned bands object is a BandStructure containing frequencies, k-points, and labels. It can be passed directly to plot_bands and find_all_gaps. See Workflow for details.

Step 3: Find Band Gaps

gaps = find_all_gaps(bands)
for g in gaps
    println("Gap between bands $(g.bands): $(round(g.gap_ratio*100; digits=1))% gap-to-midgap")
end

Expected output:

Gap between bands (1, 2): 47.4% gap-to-midgap

Plotting the Band Structure

using Plots

plot_bands(bands;
    xlabel = "Wave vector",
    ylabel = "Frequency (ωa/2πc)",
    title = "2D Photonic Crystal (TM)"
)

2D Photonic Crystal Band Structure

This band diagram shows a clear photonic band gap between the first and second bands (~50% gap-to-midgap ratio).

Next Steps

Now that you've run your first calculation, explore more:

  • Workflow: Detailed workflow for 2D photonic and phononic crystals
  • 3D Calculations: Full vector EM and elastic wave calculations
  • Examples: Complete example scripts with various structures
  • Solver Methods: Choose the right solver for your problem size
  • API Reference: Full documentation of all functions

Quick Reference

StructureWave TypeLatticeExample
1D photonicPhotonic1D()lattice_1d(a)301
1D phononicLongitudinal1D()lattice_1d(a)302
2D photonic TETEWave()square_lattice(a), hexagonal_lattice(a)103
2D photonic TMTMWave()square_lattice(a), hexagonal_lattice(a)101
2D phononic SHSHWave()square_lattice(a), hexagonal_lattice(a)201
2D phononic P-SVPSVWave()square_lattice(a), hexagonal_lattice(a)201
3D photonicTransverseEM()cubic_lattice(a), fcc_lattice(a)401
3D phononicFullElastic()cubic_lattice(a), fcc_lattice(a)