Commit edf1d940db8f3ccae236b8fa02b3c7ecdd56a840

Authored by dmayerich
1 parent 5e1cbbab

UI modifications and added more material files.

CMakeLists.txt
... ... @@ -27,6 +27,8 @@ configure_file(cyl3000fvp5.pos ${CMAKE_CURRENT_BINARY_DIR}/cyl3000fvp5.pos @ONLY
27 27 configure_file(cylslab3000.pos ${CMAKE_CURRENT_BINARY_DIR}/cylslab3000.pos @ONLY)
28 28 configure_file(etaGold.txt ${CMAKE_CURRENT_BINARY_DIR}/etaGold.txt @ONLY)
29 29 configure_file(etaSilver.txt ${CMAKE_CURRENT_BINARY_DIR}/etaSilver.txt @ONLY)
  30 +configure_file(etaSilverAnalytic.txt ${CMAKE_CURRENT_BINARY_DIR}/etaSilverAnalytic.txt @ONLY)
  31 +configure_file(etaSilverPalik.txt ${CMAKE_CURRENT_BINARY_DIR}/etaSilverPalik.txt @ONLY)
30 32 configure_file(mstm_guiwindow.ui ${CMAKE_CURRENT_BINARY_DIR}/mstm_guiwindow.ui @ONLY)
31 33  
32 34  
... ...
etaSilverAnalytic.txt 0 → 100755
  1 +lambda n k
  2 +0.0100000000000000 1.99874212285352 7.40160564289515e-07
  3 +0.0200000000000000 1.99496373791465 5.93249304218415e-06
  4 +0.0300000000000000 1.98865049436344 2.00856923709213e-05
  5 +0.0400000000000000 1.97977816906083 4.78237796031694e-05
  6 +0.0500000000000000 1.96831219444569 9.39496422498963e-05
  7 +0.0600000000000000 1.95420696748117 0.000163516145663353
  8 +0.0700000000000000 1.93740490652807 0.000261908274293207
  9 +0.0800000000000000 1.91783520880517 0.000394940720131893
  10 +0.0900000000000000 1.89541224242518 0.000568976766003941
  11 +0.100000000000000 1.87003348167680 0.000791076435636021
  12 +0.110000000000000 1.84157685895607 0.00106918505900473
  13 +0.120000000000000 1.80989735642963 0.00141237821762450
  14 +0.130000000000000 1.77482258702928 0.00183118647403141
  15 +0.140000000000000 1.73614700450444 0.00233803504447199
  16 +0.150000000000000 1.69362421378938 0.00294785264195312
  17 +0.160000000000000 1.64695658740033 0.00367893559804121
  18 +0.170000000000000 1.59578096190723 0.00455420855720960
  19 +0.180000000000000 1.53964846170926 0.00560312245782817
  20 +0.190000000000000 1.47799522295529 0.00686461815031610
  21 +0.200000000000000 1.41009844732108 0.00839195805439517
  22 +0.210000000000000 1.33500765672896 0.0102610243716721
  23 +0.220000000000000 1.25143152158357 0.0125855176537332
  24 +0.230000000000000 1.15753908229747 0.0155471652403854
  25 +0.240000000000000 1.05057962634948 0.0194626090377881
  26 +0.250000000000000 0.926065577974920 0.0249555548554986
  27 +0.260000000000000 0.775684807682064 0.0335132110894466
  28 +0.270000000000000 0.580193703304924 0.0501754876831495
  29 +0.280000000000000 0.268709074846921 0.120825004070894
  30 +0.290000000000000 0.0744887505624970 0.484239038793258
  31 +0.300000000000000 0.0549251629349535 0.727009425670726
  32 +0.310000000000000 0.0482298084669144 0.913498864267024
  33 +0.320000000000000 0.0451717819368366 1.07278258652603
  34 +0.330000000000000 0.0437226143632531 1.21549992488752
  35 +0.340000000000000 0.0431530234438622 1.34689796418303
  36 +0.350000000000000 0.0431304964260104 1.47000389708942
  37 +0.360000000000000 0.0434799352355059 1.58674361280351
  38 +0.370000000000000 0.0440996700890492 1.69842749464179
  39 +0.380000000000000 0.0449263229086013 1.80599203432380
  40 +0.390000000000000 0.0459181900705482 1.91013212769992
  41 +0.400000000000000 0.0470466346082099 2.01137892751222
  42 +0.410000000000000 0.0482913014138866 2.11014830644610
  43 +0.420000000000000 0.0496373031388701 2.20677241771830
  44 +0.430000000000000 0.0510734868153768 2.30152102443833
  45 +0.440000000000000 0.0525913241260602 2.39461636853598
  46 +0.450000000000000 0.0541841772767239 2.48624381273028
  47 +0.460000000000000 0.0558467994703216 2.57655963175531
  48 +0.470000000000000 0.0575749865868963 2.66569683000611
  49 +0.480000000000000 0.0593653290240664 2.75376956130967
  50 +0.490000000000000 0.0612150315026381 2.84087653848472
  51 +0.500000000000000 0.0631217799867603 2.92710369970778
  52 +0.510000000000000 0.0650836418940100 3.01252631934372
  53 +0.520000000000000 0.0670989902343180 3.09721069752415
  54 +0.530000000000000 0.0691664452177764 3.18121552613657
  55 +0.540000000000000 0.0712848287962605 3.26459300330508
  56 +0.550000000000000 0.0734531289050373 3.34738975027905
  57 +0.560000000000000 0.0756704710652806 3.42964757155490
  58 +0.570000000000000 0.0779360956333116 3.51140408949253
  59 +0.580000000000000 0.0802493394251032 3.59269327761261
  60 +0.590000000000000 0.0826096207624066 3.67354591146684
  61 +0.600000000000000 0.0850164272178162 3.75398995196845
  62 +0.610000000000000 0.0874693055058289 3.83405087301163
  63 +0.620000000000000 0.0899678530930330 3.91375194285001
  64 +0.630000000000000 0.0925117111951267 3.99311446687103
  65 +0.640000000000000 0.0951005589000495 4.07215799796532
  66 +0.650000000000000 0.0977341082111723 4.15090051955538
  67 +0.660000000000000 0.100412099846559 4.22935860544490
  68 +0.670000000000000 0.103134299662948 4.30754755992730
  69 +0.680000000000000 0.105900495598587 4.38548154100979
  70 +0.690000000000000 0.108710495049113 4.46317366913715
  71 +0.700000000000000 0.111564122606523 4.54063612341488
  72 +0.710000000000000 0.114461218103929 4.61788022701646
  73 +0.720000000000000 0.117401634918919 4.69491652319959
  74 +0.730000000000000 0.120385238496467 4.77175484314199
  75 +0.740000000000000 0.123411905058980 4.84840436662883
  76 +0.750000000000000 0.126481520476390 4.92487367647474
  77 +0.760000000000000 0.129593979273616 5.00117080743895
  78 +0.770000000000000 0.132749183756328 5.07730329028678
  79 +0.780000000000000 0.135947043238885 5.15327819156209
  80 +0.790000000000000 0.139187473360812 5.22910214956021
  81 +0.800000000000000 0.142470395480209 5.30478140692704
  82 +0.810000000000000 0.145795736134189 5.38032184025495
  83 +0.820000000000000 0.149163426557888 5.45572898700022
  84 +0.830000000000000 0.152573402254762 5.53100807000590
  85 +0.840000000000000 0.156025602611934 5.60616401987992
  86 +0.850000000000000 0.159519970555181 5.68120149544840
  87 +0.860000000000000 0.163056452238887 5.75612490247800
  88 +0.870000000000000 0.166634996766918 5.83093841083923
  89 +0.880000000000000 0.170255555940882 5.90564597026278
  90 +0.890000000000000 0.173918084032711 5.98025132482400
  91 +0.900000000000000 0.177622537578868 6.05475802627589
... ...
etaSilverPalik.txt 0 → 100755
  1 +lambda n k
  2 +1.240E-4 0.9990 1.29E-6
  3 +1.550E-4 1.000 2.92E-6
  4 +2.066E-4 1.002 8.36E-6
  5 +2.480E-4 1.001 1.52E-5
  6 +2.755E-4 1.001 2.21E-5
  7 +3.099E-4 1.003 3.57E-5
  8 +3.444E-4 1.003 3.24E-5
  9 +3.542E-4 1.003 1.72E-5
  10 +4.133E-4 1.001 1.43E-5
  11 +4.959E-4 1.001 2.40E-5
  12 +6.199E-4 1.001 4.72E-5
  13 +8.265E-4 0.999 1.21E-4
  14 +12.40E-4 0.998 5.23E-4
  15 +15.50E-4 0.997 1.08E-3
  16 +16.75E-4 0.998 1.42E-3
  17 +20.66E-4 0.997 2.69E-3
  18 +24.80E-4 0.997 4.57E-3
  19 +30.99E-4 0.998 8.82E-3
  20 +33.51E-4 1.007 8.23E-3
  21 +35.42E-4 1.001 1.68E-3
  22 +41.33E-4 0.996 2.32E-3
  23 +44.28E-4 0.994 2.70E-3
  24 +47.68E-4 0.992 3.11E-3
  25 +51.66E-4 0.989 3.50E-3
  26 +56.35E-4 0.987 3.45E-3
  27 +61.99E-4 0.982 3.77E-3
  28 +68.88E-4 0.978 4.31E-3
  29 +72.93E-4 0.973 4.42E-3
  30 +77.49E-4 0.968 4.38E-3
  31 +82.65E-4 0.963 4.07E-3
  32 +88.56E-4 0.955 3.54E-3
  33 +95.37E-4 0.943 3.66E-3
  34 +103.3E-4 0.926 6.22E-3
  35 +112.7E-4 0.902 1.72E-2
  36 +118.1E-4 0.890 2.61E-2
  37 +124.0E-4 0.876 3.82E-2
  38 +130.5E-4 0.861 5.65E-2
  39 +137.8E-4 0.849 8.24E-2
  40 +145.9E-4 0.846 0.111
  41 +155.0E-4 0.848 0.139
  42 +158.9E-4 0.851 0.149
  43 +163.1E-4 0.853 0.158
  44 +167.5E-4 0.853 0.166
  45 +172.2E-4 0.851 0.181
  46 +177.1E-4 0.859 0.197
  47 +182.3E-4 0.871 0.208
  48 +187.8E-4 0.883 0.211
  49 +193.7E-4 0.885 0.210
  50 +200.0E-4 0.881 0.211
  51 +206.6E-4 0.873 0.221
  52 +213.8E-4 0.868 0.237
  53 +221.4E-4 0.871 0.259
  54 +229.6E-4 0.885 0.274
  55 +233.9E-4 0.890 0.275
  56 +238.4E-4 0.889 0.276
  57 +243.1E-4 0.886 0.281
  58 +248.0E-4 0.884 0.290
  59 +253.0E-4 0.885 0.200
  60 +258.3E-4 0.888 0.309
  61 +263.8E-4 0.893 0.317
  62 +269.5E-4 0.896 0.323
  63 +281.8E-4 0.899 0.334
  64 +295.2E-4 0.897 0.349
  65 +309.9E-4 0.896 0.368
  66 +317.9E-4 0.895 0.378
  67 +326.3E-4 0.892 0.388
  68 +335.1E-4 0.885 0.400
  69 +344.4E-4 0.876 0.418
  70 +354.2E-4 0.865 0.454
  71 +364.6E-4 0.879 0.489
  72 +375.7E-4 0.899 0.514
  73 +387.4E-4 0.921 0.528
  74 +399.9E-4 0.932 0.534
  75 +413.2E-4 0.931 0.541
  76 +427.5E-4 0.919 0.557
  77 +435.0E-4 0.911 0.572
  78 +442.8E-4 0.902 0.590
  79 +450.8E-4 0.851 0.616
  80 +459.2E-4 0.886 0.650
  81 +459.2E-4 0.882 0.399
  82 +467.9E-4 0.886 0.421
  83 +476.9E-4 0.887 0.444
  84 +486.2E-4 0.891 0.468
  85 +506.1E-4 0.906 0.522
  86 +527.6E-4 0.943 0.584
  87 +539.1E-4 0.980 0.614
  88 +551.0E-4 1.029 0.624
  89 +563.6E-4 1.075 0.615
  90 +576.7E-4 1.104 0.584
  91 +590.4E-4 1.109 0.561
  92 +604.8E-4 1.105 0.549
  93 +619.9E-4 1.098 0.548
  94 +652.6E-4 1.096 0.565
  95 +688.8E-4 1.101 0.593
  96 +729.3E-4 1.121 0.635
  97 +774.9E-4 1.167 0.676
  98 +799.9E-4 1.202 0.691
  99 +826.6E-4 1.243 0.693
  100 +855.1E-4 1.281 0.679
  101 +885.6E-4 1.308 0.656
  102 +918.4E-4 1.322 0.628
  103 +953.7E-4 1.322 0.603
  104 +991.9E-4 1.315 0.588
  105 +0.1025 1.308 0.581
  106 +0.1051 1.304 0.578
  107 +0.1078 1.300 0.573
  108 +0.1107 1.293 0.566
  109 +0.1137 1.280 0.560
  110 +0.1170 1.265 0.560
  111 +0.1204 1.252 0.564
  112 +0.1240 1.241 0.568
  113 +0.1278 1.229 0.566
  114 +0.1348 1.182 0.550
  115 +0.1378 1.149 0.552
  116 +0.1409 1.112 0.563
  117 +0.1442 1.073 0.581
  118 +0.1476 1.032 0.610
  119 +0.1512 0.993 0.653
  120 +0.1550 0.962 0.706
  121 +0.1590 0.940 0.770
  122 +0.1631 0.935 0.832
  123 +0.1675 0.936 0.892
  124 +0.1722 0.942 0.951
  125 +0.1771 0.953 1.01
  126 +0.1823 0.969 1.07
  127 +0.1879 0.995 1.13
  128 +0.1937 1.028 1.18
  129 +0.1968 1.048 1.21
  130 +0.2000 1.072 1.24
  131 +0.2033 1.098 1.26
  132 +0.2066 1.125 1.27
  133 +0.2138 1.173 1.29
  134 +0.2214 1.208 1.30
  135 +0.2296 1.238 1.31
  136 +0.2384 1.265 1.33
  137 +0.2480 1.298 1.35
  138 +0.2530 1.320 1.35
  139 +0.2583 1.343 1.35
  140 +0.2638 1.372 1.35
  141 +0.2695 1.404 1.33
  142 +0.2755 1.441 1.31
  143 +0.2818 1.476 1.26
  144 +0.2883 1.502 1.19
  145 +0.2952 1.519 1.08
  146 +0.2988 1.522 0.992
  147 +0.3024 1.496 0.882
  148 +0.3061 1.432 0.766
  149 +0.3100 1.323 0.647
  150 +0.3115 1.246 0.586
  151 +0.3139 1.149 0.540
  152 +0.3155 1.044 0.514
  153 +0.3179 0.932 0.504
  154 +0.3195 0.815 0.526
  155 +0.3220 0.708 0.565
  156 +0.3237 0.616 0.609
  157 +0.3263 0.526 0.663
  158 +0.3306 0.371 0.813
  159 +0.3324 0.321 0.902
  160 +0.3351 0.294 0.986
  161 +0.3397 0.259 1.12
  162 +0.3444 0.238 1.24
  163 +0.3542 0.209 1.44
  164 +0.3647 0.186 1.61
  165 +0.3757 0.200 1.67
  166 +0.3875 0.192 1.81
  167 +0.4000 0.173 1.95
  168 +0.4133 0.173 2.11
  169 +0.4275 0.160 2.26
  170 +0.4428 0.157 2.40
  171 +0.4592 0.144 2.56
  172 +0.4769 0.132 2.72
  173 +0.4959 0.130 2.88
  174 +0.5166 0.130 3.07
  175 +0.5391 0.129 3.25
  176 +0.5636 0.120 3.45
  177 +0.5904 0.121 3.66
  178 +0.6199 0.131 3.88
  179 +0.6526 0.140 4.15
  180 +0.6888 0.140 4.44
  181 +0.7293 0.148 4.74
  182 +0.7749 0.143 5.09
  183 +0.8266 0.145 5.50
  184 +0.8856 0.163 5.95
  185 +0.9537 0.198 6.43
  186 +1.033 0.226 6.99
  187 +1.127 0.251 7.67
  188 +1.240 0.329 8.49
  189 +1.265 0.375 7.78
  190 +1.291 0.383 7.92
  191 +1.305 0.358 8.95
  192 +1.319 0.392 8.06
  193 +1.348 0.401 8.21
  194 +1.378 0.411 8.37
  195 +1.3780 0.396 9.48
  196 +1.409 0.421 8.37
  197 +1.442 0.431 8.70
  198 +1.459 0.446 10.1
  199 +1.476 0.442 8.88
  200 +1.512 0.455 9.08
  201 +1.550 0.469 9.32
  202 +1.5500 0.514 10.8
  203 +1.590 0.485 9.57
  204 +1.631 0.501 9.84
  205 +1.653 0.624 11.5
  206 +1.675 0.519 10.1
  207 +1.722 0.537 10.4
  208 +1.771 0.557 10.7
  209 +1.7710 0.844 12.2
  210 +1.823 0.578 11.1
  211 +1.879 0.600 11.4
  212 +1.907 0.873 13.3
  213 +1.937 0.624 11.8
  214 +2.000 0.650 12.2
  215 +2.066 0.668 12.6
  216 +2.0660 1.064 14.4
  217 +2.138 0.729 13.0
  218 +2.214 0.774 13.5
  219 +2.296 0.823 14.0
  220 +2.384 0.878 14.5
  221 +2.480 0.939 15.1
  222 +2.583 1.007 15.7
  223 +2.695 1.083 16.4
  224 +2.818 1.168 17.1
  225 +2.952 1.265 17.9
  226 +3.100 1.387 18.8
  227 +3.263 1.536 19.8
  228 +3.444 1.710 20.9
  229 +3.647 1.915 22.1
  230 +3.875 2.160 23.5
  231 +4.133 2.446 25.1
  232 +4.428 2.786 26.9
  233 +4.769 3.202 29.0
  234 +5.166 3.732 31.3
  235 +5.636 4.425 34.0
  236 +6.199 5.355 37.0
  237 +6.526 5.960 38.6
  238 +6.888 6.670 40.4
  239 +7.293 7.461 42.5
  240 +7.749 8.376 44.8
  241 +8.266 9.441 47.1
  242 +8.856 10.69 49.4
  243 +9.537 12.21 52.2
  244 +9.919 13.11 53.7
... ...
mstm-gui.py
... ... @@ -17,277 +17,314 @@ from matplotlib.patches import Patch
17 17 from pylab import *
18 18  
19 19 class GuiWindow(QtGui.QMainWindow):
20   -
21   - params = ParameterClass('msinput.inp')
22   -
23   - def setParams(self):
24   - #update the Gui based on values in the parameters structure
25   - self.ui.spinStartLambda.setValue(self.params.minLambda)
26   - self.ui.spinEndLambda.setValue(self.params.maxLambda)
27   - self.ui.spinNearFieldLambda.setValue(self.params.snapshotLambda)
28   - self.ui.spinNumSamples.setValue(self.params.nSamples)
29   - self.ui.spinNumSpheres.setValue(int(self.params['number_spheres']))
30   - #near field stuff
31   - self.ui.cmbPlaneSlice.setCurrentIndex(int(self.params['near_field_plane_coord']) - 1)
32   - verts = self.params['near_field_plane_vertices']
33   - self.ui.spinNearFieldWidth.setValue(verts[2] - verts[0])
34   - self.ui.spinNearFieldHeight.setValue(verts[3] - verts[1])
35   - self.ui.spinNearFieldSteps.setValue(self.params.nSteps)
36   -
37   - fi = QtCore.QFileInfo(self.params.matFilename)
38   - self.ui.txtMaterial.setText(fi.baseName())
39   -
40   - #update global parameters for the dimer simulation
41   - self.ui.spinSpacing.setValue(self.params.d)
42   - self.ui.spinRadius.setValue(self.params.a)
43   -
44   - def getParams(self):
45   - self.params.minLambda = self.ui.spinStartLambda.value()
46   - self.params.maxLambda = self.ui.spinEndLambda.value()
47   - self.params.snapshotLambda = self.ui.spinNearFieldLambda.value()
48   - self.params.nSamples = self.ui.spinNumSamples.value()
49   - self.params.nSpheres = self.ui.spinNumSpheres.value()
50   -
51   - #incident light properties
52   - if self.ui.chkRandomOrientation.isChecked():
53   - self.params['fixed_or_random_orientation'] = 1
54   - else:
55   - self.params['fixed_or_random_orientation'] = 0
56   - self.params['incident_azimuth_angle_deg'] = self.ui.spinAlpha.value()
57   - self.params['incident_polar_angle_deg'] = self.ui.spinBeta.value()
58   - self.params['polarization_angle_deg'] = self.ui.spinGamma.value()
59   -
60   - self.params.showOutput = self.ui.chkShowOutput.isChecked()
61   -
62   - self.params.inWater = self.ui.chkInWater.isChecked()
63   -
64   -
65   - #near field
66   - if self.ui.chkNearField.isChecked():
67   - self.params['calculate_near_field'] = 1
68   - else:
69   - self.params['calculate_near_field'] = 0
70   - self.params['near_field_plane_coord'] = self.ui.cmbPlaneSlice.currentIndex() + 1
71   - width = (self.ui.spinNearFieldWidth.value()/2)
72   - height = (self.ui.spinNearFieldHeight.value()/2)
73   - self.params['near_field_plane_vertices'] = [-width, -height, width, height]
74   - dx = self.ui.spinNearFieldWidth.value() / (self.ui.spinNearFieldSteps.value() - 1)
75   - self.params['spacial_step_size'] = dx
76   -
77   - #global parameters for dimers
78   - self.params.d = self.ui.spinSpacing.value()
79   - self.params.a = self.ui.spinRadius.value()
80   -
81   - return self.params
82   -
83   - def simulate(self):
84   - self.results = RunSimulation(True)
85   -
86   - #plot results of interest
87   - wl = self.results['lambda']
88   -
89   - if int(self.params['fixed_or_random_orientation']) == 0:
90   - unpol = self.results['extinction_unpolarized']
91   - para = self.results['extinction_parallel']
92   - perp = self.results['extinction_perpendicular']
93   - plt.plot(wl, unpol, 'r-', label='unpolarized')
94   - plt.plot(wl, para, 'g-', label='parallel')
95   - plt.plot(wl, perp, 'b-', label='perpendicular')
96   - else:
97   - total = self.results['extinction_total']
98   - plt.plot(wl, total, 'r-', label='extinction')
99   -
100   - #plot the near field maximum values if available
101   -
102   - if self.params['calculate_near_field']:
103   - maxima = self.results.maxNearField
104   - print(len(wl))
105   - print(len(maxima))
106   - plt.plot(wl, maxima)
107   -
108   -
109   -
110   - plt.legend(loc = 'upper left')
111   - plt.ylabel('Extinction')
112   - plt.xlabel('Wavelength (um)')
113   - plt.show()
114   -
115   - def func3(self, x,y):
116   - return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)
117   -
118   - def snapshot(self):
119   -
120   - self.results = RunSimulation(False)
121   -
122   - if self.params['calculate_near_field']:
123   - #verts = self.params['near_field_plane_vertices']
124   - #dx = (verts[2] - verts[0])/(self.params.nSteps)
125   - #x = arange(verts[0], verts[2], dx)
126   - #print(len(x))
127   - #y = arange(verts[1], verts[3], dx)
128   - #X, Y = meshgrid(x, y)
129   - E = array(self.results.gridNearField)
130   - #pcolor(X, Y, E, cmap=cm.RdBu)
131   - #colorbar()
132   - #axis([verts[0], verts[2], verts[1], verts[3]])
133   -
134   - pcolor(E, cmap=cm.RdBu)
135   - colorbar()
136   -
137   - # make these smaller to increase the resolution
138   - #dx, dy = 0.05, 0.05
139   -
140   - #x = arange(-3.0, 3.0001, dx)
141   - #y = arange(-3.0, 3.0001, dy)
142   - #X,Y = meshgrid(x, y)
143   -
144   - #Z = self.func3(X, Y)
145   - #pcolor(X, Y, Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max())
146   - #colorbar()
147   - #axis([-3,3,-3,3])
148   -
149   - show()
150   -
151   - def saveresults(self):
152   - fileName = QtGui.QFileDialog.getSaveFileName(w, 'Save Spectral Results', '', 'DAT data files (*.dat)')
153   - if fileName:
154   - self.results.saveFile(fileName)
155   -
156   - def loadmaterial(self):
157   - fileName = QtGui.QFileDialog.getOpenFileName(w, 'Load Material Refractive Index', '', 'TXT data files (*.txt)')
158   - if fileName:
159   - self.params.matFilename = fileName
160   -
161   - fi = QtCore.QFileInfo(fileName)
162   - self.ui.txtMaterial.setText(fi.baseName())
163   -
164   - def spherenum(self, i):
165   - self.ui.tblSpheres.setRowCount(i)
166   - print(i)
167   -
168   - def __init__(self):
169   - QtGui.QWidget.__init__(self)
170   -
171   - #dimer-specific settings
172   - self.params['number_spheres'] = 2
173   - self.params['sphere_position_file'] = ''
174   -
175   - #load the UI window
176   - self.ui = uic.loadUi('mstm_guiwindow.ui')
177   - #update the displayed parameters
178   - self.setParams()
179   - #display the UI
180   - self.ui.show()
181   -
182   - #controls
183   - self.connect(self.ui.btnSimulate, QtCore.SIGNAL("clicked()"), self.simulate)
184   - self.connect(self.ui.btnEvaluateNearField, QtCore.SIGNAL("clicked()"), self.snapshot)
185   - self.connect(self.ui.mnuSaveResults, QtCore.SIGNAL("triggered()"), self.saveresults)
186   - self.connect(self.ui.mnuLoadMaterial, QtCore.SIGNAL("triggered()"), self.loadmaterial)
187   - self.connect(self.ui.spinNumSpheres, QtCore.SIGNAL("valueChanged(int)"), self.spherenum)
  20 +
  21 + params = ParameterClass('msinput.inp')
  22 +
  23 + def setParams(self):
  24 + #update the Gui based on values in the parameters structure
  25 + self.ui.spinStartLambda.setValue(self.params.minLambda)
  26 + self.ui.spinEndLambda.setValue(self.params.maxLambda)
  27 + self.ui.spinNearFieldLambda.setValue(self.params.snapshotLambda)
  28 + self.ui.spinNumSamples.setValue(self.params.nSamples)
  29 + self.ui.spinNumSpheres.setValue(int(self.params['number_spheres']))
  30 + #near field stuff
  31 + self.ui.cmbPlaneSlice.setCurrentIndex(int(self.params['near_field_plane_coord']) - 1)
  32 + verts = self.params['near_field_plane_vertices']
  33 + self.ui.spinNearFieldWidth.setValue(verts[2] - verts[0])
  34 + self.ui.spinNearFieldHeight.setValue(verts[3] - verts[1])
  35 + self.ui.spinNearFieldSteps.setValue(self.params.nSteps)
  36 +
  37 + fi = QtCore.QFileInfo(self.params.matFilename)
  38 + self.ui.txtMaterial.setText(fi.baseName())
  39 +
  40 + #update global parameters for the dimer simulation
  41 + self.ui.spinSpacing.setValue(self.params.d)
  42 + self.ui.spinRadius.setValue(self.params.a)
  43 +
  44 + def getParams(self):
  45 + self.params.minLambda = self.ui.spinStartLambda.value()
  46 + self.params.maxLambda = self.ui.spinEndLambda.value()
  47 + self.params.snapshotLambda = self.ui.spinNearFieldLambda.value()
  48 + self.params.nSamples = self.ui.spinNumSamples.value()
  49 + self.params['number_spheres'] = self.ui.spinNumSpheres.value()
  50 +
  51 + #incident light properties
  52 + if self.ui.chkRandomOrientation.isChecked():
  53 + self.params['fixed_or_random_orientation'] = 1
  54 + else:
  55 + self.params['fixed_or_random_orientation'] = 0
  56 + self.params['incident_azimuth_angle_deg'] = self.ui.spinAlpha.value()
  57 + self.params['incident_polar_angle_deg'] = self.ui.spinBeta.value()
  58 + self.params['polarization_angle_deg'] = self.ui.spinGamma.value()
  59 +
  60 + self.params.showOutput = self.ui.chkShowOutput.isChecked()
  61 + self.params.inWater = self.ui.chkInWater.isChecked()
  62 +
  63 +
  64 + #near field
  65 + if self.ui.chkNearField.isChecked():
  66 + self.params['calculate_near_field'] = 1
  67 + else:
  68 + self.params['calculate_near_field'] = 0
  69 + self.params['near_field_plane_coord'] = self.ui.cmbPlaneSlice.currentIndex() + 1
  70 + width = (self.ui.spinNearFieldWidth.value()/2)
  71 + height = (self.ui.spinNearFieldHeight.value()/2)
  72 + self.params['near_field_plane_vertices'] = [-width, -height, width, height]
  73 + dx = self.ui.spinNearFieldWidth.value() / (self.ui.spinNearFieldSteps.value() - 1)
  74 + self.params['spacial_step_size'] = dx
  75 +
  76 + #global parameters for dimers
  77 + self.params.d = self.ui.spinSpacing.value()
  78 + self.params.a = self.ui.spinRadius.value()
  79 +
  80 + #get the spheres from the table
  81 + nSpheres = self.ui.tblSpheres.rowCount()
  82 + print("Row count: " + str(nSpheres))
  83 + print("Orientatino: " + str(self.params['fixed_or_random_orientation']))
  84 +
  85 + self.params.sphereList = []
  86 + for s in range(nSpheres):
  87 + a = float(self.ui.tblSpheres.item(s, 0).text())
  88 + x = float(self.ui.tblSpheres.item(s, 1).text())
  89 + y = float(self.ui.tblSpheres.item(s, 2).text())
  90 + z = float(self.ui.tblSpheres.item(s, 3).text())
  91 + self.params.addSphere(a, x, y, z)
  92 +
  93 + return self.params
  94 +
  95 + def simulate(self):
  96 + self.results = RunSimulation(True)
  97 +
  98 + #plot results of interest
  99 + wl = self.results['lambda']
  100 +
  101 + if int(self.params['fixed_or_random_orientation']) == 0:
  102 + unpol = self.results['extinction_unpolarized']
  103 + para = self.results['extinction_parallel']
  104 + perp = self.results['extinction_perpendicular']
  105 + plt.plot(wl, unpol, 'r-', label='unpolarized')
  106 + plt.plot(wl, para, 'g-', label='parallel')
  107 + plt.plot(wl, perp, 'b-', label='perpendicular')
  108 + else:
  109 + total = self.results['extinction_total']
  110 + plt.plot(wl, total, 'r-', label='extinction')
  111 +
  112 + #plot the near field maximum values if available
  113 +
  114 + if self.params['calculate_near_field']:
  115 + maxima = self.results.maxNearField
  116 + print(len(wl))
  117 + print(len(maxima))
  118 + plt.plot(wl, maxima)
  119 +
  120 +
  121 +
  122 + plt.legend(loc = 'upper left')
  123 + plt.ylabel('Extinction')
  124 + plt.xlabel('Wavelength (um)')
  125 + plt.show()
  126 +
  127 + def func3(self, x,y):
  128 + return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)
  129 +
  130 + def snapshot(self):
  131 +
  132 + self.results = RunSimulation(False)
  133 +
  134 + if self.params['calculate_near_field']:
  135 + #verts = self.params['near_field_plane_vertices']
  136 + #dx = (verts[2] - verts[0])/(self.params.nSteps)
  137 + #x = arange(verts[0], verts[2], dx)
  138 + #print(len(x))
  139 + #y = arange(verts[1], verts[3], dx)
  140 + #X, Y = meshgrid(x, y)
  141 + E = array(self.results.gridNearField)
  142 + #pcolor(X, Y, E, cmap=cm.RdBu)
  143 + #colorbar()
  144 + #axis([verts[0], verts[2], verts[1], verts[3]])
  145 +
  146 + pcolor(E, cmap=cm.RdBu)
  147 + colorbar()
  148 + print("Maximum enhancement: " + str(abs(E).max()))
  149 +
  150 + # make these smaller to increase the resolution
  151 + #dx, dy = 0.05, 0.05
  152 +
  153 + #x = arange(-3.0, 3.0001, dx)
  154 + #y = arange(-3.0, 3.0001, dy)
  155 + #X,Y = meshgrid(x, y)
  156 +
  157 + #Z = self.func3(X, Y)
  158 + #pcolor(X, Y, Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max())
  159 + #colorbar()
  160 + #axis([-3,3,-3,3])
  161 +
  162 + show()
  163 +
  164 + def saveresults(self):
  165 + fileName = QtGui.QFileDialog.getSaveFileName(w, 'Save Spectral Results', '', 'DAT data files (*.dat)')
  166 + if fileName:
  167 + self.results.saveFile(fileName)
  168 +
  169 + def loadmaterial(self):
  170 + fileName = QtGui.QFileDialog.getOpenFileName(w, 'Load Material Refractive Index', '', 'TXT data files (*.txt)')
  171 + if fileName:
  172 + self.params.matFilename = fileName
  173 +
  174 + fi = QtCore.QFileInfo(fileName)
  175 + self.ui.txtMaterial.setText(fi.baseName())
  176 +
  177 + def spherenum(self, i):
  178 + self.ui.tblSpheres.setRowCount(i)
  179 + print(i)
  180 +
  181 + def updatedimers(self):
  182 +
  183 + d = self.ui.spinSpacing.value()
  184 + a = self.ui.spinRadius.value()
  185 +
  186 + self.ui.tblSpheres.setItem(0, 0, QtGui.QTableWidgetItem(str(a)))
  187 + self.ui.tblSpheres.setItem(0, 1, QtGui.QTableWidgetItem(str(-(d + 2*a)/2)))
  188 + self.ui.tblSpheres.setItem(0, 2, QtGui.QTableWidgetItem(str(0.0)))
  189 + self.ui.tblSpheres.setItem(0, 3, QtGui.QTableWidgetItem(str(0.0)))
  190 +
  191 + self.ui.tblSpheres.setItem(1, 0, QtGui.QTableWidgetItem(str(a)))
  192 + self.ui.tblSpheres.setItem(1, 1, QtGui.QTableWidgetItem(str((d + 2*a)/2)))
  193 + self.ui.tblSpheres.setItem(1, 2, QtGui.QTableWidgetItem(str(0.0)))
  194 + self.ui.tblSpheres.setItem(1, 3, QtGui.QTableWidgetItem(str(0.0)))
  195 +
  196 +
  197 + def __init__(self):
  198 + QtGui.QWidget.__init__(self)
  199 +
  200 + #dimer-specific settings
  201 + self.params['number_spheres'] = 2
  202 + self.params['sphere_position_file'] = ''
  203 +
  204 + #load the UI window
  205 + self.ui = uic.loadUi('mstm_guiwindow.ui')
  206 +
  207 +
  208 +
  209 + #controls
  210 + self.connect(self.ui.btnSimulate, QtCore.SIGNAL("clicked()"), self.simulate)
  211 + self.connect(self.ui.btnEvaluateNearField, QtCore.SIGNAL("clicked()"), self.snapshot)
  212 + self.connect(self.ui.mnuSaveResults, QtCore.SIGNAL("triggered()"), self.saveresults)
  213 + self.connect(self.ui.mnuLoadMaterial, QtCore.SIGNAL("triggered()"), self.loadmaterial)
  214 + self.connect(self.ui.spinNumSpheres, QtCore.SIGNAL("valueChanged(int)"), self.spherenum)
  215 + self.connect(self.ui.spinRadius, QtCore.SIGNAL("valueChanged(double)"), self.updatedimers)
  216 + self.connect(self.ui.spinSpacing, QtCore.SIGNAL("valueChanged(double)"), self.updatedimers)
  217 +
  218 + #update the displayed parameters
  219 + self.setParams()
  220 +
  221 + #update the sphere table with the default dimer values
  222 + self.updatedimers()
  223 +
  224 + #display the UI
  225 + self.ui.show()
188 226  
189 227  
190 228 class ProgressBar(QtGui.QWidget):
191   - def __init__(self, parent=None, total=20):
192   - super(ProgressBar, self).__init__(parent)
193   - self.name_line = QtGui.QLineEdit()
  229 + def __init__(self, parent=None, total=20):
  230 + super(ProgressBar, self).__init__(parent)
  231 + self.name_line = QtGui.QLineEdit()
194 232  
195   - self.progressbar = QtGui.QProgressBar()
196   - self.progressbar.setMinimum(1)
197   - self.progressbar.setMaximum(total)
  233 + self.progressbar = QtGui.QProgressBar()
  234 + self.progressbar.setMinimum(1)
  235 + self.progressbar.setMaximum(total)
198 236  
199   - main_layout = QtGui.QGridLayout()
200   - main_layout.addWidget(self.progressbar, 0, 0)
  237 + main_layout = QtGui.QGridLayout()
  238 + main_layout.addWidget(self.progressbar, 0, 0)
201 239  
202   - self.setLayout(main_layout)
203   - self.setWindowTitle("Progress")
  240 + self.setLayout(main_layout)
  241 + self.setWindowTitle("Progress")
204 242  
205   - def update_progressbar(self, val):
206   - self.progressbar.setValue(val)
207   -
  243 + def update_progressbar(self, val):
  244 + self.progressbar.setValue(val)
  245 +
