Getting started

Installation

The package requires Julia 1.10 or later:

using Pkg
Pkg.add(url="https://github.com/nano-optics/CoupledDipole.jl")

For local development, clone the repository and run Pkg.develop(path=".") from an environment in which you want to use the checkout.

First spectrum

A Cluster describes the dipoles and a Material supplies optical functions. Particle functions return dielectric functions, while "medium" returns a refractive index (not a dielectric function).

using CoupledDipole

wavelengths = collect(450.0:10.0:850.0)
material = Material(wavelengths,
    Dict("Au" => epsilon_Au, "medium" => λ -> 1.33))
dimer = cluster_dimer(80, 20, 20, 40, π / 4)
response = spectrum_oa(dimer, material)
first(oa_df(response, wavelengths), 6)
6×4 DataFrame
Rowwavelengthvaluetypecrosstype
Float64Float64StringString
1450.03492.75averageextinction
2460.03490.16averageextinction
3470.03531.17averageextinction
4480.03625.73averageextinction
5490.03778.41averageextinction
6500.03978.55averageextinction

The distance, semi-axes and wavelengths above are in nm; cross-sections are in nm^2 per dipole, not the total for the cluster. The bundled material models expect wavelengths in nm. Molecular PointDipole() materials supply a polarisability instead of a dielectric function.

response.average contains orientation-averaged extinction, absorption and scattering; response.dichroism contains circular-dichroism differences. For direction-dependent illumination use spectrum_dispersion with rotation objects such as [RotZYZ(0.0, 0.0, 0.0)].

Convergence and limitations

The examples use modest wavelength and angular grids for fast execution. Increase N_inc and N_sca independently to check orientation/scattering convergence, especially for spatially extended clusters. Point dipoles do not resolve internal particle structure. The solver currently assumes a homogeneous host medium; planar interfaces and multilayer substrates are not implemented.

Plotting and interactive examples

Install and load CairoMakie, GLMakie, or WGLMakie before calling visualise_makie. The solver itself does not require a plotting backend. See Running the Pluto examples for interactive, plotted simulations.