Closed matt8s closed 1 year ago
Update: Your original script contains a wave channel (i.e. diffraction order) exactly parallel to the $xy$ plane, which is at the Wood's anomaly condition.
Now, the convergence issue near and at Wood's anomaly is solved in v0.3.3.
Inkstone is developed independently from S4.
close for now; feel free to comment/reopen
This explains the error at angle of incidence = 0 degrees, but it doesn't explain why there are still errors at 1 degree. I describe these additional errors in my original post.
Hi @matt8s, Can yo please update to ver 0.3.3 (newest) and see if this issue persists?
Thank you for your transparent and usable Python port of S4.
To verify that the code works correctly, I attempted to reproduce the Fresnel equations using a simple two layer model -- the first layer with n=1, and the second with n=1.5. I have been unable to get this to work in Inkstone, but I did get it to work with an equivalent code for Phoebe-P S4 . Attached are the codes I used for both Inkstone, fresnel_inkstone_te.py (which doesn't work); and S4, Fresnel_S4_TE.py (working).
In inkstone, when I use angle = np.linspace(0, 90, 91) , I get the error: /inkstone/params.py:525: RuntimeWarning: Vacuum propagation constant 0 encountered. Possibly Wood's anomaly. warn("Vacuum propagation constant 0 encountered. Possibly Wood's anomaly.", RuntimeWarning)
When I use angle = np.linspace(1, 90, 90) , I get the error: Traceback (most recent call last): File "fresnel_inkstone_te.py", line 71, in
glapf, glapb = s.GetPowerFlux('gla')
File "/inkstone/simulator.py", line 1204, in GetPowerFlux
self.solve()
File "/inkstone/simulator.py", line 890, in solve
self._calc_sm()
File "/inkstone/simulator.py", line 704, in _calc_sm
s = next(ll[-1] for ll in self.csms if ll[-1][1] == n_layers-2)
StopIteration
If between the "air" air and "gla" glass layers, I add an intermediate layer: s.AddLayer(name='gla-int', thickness=1, material_background='glass')
and still keep angle = np.linspace(1, 90, 90) then I get the error
/.local/lib/python3.9/site-packages/inkstone/layer.py:545: RuntimeWarning: divide by zero encountered in divide vh = -1j p @ v / w[:, None, :] /.local/lib/python3.9/site-packages/inkstone/layer.py:545: RuntimeWarning: invalid value encountered in divide vh = -1j p @ v / w[:, None, :] Traceback (most recent call last): File "/inkstone/Fresnel_Inkstone/fresnel_inkstone_te.py", line 72, in
glapf, glapb = s.GetPowerFlux('gla')
File "/.local/lib/python3.9/site-packages/inkstone/simulator.py", line 1204, in GetPowerFlux
self.solve()
File "/.local/lib/python3.9/site-packages/inkstone/simulator.py", line 890, in solve
self._calc_sm()
File "/.local/lib/python3.9/site-packages/inkstone/simulator.py", line 682, in _calc_sm
ll[ilm].solve()
File "/.local/lib/python3.9/site-packages/inkstone/layer.py", line 702, in solve
self._calc_im()
File "/.local/lib/python3.9/site-packages/inkstone/layer.py", line 652, in _calc_im
al0, bl0 = im(self.phil, self.psil, self.pr.phi0, self.pr.psi0, self._phil_is_idt)
File "/.local/lib/python3.9/site-packages/inkstone/im.py", line 36, in im
term2 = sla.solve(psi1, psi2)
File "/.local/lib/python3.9/site-packages/scipy/linalg/_basic.py", line 140, in solve
a1 = atleast_2d(_asarray_validated(a, check_finite=check_finite))
File "/.local/lib/python3.9/site-packages/scipy/_lib/_util.py", line 287, in _asarray_validated
a = toarray(a)
File "/.local/lib/python3.9/site-packages/numpy/lib/function_base.py", line 627, in asarray_chkfinite
raise ValueError(
ValueError: array must not contain infs or NaNs