S4 icon indicating copy to clipboard operation
S4 copied to clipboard

Nonsense results when adding only patterns with same index as background

Open sbyrnes321 opened this issue 9 years ago • 0 comments

If the background index of all layers is 1, and you add only one or more structures with index 1, then there's really nothing happening here, the light should just pass right through.

(Running this simulation in the first place might seem like a silly thing to do ... I tried it because I wanted a quick "control" simulation where I knew what results to expect.)

But when you do this, you actually get totally wrong results. Here is an example lua script...

S = S4.NewSimulation()
S:SetLattice({1,0}, {0,1})
S:SetNumG(100)
S:AddMaterial("Air", {1,0})

S:AddLayer('start', 0, 'Air')
S:AddLayer('middle', 2, 'Air')
S:AddLayer('end', 0, 'Air')

S:SetLayerPatternCircle('middle', 'Air', {0.4,0.5}, .1)

S:SetFrequency(1/.3)

--S:SetExcitationPlanewave({incident_theta,incident_phi}, {s_amplitude, s_phase}, {p_amplitude, p_phase})
S:SetExcitationPlanewave({0,0},{1,0},{0,0})

Exr, Eyr, Ezr, Hxr, Hyr, Hzr, Exi, Eyi, Ezi, Hxi, Hyi, Hzi = S:GetFields({1.2, 3.4, 0.1})
print('Ex=', Exr, Exi, "Ey=", Eyr, Eyi, "Ez=", Ezr, Ezi)
print('Hx=', Hxr, Hxi, "Hy=", Hyr, Hyi, "Hz=", Hzr, Hzi)
print('|E|^2=', Exr^2 + Exi^2 + Eyr^2 + Eyi^2 + Ezr^2 + Ezi^2)
print('|H|^2=', Hxr^2 + Hxi^2 + Hyr^2 + Hyi^2 + Hzr^2 + Hzi^2)

forw,_ = S:GetAmplitudes('end',0)
_,back = S:GetAmplitudes('start',0)
G = S:GetNumG()
print('should be zero:', back[1][1], back[1][2], back[1+G][1], back[1+G][2])

...and the results...

Ex=     0       0       Ey=     0.2845451881264 -0.20715202380262       Ez=
0       0
Hx=     -0.15080894970699       -0.20715202380262       Hy=     0       0
Hz=     0       0
|E|^2=  0.12387792505141
|H|^2=  0.065655300277248
should be zero: 0.30718954248366        -0.95164835153994       0       0

When the circle has index 1.000001 instead of 1, it takes much longer to run and you get the expected results |E|^2 ~ |H|^2 ~ 1, and reflection ~ 0.

Interestingly, another way to get the expected results is if both theta and phi are nonzero for the incident wave.

This is with the S4 1.1.1 Windows .exe downloaded from the website (NOT compiled myself).

Thanks in advance! --Steve

sbyrnes321 avatar Sep 11 '15 20:09 sbyrnes321