Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabular dispersions might break Solver2x2 #131

Closed
MarJMue opened this issue Apr 16, 2023 · 5 comments · Fixed by #134
Closed

Tabular dispersions might break Solver2x2 #131

MarJMue opened this issue Apr 16, 2023 · 5 comments · Fixed by #134

Comments

@MarJMue
Copy link
Collaborator

MarJMue commented Apr 16, 2023

Using something like this Si_Palik.txt to generate a dispersion leads to rounding errors, where k varies around 0 in the IR and can become negative.

This breaks Solver2x2 as described in #130.

lbda = np.linspace(200, 1700, 10)
table = elli.Table(Si_Palik.index.values, Si_Palik["n"] + 1j * Si_Palik["k"])
table.get_refractive_index(lbda)

array([0.9151964 +2.75630140e+00j, 6.68599419+2.47306141e+00j,
       4.14435409+4.37175170e-02j, 3.78316134+1.26652976e-02j,
       3.64459034+2.26450024e-02j, 3.56345879+1.10329426e-02j,
       3.5193    -7.62329653e-21j, 3.50295359-2.04540250e-06j,
       3.47835012+3.04455261e-08j, 3.46418165+7.81489545e-09j])

Edit: I think the cubic interpolation leads to oscillations in this case. Setting it to linear fixes the issue, but i have no idea how we should handle this correctly.

@MarJMue
Copy link
Collaborator Author

MarJMue commented Apr 16, 2023

Interpolation linear for comparison.

array([0.93614634+2.77121951j, 6.68401587+2.47180952j,
       4.1445037 +0.04452593j, 3.7830625 +0.0125625j ,
       3.65430495+0.0086344j , 3.57653854+0.00295387j,
       3.5193    +0.j        , 3.50127674+0.j        ,
       3.4782549 +0.j        , 3.46414615+0.j        ])

@domna
Copy link
Member

domna commented Apr 16, 2023

Nice find. This is bad. Maybe there is an interpolation which is sign-safe, but I think we could also switch to linear per default. What do you think?

@MarJMue
Copy link
Collaborator Author

MarJMue commented Apr 16, 2023

With the linear default we would lose accuracy in other ranges.
Alternatively we could implement a lower boundary which would be rounded to 0, but that would hurt high precission data from RII.
RII seems to use linear interpolation, too.

However I think we should make it configurable, but that might be clunky with the parameters...

@domna
Copy link
Member

domna commented Apr 17, 2023

Do you think this would impact the accuracy much? I would expect that the values are close enough most of the time anyways.

I had a short look and it seems that linear interpolation is the only interpolation which is guaranteed to stay inside the data range. I would suggest we add an option to select different interpolations but set linear to the default value. This way we can always guarantee correct data but if users like more precision they are able to select a more accurate interpolation.

@MarJMue
Copy link
Collaborator Author

MarJMue commented Apr 17, 2023

I agree. Linear interpolation should be good enough and is the simplest fix.
If someone needs something better there is always the possibility to use some formula dispersion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants