begin
    import Pkg
    Pkg.activate(joinpath(@__DIR__, ".."))
    using CoupledDipole
    using CairoMakie
end

Chiral gold-nanorod dimer

Two crossed nanorods couple to produce circular dichroism. Compare their orientation-averaged response with an isolated rod. All lengths are in nm; cross-sections are in nm^2 per particle. The host value below is its refractive index, whereas epsilon_Au returns the gold dielectric function.

Edit the separation or twist and rerun the notebook. The modest wavelength grid keeps this example quick; refine it and the angular cubature for research.

begin
    wavelengths = collect(450.0:1.0:850.0)
    material = Material(wavelengths, Dict("Au" => epsilon_Au, "medium" => λ -> 1.33))
    separation = 80.0
    twist = π / 4
    single = cluster_single(20, 20, 40)
    dimer = cluster_dimer(separation, 20, 20, 40, twist)
end
Cluster{Float64, Float64, Int64, ParticleDipole}(StaticArraysCore.SVector{3, Float64}[[0.0, -40.0, 0.0], [0.0, 40.0, 0.0]], Rotations.QuatRotation{Float64}[[1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0], [0.7071067811865475 0.0 -0.7071067811865476; 0.0 1.0 0.0; 0.7071067811865476 0.0 0.7071067811865475]], StaticArraysCore.SVector{3, Int64}[[20, 20, 40], [20, 20, 40]], ["Au", "Au"], [ParticleDipole(), ParticleDipole()])
begin
    isolated = spectrum_oa(single, material)
    coupled = spectrum_oa(dimer, material)
    @assert all(isfinite, coupled.average.extinction)
    @assert length(coupled.average.extinction) == length(wavelengths)
end
let
    fig = Figure(size=(800, 350))
    average = Axis(fig[1, 1], xlabel="Wavelength / nm", ylabel="Extinction / nm^2")
    dichroism = Axis(fig[1, 2], xlabel="Wavelength / nm", ylabel="Circular dichroism / nm^2")
    lines!(average, wavelengths, isolated.average.extinction; label="single")
    lines!(average, wavelengths, coupled.average.extinction; label="dimer")
    lines!(dichroism, wavelengths, coupled.dichroism.extinction)
    axislegend(average)
    fig
end