Proposal: adaptive integration
Dear Raysect team,
we believe that a non-uniform/adaptive integration in InhomogeneousVolumeEmitter would be ideal to speed up the process.
The leading idea would be to allow the user to define a mathematical rule to arbitrarily space source samples along the ray direction. While the current uniform integration places samples at a constant distance step (deafult = 1 cm), an adaptive integration would allow to put more closely-spaced samples in regions of interest (e.g. close to the maximum emission), and more coarsely-spaced elsewhere (e.g. where the emission approaches its minimum / vanishes). This has been preliminarily proven to reduce the computational cost of more than a factor 10, with no associated decrease in the precision.
Quoting the wise strategy suggested by @vsnever (from this issue)
-
I think that instead of modifying the
NumericalIntegratorclass, it would be more correct to define a separateAdaptiveNumericalIntegrator(VolumeIntegrator)class. -
Ideally,
AdaptiveNumericalIntegratorshould work with anyInhomogeneousVolumeEmitterinstant, and should not rely on special material methods such asstep_function_3d(). Of course, the emission spectrum must be reduced to a single value in order to calculate the error required to correct the integration step. Some obvious options are the total intensity error and the maximum spectral intensity error. I think it would be nice to give the user the option to choose between several methods of spectrum reduction. -
In
NumericalIntegratoryou have the loopwhile length_traveled < length:. The user expects thatlength_traveledis equal tolengthwhen integration stops, and herelength_traveledcan be greater thanlengthby the value lower thanstep. This potentially creates the debugging hell for the user, not to mention that the end point of integration lies outside the bounding primitive.
What do you think? Thank you! Cheers, Matteo
An expanded integration system, where materials inform the integrator what step size is appropriate is slated for version 1.0. However this is a breaking change and would require cherab's materials to be completely rewritten. The current design is unsatisfactory and not worth extending.
See #357.