celes icon indicating copy to clipboard operation
celes copied to clipboard

Error: complex refractive index of medium

Open Melowa opened this issue 6 years ago • 3 comments

Running the example file CELES_MAIN.m with a non-zero imaginary part of 'mediumRefractiveIndex' causes the execution to terminate with an error right after it says "compute scattered field plane wave pattern:" The error is: "Error using celes_planeWavePattern/validatePropertiesImpl (line 123) invalid k value: Expected input to be real." the refractive index I used was 1.2 + 0.01i and the light wavelength 500. Also, output.initialFieldPower is complex, with large imaginary part, in my case 3.7e6 + 3.1e4i. Does anyone else have this issue?

Melowa avatar May 15 '18 11:05 Melowa

Hi Melowa!

Unfortunately, the case of a surrounding medium with absorption is currently not implemented. This is why the code complains when you try to define a complex refractive index.

According to @lpattelli You can tweak the code to run also with a complex refractive index of the surrounding medium by commenting lines 122 and 123 of the file celes/src/classes/celes_planeWavePattern.m (the lines that check for real refractive index and throw the error you get). However, I don't know if the fields that you compute that way will be correct. Also, I don't see how the far field power of the initial field or the scattered field could be defined in a meaningful way if you have an absorbing surrounding medium.

As @lpattelli has further pointed out, the MSTM code by Daniel Mackowski has a setting for medium_imag_ref_index, so maybe you can consider using that code instead of CELES.

AmosEgel avatar May 15 '18 13:05 AmosEgel

Maybe we should leave it open such that people who obtain the same error can see this.

AmosEgel avatar May 15 '18 14:05 AmosEgel

Thanks, this is very helpful! I was simulating particles in water. For my wavelength of interest the imaginary part of the medium refractive index is anyway small, so I will neglect it. In principle I am only interested in a finite region of space (without far field).

Melowa avatar May 15 '18 14:05 Melowa