-
Notifications
You must be signed in to change notification settings - Fork 4
Add phase integrals #59
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
Changes from all commits
a8326f2
9f4496d
fbb898e
1177443
6d95340
4ecea3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,135 @@ | ||||||||||||||
| #################### | ||||||||||||||
| # The abstract phase integral interface | ||||||||||||||
| # | ||||||||||||||
| # In this file, the abstract interface for different computation methods of | ||||||||||||||
| # phase integrals is defined. | ||||||||||||||
| #################### | ||||||||||||||
| """ | ||||||||||||||
| Abstract base type for defining a method for phase integral computation. | ||||||||||||||
| """ | ||||||||||||||
| abstract type ComputeMethod end | ||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| Analytic method for phase integral computation. | ||||||||||||||
| Requires an existing implementation of analytic formulas for computing the | ||||||||||||||
| entities in the phase integrals. | ||||||||||||||
| """ | ||||||||||||||
| struct Analytic <: ComputeMethod end | ||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| Fully numerical method for phase integral computation. | ||||||||||||||
| """ | ||||||||||||||
| struct Numeric <: ComputeMethod end | ||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| Struct holding setup specific information to compute phase integrals. | ||||||||||||||
| ToDo: We mix physical and numerical aspects in this class. | ||||||||||||||
| This does not seem ideal to me (Klaus). | ||||||||||||||
| """ | ||||||||||||||
| struct PhaseIntegral{F<:AbstractBackgroundField, C<:ComputeMethod} | ||||||||||||||
| bgfield::F | ||||||||||||||
| method::C | ||||||||||||||
|
|
||||||||||||||
| function PhaseIntegral(bgfield::F, method::C) where {F<:AbstractBackgroundField, C<:ComputeMethod} | ||||||||||||||
| _assert_compatibility(bgfield, method) | ||||||||||||||
| new(bgfield, method) | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use explicit returns.
Suggested change
|
||||||||||||||
| end | ||||||||||||||
|
Comment on lines
+25
to
+38
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this part of the interface or is it an implementation of the interface? |
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| _assert_compatibility(::AbstractBackgroundField, ::ComputeMethod) | ||||||||||||||
| Interface function enforcing essential error check whether the respective functions exist that compute the phase integrals of the provided background field by the required method. | ||||||||||||||
| This function represents the default case stating that compute method and background field are not compatible. | ||||||||||||||
| It must be specialized for compatible types as | ||||||||||||||
| _assert_compatibility(::CompatibleField, ::CompatibleComputeMethod) = nothing | ||||||||||||||
| """ | ||||||||||||||
| function _assert_compatibility(<:AbstractBackgroundField, <:ComputeMethod) | ||||||||||||||
| throw(ArgumentError("phase integral of provided background field cannot be computed with required method!")) | ||||||||||||||
| end | ||||||||||||||
|
Comment on lines
+51
to
+53
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| compute(pi::PhaseIntegral, vi::VertexInput) | ||||||||||||||
| Interface function for [`PhaseIntegral`](@ref), which returns the result of the computation. | ||||||||||||||
| Need to be specialized? I need to check on what the computation of phase integrals actually depends. | ||||||||||||||
| """ | ||||||||||||||
| function compute end | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| Interface function returning background field. | ||||||||||||||
| All interface functions of background field, e.g. [`reference_momentum()`](@ref) can then be called on it. | ||||||||||||||
| """ | ||||||||||||||
| background_field(pi::PhaseIntegral) = pi.bgfield | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| Composite type providing all (kinematic) information, required for dressed vertex computation and physe integral computation further down the line, via interface functions | ||||||||||||||
| TODO: Should pnum become an explicit dependence of compute(pi, vi) in order to not construct a new VertexInput for every l, which is probably very slow. Because in the end we want to integrate the dressed vertex function Gamma^\mu over pnum. | ||||||||||||||
| """ | ||||||||||||||
| struct VertexInput{M<:QEDbase.AbstractFourMomentum,T<:Real} | ||||||||||||||
| pin::M | ||||||||||||||
| pout::M | ||||||||||||||
| pnum::T | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| Interface functions of VertexInput | ||||||||||||||
| """ | ||||||||||||||
| in_momentum(vi::VertexInput) = vi.pin | ||||||||||||||
| out_momentum(vi::VertexInput) = vi.pout | ||||||||||||||
| photon_number_parameter(vi::VertexInput) = vi.pnum | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| # TODO: The follwing is old stuff from 2024 and should be removed if not required in the implementation started in May 2025 | ||||||||||||||
| # phase integrals B_i(l) | ||||||||||||||
| # | ||||||||||||||
| # TODO: Up to now, all of this is just copy paste and needs to be adapted to phase integrals | ||||||||||||||
| """ | ||||||||||||||
| computeB1(ph_int_stp::PhaseIntegral, pol::AbstractPolarization, a0, pnum, alpha1x, alpha1y, alpha2) | ||||||||||||||
| Return the first phase integral for the given setup `ph_Int_stp`, background field strength `a0`, photon number parameter `pnum`, components of the kinematic vector factor ``\\alpha_1^\\mu``, and kinematic scalar factor ``\\alpha_2``. | ||||||||||||||
| !!! note "Convention" | ||||||||||||||
| The first phase integral is defined as: | ||||||||||||||
| ```math | ||||||||||||||
| \\begin{align*} | ||||||||||||||
| B_1^\\mu(l, p, p^\\prime)& = \\int \\mathrm{d}\\varphi A^\\mu(\\varphi)\\exp[\\imath l \\varphi + \\imath G(\\varphi)] \\\\ | ||||||||||||||
| \\end{align*} | ||||||||||||||
| ``` | ||||||||||||||
| where ``A^\\mu(\\varphi)`` is the background field, ``G(\\varphi,p, p^\\prime)`` is the [`phase function`](@ref), ``(p,p^\\prime)`` the given phase space point, and ``l`` the photon number parameter. | ||||||||||||||
| """ | ||||||||||||||
| function computeB1 end | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually use snake_case for function names, so this should probably be |
||||||||||||||
|
|
||||||||||||||
| # TODO: REWORK THE FOLLOWING DOCUMENTATION | ||||||||||||||
| """ | ||||||||||||||
| computeB2() | ||||||||||||||
| Return the second phase integral. | ||||||||||||||
| !!! note "Convention" | ||||||||||||||
| The second phase integral is defined as: | ||||||||||||||
| ```math | ||||||||||||||
| \\begin{align*} | ||||||||||||||
| B_2(l, p, p^\\prime)& = \\int \\mathrm{d}\\varphi A(\\varphi)^2 \\exp[\\imath l \\varphi + \\imath G(\\varphi)] \\\\ | ||||||||||||||
| \\end{align*} | ||||||||||||||
| ``` | ||||||||||||||
| """ | ||||||||||||||
| function computeB2 end | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| ###################### | ||
| # First phase integral | ||
| ###################### | ||
|
|
||
| # Does it need to be the same T for all arguments? | ||
| function phase_integral_1( | ||
| field::AbstractPulsedPlaneWaveField, | ||
| pol::AbstractPolarization, | ||
| p_in::T, | ||
| p_out::T, | ||
| pnum::T | ||
| ) where {T<:Real} | ||
| return quadgk(t -> amplitude(field, pol, t)*_shared_integrand(field, pol, p_in, p_out, t, pnum), endpoints(domain(field))...)[1] | ||
| end | ||
|
|
||
| function phase_integral_1( | ||
| field::AbstractPulsedPlaneWaveField, | ||
| pol::AbstractPolarization, | ||
| p_in::T, | ||
| p_out::T, | ||
| photon_number_parameter::AbstractVector{T} | ||
| ) where {T<:Real} | ||
| # TODO: maybe use broadcasting here | ||
| return map(x -> phase_integral_1(field, pol, p_in, p_out, x), photon_number_parameter) | ||
| end | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could think about dispatching on a
::Val{N}type instead of having these three different function names.