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)| Row | wavelength | value | type | crosstype |
|---|---|---|---|---|
| Float64 | Float64 | String | String | |
| 1 | 450.0 | 3492.75 | average | extinction |
| 2 | 460.0 | 3490.16 | average | extinction |
| 3 | 470.0 | 3531.17 | average | extinction |
| 4 | 480.0 | 3625.73 | average | extinction |
| 5 | 490.0 | 3778.41 | average | extinction |
| 6 | 500.0 | 3978.55 | average | extinction |
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.