Bläddra i källkod

digitize rs4 params for mesomie

Konstantin Ladutenko 2 år sedan
förälder
incheckning
52df45f1b0

+ 37 - 0
examples/NatureComm-2020-Plasmon–emitter_interactions_at_the_nanoscale/plot_d_param.py

@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+# -*- coding: UTF-8 -*-
+from cProfile import label
+from matplotlib import markers, pyplot as plt
+import numpy as np
+from scipy import interpolate
+
+arr2D = np.loadtxt('rs4-im-d_perp.csv', delimiter=',')
+im_d = arr2D[arr2D[:, 0].argsort()]
+arr2D = np.loadtxt('rs4-re-d_perp.csv', delimiter=',')
+re_d = arr2D[arr2D[:, 0].argsort()]
+
+xmin_im = np.min(im_d[:, 0])
+xmin_re = np.min(re_d[:, 0])
+xmax_im = np.max(im_d[:, 0])
+xmax_re = np.max(re_d[:, 0])
+x = np.linspace(np.max([xmin_im, xmin_re]), np.min([xmax_im, xmax_re]), 100)
+im_d_y = interpolate.interp1d(im_d[:, 0],  im_d[:, 1])
+re_d_y = interpolate.interp1d(re_d[:, 0],  re_d[:, 1])
+
+data = np.array([x.T, re_d_y(x).T, im_d_y(x).T])
+np.savetxt('rs4-d_perp.txt', data)
+
+# print(data)
+# plt.plot(im_d[:, 0], im_d[:, 1], marker='o', ls='')
+# plt.plot(x, im_d_y(x))
+# plt.plot(re_d[:, 0], re_d[:, 1], marker='o', ls='')
+# plt.plot(x, re_d_y(x))
+# plt.xlim((0, 1))
+# plt.ylim((-4, 5))
+# plt.show()
+
+from_disk = np.loadtxt('rs4-d_perp.txt')
+plt.plot(from_disk[0, :], from_disk[1, :], label='re d')
+plt.plot(from_disk[0, :], from_disk[2, :], label='im d')
+plt.legend()
+plt.show()

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
examples/NatureComm-2020-Plasmon–emitter_interactions_at_the_nanoscale/rs4-d_perp.txt


+ 63 - 0
examples/NatureComm-2020-Plasmon–emitter_interactions_at_the_nanoscale/rs4-im-d_perp.csv

@@ -0,0 +1,63 @@
+0.014904519311841613, 0.002873130514824851
+0.03784700868518426, 0.004484850335447987
+0.0607894980585269, 0.00649950011122602
+0.0837319874318696, 0.009722939752472293
+0.10667447680521225, 0.011737589528251213
+0.12961696617855495, 0.012946379393718566
+0.1525594555518976, 0.01737860890043219
+0.17550194492524024, 0.02019911858652179
+0.19844443429858294, 0.025437208003546985
+0.22138692367192558, 0.028660647644793258
+0.24432941304526828, 0.035107526927284916
+0.26727190241861093, 0.04074854629946589
+0.2902143917919536, 0.05001593526804804
+0.3131568811652962, 0.06049211410209754
+0.33609937053863886, 0.07258001275677017
+0.3590418599119816, 0.0874884210975333
+0.38198434928532427, 0.10642612898985337
+0.4049268386586669, 0.13019899634404375
+0.42786932803200955, 0.16082167293588068
+0.4508118174053522, 0.19829415876536594
+0.47375430677869496, 0.24906333311499118
+0.4966967961520376, 0.3111145462089775
+0.5196392855253802, 0.3844477980473249
+0.542581774898723, 0.4597956996614512
+0.5655242642720655, 0.5299055118585532
+0.5884667536454082, 0.6028358337417448
+0.611409243018751, 0.6781837353558711
+0.6343517323920935, 0.7676341854004489
+0.6572942217654363, 0.8788428530234373
+0.680392570441587, 1.000557731526822
+0.7019842791905933, 1.1891734742401745
+0.7175182563704607, 1.418607820950089
+0.7307818830394244, 1.6466808275666152
+0.7425272567351524, 1.9523173272649688
+0.7540828488092255, 2.3360213634777742
+0.7483472264658899, 2.134152813313233
+0.7673653426569502, 2.869399639152829
+0.7612523767383952, 2.632125397891183
+0.7796063682370693, 3.532363713698813
+0.7720066686321496, 3.157008819474081
+0.7748744798038174, 3.3101222024332677
+0.7917627011480834, 4.2449931671043935
+0.7850552094632381, 3.856172877660348
+0.7877796300763227, 4.022502363148644
+0.8059424341635522, 4.772608706331937
+0.7985339219700769, 4.533954786226349
+0.8282476321654131, 4.388183682450002
+0.8229103169292535, 4.609168377855425
+0.8335212182644245, 4.120494928242524
+0.8404039650764275, 3.713620096954386
+0.8358154672017588, 3.9838210874536917
+0.8464263685369298, 3.419074462307384
+0.8536675917453909, 3.0273048216018448
+0.8487206174742641, 3.277887806020807
+0.8657681616614006, 2.494162181245852
+0.8601918621609355, 2.763211943301855
+0.8771597449266368, 2.1284417899488437
+0.8927733835279392, 1.7897173567901667
+0.9090201207943325, 1.5624120071709093
+0.9311701886597143, 1.4522121792100782
+0.9541126780330569, 1.450600459389455
+0.976924812353142, 1.5461343064492858
+0.9913942232647388, 1.711887104309458

+ 62 - 0
examples/NatureComm-2020-Plasmon–emitter_interactions_at_the_nanoscale/rs4-re-d_perp.csv

@@ -0,0 +1,62 @@
+0.014904519311841613, 0.6189530319479752
+0.03784700868518426, 0.6205647517685984
+0.0607894980585269, 0.6237881914098438
+0.0837319874318696, 0.629026280826869
+0.10667447680521225, 0.6342643702438941
+0.12961696617855495, 0.6415171094366974
+0.1525594555518976, 0.6515903583155911
+0.17550194492524024, 0.6620665371496406
+0.19844443429858294, 0.6757661556249364
+0.22138692367192558, 0.6898687040553879
+0.24432941304526828, 0.7071946921270857
+0.26727190241861093, 0.7253265401090943
+0.2902143917919536, 0.7486964775081288
+0.3131568811652962, 0.7740810646829415
+0.33609937053863886, 0.8026890914989995
+0.3590418599119816, 0.8337146980459931
+0.38198434928532427, 0.869978394010011
+0.4049268386586669, 0.9086596697049636
+0.42786932803200955, 0.951370244951474
+0.4508118174053522, 1.0001247695253204
+0.47375430677869496, 1.0512968738301014
+0.4966967961520376, 1.0992455384936362
+0.5196392855253802, 1.1367180243231214
+0.542581774898723, 1.1661319110494919
+0.5655242642720655, 1.1947399378655499
+0.5884667536454082, 1.2297948439641004
+0.611409243018751, 1.2781464385827919
+0.6343517323920935, 1.3442269512283351
+0.6572942217654363, 1.433677401272913
+0.6802367111387788, 1.552944667999017
+0.703771465862792, 1.6873305673903127
+0.7243691386138895, 1.8589296759442986
+0.7442844939726938, 2.080917219238109
+0.7662710462888138, 2.0906238193006663
+0.7795557598046281, 1.8796463703781212
+0.7909660869337312, 1.4059785497402828
+0.7849118189046547, 1.6758383043215224
+0.7959050950627147, 1.08272541033225
+0.8037634599890007, 0.5239055800893428
+0.7992508747629938, 0.8441908768800426
+0.807376339749386, 0.19305606934834163
+0.8158841795586673, -0.5990719880914632
+0.8102919477739152, -0.07771286051632664
+0.8121560250354991, -0.28240127773545076
+0.8202814900218913, -0.9244030062836206
+0.828730286659991, -1.5885579817780018
+0.8236272697221705, -1.172070618719359
+0.8257781281009213, -1.344524639526023
+0.8400375225378254, -2.1596915325965806
+0.8350985144088419, -1.866721861407882
+0.8551731926105166, -2.4183777400111275
+0.8781156819838594, -2.3969776823928566
+0.9010581713572019, -2.2793221354873765
+0.9240006607305447, -2.2321793307341533
+0.9466035408861899, -2.3763824075120823
+0.9556899741774743, -2.4791000401101595
+0.9644141576365479, -2.7613402728785754
+0.9700290300358134, -3.0149110616197223
+0.9769755059849643, -3.3815474741481157
+0.9734704034418149, -3.139980519700071
+0.9799229785780674, -3.709454856320205
+0.9820738369568183, -3.9093081140774597

