Closed szabo137 closed 3 months ago
Another thought: We should probably add an @inline
to all of the functions that just delegate by broadcast or some check.
@steindev Thanks for reviewing, I hopefully addressed all comments. Ready for revisiting!
@tjungni would you please approve in case all your comments are resolved?
@tjungni I addressed all of your comments and appreciate your approval.
Problem statement
The current implementation only allows implementing
differential_cross_section
directly for given processes. Furthermore, the interface does not allow the implementation of different phase-space coordinate systems, e.g. to model $d\sigma/dE$ and $d\sigma/d\cos\theta$ for the same process.Suggested solution
Advanced process interface
I suggest to disassemble the differential cross-sections interface into a more flexible interface:
where the functions with the asterisk give the new interface for the calculation of differential cross-sections:
_matrix_element
: the matrix element of the process_phase_space_factor
: the value of the pre-differential factor of the phase-space measure_is_in_phasespace
: checks if a given input is physical, see below_incident_flux
: the incident particle flux, used to normalize the probability_avg_normalization
: normalization for averaging of squared matrix elementsThe underscore of those functions implies, that they are not exported, and no input validation check is performed. For the functions
_differential_cross_section
and_differential_probability
there are versionsdifferential_cross_section
anddifferential_probability
, where input validation is performed.Phase space definition
To attack the original problem using different coordinate systems for the same process, this PR adds a simple system for coordinate systems and frames of reference. Those are propagated through a composite type:
Currently, the given example implementations are very limited, but this deserves an interface in the future. A dedicated issue will be opened during the review process of this PR (see todos below).
Phase space check
Not included in the input validation is the check if given incoming and outgoing phase-spaces are physical, i.e. if all momenta are on-shell and fulfill some sort of energy-momentum conservation. Therefore, I suggest to add another interface function
which returns
true
if the input is physical, andfalse
otherwise. Consequently, there are unsafe versions of cross-sections and probabilities, which don't perform the check given by the function above, and safe versions, which return null if the condition given by_is_in_phasespace
is not met.Final remarks
To conclude, the different versions of cross-section and probability functions, derived from the interface above, are
where only the functions without an underscore are exported, for all of those functions, there are implementations for all combinations of vectors and matrices for the incoming and outgoing phase space.
Todos:
(_(unsafe_))probability
_[unsafe_]probability
to_[unsafe]differential_probability
PhasespaceDefinition