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

Add Bruggeman EMA and depolarisation_factor property #46

Merged
merged 11 commits into from
Mar 23, 2022

Conversation

haydenrob
Copy link
Contributor

No description provided.

@haydenrob
Copy link
Contributor Author

@andyfaff all tests in test_refellips.py passed locally for me, but test 11 fails on test_linux - I'm not sure why. Perhaps the way I've implemented warnings isn't correct for the Bruggeman approach?

refellips/structureSE.py Outdated Show resolved Hide resolved
refellips/structureSE.py Outdated Show resolved Hide resolved
haydenrob and others added 4 commits March 22, 2022 12:17
Co-authored-by: Andrew Nelson <andyfaff@gmail.com>
@andyfaff
Copy link
Contributor

Can you provide me with the equations/paper where the Bruggeman EMA is given? I'm not sure that you've implemented it correctly.

A clue to why that test is failing can be found here. The sqrt calculation on refellips/structureSE.py:1014 is being provided with an invalid value.
I then changed the code to print(slabs[..., 1:3]) just before the sqrt. It turns out that all the values in column 1 are negative. Pretty sure that refractive indices should be positive. Anyway, the sqrt operation is trying to take the sqrt of a negative number and it doesn't like it.

Which brings me to a further point, are we doing any of the EMA calculations correctly?? Let's consider the 'linear' EMA. The first thing we do is to square n and k separately:

>>> n = np.array([1, 2])
>>> n = n**2
>>> print(n)
[1 4]

However, this is totally different to:

>>> np.power(complex(1, 2), 2)
(-3+4j)

The averaging of the solvent and material is then done separately on n**2 (column 1) and k**2 (column 2), before taking the sqrt.

Should we be performing these calculations using the first or second forms?

I would hope that the test suite should detect this.

@haydenrob
Copy link
Contributor Author

Just for reference, both EMA calcs are drawn from this paper.

  • Maxwell-Garnett comes from Eq 34
  • Bruggeman EMA comes from Eq 39

@haydenrob
Copy link
Contributor Author

@andyfaff okay to merge?

@andyfaff
Copy link
Contributor

It looks ok to me. I think a little refactor might be in order in a later PR. I'm thinking about introducing a MixedMaterialSlabSE class, and it would be nice to use the overall_RI function to do that.

@andyfaff
Copy link
Contributor

I haven't checked the maths, relying on you to do that.

@andyfaff
Copy link
Contributor

If you're happy then merge.

@haydenrob
Copy link
Contributor Author

I like the idea of the MixedMaterialSlabSE, but definitely something to look at later. Maths should be all good, and it converges with WVASE calcs as well.

@haydenrob haydenrob merged commit b1c60fa into refnx:master Mar 23, 2022
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 this pull request may close these issues.

None yet

2 participants