+ 37 - 0
examples/NatureComm-2020-Plasmon–emitter_interactions_at_the_nanoscale/suppFig5.py

@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+# -*- coding: UTF-8 -*-
+from cProfile import label
+from matplotlib import markers, pyplot as plt
+import numpy as np
+from scipy import interpolate
+
+arr2D = np.loadtxt('rs4-im-d_perp.csv', delimiter=',')
+im_d = arr2D[arr2D[:, 0].argsort()]
+arr2D = np.loadtxt('rs4-re-d_perp.csv', delimiter=',')
+re_d = arr2D[arr2D[:, 0].argsort()]
+
+xmin_im = np.min(im_d[:, 0])
+xmin_re = np.min(re_d[:, 0])
+xmax_im = np.max(im_d[:, 0])
+xmax_re = np.max(re_d[:, 0])
+x = np.linspace(np.max([xmin_im, xmin_re]), np.min([xmax_im, xmax_re]), 100)
+im_d_y = interpolate.interp1d(im_d[:, 0],  im_d[:, 1])
+re_d_y = interpolate.interp1d(re_d[:, 0],  re_d[:, 1])
+
+data = np.array([x.T, re_d_y(x).T, im_d_y(x).T])
+np.savetxt('rs4-d_perp.txt', data)
+
+# print(data)
+# plt.plot(im_d[:, 0], im_d[:, 1], marker='o', ls='')
+# plt.plot(x, im_d_y(x))
+# plt.plot(re_d[:, 0], re_d[:, 1], marker='o', ls='')
+# plt.plot(x, re_d_y(x))
+# plt.xlim((0, 1))
+# plt.ylim((-4, 5))
+# plt.show()
+
+from_disk = np.loadtxt('rs4-d_perp.txt')
+plt.plot(from_disk[0, :], from_disk[1, :], label='re d')
+plt.plot(from_disk[0, :], from_disk[2, :], label='im d')
+plt.legend()
+plt.show()

+ 12 - 10
tests/test_py.py

@@ -2,8 +2,12 @@ import unittest
 from scattnlay import mie, mie_mp
 from scattnlay import mesomie
 
+# A list of tests for a bulk sphere from
+# Hong Du, "Mie-scattering calculation," Appl. Opt. 43, 1951-1956 (2004)
+# table 1: sphere size and refractive index
+# followed by resulting extinction and scattering efficiencies
 test_cases = [
-    # x, {Re(m), Im(m)}, Qext, Qsca, test_name
+    # x, m, Qext, Qsca #, test_name
     [0.099, 0.75+0j, 7.417859e-06, 7.417859e-06],  # ,'a'],
     [0.101, 0.75+0j, 8.033538e-06, 8.033538e-06],  # ,'b'],
     [10, 0.75+0j, 2.232265, 2.232265],  # ,'c'],
@@ -31,18 +35,16 @@ class TestStringMethods(unittest.TestCase):
             for case in test_cases:
                 x = case[0]
                 m = case[1]
-                solver.calc_ab(x,        # R
-                               x,   # xd
-                               x * m,    # xm
-                               1,   # eps_d
-                               m * m,    # eps_m
-                               0,   # d_parallel
-                               0)   # d_perp
-                # solver.calc_ab()
+                solver.calc_ab(x,      # R
+                               x,      # xd
+                               x * m,  # xm
+                               1,      # eps_d
+                               m * m,  # eps_m
+                               0,      # d_parallel
+                               0)      # d_perp
                 solver.calc_Q()
                 Qext = solver.GetQext()
                 Qsca = solver.GetQsca()
-                # print(Qext)
                 self.assertTrue((case[2]-Qext)/Qext < tol)
                 self.assertTrue((case[3]-Qsca)/Qsca < tol)
 

Vissa filer visades inte eftersom för många filer har ändrats