QEDjl-project / QEDprocesses.jl

[WIP]: QEDprocesses.jl: Modeling of scattering processes for QED.jl
https://qedjl-project.github.io/QEDprocesses.jl/stable/
MIT License
1 stars 3 forks source link

Computation and process setup interface #14

Closed szabo137 closed 12 months ago

szabo137 commented 1 year ago

With this PR, the concept of computation setups is introduced, and general as well as functionality related to scattering processes is implemented.

Description of the problem

One of the main tasks of this package is the computation of quantities like differential and total cross-section for given scattering processes and a given set of parameters. Usually, these quantities depend on a fixed set of initial parameters, and their value needs to be calculated for large amounts of input data. For example, the differential cross-section of a process depends on the generic scattering process, the compute model, and all sorts of initial parameters, which might be physical (e.g. energy scales) or technical (e.g. integrator settings). Once initialized, the differential cross-section is still a function of the external momenta of a scattering process. Therefore, for a given set of input data, i.e. momenta, one needs to be able to compute the respective value of the differential cross-section using the given setting.

Suggested solution

The initial parameters for a given quantity will be collected in a setup, which, once initialized, describes the initialized quantity, i.e. the quantity with fixed initial parameters. The actual computation can be performed by calling a member function compute on the setup object and the respective input arguments. The implementation described below defines an interface, that unifies this approach and extends the computation workflow by adding input verification and post-processing steps.

Implementation details

The root type for all setups is AbstractSetup, for which the following interface functions are defined:

_input_validation(stp::AbstractSetup, input::Any)
_compute(stp::AbstractSetup, input::Any)
_post_computation(stp::AbstractSetup, input::Any, result::Any)

None of those functions is exported, but they need to be added for a concrete implementation of AbstractSetup. For all functions, except _compute, a generic fallback is implemented, which uses a default implementation for the respective function. Based on the interface functions, the actual compute function is implemented as


compute(stp::AbstractSetup, input::Any)

where internally, the following steps are performed:

  1. input validation by calling _input_validation
  2. actual computation by calling _compute
  3. post-processing by calling _post_computation

Additionally, based on AbstractSetup, a specialized version of setups related to the combination of scattering processes and compute models is implemented: AbstractProcessSetup<:AbstractSetup, where the following functions are added to the setup interface:

scattering_process(stp::AbstractProcessSetup)
compute_model(stp::AbstractProcessSetup)

Based on them, the following functions are delegated to the respective type parameter:

number_incoming_particles(stp::AbstractProcessSetup)
number_outgoing_particles(stp::AbstractProcessSetup)

Final remarks

The possibilities for functionality based on the setup definition above are not exhausted by the set of interface functions defined with this PR. For example, the pre-and post-processing could be enhanced by more fine granular structures. Furthermore, the initialization step of a setup could have its input validation. This is currently delegated to the users, who implement a setup by themself. Finally, the set of functions defined on AbstractProcessSetup and delegated to the process and model, could be extended if necessary. However, all the points above should be considered only if they are necessary, which implies opening dedicated issues if any.

szabo137 commented 1 year ago

I added a description to this PR and therefore removed the draft status.

szabo137 commented 1 year ago

Sorry for being maybe a little pedantic 😅

Not at all, this review was very good and helped a lot to improve the PR!