208 246  
209 247 def RunSimulation(spectralSim = True):
210   -
211   - #set the parameters based on the UI
212   - parameters = w.getParams()
213   -
214   -
215   -
216   - #load the material
217   - material = MaterialClass(parameters.matFilename)
218   -
219   - #add water if necessary
220   - if parameters.inWater:
221   - material.addSolution(1.33)
222   -
223   - #for a spectral simulation, set the range and number of samples
224   - if spectralSim:
225   - minLambda = parameters.minLambda
226   - maxLambda = parameters.maxLambda
227   - nSamples = parameters.nSamples
228   - else:
229   - minLambda = parameters.snapshotLambda
230   - maxLambda = parameters.snapshotLambda
231   - nSamples = 1
232   -
233   - #store the simulation results
234   - results = SimParserClass(parameters)
235   -
236   - #create a progress bar
237   - pbar = ProgressBar(total=nSamples)
238   - pbar.show()
239   -
240   - #for each wavelength in the material
241   - for i in range(nSamples):
242   -
243   - if i == 0:
244   - l = minLambda
245   - else:
246   - l = minLambda + i*(maxLambda - minLambda)/(nSamples - 1)
247   -
248   -
249   -
250   - #set the computed parameters
251   - m = material[l]
252   - n = m.n
253   - parameters['real_ref_index_scale_factor'] = n.real
254   - parameters['imag_ref_index_scale_factor'] = n.imag
255   - parameters['length_scale_factor'] = (2.0 * 3.14159)/l
256   - parameters['scattering_plane_angle_deg'] = gamma;
257   - parameters['near_field_output_data'] = 0
258   -
259   - a = parameters.a;
260   - d = parameters.d;
261   - parameters.clearSpheres()
262   - parameters.addSphere(a, -(d + 2*a)/2, 0, 0)
263   - parameters.addSphere(a, (d + 2*a)/2, 0, 0)
264   -
265   - #save the scripted input file
266   - parameters.saveFile(l, 'scriptParams.inp')
267   -
268   - #run the binary
269   - from subprocess import call
270   - if parameters.showOutput:
271   - call(["./ms-tmatrix", "scriptParams.inp"])
272   - else:
273   - devnull = open('/dev/null', 'w')
274   - call(["./ms-tmatrix", "scriptParams.inp"], stdout=devnull)
275   -
276   - #parse the simulation results
277   - results.parseSimFile(l, 'test.dat')
278   -
279   - if parameters['calculate_near_field']:
280   - results.parseNearField('nf-temp.dat')
281   -
282   -
283   - #update the progress bar
284   - pbar.update_progressbar(i+1)
285   -
286   - #return the results
287   - return results;
288   -
289   -
290   -
  248 +
  249 + #set the parameters based on the UI
  250 + parameters = w.getParams()
  251 +
  252 +
  253 +
  254 + #load the material
  255 + material = MaterialClass(parameters.matFilename)
  256 +
  257 + #add water if necessary
  258 + if parameters.inWater:
  259 + material.addSolution(1.33)
  260 +
  261 + #for a spectral simulation, set the range and number of samples
  262 + if spectralSim:
  263 + minLambda = parameters.minLambda
  264 + maxLambda = parameters.maxLambda
  265 + nSamples = parameters.nSamples
  266 + else:
  267 + minLambda = parameters.snapshotLambda
  268 + maxLambda = parameters.snapshotLambda
  269 + nSamples = 1
  270 +
  271 + #store the simulation results
  272 + results = SimParserClass(parameters)
  273 +
  274 + #create a progress bar
  275 + pbar = ProgressBar(total=nSamples)
  276 + pbar.show()
  277 +
  278 + #for each wavelength in the material
  279 + for i in range(nSamples):
  280 +
  281 + if i == 0:
  282 + l = minLambda
  283 + else:
  284 + l = minLambda + i*(maxLambda - minLambda)/(nSamples - 1)
  285 +
  286 + #set the computed parameters
  287 + m = material[l]
  288 + n = m.n
  289 + parameters['real_ref_index_scale_factor'] = n.real
  290 + parameters['imag_ref_index_scale_factor'] = n.imag
  291 + parameters['length_scale_factor'] = (2.0 * 3.14159)/l
  292 + parameters['scattering_plane_angle_deg'] = gamma;
  293 + parameters['near_field_output_data'] = 0
  294 + #parameters['number_spheres'] = 1
  295 +
  296 + #a = parameters.a;
  297 + #d = parameters.d;
  298 + #parameters.clearSpheres()
  299 + #parameters.addSphere(a, -(d + 2*a)/2, 0, 0)
  300 + #parameters.addSphere(a, (d + 2*a)/2, 0, 0)
  301 +
  302 + #save the scripted input file
  303 + parameters.saveFile(l, 'scriptParams.inp')
  304 +
  305 + #run the binary
  306 + from subprocess import call
  307 + if parameters.showOutput:
  308 + call(["./ms-tmatrix", "scriptParams.inp"])
  309 + else:
  310 + devnull = open('/dev/null', 'w')
  311 + call(["./ms-tmatrix", "scriptParams.inp"], stdout=devnull)
  312 +
  313 + #parse the simulation results
  314 + results.parseSimFile(l, 'test.dat')
  315 +
  316 + if parameters['calculate_near_field']:
  317 + results.parseNearField('nf-temp.dat')
  318 +
  319 +
  320 + #update the progress bar
  321 + pbar.update_progressbar(i+1)
  322 +
  323 + #return the results
  324 + return results;
  325 +
  326 +
  327 +
291 328  
292 329  
293 330  
... ...
mstm_guiwindow.ui
... ... @@ -651,6 +651,12 @@
651 651 <height>22</height>
652 652 </rect>
653 653 </property>
  654 + <property name="decimals">
  655 + <number>3</number>
  656 + </property>
  657 + <property name="singleStep">
  658 + <double>0.001000000000000</double>
  659 + </property>
654 660 </widget>
655 661 <widget class="QLabel" name="label_11">
656 662 <property name="geometry">
... ... @@ -679,7 +685,7 @@
679 685 </rect>
680 686 </property>
681 687 <attribute name="horizontalHeaderDefaultSectionSize">
682   - <number>89</number>
  688 + <number>80</number>
683 689 </attribute>
684 690 <attribute name="verticalHeaderDefaultSectionSize">
685 691 <number>30</number>
... ... @@ -691,7 +697,7 @@
691 697 </column>
692 698 <column>
693 699 <property name="text">
694   - <string>pX</string>
  700 + <string>x</string>
695 701 </property>
696 702 </column>
697 703 <column>
... ...
mstm_materials.py
... ... @@ -80,11 +80,11 @@ class MaterialClass:
80 80 #open the real refractive index file
81 81 irFID = open(fileName, 'r')
82 82 #read the first line to get the units (wavelength (um) or wavenumber (cm^2))
83   - lightUnits = irFID.readline().split('\t', 1)[0]
  83 + lightUnits = irFID.readline().split()[0]
84 84  
85 85 #load the material
86 86 for line in irFID:
87   - l, n, k = map(float, line.split("\t"))
  87 + l, n, k = map(float, line.split())
88 88  
89 89 #if units are in wavenumber, convert to wavelength
90 90 if lightUnits == "nu":
... ...
mstm_simparser.py
... ... @@ -82,7 +82,7 @@ class SimParserClass:
82 82 self.gridNearField[y].append(values[2])
83 83  
84 84 E = array(self.gridNearField)
85   - self.maxNearField.append(pow(E.max(), 2))
  85 + self.maxNearField.append(abs(E).max())
86 86  
87 87  
88 88 def saveFile(self, fileName):
... ...