edmundsj / rcwa

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

Different number of harmonics in x and y directions #54

Open Ranejans opened 1 year ago

Ranejans commented 1 year ago

I used a previous version of the code to run some simulations and noticed that the code didn't work if you use a different number of harmonics in the x and y directions. I was able to trace the problem down to two functions in the matrices.py file: calculateDiffractionReflectionEfficiency and calculateDiffractionTransmissionEfficiency, where the transmission and reflection results are reshaped from column vectors to matrices. Here the code assumes the resulting matrices to be square, which is not the case is a different number of harmonics is used in the x and y direction. It was a simple fix to adjust it to be able to use a different number of harmonics in both directions. I noticed that the same assumption is being made in the most recent version of the code and I just wanted to point it out to you.

I think it's just a matter of changing R = R.reshape((RDimension, RDimension)) to R = R.reshape(numberHarmonics)

and T = T.reshape((TDimension, TDimension)) to T = T.reshape(numberHarmonics)

in lines 141 and 157 respectively in matrices.py