Chiral dimer of gold nanorods

This example considers the "fingers-crossed" configuration of two gold nanorods arranged in a chiral dimer, with a pi/4 dihedral angle. The dipole-dipole interaction leads to circular dichroism with a characteristic bisignate lineshape.

using CoupledDipole
using DataFrames
using VegaLite


## materials
wavelength = collect(450:2:850.0)
media = Dict([("Au", epsilon_Au), ("medium", x -> 1.33)])
mat = Material(wavelength, media)

## dimer geometry
cl0 = cluster_single(20, 20, 40)
cl1 = cluster_dimer(80, 20, 20, 40, π/4)
Cluster{Float64, Float64, Int64}(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]], SVector{3, Int64}[[20, 20, 40], [20, 20, 40]], ["Au", "Au"], "particle")

The following lines simulate the orientation-averaged optical response,

oa0 = spectrum_oa(cl0, mat)
oa1 = spectrum_oa(cl1, mat)
(average = CoupledDipole.CrossSections{Float64}([3492.745567817046, 3489.2759312756307, 3487.1919489766883, 3486.5842766774617, 3487.543610351832, 3490.1603103945417, 3494.5239353642314, 3500.7226614497126, 3508.842559600603, 3518.9666975909226  …  245.7288426045276, 241.8676138081775, 238.10092665919262, 234.4255881841741, 230.83854252705464, 227.33686386140837, 223.9177497280484, 220.5785147690094, 217.31658483119617, 214.12949141498706], [3074.8498218254454, 3076.0694669658697, 3078.337069650577, 3081.719485584245, 3086.283010845896, 3092.092957441595, 3099.213139385334, 3107.7052487307283, 3117.628097524427, 3129.0366979290857  …  94.5252916823758, 93.14529270606448, 91.8011640982456, 90.4915839293593, 89.21529159943904, 87.9710844663641, 86.75781468659565, 85.57438625336138, 84.4197522184325, 83.29291208471203], [417.85471171367294, 413.1665739416112, 408.81604755439054, 404.82693339582625, 401.22363200106304, 398.0311922227568, 395.2753588676379, 392.9826161053122, 391.1802226195683, 389.896233523129  …  151.20389963745, 148.7226620688931, 146.3000959908846, 143.9343303526015, 141.6235698912322, 139.36609141602037, 137.1602403051162, 135.0044272013622, 132.89712489415498, 130.8368653754495]), dichroism = CoupledDipole.CrossSections{Float64}([42.38643884277195, 42.22440559713411, 42.11790447714539, 42.06733213492995, 42.07310284912545, 42.13571266084481, 42.25580807205816, 42.43426043179411, 42.672247530883304, 42.97134436125995  …  7.343552256564733, 7.202304612206879, 7.064129118102884, 6.92896309776668, 6.796743978555322, 6.667409449626792, 6.540897599202046, 6.417147033388624, 6.296096978581179, 6.177687369240638], [10.49104633441688, 10.632564687588943, 10.789255258915444, 10.957717104134531, 11.134383903384407, 11.315544723254865, 11.497363745693082, 11.675899711147595, 11.847126204250992, 12.006954356179811  …  -4.170971079128533, -4.068337103046258, -3.9693728693147685, -3.873908951666494, -3.781785378905429, -3.6928510219120367, -3.606963025640219, -3.5239862824344668, -3.4437929433253034, -3.366261964254877], [31.899106365025197, 31.595811353206738, 31.332892622785923, 31.11414786549935, 30.943557968297984, 30.82533040118068, 30.763948199813576, 30.764224920932303, 30.831365962846522, 30.97103663274411  …  11.513745091653888, 11.269884695338106, 11.032765503400249, 10.802155439322728, 10.577831984339262, 10.359581722456747, 10.147199909770336, 9.940490066656874, 9.739263591520583, 9.543339394844532]))

From there we combine the cross-sections in long-format dataframes for plotting,

d0 = oa_df(oa0, mat.wavelengths)
d1 = oa_df(oa1, mat.wavelengths)

d = [insertcols!(d1, :cluster => "dimer");
     insertcols!(d0, :cluster => "single")]

d |> @vlplot(
 width= 400,
 height =  300,
     mark = {:line},
     row = "type",
     resolve={scale={y="independent"}},
     encoding = {x = "wavelength:q", y = "value:q", color = "variable:n", strokeDash="cluster:n"}
 )