Skip to content

Commit 6d95340

Browse files
committed
Refactor implementation according to vision for usage
1 parent 1177443 commit 6d95340

File tree

2 files changed

+95
-60
lines changed

2 files changed

+95
-60
lines changed

src/interfaces/background_field_interface.jl

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# The abstract background field interface
33
#
44
# In this file, the abstract interface for different types of background fields
5-
# is defined.
5+
# is defined.
66
####################
77
"""
88
Abstract base type for describing classical background fields.
@@ -45,13 +45,13 @@ function reference_momentum end
4545
4646
domain(::AbstractPulsedPlaneWaveField)
4747
48-
Interface function for [`AbstractPulsedPlaneWaveField`](@ref), which returns interval (as a `IntervalSets.Interval`) for the given background field.
48+
Interface function for [`AbstractPulsedPlaneWaveField`](@ref), which returns interval (as a `IntervalSets.Interval`) for the given background field.
4949
5050
"""
5151
function domain end
5252

5353
"""
54-
54+
5555
pulse_length(::AbstractPulsedPlaneWaveField)
5656
5757
Interface function for [`AbstractPulsedPlaneWaveField`](@ref), which returns a dimensionless representative number for the duration of the background field,
@@ -68,35 +68,35 @@ Interface function for [`AbstractPulsedPlaneWaveField`](@ref), which returns the
6868
!!! note "Single point implementation"
6969
7070
The interface function can be implemented for just one phase point as input. With that, evaluation on a vector of inputs is generically implemented by broadcasting.
71-
However, if there is a better custom implementation for vectors in input values, consider implementing
71+
However, if there is a better custom implementation for vectors in input values, consider implementing
7272
```Julia
73-
73+
7474
_envelope(::AbstractPulsedPlaneWaveField, phi::AbstractVector{T<:Real})
7575
7676
```
7777
7878
!!! note "unsafe implementation"
79-
80-
This is the unsafe version of the phase envelope function, i.e. this should be implement without input checks like the domain check.
81-
In the safe version [`envelope`](@ref), a domain check is performed, i.e. it returns the value of `_envelope` if the passed in `phi`
82-
is in the `domain` of the field, and zero otherwise.
79+
80+
This is the unsafe version of the phase envelope function, i.e. this should be implement without input checks like the domain check.
81+
In the safe version [`envelope`](@ref), a domain check is performed, i.e. it returns the value of `_envelope` if the passed in `phi`
82+
is in the `domain` of the field, and zero otherwise.
8383
8484
"""
8585
function _envelope end
8686

8787
function _envelope(
8888
field::AbstractPulsedPlaneWaveField, phi::AbstractVector{T}
8989
) where {T<:Real}
90-
# TODO: maybe use broadcasting here
90+
# TODO: maybe use broadcasting here
9191
return map(x -> _envelope(field, x), phi)
9292
end
9393

9494
"""
95-
95+
9696
envelope(pulsed_field::AbstractPulsedPlaneWaveField, phi::Real)
97-
98-
Return the value of the phase envelope function (also referred to as pulse envelope or pulse shape)
99-
for given `pulsed_field` and phase `phi`. Performs domain check on `phi` before calling [`_envelope`](@ref);
97+
98+
Return the value of the phase envelope function (also referred to as pulse envelope or pulse shape)
99+
for given `pulsed_field` and phase `phi`. Performs domain check on `phi` before calling [`_envelope`](@ref);
100100
returns zero if `phi` is not in the domain returned by `[domain](@ref)`.
101101
"""
102102
function envelope(field::AbstractPulsedPlaneWaveField, phi::Real)
@@ -106,7 +106,7 @@ end
106106
function envelope(
107107
field::AbstractPulsedPlaneWaveField, phi::AbstractVector{T}
108108
) where {T<:Real}
109-
# TODO: maybe use broadcasting here
109+
# TODO: maybe use broadcasting here
110110
return map(x -> envelope(field, x), phi)
111111
end
112112

@@ -123,15 +123,15 @@ function _amplitude(
123123
pol::AbstractDefinitePolarization,
124124
phi::AbstractVector{T},
125125
) where {T<:Real}
126-
# TODO: maybe use broadcasting here
126+
# TODO: maybe use broadcasting here
127127
return map(x -> _amplitude(field, pol, x), phi)
128128
end
129129

130130
"""
131131
132132
amplitude(field::AbstractPulsedPlaneWaveField, pol::AbstractDefinitePolarization, phi)
133133
134-
Returns the value of the amplitude for a given polarization direction and phase variable `phi`.
134+
Returns the value of the amplitude for a given polarization direction and phase variable `phi`.
135135
136136
!!! note "Conventions"
137137
@@ -143,7 +143,7 @@ Returns the value of the amplitude for a given polarization direction and phase
143143
```
144144
145145
!!! note "Safe implementation"
146-
146+
147147
In this function, a domain check is performed, i.e. if `phi` is in the domain of the field,
148148
the value of the amplitude is returned, and zero otherwise.
149149
"""
@@ -158,7 +158,7 @@ function amplitude(
158158
pol::AbstractDefinitePolarization,
159159
phi::AbstractVector{T},
160160
) where {T<:Real}
161-
# TODO: maybe use broadcasting here
161+
# TODO: maybe use broadcasting here
162162
return map(x -> amplitude(field, pol, x), phi)
163163
end
164164

