Kaynağa Gözat

forgoten files

Konstantin Ladutenko 10 yıl önce
ebeveyn
işleme
feb3ad9a4b

+ 121 - 0
tests/python/coating-flow.py

@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+#
+#    Copyright (C) 2009-2015 Ovidio Peña Rodríguez <ovidio@bytesfall.com>
+#
+#    This file is part of python-scattnlay
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    The only additional remark is that we expect that all publications
+#    describing work using this software, or all commercial products
+#    using it, cite the following reference:
+#    [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by
+#        a multilayered sphere," Computer Physics Communications,
+#        vol. 180, Nov. 2009, pp. 2348-2354.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This test case calculates the electric field in the
+# E-k plane, for an spherical Si-Ag-Si nanoparticle. Core radius is 17.74 nm,
+# inner layer 23.31nm, outer layer 22.95nm. Working wavelength is 800nm, we use
+# silicon epsilon=13.64+i0.047, silver epsilon= -28.05+i1.525
+
+import os, cmath
+import numpy as np
+from scattnlay import fieldnlay
+from fieldplot import fieldplot
+
+
+if __name__ == '__main__':
+    import argparse
+
+    parser = argparse.ArgumentParser()
+
+    parser.add_argument("dirnames", nargs='*', default='.', help="read all data from DIR(S)")
+    parser.add_argument("-f", "--filename", dest="fname", nargs='?', default=None,
+                        help="name of 'n' file")
+    parser.add_argument("-w", "--wavelength", dest="wl", default=3.75, type=float,
+                        help="wavelength of electromagnetic wave")
+    parser.add_argument("-r", "--radius", dest="rad", default=None, type=float,
+                        help="radius of PEC sphere")
+    parser.add_argument("-t", "--thickness", dest="tc", default=0.8, type=float,
+                        help="thickness of cloaking layer")
+    parser.add_argument("-n", "--npoints", dest="npts", default=101, type=int,
+                        help="number of points for the grid")
+
+    args = parser.parse_args()
+
+    for dirname in args.dirnames:
+        print "Calculating spectra for data file(s) in dir '%s'..." % (dirname)
+
+        wl = args.wl # cm
+        if (args.rad is None):
+            Rs = 0.75*wl  # cm
+        else:
+            Rs = args.rad # cm
+        tc = args.tc # cm
+
+        if (args.fname is None):
+            files = [x for x in os.listdir('%s/' % (dirname)) if x.endswith('.dat')]
+            files.sort()
+        else:
+            files = [args.fname]
+
+        npts = args.npts # cm
+
+        if not os.path.exists('%s/flow-results/' % (dirname)):
+            os.makedirs('%s/flow-results/' % (dirname))
+
+        Rt = Rs + tc # cm
+
+        print "Wl = %.2f, Rs = %.2f, tc = %.2f, Rt = %.2f" % (wl, Rs, tc, Rt)
+
+        ms = 1.0 + 40.0j
+        for i, fname in enumerate(files):
+            print "Calculating spectra for file '%s'..." % (fname)
+
+            basename = os.path.splitext(fname)[0]
+
+            nvalues = np.loadtxt('%s/%s' % (dirname, fname))*1.0 + 1e-11j
+
+            tl = tc/len(nvalues) # cm
+            r = [Rs]
+
+            for i in range(len(nvalues)):
+                r += [r[i] + tl]
+
+            x = np.ones((1, len(nvalues) + 1), dtype = np.float64)
+            m = np.ones((1, len(nvalues) + 1), dtype = np.complex128)
+
+            x[0] = 2.0*np.pi*np.array(r, dtype = np.float64)/wl
+            m[0] = np.array([ms] + nvalues[:, 1].tolist(), dtype = np.complex128)
+
+            factor = 2
+            comment='PEC-'+basename
+            WL_units='cm'
+            flow_total = 39
+            #flow_total = 0
+            #crossplane='XZ'
+            crossplane='YZ'
+            #crossplane='XY'
+
+            # Options to plot: Eabs, Habs, Pabs, angleEx, angleHy
+            field_to_plot='Pabs'
+            #field_to_plot='Eabs'
+            #field_to_plot='angleEx'
+            fieldplot(x[0],m[0], wl, comment, WL_units, crossplane, field_to_plot, npts,
+                      factor, flow_total, pl=0, outline_width=0.1)
+
+
+        print "Done!!"
+

+ 5 - 0
tests/python/coating-flow.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+python coating-flow.py -w 3.75 -t 0.80 -f index-dv.dat -n 1501
+#python coating-flow.py -w 3.75 -t 0.62 -f index-sv.dat -n 1501
+# python coating-flow.py -w 3.75 -t 2.40 -f index-ch.dat -n 501

+ 98 - 0
tests/python/index-ch.dat

