Hi Mattia,
> I have also made a python script that takes the S11 component as function of theta and phi (using the -store_scatgrid
> option) and integrates it in the backward and forward hemisphere with respect to the impinging light direction, taking
> into account the eventual substrate presence and the proper reference frame. As expected, I have noticed that the
> simulation time can skyrocket with a too complex theta-phi grid. I was wondering your opinion about this, now I am
> working with 721 values for theta and 361 for phi. Probably a bit excessive... I will try to run some test to
> determine the accuracy and avoid wasting too much time.
Yes, this seems large, but ultimately it depends on your accuracy requirements and the specific algorithm you use for
integration. You can compare them with the default values in file `alldir_params.dat`, which are (if you grind through
the definition of Jmax in the comments) 65 and 32 for theta and phi, respectively. However, as mentioned previously, I
changed it to 257x128 for particles on substrate to get good accuracy. In principle, built-in integration is based on
adaptive (high-order) Romberg algorithm (for theta), but it is expected to be not efficient for discontinuous functions.
When you handle the jumps explicitly (cutting the range at theta=90, but maybe also at total-internal reflection angle),
you can definitely make it more efficient in combination with some high-order quadrature (or at least some integration
rule). For phi integration, the simplest trapezoidal rule on the uniform grid is the most efficient one due to the
periodicity of the integral, so it may be sufficient to use about 32 angles for wavelength-sized particles (but this
needs more testing). For example, I have just tested the grid 257x32 and it resulted in almost the same integration
accuracy as a denser one. So the number of phi values may even be decreased further after some tests.
> It may also be of interest (even if expected) that considering the phi dependence is fundamental for very asymmetric
> particles (in the plane perpendicular to the light direction). If the option -store_scatgrid is not included and the
> Csca integration is thus performed only considering the theta dependence, the results are not consistent, but this
> still will need further investigation.
I guess, it would be interesting to have a separate (faster) simulation option for symmetric particles (based on the
Mueller file), but you do not have as much flexibility here in terms of varying the grid of theta (it must always be
uniform). Then, some simple function to test it against the solid-angle integration is also desirable.
Similarly, you can also implement use of `-Csca` with modified theta ranges in `alldir_params.dat` (that I discussed
previously) and testing against the explicit integration. (based on your text below, I am not sure if you've already
tried it).
> I have double checked that instead by considering both theta and phi, the integrated Csca is consistent with the Csca
> calculated internally by ADDA and with Cext-Cabs computation, and it does take into account that the cross section
> coming from the light propagating into the substrate should be divided by the substrate refractive index squared. I
> have also checked with asymmetric and not standard particles. This script is meant to perform simulation for a
> spectrum of wavelength in parallel (user can decide how many at the same time), but of course can be used for a single
> wavelength, and complex shapes can be taken care of (as long as user has the .geom file - but I am also working in
> this direction). It is basically a standalone script that runs simulation in parallel, reads all the folder outputs,
> do the integration and save the desired quantities in simple .txt files as function of the wavelength. If you think it
> can be useful to the community, I will gladly share it as soon as I write some basic documentation (at this stage it
> is still not really user friendly).
This sounds great. I would only put a bit more emphasis on core functions, like the ones to (efficiently) calculate
hemi-spherical values for any ADDA command line. The wrappers on top of it (like scanning over wavelengths) can also be
useful for users, depending on their applications, but they should not hide the core functions. Thus, the latter should
be easy to reuse in a wide variety of applications. Once you are ready with the code, take a look at
https://github.com/adda-team/adda/wiki/InstructionCommitters#examples .
Maxim.