Skip to content

Commit d23a934

Browse files
committed
Added smooth windows to limit time integrals
1 parent 31c3eda commit d23a934

File tree

5 files changed

+64
-8
lines changed

5 files changed

+64
-8
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.1.0"
66
[deps]
77
ElectricFields = "2f84ce32-9bb1-11e8-0d9f-3dce90a4beca"
88
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
9+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
910
HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
@@ -18,6 +19,7 @@ UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a"
1819
[compat]
1920
ElectricFields = "0.1, 0.2"
2021
FastGaussQuadrature = "0.4.7, 0.5"
22+
FillArrays = "1"
2123
HCubature = "1.5"
2224
ProgressMeter = "1.5,1.6"
2325
SpecialFunctions = "1.3,2"

src/StrongFieldApproximation.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using FastGaussQuadrature
77

88
using LinearAlgebra
99
using StaticArrays
10+
using FillArrays
1011

1112
using ProgressMeter
1213
using TimerOutputs
@@ -20,6 +21,7 @@ include("momentum_grid.jl")
2021
include("units.jl")
2122
include("field.jl")
2223
include("volkov.jl")
24+
include("windows.jl")
2325

2426
include("channels.jl")
2527
include("system.jl")

src/dyson_expansions.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function recombination(system::System, diagram::Diagram, 𝐩, 𝐀, i)
1818
end
1919
end
2020

21-
function integrate_diagram(::Type{Amp}, system::System, diagram::Diagram, iref, 𝐤=nothing; memory=typemax(Int), imin=1,
21+
function integrate_diagram(::Type{Amp}, system::System, diagram::Diagram, iref, 𝐤=nothing;
22+
window=flat_window(), imin=1,
2223
to=TimerOutput(), verbosity=1) where Amp
2324
ions, unique_momenta, momenta, indeterminate_momenta, order = @timeit to "Analyze diagram" analyze_diagram(system, diagram)
2425

@@ -39,10 +40,18 @@ function integrate_diagram(::Type{Amp}, system::System, diagram::Diagram, iref,
3940
ctT = complex(eltype(system.t))
4041

4142
is = vcat(iref, zeros(Int, order))
43+
44+
memory = length(window)
45+
if memory < iref
46+
window = vcat(window, zeros(eltype(window), iref))
47+
end
4248
end
4349

4450
@timeit to "Time loop" begin
4551
for i in TelescopeIterator(max(1,imin):iref-1, order, memory)
52+
windw = @timeit "Window" prod(window[(i[1] + 1) .- i])
53+
iszero(windw) && continue
54+
4655
is[2:end] .= i
4756
# is = vcat(iref, i)
4857
# is = (iref,i...)
@@ -89,7 +98,9 @@ function integrate_diagram(::Type{Amp}, system::System, diagram::Diagram, iref,
8998
end
9099
end
91100

92-
amplitude += ∂a
101+
@timeit to "Accumulate amplitude" begin
102+
amplitude += ∂a * windw
103+
end
93104
end
94105
end
95106

@@ -122,7 +133,7 @@ function photoelectron_spectrum(k::AbstractArray{T},
122133
end
123134

124135
function photoelectron_spectrum(k, args...; kwargs...)
125-
system = System(args...; kwargs...)
136+
system = System(args...)
126137
photoelectron_spectrum(k, system, Diagram(system); kwargs...)
127138
end
128139

@@ -140,18 +151,19 @@ function induced_dipole(system::System, diagram::Diagram; verbosity = 1, kwargs.
140151
DT = eltype(system.𝐀)
141152
𝐝 = zeros(DT, length(t))
142153

143-
memory = get(kwargs, :memory, typemax(Int))
154+
memory = length(get(kwargs, :window, flat_window()))
144155

145156
@showprogress for (i,t) in enumerate(t)
146-
𝐝̃ = integrate_diagram(DT, system, diagram, i; imin=i-memory, verbosity=verbosity-1, kwargs...)
157+
𝐝̃ = integrate_diagram(DT, system, diagram, i; imin=i-memory,
158+
verbosity=verbosity-1, kwargs...)
147159
𝐝[i] = 2real(𝐝̃)
148160
end
149161

150162
𝐝
151163
end
152164

153165
function induced_dipole(args...; kwargs...)
154-
system = System(args...; kwargs...)
166+
system = System(args...)
155167
diagram = Diagram([(1,0),(1,0)], system)
156168
induced_dipole(system, diagram; kwargs...)
157169
end

src/system.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ System(ionization_channels::AbstractVector{<:IonizationChannel},
7373
System(ionization_channels, nothing, NoCouplings,
7474
F, fs)
7575

76-
System(Iₚ::Number, args...; kwargs...) =
77-
System([IonizationChannel(Iₚ, args...)], args...; kwargs...)
76+
System(Iₚ::Number, args...) =
77+
System([IonizationChannel(Iₚ, args...)], args...)
7878

7979
num_channels(system::System) = length(system.ionization_channels)
8080

src/windows.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
flat_window(n=typemax(Int)) = Trues(n)
2+
3+
#=
4+
5+
Smooth turn-off of scalar functions, following Eqs. (18–21) of
6+
7+
- Becke, A. D. (1988). A Multicenter Numerical Integration Scheme for
8+
Polyatomic Molecules. The Journal of Chemical Physics, 88(4),
9+
2547–2553. http://dx.doi.org/10.1063/1.454033
10+
11+
=#
12+
13+
function becke_smoother(μ, k::Integer)
14+
p = μ -> 3μ/2 - μ^3/2
15+
f = μ
16+
for i = 1:k
17+
f = p(f)
18+
end
19+
(1-f)/2
20+
end
21+
22+
function becke_smoother(x, a, b, k)
23+
if x < a
24+
one(x)
25+
elseif x > b
26+
zero(x)
27+
else
28+
becke_smoother(2*(x-a)/(b-a)-1, k)
29+
end
30+
end
31+
32+
function smooth_window(::Type{T}, nflat, nsmooth, k) where T
33+
w = ones(T, nflat+nsmooth)
34+
for i = eachindex(w)
35+
w[i] = becke_smoother(i, nflat, nflat+nsmooth, k)
36+
end
37+
w
38+
end
39+
40+
export flat_window, smooth_window

0 commit comments

Comments
 (0)