@@ -197,46 +197,6 @@ function generic_spectrum(
197197
pol::AbstractDefinitePolarization,
198198
photon_number_parameter::AbstractVector{T},
199199
) where {T<:Real}
200-
# TODO: maybe use broadcasting here
200+
# TODO: maybe use broadcasting here
201201
return map(x -> generic_spectrum(field, pol, x), photon_number_parameter)
202202
end
203-
204-
# phase integrals B_i(l)
205-
#
206-
# TODO: Up to now, all of this is just copy paste and needs to be adapted to phase integrals
207-
"""
208-
209-
phase_integral_1(field::AbstractPulsedPlaneWaveField, pol::AbstractDefinitePolarization, p_in::, p_out::, pnum)
210-
211-
Return the first phase integral of the given field, for the given phase space point `p_in, p_out` and a given photon number parameter `pnum`.
212-
213-
!!! note "Convention"
214-
215-
The first phase integral is defined as:
216-
217-
```math
218-
\\begin{align*}
219-
B_1^\\mu(l, p, p^\\prime)& = \\int \\mathrm{d}\\varphi A^\\mu(\\varphi)\\exp[\\imath l \\varphi + \\imath G(\\varphi)] \\\\
220-
\\end{align*}
221-
```
222-
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.
223-
"""
224-
function phase_integral_1 end
225-
226-
"""
227-
228-
phase_integral_2(field::AbstractPulsedPlaneWaveField, pol::AbstractDefinitePolarization, p_in::, p_out::, pnum)
229-
230-
Return the second phase integral of the given field, for the given phase space point `p_in, p_out` and a given photon number parameter `pnum`.
231-
232-
!!! note "Convention"
233-
234-
The second phase integral is defined as:
235-
236-
```math
237-
\\begin{align*}
238-
B_2(l, p, p^\\prime)& = \\int \\mathrm{d}\\varphi A(\\varphi)^2 \\exp[\\imath l \\varphi + \\imath G(\\varphi)] \\\\
239-
\\end{align*}
240-
```
241-
"""
242-
function phase_integral_2 end

src/interfaces/phase_integrals.jl

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
####################
2+
# The abstract phase integral interface
3+
#
4+
# In this file, the abstract interface for different copmutation methods of
5+
# phase integrals is defined.
6+
####################
7+
"""
8+
Abstract base type for defining a method for phase integral computation.
9+
"""
10+
abstract type Method end
11+
12+
"""
13+
Analytic method for phase integral computation.
14+
15+
Requires an existing implementation of analytic formulas for computing the
16+
entities in the phase integrals.
17+
"""
18+
struct Analytic <: Method end
19+
20+
"""
21+
Fully numerical method for phase integral computation based on QuadGK.
22+
"""
23+
struct QuadGK <: Method end
24+
25+
"""
26+
Struct holding setup specific information to compute phase integrals.
27+
28+
ToDo: We mix physical and numerical aspects in this class.
29+
This does not seem ideal to me (Klaus).
30+
"""
31+
struct PhaseIntegral{P<:AbstractPulsedPlaneWaveField, M<:Method}
32+
pulse::P
33+
method::M
34+
end
35+
36+
# phase integrals B_i(l)
37+
#
38+
# TODO: Up to now, all of this is just copy paste and needs to be adapted to phase integrals
39+
"""
40+
41+
computeB1(ph_int_stp::PhaseIntegral, pol::AbstractPolarization, a0, pnum, alpha1x, alpha1y, alpha2)
42+
43+
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``.
44+
45+
!!! note "Convention"
46+
47+
The first phase integral is defined as:
48+
49+
```math
50+
\\begin{align*}
51+
B_1^\\mu(l, p, p^\\prime)& = \\int \\mathrm{d}\\varphi A^\\mu(\\varphi)\\exp[\\imath l \\varphi + \\imath G(\\varphi)] \\\\
52+
\\end{align*}
53+
```
54+
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.
55+
"""
56+
function computeB1 end
57+
58+
# TODO: REWORK THE FOLLOWING DOCUMENTATION
59+
"""
60+
61+
computeB2()
62+
63+
Return the second phase integral.
64+
65+
!!! note "Convention"
66+
67+
The second phase integral is defined as:
68+
69+
```math
70+
\\begin{align*}
71+
B_2(l, p, p^\\prime)& = \\int \\mathrm{d}\\varphi A(\\varphi)^2 \\exp[\\imath l \\varphi + \\imath G(\\varphi)] \\\\
72+
\\end{align*}
73+
```
74+
"""
75+
function computeB2 end

0 commit comments

Comments
 (0)