Skip to content

Commit c9a150a

Browse files
committed
version 1.0.0
1 parent 230f283 commit c9a150a

File tree

8 files changed

+226
-9
lines changed

8 files changed

+226
-9
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/Manifest.toml
22
/docs/build/
3-
/developper_notes
43

5-
/example_dev
4+
/result

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "jlmie"
22
uuid = "83f16f31-eeab-45e4-be0e-7fc4231b6e5b"
33
authors = ["Tatsuki Hinamoto"]
4-
version = "0.1.0"
4+
version = "1.0.0"
55

66
[deps]
77
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

developper_notes.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

example_dev/test.jl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This code separately visualize the 3D radiation pattern
2+
# of electric and magnetic resonances.
3+
# Because the amplitude of scattering intensity is normalized,
4+
# the setting of wavelength is not very important...
5+
6+
# import needed packages
7+
# for jlmie.jl
8+
include("..\\src\\jlmie.jl")
9+
using SpecialFunctions
10+
# for this script
11+
using Plots
12+
13+
# settings
14+
# structure
15+
nmat = 3.5 # refractive index of a sphere
16+
radius = 100*1e-9
17+
18+
# environment
19+
nenv = 1.00
20+
21+
# wavelenth (not very important)
22+
lbd0ED = 618*1e-9 # ED
23+
lbd0MD = 831*1e-9 # MD
24+
lbd0 = [lbd0ED lbd0MD]
25+
26+
# angular range
27+
theta = range(0,π,length=37) # per 5 degrees with length 37
28+
phi = range(0,2π,length=73) # per 5 degrees with length 73
29+
30+
# other settings
31+
n = 1
32+
EorH = 2 # 1: Eelectric, 2: Magnemtic
33+
Isff = zeros(length(theta),length(phi))
34+
for i = 1:length(theta)
35+
for j = 1:length(phi)
36+
Isff[i,j] = jlmie_Isff_EM_n(nmat,radius,lbd0[EorH],nenv,theta[i],phi[j],n)[EorH]
37+
end
38+
end
39+
Isff = Isff/maximum(Isff)
40+
mat_x = Isff.* (sin.(theta) .* cos.(phi)')
41+
mat_y = Isff.* (sin.(theta) .* sin.(phi)')
42+
mat_z = Isff.* (cos.(theta) .* cos.(phi*0)')
43+
44+
# Just a sphere
45+
# mat_x = 1 .* (sin.(theta) * cos.(phi)')
46+
# mat_y = 1 .* (sin.(theta) * sin.(phi)')
47+
# mat_z = 1 .* (cos.(theta) * cos.(phi*0)')
48+
49+
# show results
50+
pyplot()
51+
plt = plot(mat_x,mat_y,mat_z,
52+
st=:surface,
53+
camera=(30,30), # azimuth, elevate
54+
xlabel="x",
55+
ylabel="y",
56+
zlabel="z",
57+
xlims=(-1,1),
58+
ylims=(-1,1),
59+
zlims=(-1,1),
60+
)
61+
display(plt)
62+
63+
# save
64+
if false
65+
runningfilename = splitext(splitpath(@__FILE__)[end])[1]
66+
outfilename = ".\\result\\" * runningfilename
67+
savefig(plt,outfilename)
68+
println("Graph has been saved in result directory")
69+
end

example_dev/test2.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
using jlmie
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using jlmie
2+
using Plots
3+
4+
n = 3
5+
# angular range
6+
theta = range(0,2π,length=73) # per 5 degrees with length 73
7+
mu = cos.(theta)
8+
pin,taun = jlmie_pt(mu,n)
9+
# show results
10+
# validation can be done by comparing to ITMO Mie Calculator
11+
# https://physics.itmo.ru/en/mie
12+
plt = plot(theta, pin, proj=:polar,
13+
# xlabel = "Wavelength (nm)",
14+
# ylabel = "Scattering efficiency",
15+
# legend = false,
16+
label = "pi",
17+
# xlims =(-3,3),
18+
# ylims =(-3,3),
19+
# aspect_ratio =0.5,
20+
# title ="TITLE",
21+
# linecolor =:blue,
22+
# linewidth =5,
23+
# linestyle =:dot,
24+
# size =(400,300),
25+
) # https://qiita.com/I_ppp/items/dca3552affa6a672e4bd
26+
plot!(theta, taun, proj=:polar,label="tau")
27+
display(plt)
28+
29+
# save
30+
if true
31+
runningfilename = splitext(splitpath(@__FILE__)[end])[1]
32+
outfilename = ".\\result\\" * runningfilename
33+
savefig(plt,outfilename)
34+
println("Graph has been saved in result directory")
35+
end
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This code separately visualize the 3D radiation pattern
2+
# of electric and magnetic resonances.
3+
# Because the amplitude of scattering intensity is normalized,
4+
# the setting of wavelength is not very important...
5+
6+
using jlmie
7+
using Plots
8+
9+
# settings
10+
# structure
11+
nmat = 3.5 # refractive index of a sphere
12+
radius = 100*1e-9
13+
14+
# environment
15+
nenv = 1.00
16+
17+
# wavelenth (not very important)
18+
lbd0ED = 618*1e-9 # ED
19+
lbd0MD = 831*1e-9 # MD
20+
lbd0 = [lbd0ED lbd0MD]
21+
22+
# angular range
23+
theta = range(0,π,length=37) # per 5 degrees with length 37
24+
phi = range(0,2π,length=73) # per 5 degrees with length 73
25+
26+
# other settings
27+
n = 1
28+
EorH = 2 # 1: Eelectric, 2: Magnemtic
29+
Isff = zeros(length(theta),length(phi))
30+
for i = 1:length(theta)
31+
for j = 1:length(phi)
32+
Isff[i,j] = jlmie_Isff_EM_n(nmat,radius,lbd0[EorH],nenv,theta[i],phi[j],n)[EorH]
33+
end
34+
end
35+
Isff = Isff/maximum(Isff)
36+
mat_x = Isff.* (sin.(theta) * cos.(phi)')
37+
mat_y = Isff.* (sin.(theta) * sin.(phi)')
38+
mat_z = Isff.* (cos.(theta) * cos.(phi*0)')
39+
40+
# Just a sphere
41+
# mat_x = 1 .* (sin.(theta) * cos.(phi)')
42+
# mat_y = 1 .* (sin.(theta) * sin.(phi)')
43+
# mat_z = 1 .* (cos.(theta) * cos.(phi*0)')
44+
45+
# show results
46+
pyplot()
47+
plt = plot(mat_x,mat_y,mat_z,
48+
st=:surface,
49+
camera=(30,30), # azimuth, elevate
50+
xlabel="x",
51+
ylabel="y",
52+
zlabel="z",
53+
xlims=(-1,1),
54+
ylims=(-1,1),
55+
zlims=(-1,1),
56+
)
57+
display(plt)
58+
59+
# save
60+
if true
61+
runningfilename = splitext(splitpath(@__FILE__)[end])[1]
62+
outfilename = ".\\result\\" * runningfilename
63+
savefig(plt,outfilename)
64+
println("Graph has been saved in result directory")
65+
end

example_dev/xx03_cart2sph_check.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using jlmie
2+
using Plots
3+
4+
# # xz plot range
5+
# x = (-150:5:150)
6+
# y = 0.0
7+
# z = (-150:5:150)
8+
# # calculation using broadcast
9+
# r, theta, phi = cart2sph(x',y,z)
10+
# # heatmap(x,z,r)
11+
# # heatmap(x,z,theta)
12+
# # heatmap(x,z,phi)
13+
14+
# meshgrid type calculation
15+
# mat_x = x' .* ones(length(z))
16+
# mat_z = ones(length(x))' .* z
17+
# mat_r,mat_theta,mat_phi = cart2sph(mat_x,y,mat_z)
18+
# calculation using broadcast
19+
# r, theta, phi = cart2sph(x',y,z)
20+
# heatmap(x,z,r)
21+
# heatmap(x,z,theta)
22+
# heatmap(x,z,phi)
23+
24+
x = (-150:1:150)
25+
y = (-150:1:150)
26+
z = (-150:1:150)
27+
28+
xyz = 2 # 1:x, 2:y, 3:z
29+
if xyz == 1
30+
# xz plot range
31+
mat_x = x' .* ones(length(z))
32+
mat_z = ones(length(x))' .* z
33+
mat_r,mat_theta,mat_phi = cart2sph(mat_x,0,mat_z)
34+
p1 = heatmap(x,z,mat_r)
35+
p2 = heatmap(x,z,mat_theta)
36+
p3 = heatmap(x,z,mat_phi)
37+
elseif xyz == 2
38+
# yz plot range
39+
mat_y = y' .* ones(length(y))
40+
mat_z = ones(length(y))' .* z
41+
mat_r,mat_theta,mat_phi = cart2sph(0,mat_y,mat_z)
42+
p1 = heatmap(y,z,mat_r)
43+
p2 = heatmap(y,z,mat_theta)
44+
p3 = heatmap(y,z,mat_phi)
45+
elseif xyz == 3
46+
# xy plot range
47+
mat_x = x' .* ones(length(y))
48+
mat_y = ones(length(x))' .* y
49+
mat_r,mat_theta,mat_phi = cart2sph(mat_x,mat_y,0)
50+
p1 = heatmap(x,y,mat_r)
51+
p2 = heatmap(x,y,mat_theta)
52+
p3 = heatmap(x,y,mat_phi)
53+
end
54+
plot(p1,p2,p3)

0 commit comments

Comments
 (0)