From b2a305b5955431f924ee1ecc792419e4458ec896 Mon Sep 17 00:00:00 2001 From: baptiste Date: Mon, 21 Nov 2022 21:48:27 +1300 Subject: [PATCH] fixed --- dev/book/dimer_linear.jl | 14 ++++++++++---- src/Clusters.jl | 8 ++++---- src/HighLevel.jl | 4 ++-- src/Materials.jl | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dev/book/dimer_linear.jl b/dev/book/dimer_linear.jl index b8f5734..355c3e5 100644 --- a/dev/book/dimer_linear.jl +++ b/dev/book/dimer_linear.jl @@ -10,6 +10,8 @@ using FastGaussQuadrature using DataFrames using VegaLite +using AlgebraOfGraphics, CairoMakie + # dimer_model <- function(d, orientation = c("head-to-tail", "side-by-side"), @@ -95,10 +97,16 @@ wavelength = collect(450:2:850.0) media = Dict([("Au", epsilon_Au), ("medium", x -> 1.33)]) mat = Material(wavelength, media) +sizes = [SVector(0.0, 0.0, 0.0)] +positions = [SVector(0.0, 0.0, 0.0)] +# input parameters are Euler angles +rotations = [UnitQuaternion(RotZYZ(0.0, 0.0, 0.0))] +Cluster(positions, rotations, sizes, ["Au"], "particle") + cl0 = cluster_single(20.0, 50.0, 20.0) # cl0 = cluster_single(50.0, 20.0, 20.0) -# s = spectrum_dispersion(cl0, mat, [UnitQuaternion(RotZ(0.0))]) -s = spectrum_dispersion(cl0, mat, [SVector(0.0, 0.0, 0.0)]) + +s = spectrum_dispersion(cl0, mat, [UnitQuaternion(RotZ(0.0))]) single = dispersion_df(s, mat.wavelengths) @@ -119,8 +127,6 @@ draw(layer * xy, facet=(; linkyaxes=:none)) # encoding = {x = "wavelength:q", y = "value:q", color = "d:n", strokeDash = "cluster:n"} # ) -using AlgebraOfGraphics, CairoMakie - # set_aog_theme!() diff --git a/src/Clusters.jl b/src/Clusters.jl index 2b501c1..5ab3548 100644 --- a/src/Clusters.jl +++ b/src/Clusters.jl @@ -49,7 +49,7 @@ function cluster_single(a, b, c, α=0.0, β=0.0, γ=0.0, material="Au", type="pa sizes = [SVector(a, b, c)] positions = [SVector(0.0, 0.0, 0.0)] # input parameters are Euler angles - rotations = [UnitQuaternion(RotZYZ([α, β, γ]))] + rotations = [Rotations.UnitQuaternion(Rotations.RotZYZ(α, β, γ))] Cluster(positions, rotations, sizes, [material], type) end @@ -159,7 +159,7 @@ cluster_line(3, 500, 20, 20, 30, 0, 0, 0) function cluster_line(N, Λ, a, b, c, α=0.0, β=0.0, γ=0.0, material="Au", type="particle") sizes = [SVector(a, b, c) for ii in 1:N] # identical particles - rotations = [UnitQuaternion(RotZYZ([α, β, γ])) for _ ∈ 1:N] # identical particles + rotations = [UnitQuaternion(RotZYZ(α, β, γ)) for _ ∈ 1:N] # identical particles positions = SVector.(-(N - 1)*Λ/2:Λ:(N-1)*Λ/2, zero(eltype(Λ)), zero(eltype(Λ))) @@ -192,7 +192,7 @@ function cluster_array(N, Λ, a, b, c, α=0.0, β=0.0, γ=0.0, material="Au", ty N = N′^2 # actual number, may have fewer than original N particles sizes = [SVector(a, b, c) for _ ∈ 1:N] # identical particles - rotations = [UnitQuaternion(RotZYZ([α, β, γ])) for _ ∈ 1:N] # identical particles + rotations = [UnitQuaternion(RotZYZ(α, β, γ)) for _ ∈ 1:N] # identical particles x = -(N′ - 1)*Λ/2:Λ:(N′-1)*Λ/2 positions = SVector.(Iterators.product(x, x, zero(eltype(x))))[:] @@ -245,7 +245,7 @@ function cluster_shell(N, a, b, c, R; orientation="radial", material="Rhodamine" end - quaternions = [UnitQuaternion(RotZYZ([r[1], r[2], r[3]])) for r in rotations] + quaternions = [UnitQuaternion(RotZYZ(r[1], r[2], r[3])) for r in rotations] Cluster(positions, inv.(quaternions), sizes, [material for _ ∈ 1:N], type) diff --git a/src/HighLevel.jl b/src/HighLevel.jl index 4e00a44..a3864b2 100644 --- a/src/HighLevel.jl +++ b/src/HighLevel.jl @@ -54,8 +54,8 @@ function spectrum_dispersion( # store all rotation matrices # ParticleRotations = map(euler_passive, cl.angles) ParticleRotations = map(RotMatrix, cl.rotations) # now (active) Rotation objects - IncidenceRotations = map(euler_active, Incidence) # old Euler, no longer needed - #IncidenceRotations = map(RotMatrix, Incidence) # now given as quaternions + # IncidenceRotations = map(euler_active, Incidence) # old Euler, no longer needed + IncidenceRotations = map(RotMatrix, Incidence) # now given as quaternions ScatteringVectors = map(euler_unitvector, quad_sca.nodes) # NOTE: we only need the third column to rotate kz, should specialise diff --git a/src/Materials.jl b/src/Materials.jl index 8e068f5..4d438ad 100644 --- a/src/Materials.jl +++ b/src/Materials.jl @@ -265,7 +265,7 @@ function alpha_kuwata(λ, ε, ε_m, Size) V = 4π / 3 * prod(Size) x = @. 2π / λ * Size - χ = depolarisation_spheroid(Size...) + χ = depolarisation_ellipsoid(Size...) A = @. -0.4865 * χ - 1.046 * χ^2 + 0.8481 * χ^3 B = @. 0.01909 * χ + 0.19999 * χ^2 + 0.6077 * χ^3