Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with absorption profile calculation when using angular redistribution matrix method #56

Closed
phoebe-p opened this issue Mar 14, 2023 · 2 comments

Comments

@phoebe-p
Copy link
Member

phoebe-p commented Mar 14, 2023

Describe the bug
When there is a significant contribution to the interface absorption in the front surface from light which is incident on the front surface from inside the cell, the absorption profiles are not calculated correctly when using RT+TMM to calculate the redistribution matrices. This can be seen by comparing to absorption profiles calculated with either TMM or RT with integrated TMM (no redistribution matrices, pure ray-tracing). This is an unusual situation, because usually the bulk layer would absorb any short-wavelength light which is easily absorbed in front layers, so unless you have e.g. a thin or transparent bulk this is not noticeable, hence why it was not noticed in tests previously. The issue does not seem to occur when other methods are used to calculate the redistribution matrices, possible issue with e.g. binning for the ray-tracing angular redistribution matrix calculations?

IMPORTANT NOTE: All the issues discussed here only affected absorption profiles, and NOT the calculation of total reflection, transmission, and absorption per layer (not position-resolved).

To Reproduce
The issue only seems to occur when the front redistribution matrix is calculated using RT + TMM. If all the matrices are calculated using TMM, or the rear matrices are calculated with RT + TMM and the front matrix with just TMM, the issue does not occur.

The discrepancy appears to be a convergence issue; using enough rays and angular bins gives very similar results when comparing pure RT and RT + angular redistribution matrices.

Expected behavior
For a planar structure, should be able to replicate absorption profiles across methods (TMM, pure RT with TMM probabilities, TMM with angular redistribution matrices, RT + TMM with angular redistribution matrices).

Screenshots

Environment (please complete the following information):

  • RayFlare version [e.g. 1.1.0]
@phoebe-p
Copy link
Member Author

phoebe-p commented Mar 15, 2023

With further testing, there was definitely an issue with the bulk absorption profile for light travelling backwards in the bulk, which will be addressed in #55. This was due to the "outgoing" and "incoming" ray definitions used in the matrix multiplication (see here. When calculating the total absorption per bin, which is used to scale the absorption profile to make sure integrated and total absorption agree regardless of the depth spacing chosen. However, when calculating the upwards-travelling profile in the bulk medium (i.e. light reflected from the back and travelling towards the front surface), vf_2 and vb_2 (the binned intensity of the light before and after traversing the bulk) were not in the same format, resulting in incorrect absorption per bin and thus incorrect scaling.

However, the differences in absorption profile when comparing methods for pyramidal textures seem to be due to convergence issue when using the angular redistribution matrix approach. Using a pyramidal back surface (RT + TMM) and a planar front surface (treated with both TMM and RT + TMM for testing purposes) gives very similar results (taking into account random noise from the ray-tracing) in terms of the profile matrices generated, and also agrees well qualitatively with 100% ray-tracing.

GaInP/GaAs/Ge stack (with purposely strange layer thicknesses in order to test this behaviour). Dashed lines = angular redistribution matrices, solid lines = RT with TMM probabilities, no matrices.

Total R/A/T:
image

Front surface absorption profile:
image

Back surface absorption profile:
image

Bulk absorption profile:
image

scratch_18.txt

@phoebe-p
Copy link
Member Author

Separately, there was an issue when calculating absorption profiles in the surfaces (as opposed to the bulk, as discussed in the previous comment). This was due to a bug when calculating the TMM lookup tables prior to generating the angular redistribution matrices using RT + TMM. When specifying the profile layers (prof_layers= in the Interface), if not all the layers were selected, for the profile coming from the rear the profile would be calculated for the wrong layers because the prof_layers variable was not being flipped appropriately with the structure. This was also addressed in #55.

phoebe-p added a commit that referenced this issue Mar 21, 2023
- Add ability to use pre-calculated TMM lookup tables directly in ray-tracing (as opposed to the currently-implemented functionality, which allows this only for a single surface in combination with the angular redistribution matrix method)
- Make automatic calculation of x and y limits for ray-tracing more robust
- Remove avoid_limits option, user can set `options.x_limits` and `options.y_limits` manually
- Add functions for generating a roughened planar surface (`rough_planar_surface`), roughened pyramids (`rough_pyramids`), and a (roughened or smooth) surface with hemispherical caps (`hemisphere_surface`)
- Remove random_pyramids function based on scan data
- Change behaviour in `single_ray_stack` so that the ray position is randomised to strike somewhere inside the unit cell, even if the surface is not periodic (`periodic = False` in options)
- Fix issue in tmm_structure.calculate where unphysical values for A_per_layer were calculated (datatype error in numpy array)?
- Fix test comparing periodic and non-periodic ray-tracing
- Change make_absorption_function to require a different result input format (the full result of the optical calculation, rather than just the profile part). This is to standardize its behaviour across all methods
- Add `overwrite` argument to process_structure() and rt_structure.calculate() to overwrite rather than load previously-generated lookup tables/redistribution matrices 
- Fix bug in calculation of bulk absorption profile for backwards-travelling rays in angular redistribution matrix method (#56)
- Fix bug in calculation of coefficients for TMM profile calculation generated during lookup table creation; if not all profile layers were requested, the `prof_layers` list was not getting flipped correctly to calculate the coefficients for the right layers. This only affected contributions to the absorption profile for rear incidence on a surface (usually negligible)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant