-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add phase integrals #59
base: dev
Are you sure you want to change the base?
Changes from all commits
a8326f2
9f4496d
fbb898e
1177443
6d95340
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,75 @@ | ||
#################### | ||
# The abstract phase integral interface | ||
# | ||
# In this file, the abstract interface for different copmutation methods of | ||
# phase integrals is defined. | ||
#################### | ||
""" | ||
Abstract base type for defining a method for phase integral computation. | ||
""" | ||
abstract type Method end | ||
|
||
""" | ||
Analytic method for phase integral computation. | ||
|
||
Requires an existing implementation of analytic formulas for computing the | ||
entities in the phase integrals. | ||
""" | ||
struct Analytic <: Method end | ||
|
||
""" | ||
Fully numerical method for phase integral computation based on QuadGK. | ||
""" | ||
struct QuadGK <: Method 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{P<:AbstractPulsedPlaneWaveField, M<:Method} | ||
pulse::P | ||
method::M | ||
end | ||
Comment on lines
+12
to
+34
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. This is implementation-related and should not go into the interfaces directory.
Comment on lines
+28
to
+34
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. This doesn't seem like a problem to me necessarily, at least there shouldn't be any overhead since This struct is intended to become the main part for user-facing functions? In this case we should think about which (if any) parts of the functionality of the plane wave fields and the methods can be implemented as orthogonal interfaces. |
||
|
||
# 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 | ||
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 | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,119 @@ | ||||||||||||||||||||||||||||||||||||||||
########################################### | ||||||||||||||||||||||||||||||||||||||||
# Definitions common to all phase integrals | ||||||||||||||||||||||||||||||||||||||||
########################################### | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# TODO: We need to talk about the handling of field polarization! | ||||||||||||||||||||||||||||||||||||||||
# Since some of the quantities required in phase integral computation are four-vectors, just as the bg-field itself, | ||||||||||||||||||||||||||||||||||||||||
# we need to return these as four-vectors, or their components. | ||||||||||||||||||||||||||||||||||||||||
# However, we do not even provide the field as a four-vector, yet. | ||||||||||||||||||||||||||||||||||||||||
# We just return its "amplitude", which is only the oscillator times the envelope, | ||||||||||||||||||||||||||||||||||||||||
# not even taking the correct maximum value a_0 of the field into account. (TODO!) | ||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||
# I think both the polarization and the maximum value of the field should be a user defined quantity, | ||||||||||||||||||||||||||||||||||||||||
# but then these should also be members of the field struct, shouldn't they? | ||||||||||||||||||||||||||||||||||||||||
# Or are these separately set in the Process? | ||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||
# All in all, I wonder how we should treat four-vectors in QEDfields. | ||||||||||||||||||||||||||||||||||||||||
# The problem of missing vectorial information appears here in _field_integral(), _kinematic_vector_phase_factor(), and phase_integral_1(). | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# TODO: The factors and integrals should not depend on the momenta of particles | ||||||||||||||||||||||||||||||||||||||||
# but on the Process and Phase Space Point (the latter of which holds the momenta) | ||||||||||||||||||||||||||||||||||||||||
# Question: Does the process hold a reference to the background field? | ||||||||||||||||||||||||||||||||||||||||
# If so, the explicit dependence on the background field should be removed to. | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# from QEDprocesses.jl/src/constants.jl | ||||||||||||||||||||||||||||||||||||||||
# TODO: we might want to move the constants.jl file to QEDbase? See also TODO in QEDprocesses.jl/src/processes/one_photon_compton/perturbative/cross_section.jl | ||||||||||||||||||||||||||||||||||||||||
const ALPHA = inv(137.035999074) | ||||||||||||||||||||||||||||||||||||||||
const ELEMENTARY_CHARGE = sqrt(4 * pi * ALPHA) | ||||||||||||||||||||||||||||||||||||||||
const ELEMENTARY_CHARGE_SQUARE = 4 * pi * ALPHA | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+24
to
+28
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. I agree, but I think QEDcore would be a better place instead of QEDbase. |
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# definite integral of PPW field | ||||||||||||||||||||||||||||||||||||||||
# TODO: Why does integration always start at 0? | ||||||||||||||||||||||||||||||||||||||||
@inline function _field_integral( | ||||||||||||||||||||||||||||||||||||||||
field::AbstractPulsedPlaneWaveField, | ||||||||||||||||||||||||||||||||||||||||
pol::AbstractPolarization, | ||||||||||||||||||||||||||||||||||||||||
phi::T | ||||||||||||||||||||||||||||||||||||||||
) where {T<:Real} | ||||||||||||||||||||||||||||||||||||||||
return quadgk(t -> amplitude(field, pol, t), 0.0, phi)[1] | ||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+30
to
+38
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. Shouldn't these functions take a
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# definite integral of squared PPW field | ||||||||||||||||||||||||||||||||||||||||
# TODO: Why does integration always start at 0? | ||||||||||||||||||||||||||||||||||||||||
@inline function _field_squared_integral( | ||||||||||||||||||||||||||||||||||||||||
field::AbstractPulsedPlaneWaveField, | ||||||||||||||||||||||||||||||||||||||||
pol::AbstractPolarization, | ||||||||||||||||||||||||||||||||||||||||
phi::T | ||||||||||||||||||||||||||||||||||||||||
) where {T<:Real} | ||||||||||||||||||||||||||||||||||||||||
return quadgk(t -> amplitude(field, pol, t)^2, 0.0, phi)[1] | ||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# kinematic vector factor alpha_1^mu appearing in Volkov phase | ||||||||||||||||||||||||||||||||||||||||
# TODO: Is `ELEMENTARY_CHARGE` actually related to the scattering particle or just a factor | ||||||||||||||||||||||||||||||||||||||||
@inline function _kinematic_vector_phase_factor( | ||||||||||||||||||||||||||||||||||||||||
field::AbstractPulsedPlaneWaveField, | ||||||||||||||||||||||||||||||||||||||||
p_in::MT, | ||||||||||||||||||||||||||||||||||||||||
p_out::MT, | ||||||||||||||||||||||||||||||||||||||||
) where {MT<:AbstractFourMomentum} | ||||||||||||||||||||||||||||||||||||||||
k_mu = momentum(field) | ||||||||||||||||||||||||||||||||||||||||
return ELEMENTARY_CHARGE*(p_out/(k_mu*p_out) - p_in/(k_mu*p_in)) | ||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# kinematic scalar factor alpha_2 appearing in Volkov phase | ||||||||||||||||||||||||||||||||||||||||
# TODO: Is `ELEMENTARY_CHARGE` actually related to the scattering particle or just a factor | ||||||||||||||||||||||||||||||||||||||||
@inline function _kinematic_scalar_phase_factor( | ||||||||||||||||||||||||||||||||||||||||
field::AbstractPulsedPlaneWaveField, | ||||||||||||||||||||||||||||||||||||||||
p_in::MT, | ||||||||||||||||||||||||||||||||||||||||
p_out::MT, | ||||||||||||||||||||||||||||||||||||||||
) where {MT<:AbstractFourMomentum} | ||||||||||||||||||||||||||||||||||||||||
k_mu = momentum(field) | ||||||||||||||||||||||||||||||||||||||||
return ELEMENTARY_CHARGE_SQUARE * (1/(k_mu*p_in) - 1/(k_mu*p_out)) | ||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# non-linear Volkov phase | ||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
_phase_function(field::AbstractPulsedPlaneWaveField, pol::AbstractPolarization, p_in::, p_out::, phi::) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
Return the phase function (or non-linear Volkov phase), for the given phase space point `p_in, p_out` and a given phase value `phi`. | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
!!! note "Convention" | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
The non-linear Volkov phase is defined as: | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
```math | ||||||||||||||||||||||||||||||||||||||||
\\begin{align*} | ||||||||||||||||||||||||||||||||||||||||
G(\\varphi,p, p^\\prime)& = \\alpha_1^\\mu \\int\\limits_0^\\varphi \\mathrm{d}\\varphi^\\prime A_\\mu(\\varphi^\\prime) | ||||||||||||||||||||||||||||||||||||||||
+ \\alpha_2 \\int\\limits_0^\\varphi \\mathrm{d}\\varphi^\\prime A^2(\\varphi^\\prime) \\\\ | ||||||||||||||||||||||||||||||||||||||||
\\end{align*} | ||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||
where ``A^\\mu(\\varphi)`` is the background field, ``\\alpha_1^\\mu`` is the [`kinematic vector phase factor`](@ref), and ``\\alpha_2`` is the [`kinematic scalar phase factor`](@ref). | ||||||||||||||||||||||||||||||||||||||||
Both ``\\alpha_1^\\mu`` and ``\\alpha_2`` depend on the given phase space point ``(p,p^\\prime)`` and the field's reference momentum ``k^\\mu`` the photon number parameter. | ||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||
@inline function _phase_function( | ||||||||||||||||||||||||||||||||||||||||
field::AbstractPulsedPlaneWaveField, | ||||||||||||||||||||||||||||||||||||||||
pol::AbstractPolarization, | ||||||||||||||||||||||||||||||||||||||||
p_in::MT, | ||||||||||||||||||||||||||||||||||||||||
p_out::MT, | ||||||||||||||||||||||||||||||||||||||||
phi::T | ||||||||||||||||||||||||||||||||||||||||
) where {MT<:AbstractFourMomentum, T<:Real} | ||||||||||||||||||||||||||||||||||||||||
first = _kinematic_vector_phase_factor(field, p_in, p_out) * _field_integral(field, pol, phi) | ||||||||||||||||||||||||||||||||||||||||
second = _kinematic_scalar_phase_factor(field, p_in, p_out) * _field_squared_integral(field, pol, phi) | ||||||||||||||||||||||||||||||||||||||||
return first+second | ||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
# integrand shared by all phase integrals | ||||||||||||||||||||||||||||||||||||||||
@inline function _shared_integrand( | ||||||||||||||||||||||||||||||||||||||||
field::AbstractPulsedPlaneWaveField, | ||||||||||||||||||||||||||||||||||||||||
pol::AbstractPolarization, | ||||||||||||||||||||||||||||||||||||||||
p_in::MT, | ||||||||||||||||||||||||||||||||||||||||
p_out::MT, | ||||||||||||||||||||||||||||||||||||||||
phi::T, | ||||||||||||||||||||||||||||||||||||||||
pnum::T | ||||||||||||||||||||||||||||||||||||||||
) where {MT<:AbstractFourMomentum, T<:Real} | ||||||||||||||||||||||||||||||||||||||||
return exp(1im*(pnum*phi + _phase_function(field, pol, p_in, p_out, phi))) | ||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
include("zeroth_integral.jl") | ||||||||||||||||||||||||||||||||||||||||
include("first_integral.jl") | ||||||||||||||||||||||||||||||||||||||||
include("second_integral.jl") | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+117
to
+119
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. Per the coding guidelines, we only use includes at the top-level, so these includes should be moved to the QEDfields.jl file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
####################### | ||
# Second phase integral | ||
####################### | ||
|
||
# Does it need to be the same T for all arguments? | ||
function phase_integral_2( | ||
field::AbstractPulsedPlaneWaveField, | ||
pol::AbstractPolarization, | ||
p_in::T, | ||
p_out::T, | ||
pnum::T | ||
) where {T<:Real} | ||
return quadgk(t -> amplitude(field, pol, t)^2 * _shared_integrand(field, pol, p_in, p_out, t, pnum), endpoints(domain(field))...)[1] | ||
end | ||
|
||
function phase_integral_2( | ||
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_2(field, 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.
Please add the type/struct/function definition (or something close that gets the idea across) in the docs too.
Also I'm not sure if the names
Method
andAnalytic
are a bit too unspecialized.