edmundsj / rcwa

Rigorous Coupled Wave Analysis for the calculation of Photonic Crystal R/T spectra
MIT License
93 stars 29 forks source link

Fix _k_matrix_1D #55

Open quant opened 1 year ago

quant commented 1 year ago

The fix normalizes reciprocal lattice vectors in _k_matrix_1D just like it is done in _k_matrix_2D.

Without normalization the 1D grating gives different results for different units of length, as the test shows

edmundsj commented 1 year ago

Can you add to your description what this fixes? It's been a minute and I don't recall it being necessary to normalize the reciprocal lattice vectors.

quant commented 1 year ago

I made the description. I am sorry, I should have begun with it. For the test - it may better be placed into a separate user tests test file.

edmundsj commented 1 year ago

Not at all, thank you for contributing! I believe you're correct, I'll hunt down the primary source for this ASAP to confirm. How did you notice this error?

quant commented 1 year ago

I found the issue exactly as the test shows: R and T in 1D setup were unexpectedly dependent on the unit of length used (nm vs um). After some debugging I located the inconsistency, fixed and tested it and now I (almost) trust the 1D path.

Still there is an insignificant issue with zero incident angle, and another minor issue with P_matrix() when er is a scalar, but I am not ready yet to file an issue and suggest a fix.