Dear Zhengxin,
thanks for you interest in the Smuthi code and welcome in the mailing list.
The error comes from the following lines in your script.
# plane wave expansion of total transmitted field
pwe_total_T = pbpost.transmitted_plane_wave_expansion(initial_field,
random_sequential_addition(),
layer_system,
a1, a2)
# plane wave expansion of total reflected field
pwe_total_R = pbpost.reflected_plane_wave_expansion(initial_field,
random_sequential_addition(),
layer_system,
a1, a2)
In each of these commands, you calculate a new particle list by calling the random_sequential_addition(). But these methods expect the same particle list for which the simulation has been run already. In fact, some simulation results are stored in the particle objects. So generating new particle lists means they don't have the simulation results to them and this is why the error is thrown. Besides, the newly generated particle lists might differ in position from the previous ones, as they are random generated ...
You can try
my_particle_list =
random_sequential_addition()
and then
simulation = Simulation(...
particle_list=my_particle_list,
...)
and finally
pwe_total_T = pbpost.transmitted_plane_wave_expansion(...
my_particle_list,
...)
pwe_total_R = pbpost.reflected_plane_wave_expansion(...
my_particle_list,
...)
Regarding the imaginary part of the substrate refractive index: It seems to me that the imaginary part of the refractive index is very small, right? So maybe you want to just neglect it (i.e., set the imaginary part to zero)? Then you could work with scattering cross sections and other far field operations both in the top and bottom layer.
Some other observations: The layer thickness of 100 is
pretty large compared to the wavelength of 3. That can lead to problems.
Smuthi is designed for mesoscopic systems, where layer thicknesses are
not much larger than the wavelength (a factor of 10 is probably ok, but
30 could be too much. You have to check ...). Typically, we would treat very thick layers as infinitely thick and then do an incoherent treatment of layer systems with multiple very thick layers.
The
integral contour looks not ideal to me, it should deflect into the
imaginary already before 1 (to avoid the branch cut at neff=1). You can
probably just go with the standard contour, wihtout defining one by
yourself. The automatically assigned integral contour takes care of avoiding the branch cuts.
Hope this helps a bit. If you have more questions or if anything is still unclear, don't hestiate to ask again.
Best regards,
Amos