Skip to content

Commit 4725c44

Browse files
committed
made the wedge simulation work, maybe
1 parent ea70c80 commit 4725c44

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

example_metamaterial_wedge/batch.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
## example:
4+
## ./batch.sh radius=10u resolution=4u simtime=30p
5+
6+
../scatter.py model=RodArray $@
7+
../effparam.py
8+
last_simulation_name=`cat last_simulation_name.dat`
9+
rm -f effparam.dat; ln -s effparam/${last_simulation_name}_effparam.dat effparam.dat
10+
11+
../wedge_refraction.py $@
12+
last_simulation_name=`cat last_simulation_name.dat`
13+
../scripts_postpro/plot_FA.py $last_simulation_name/wedge_at_x0.000e+00_z*.h5

scripts_postpro/plot_FA.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
h5file = h5py.File(filename, "r")
3636
print "Found datasets:", h5file.keys()
3737
time1 = time.time()
38-
data = np.array(h5file['ex.r'])
38+
data = np.array(h5file['ex.r']) * (1+0j)
3939
data += np.array(h5file['ex.i']) * 1j
4040
print "Loaded dataset with shape:", data.shape, 'in %04d s.' % (time.time()-time1)
4141
try:
@@ -54,6 +54,8 @@
5454
freq = np.fft.fftshift(freq) #+ freq[len(freq)/2]
5555
Efy = np.fft.fftshift(Efy)
5656

57+
print("debug", len(t), (t[1]-t[0]), freq, Efy)
58+
5759
## Fourier transform along the spatial axis
5860
kT = np.fft.fftfreq(len(y), d=(y[1]-y[0])) # calculate the frequency axis with proper spacing
5961
Ef = np.fft.fft(Efy, axis=0) / len(y) * 2*np.pi # calculate the FFT values
@@ -73,7 +75,7 @@ def fftshift2(arr): return np.vstack([arr[len(arr)/2:,:], arr[:len(arr)/2,:]])
7375
contours = plt.contourf(t, y, Et, cmap=matplotlib.cm.RdBu, extend='both') # levels=np.arange(0.,1,.01),
7476
else:
7577
toplot = np.log10(np.abs(Ef))
76-
contours = plt.contourf(freq, kT, toplot, cmap=matplotlib.cm.gist_earth, levels=np.linspace(np.min(toplot)*.8+np.max(toplot)*.2,np.max(toplot),200) ,extend='both') #
78+
contours = plt.contourf(freq, kT, toplot, cmap=matplotlib.cm.gist_earth, levels=np.linspace(np.min(toplot)*.5+np.max(toplot)*.5,np.max(toplot),200) ,extend='both') #
7779
#contours = plt.contourf(freq, kT, np.abs(Ef), cmap=matplotlib.cm.gist_earth, extend='both') # levels=np.arange(0.,1,.01),
7880
plt.plot([0, maxfreq], [0, 0], c='w',lw=.5)
7981
plt.plot([0, maxfreq], [0, maxfreq/c], c='w',lw=.5)

scripts_postpro/plot_TY.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
h5file = h5py.File(filename, "r")
3434
print "Found datasets:", h5file.keys()
3535
time1 = time.time()
36-
data = np.array(h5file['ex.r'])
36+
data = np.array(h5file['ex.r']) * (1+0j)
3737
data += np.array(h5file['ex.i']) * 1j
3838
print "Loaded dataset with shape:", data.shape, 'in %04d s.' % (time.time()-time1)
3939
try:

wedge_refraction.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#import meep
3535

3636
class Wedge_model(meep_utils.AbstractMeepModel): #{{{
37-
""" Array of circular metallic wires along electric field
37+
""" Array of circular wires parallel to the electric field
3838
FD 2013-07-13
3939
"""
4040
def cell_centers(self):
@@ -96,7 +96,6 @@ def where_wire(self, r):
9696

9797

9898
# Model selection
99-
import model_simple_structures
10099
model_param = meep_utils.process_param(sys.argv[1:])
101100
model = Wedge_model(**model_param)
102101

@@ -161,10 +160,10 @@ def complex_vec(self, vec): ## Note: the 'vec' coordinates are _relative_ to t
161160
if "snapshote" in model.comment:
162161
slices += [meep_utils.Slice(model=model, field=f, components=(meep.Ex, meep.Ey, meep.Ez), at_t=np.inf, name='SnapshotE')]
163162

164-
slices += [meep_utils.Slice(field=f, components=(meep.Ex), min_timestep=.1e-12, name='wedge',
165-
volume=meep.volume(
166-
meep.vec(0, -model.size_y/2+model.pml_thickness, model.size_z/2-model.pml_thickness),
167-
meep.vec(0, model.size_y/2-model.pml_thickness, model.size_z/2-model.pml_thickness)),
163+
#volume=meep.volume(
164+
#meep.vec(0, -model.size_y/2+model.pml_thickness, model.size_z/2-model.pml_thickness),
165+
#meep.vec(0, model.size_y/2-model.pml_thickness, model.size_z/2-model.pml_thickness)),
166+
slices += [meep_utils.Slice(field=f, components=(meep.Ex), min_timestep=.1e-12, name='wedge', at_x=0, at_z=model.size_z/2-model.pml_thickness,
168167
model=model, outputdir=model.simulation_name, pad=model.pml_thickness, outputhdf=True, outputvtk=True, outputgif=True)]
169168

170169
#pad = model.pml_thickness

0 commit comments

Comments
 (0)