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

Computation and process setup interface #14

Merged
merged 19 commits into from
Oct 5, 2023

Conversation

szabo137
Copy link
Member

@szabo137 szabo137 commented Sep 26, 2023

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.

Copy link
Member

@tjungni tjungni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some pariticles are still hiding

src/interfaces/process_interface.jl Outdated Show resolved Hide resolved
src/interfaces/process_interface.jl Outdated Show resolved Hide resolved
src/interfaces/process_interface.jl Outdated Show resolved Hide resolved
Copy link
Member

@AntonReinhard AntonReinhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being maybe a little pedantic 😅

src/interfaces/process_interface.jl Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
test/interfaces/setup_interface.jl Show resolved Hide resolved
test/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
test/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
@szabo137
Copy link
Member Author

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

@szabo137 szabo137 marked this pull request as ready for review September 27, 2023 12:04
Copy link
Member Author

@szabo137 szabo137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reacted to every concern, please feel free to comment on my replies.

src/interfaces/process_interface.jl Show resolved Hide resolved
src/interfaces/setup_interface.jl Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Show resolved Hide resolved
src/interfaces/setup_interface.jl Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
test/interfaces/setup_interface.jl Show resolved Hide resolved
@szabo137
Copy link
Member Author

Sorry for being maybe a little pedantic 😅

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

Copy link
Member

@tjungni tjungni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more typos

src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
szabo137 and others added 3 commits September 28, 2023 15:21
Fixed typos in docstrings

Co-authored-by: Tom Jungnickel <140055258+tjungni@users.noreply.github.com>
tjungni
tjungni previously approved these changes Oct 4, 2023
Copy link
Member

@tjungni tjungni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my side everything is resolved.

AntonReinhard
AntonReinhard previously approved these changes Oct 4, 2023
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
…input the derivation; adjusted the tests and docstrings accordingly
@szabo137 szabo137 dismissed stale reviews from AntonReinhard and tjungni via c3d4456 October 4, 2023 22:01
…sert_valid_input covers all necessary usecases
AntonReinhard
AntonReinhard previously approved these changes Oct 5, 2023
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
src/interfaces/setup_interface.jl Outdated Show resolved Hide resolved
fixed comments on comments

Co-authored-by: Anton Reinhard <s1509337@msx.tu-dresden.de>
@AntonReinhard AntonReinhard merged commit 26cf2b9 into QEDjl-project:dev Oct 5, 2023
1 of 3 checks passed
@szabo137 szabo137 added this to the Release 0.1.0 milestone Oct 23, 2023
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

Successfully merging this pull request may close these issues.

None yet

3 participants