@@ -0,0 +1,98 @@
+#Layer N	Index	
+# TargetR2.8125-index-n-1k-1-CoatingW02.400-FinalRCS24.0577diff-54.3%-n96-s406.642299335648-index
+1	5.749335803512620302	
+2	3.141762961744382743	
+3	3.517942484287340577	
+4	4.791493884037310025	
+5	3.735822254252520125	
+6	2.083879849088456027	
+7	6.690275153118312446	
+8	4.93218340173765224	
+9	1.775615487238558776	
+10	5.176026567191519767	
+11	3.743194574611140357	
+12	2.866197219283298292	
+13	2.185180285910699904	
+14	4.414273003084785429	
+15	4.868023736776916799	
+16	1.710170432391318052	
+17	3.50796206700414448	
+18	2.697988996898661895	
+19	3.553957623718730474	
+20	7.999980780105266476	
+21	3.894242708766762373	
+22	7.998130485037586723	
+23	2.331279488473009032	
+24	6.079118361707619655	
+25	7.432492661618770313	
+26	4.595789892550891764	
+27	4.292344676729104691	
+28	5.332981371688163108	
+29	2.93942304734845461	
+30	4.706237624636468553	
+31	3.348093523938082239	
+32	1.725161528985504011	
+33	2.700514574998721606	
+34	2.749975835488200016	
+35	6.127403895715513471	
+36	7.999989501592007279	
+37	7.999999862141754292	
+38	7.997222358772536843	
+39	7.885835231178068838	
+40	1.104874591509938497	
+41	2.557385992494067839	
+42	1.283487106436893566	
+43	4.280402167755322118	
+44	4.15545727580456159	
+45	1.107605812272585144	
+46	1.66302549303807945	
+47	1.406567313133828545	
+48	1.638577522082844684	
+49	1.40392641764507875	
+50	6.578845533119020317	
+51	3.58680531520020951	
+52	4.162243508120385904	
+53	2.420274012058465374	
+54	3.806898234367299239	
+55	7.9999154826863208	
+56	7.299283239081675312	
+57	7.957581641865791866	
+58	7.999756463939247553	
+59	1.000307210296912386	
+60	1.268650135088047692	
+61	6.558667066646631127	
+62	1.009636547370579063	
+63	7.683437169416794887	
+64	7.616087731862954513	
+65	1.412789224110302388	
+66	5.092962017268542141	
+67	2.636203543845038411	
+68	5.864195462731800923	
+69	5.559535453969105312	
+70	4.212327947425384522	
+71	3.775995746343467463	
+72	2.79644746238645947	
+73	2.990656024028564897	
+74	2.268934872808900938	
+75	3.53529066398966263	
+76	5.170244446423582829	
+77	1.000153502850401388	
+78	4.146432814237805964	
+79	4.502227612310949922	
+80	3.574165620116289244	
+81	5.941097162753926852	
+82	7.999414796963508323	
+83	5.936878282510322791	
+84	4.649745206189950686	
+85	7.572390563536975705	
+86	4.780985022403201334	
+87	4.356413030716980828	
+88	3.718350395661014218	
+89	4.11922953620705723	
+90	3.151317818732550791	
+91	2.602738005170567526	
+92	4.780286744896858231	
+93	1.297975845438861464	
+94	6.370021149298636942	
+95	1.418719383122659439	
+96	4.580971796543868102	

+ 34 - 0
tests/python/index-dv.dat

@@ -0,0 +1,34 @@
+#Layer N	Index	
+# TargetR2.8125-CoatingW00.800-FinalRCS25.3412diff-51.9%-n32-s139.585414476121-index
+1	2.914401365946849953	
+2	7.999999568066106903	
+3	7.999999805091645655	
+4	7.999999238794624823	
+5	7.999999854193549531	
+6	5.979617734581032629	
+7	2.90056030279753907	
+8	2.513877134657918955	
+9	2.313975248489835934	
+10	2.186263097301196279	
+11	2.103731626279280675	
+12	2.050425337776427881	
+13	2.02722718503005872	
+14	2.043407875278105301	
+15	2.141954143805122612	
+16	2.779546399372911925	
+17	7.999999963405493908	
+18	7.999999959245399417	
+19	7.999999992785230774	
+20	7.999999763204644232	
+21	7.999999962594151803	
+22	3.607211241982554384	
+23	2.519963615602491824	
+24	2.30033851793211408	
+25	2.210019176974556299	
+26	2.177346881906367049	
+27	2.187732694221404373	
+28	2.241437964316892462	
+29	2.363784302705050688	
+30	2.652539546222675515	
+31	5.370055597183615248	
+32	7.999999378375875381	

+ 18 - 0
tests/python/index-sv.dat

@@ -0,0 +1,18 @@
+#Layer N	Index	
+# TargetR2.8125-CoatingW00.620-FinalRCS27.4228diff-47.9%-n16-s50.421839621567-index
+1	1.000000000922160126	
+2	1.000000697299052721	
+3	7.994698322241974076	
+4	7.999985996968639768	
+5	6.748281789975593803	
+6	3.482762722162508151	
+7	2.380626616473425994	
+8	2.159309340071060568	
+9	2.034109569517063676	
+10	1.884925694693077025	
+11	1.828250073364771744	
+12	2.04069028461526214	
+13	2.296151028318206055	
+14	5.572006973799219054	
+15	1.000005309961293776	
+16	1.000035201183201217