Skip to content

Commit f1ce4f6

Browse files
Serguei PatchkovskiiSerguei Patchkovskii
Serguei Patchkovskii
authored and
Serguei Patchkovskii
committed
Added support for directly-interpolated waveforms
Added support for VP_SHAPE='alt spline', which directly interpolates waveforms for the vector-potential. This form is intended as a replacement for the more restrictive VP_SHAPE='table', and should be particularly useful for calculating RABBITT and streaking spectra. Also added new config files for gfortran 12 and Intel OneAPI compilers, and made some cosmetic changes to the makefiles.
1 parent eed53f5 commit f1ce4f6

10 files changed

+191
-23
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.x
44
*.il
55
*.a
6+
*.swp
67
*__genmod.f90
78
*.optrpt
89
*.dbg

Diff for: Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.PHONY: goal clear
2+
13
goal: makefile.dep
24
$(MAKE) spherical_tdse.x
35
# make build_pes.x
@@ -22,6 +24,9 @@ ACT2 = -e 's/^!\*nm/ /' # Disable MPI statements
2224
# include configs/babel-ifort18_opt.mak
2325
# include configs/zen-gfortran-7_opt.mak
2426
# include configs/zen-gfortran-11_opt.mak
27+
# include configs/zen-gfortran-12_opt.mak
28+
# include configs/zen-oneapi_opt.mak
29+
# include configs/zen-oneapi_opt_mpi.mak
2530
# include configs/zen-aocc-1.1_opt.mak # VERY SLOW CODE. DO NOT USE.
2631
# include configs/oink-gfortran_opt.mak
2732
# include configs/macos_m1-gfortran_opt.mak

Diff for: configs/zen-gfortran-12_opt.mak

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
BUILD_ID :="Optimized gfortran-12 (ZEN/EPYC), built on $(shell hostname) at $(shell date)"
2+
ACT = sed -e 's/^!\*qd/ /' # Enable quad-math statements
3+
# WARNING: requesting -mtune=znver2 leads to incorrect code
4+
# WARNING: requesting -fexternal-blas leads to unreasonable stack requirements
5+
F90 = gfortran-12 -I. \
6+
-flto -O3 -fprotect-parens -march=native -mtune=native -fopenmp \
7+
-ffast-math -fcx-fortran-rules -mrecip \
8+
-floop-block \
9+
-fno-realloc-lhs -fbacktrace -g \
10+
-static-libgfortran \
11+
-cpp -D__BUILD_ID__='$(BUILD_ID)' -ffree-line-length-none
12+
# -fexternal-blas -fblas-matmul-limit=50 # Causes memory errors
13+
# -floop-block # Requires Graphite isl, not configured on many distributions
14+
# -ffast-math -fcx-fortran-rules -mrecip
15+
F90L = $(F90)
16+
LAPACK = -lopenblas_openmp # -lquadlapack_gfortran
17+
LIBEXTRA = -B/usr/share/libhugetlbfs -lhugetlbfs -Wl,--hugetlbfs-align

Diff for: configs/zen-oneapi_opt.mak

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
BUILD_ID :="Optimized Intel oneAPI, built on $(shell hostname) at $(shell date)"
2+
ACT = sed -e 's/^!\*qd/ /' # Enable quad-math statements
3+
#ACT2 = -e 's/^!\*mp/ /' # Enable MPI statements
4+
F90 = ifort \
5+
-qopenmp -qmkl=sequential -align all -align array256byte -pad \
6+
-warn -assume buffered_io \
7+
-O3 -ipo8 -no-prec-div -xAVX -axAVX2,MIC-AVX512 -complex_limited_range -fp-model fast=1 -ftz -assume protect_parens -heap-arrays 32 \
8+
-qopt-prefetch=0 -qopt-matmul -qopt-subscript-in-range -qopt-dynamic-align \
9+
-qopt-mem-layout-trans=3 -qopt-multi-version-aggressive \
10+
-debug full -debug extended -traceback -qopt-report=5 \
11+
-cpp -D__BUILD_ID__='$(BUILD_ID)'
12+
F90L = $(F90)
13+
LAPACK = # Lapack is in Intel MKL,
14+
LIBEXTRA = \
15+
-static-intel -qopenmp-link=static \
16+
-lhugetlbfs -Wl,-z,common-page-size=2097152 -Wl,-z,max-page-size=2097152 \
17+
-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm

Diff for: configs/zen-oneapi_opt_mpi.mak

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
BUILD_ID :="Optimized Intel oneAPI (MPI), built on $(shell hostname) at $(shell date)"
2+
ACT = sed -e 's/^!\*qd/ /' # Enable quad-math statements
3+
ACT2 = -e 's/^!\*mp/ /' # Enable MPI statements
4+
F90 = mpiifort \
5+
-qopenmp -qmkl=sequential -align all -align array256byte -pad \
6+
-warn -assume buffered_io \
7+
-O3 -ipo8 -no-prec-div -xAVX -axAVX2,MIC-AVX512 -complex_limited_range -fp-model fast=1 -ftz -assume protect_parens -heap-arrays 32 \
8+
-qopt-prefetch=0 -qopt-matmul -qopt-subscript-in-range -qopt-dynamic-align \
9+
-qopt-mem-layout-trans=3 -qopt-multi-version-aggressive \
10+
-debug full -debug extended -traceback -qopt-report=5 \
11+
-cpp -D__BUILD_ID__='$(BUILD_ID)'
12+
F90L = $(F90)
13+
LAPACK = # Lapack is in Intel MKL,
14+
LIBEXTRA = \
15+
-static-intel -static_mpi -qopenmp-link=static \
16+
-lhugetlbfs -Wl,-z,common-page-size=2097152 -Wl,-z,max-page-size=2097152 \
17+
-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm

Diff for: doc/CHANGES.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
Last updated: 2022 Jul 19
1+
Last updated: 2022 September 26
22
------------
33

44
Change log
55
----------
66

7+
2022 Sep 26
8+
9+
- Added vp_shape="alt spline".
10+
711
2022 Jul 19
812

913
- Added vp_shape="zz Sin2".

Diff for: doc/INPUT.txt

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Last updated: 2021 Aug 10
1+
Last updated: 2022 September 26
22
------------
33

44
All input to scid-tdse is provided through the sph_tdse namelist, with one
@@ -990,10 +990,23 @@ Input keywords
990990
description of the format. VP_SCALE has no effect.
991991
WARNING: VP_SHAPE="table" is powerful, but makes it easy to
992992
WARNING: request a non-sensical calculation. Here be dragons.
993+
For most cases, VP_SHAPE="alt spline" is probably a better
994+
choice, as it is less dependent on the parameters of the
995+
calculation.
993996
'spline' - The vector potential is defined by cubic splines, specified
994997
in file given by VP_TABLE (see VP_TABLE for the description).
995-
The result of the spline interpolation will be multiplied by
998+
The vector-potential is given by envelope + phase. The
999+
result of the spline interpolation will be multiplied by
9961000
VP_SCALE.
1001+
'alt spline' - The vector-potential is defined by cubic splines, specified
1002+
in VP_TABLE (see below for the description). The splines
1003+
interpolate the vector-potential directly, so that a much
1004+
denser set of spline points will likely be needed than for
1005+
'spline'. The interpolated vector-potential is scaled by
1006+
VP_SCALE and is delayed in time by VP_PARAM(3). If two sets
1007+
of splines are given in the VP_TABLE, the second set is
1008+
scaled and delayed by VP_SCALE_X and VP_PARAM_X(3),
1009+
respectively.
9971010
"Gaussian" pulses above have envelopes modified at the wings to have
9981011
finite duration. See code in GaussianVP() in vectorpotential_tools.f90
9991012
for further details. The parameters are (add _X for the secondary component):
@@ -1016,11 +1029,14 @@ Input keywords
10161029
VP_PARAM(4) - Full width at zero [atomic units]
10171030
"Flat-Sin2" pulses take the same parameters as "Sin2", plus:
10181031
VP_PARAM(11) - Duration of the raising/falling edges [atomic units]
1032+
"alt spline" pulses depend on the following parameters:
1033+
VP_SCALE - overall vector potential magnitude
1034+
VP_PARAM(3) - Pulse time offset [atomic units]
10191035
Also see FIELD_PREVIEW.
10201036

10211037
VP_TABLE='vp.table' (vectorpotential_tools.f90)
1022-
Name of the file containing defining the vector-potential. Relevant
1023-
if VP_SHAPE='table' and VP_SHARE='spline'. Also pay attention to the
1038+
Name of the file containing defining the vector-potential. Relevant if
1039+
VP_SHAPE='table', 'spline', and 'alt spline'. Also pay attention to the
10241040
value of ROTATION_MODE, as discussed below.
10251041

10261042
For VP_SHAPE='table', the file must contain the contents of the
@@ -1053,19 +1069,30 @@ Input keywords
10531069
that all polar angles are zero and set ROTATION_MODE='none'. This also
10541070
disables vector-potential unwrapping.
10551071

1056-
For VP_SHAPE='spline', the input file is expected to defined six splines,
1072+
For VP_SHAPE='spline', the input file is expected to contain six splines,
10571073
two for each Cartesian direction. For each pair, the first spline defines
10581074
the Cartesian amplitude SA_{x/y/z}(t) of the vector-potential. The second
10591075
spline gives the corresponding phase SP_{x/y/z}(t), so that the vector
10601076
potential along that direction is given by:
10611077

10621078
A_{x/y/z}(t) = SA_{x/y/z}(t) * cos(SP_{x/y/z}(t))
10631079

1064-
The resulting vector-potential will undergo field-unwrapping (unless
1065-
disabled by FIELD_UNWRAP=.FALSE.), and will be assumed to have general
1066-
polarization (unless linear polarization along the Z axis is explicitly
1067-
requested, by setting ROTATION_MODE='none'). It is expected that the
1068-
vector-potential is physical; no attempt to enforce this is made.
1080+
For VP_SHAPE='alt spline', the input file is expected to contain six
1081+
splines. The first three splines (one for each Cartesian direction) are
1082+
delayed in time by VP_PARAM(3) and scaled by VP_SCALE. The following
1083+
three splines are delayed by VP_PARAM_X(3) and scaled by VP_SCALE_X, so
1084+
that the vector potential along Cartesian directions is given by:
1085+
1086+
A_x(t) = VP_SCALE*SP_1(t-VP_PARAM(3)) + VP_SCALE_X*SP_4(t-VP_PARAM_X(3))
1087+
A_y(t) = VP_SCALE*SP_2(t-VP_PARAM(3)) + VP_SCALE_X*SP_5(t-VP_PARAM_X(3))
1088+
A_z(t) = VP_SCALE*SP_3(t-VP_PARAM(3)) + VP_SCALE_X*SP_6(t-VP_PARAM_X(3))
1089+
1090+
For both VP_SHAPE='spline' and 'alt spline', the resulting vector-potential
1091+
will undergo field-unwrapping (unless disabled by FIELD_UNWRAP=.FALSE.),
1092+
and will be assumed to have general polarization (unless linear polarization
1093+
along the Z axis is explicitly requested, by setting ROTATION_MODE='none').
1094+
It is expected that the vector-potential is physical; no attempt to enforce
1095+
this is made.
10691096

10701097
For each spline, we expect:
10711098

Diff for: examples/Makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: clean single cheap medium all
2+
3+
all:
4+
./run-all.sh all
5+
6+
clean:
7+
./clean.sh
8+
9+
single:
10+
./run-all.sh single hydrogen_1S_2P0_uniform.inp
11+
12+
cheap:
13+
./run-all.sh cheap
14+
15+
medium:
16+
./run-all.sh medium
17+
18+
all:
19+
./run-all.sh all

Diff for: math.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module math
3636
public MathInterpolate
3737
public rcsid_math
3838
!
39-
character(len=clen), save :: rcsid_math = "$Id: math.f90,v 1.12 2021/04/26 15:44:44 ps Exp ps $"
39+
character(len=clen), save :: rcsid_math = "$Id: math.f90,v 1.13 2022/02/19 18:54:26 ps Exp $"
4040
!
4141
!
4242
integer(ik), parameter :: factorial_slack = 5 ! Extra factorials to produce while filling the cache

Diff for: vectorpotential_tools.f90

+72-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!
22
! SCID-TDSE: Simple 1-electron atomic TDSE solver
3-
! Copyright (C) 2015-2021 Serguei Patchkovskii, [email protected]
3+
! Copyright (C) 2015-2022 Serguei Patchkovskii, [email protected]
44
!
55
! This program is free software: you can redistribute it and/or modify
66
! it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@ module vectorpotential_tools
5959
public vp_apot
6060
public rcsid_vectorpotential_tools
6161
!
62-
character(len=clen), save :: rcsid_vectorpotential_tools = "$Id: vectorpotential_tools.f90,v 1.19 2022/07/19 10:03:20 ps Exp $"
62+
character(len=clen), save :: rcsid_vectorpotential_tools = "$Id: vectorpotential_tools.f90,v 1.21 2022/09/26 17:19:41 ps Exp ps $"
6363
!
6464
! List of vector-potential names. These are used in a couple different places;
6565
! I would prefer any typos to cause a compile-time error!
@@ -78,6 +78,7 @@ module vectorpotential_tools
7878
character(len=*), parameter :: vpn_xySin2 = 'xy Sin2'
7979
character(len=*), parameter :: vpn_zxCW = 'zx CW'
8080
character(len=*), parameter :: vpn_spline = 'spline'
81+
character(len=*), parameter :: vpn_altspline = 'alt spline'
8182
!
8283
real(xk), save :: vp_scale = 0.00_xk ! Overall magnitude of the vector potential
8384
character(len=clen), save :: vp_shape = ' ' ! Shape of the vector-potential. See vp_apot()
@@ -105,6 +106,11 @@ module vectorpotential_tools
105106
! is described in doc/INPUT.txt, under the vp_table keyword.
106107
! vp_scale is influential in this case; don't forget to set it.
107108
!
109+
! For vp_shape='alt spline', the file should contain six individual
110+
! splines, which are interpreted as two vector-potentials shifted
111+
! in time by VP_PARAM(3)/VP_PARAM_X(3), and scaled by
112+
! VP_SCALE/VP_SCALE_X. See doc/INPUT.txt for details
113+
!
108114
! In either case, the data should be supplied in Fortran
109115
! free-form input format, with no fixed columns or formats.
110116
!
@@ -141,12 +147,16 @@ module vectorpotential_tools
141147
real(xk), save :: flat_raise = 0._xk ! vp_param(11) : Duration of the raising and falling edges, in
142148
! atomic units of time
143149
!
144-
! Data for vp_shape='spline', loaded from the file specified by vp_table
150+
! Data for vp_shape='spline' or 'alt spline', loaded from the file specified by vp_table
145151
!
146-
type(cs_data), save :: splines(6) ! We define six splines in total, two for each Cartesian direction:
152+
type(cs_data), save :: splines(6) ! vp_shape='spline'
153+
! We define six splines in total, two for each Cartesian direction:
147154
! 1,2: Envelope and phase for A_x
148155
! 3,4: Ditto, for A_y
149156
! 5,6: Ditto, for A_z
157+
! vp_shape='alt spline'
158+
! 1,2,3: X/Y/Z components of the vector-potential 1
159+
! 4,5,6: X/Y/Z components of the vector-potential 2
150160
!
151161
contains
152162
!
@@ -252,6 +262,8 @@ function vp_apot(t,theta,phi) result(apot)
252262
ph = atan2(ay,ax)
253263
case (vpn_spline)
254264
call vp_spline(t,apot,th,ph)
265+
case (vpn_altspline)
266+
call vp_altspline(t,apot,th,ph)
255267
end select
256268
if (present(theta)) theta = th
257269
if (present(phi) ) phi = ph
@@ -301,6 +313,8 @@ subroutine initialize
301313
omega = vp_param(1)
302314
case (vpn_spline)
303315
call init_splines
316+
case (vpn_altspline)
317+
call init_altsplines
304318
end select
305319
first = .false.
306320
!$omp flush(first)
@@ -523,9 +537,6 @@ subroutine vp_spline(t,vpot,th,ph)
523537
end subroutine vp_spline
524538
!
525539
subroutine init_splines
526-
integer(ik) :: iu, ios, ispl, npts
527-
real(xk), allocatable :: xy(:,:)
528-
character(len=clen) :: msg
529540
character(len=10), parameter :: names(6) = (/ 'X envelope', 'X phase ', &
530541
'Y envelope', 'Y phase ', &
531542
'Z envelope', 'Z phase ' /)
@@ -534,6 +545,56 @@ subroutine init_splines
534545
write (out,"(t5,'Loading splines from ',a)") trim(vp_table)
535546
write (out,"(t5,'Scaling factor = ',g0.8)") vp_scale
536547
!
548+
call init_splines_common(names)
549+
end subroutine init_splines
550+
!
551+
subroutine vp_altspline(t,vpot,th,ph)
552+
real(xk), intent(in) :: t ! Time where we need the vector-potential
553+
real(xk), intent(out) :: vpot, th, ph ! Vector-potential, spherical coordinates
554+
!
555+
real(xk) :: vp_x, vp_y, vp_z ! Cartesian components of the vector-potential
556+
!
557+
vp_x = vp_scale * cs_evaluate(splines(1),t-vp_param (3))
558+
vp_y = vp_scale * cs_evaluate(splines(2),t-vp_param (3))
559+
vp_z = vp_scale * cs_evaluate(splines(3),t-vp_param (3))
560+
vp_x = vp_x + vp_scale_x * cs_evaluate(splines(4),t-vp_param_x(3))
561+
vp_y = vp_y + vp_scale_x * cs_evaluate(splines(5),t-vp_param_x(3))
562+
vp_z = vp_z + vp_scale_x * cs_evaluate(splines(6),t-vp_param_x(3))
563+
!
564+
! Special case: if the X and Y fields vanish identically, force theta and phi to be zero
565+
! In all other cases, the unwrap routine should take of keeping the vector-potential
566+
! as smooth as possible.
567+
!
568+
if (vp_x==0._xk .and. vp_y==0._xk) then
569+
vpot = vp_z ; th = 0._xk ; ph = 0._xk
570+
else
571+
vpot = sqrt(vp_x**2+vp_y**2+vp_z**2)
572+
th = acos(vp_z/vpot)
573+
ph = atan2(vp_y,vp_x)
574+
end if
575+
end subroutine vp_altspline
576+
!
577+
subroutine init_altsplines
578+
character(len=2), parameter :: xyz(6) = (/ 'X1', 'Y1', 'Z1', 'X2', 'Y2', 'Z2' /)
579+
!
580+
write (out,"(/'Using cubic-spline interpolation to define the vector-potential')")
581+
write (out,"(t5,'Loading splines from ',a)") trim(vp_table)
582+
write (out,"(t5,'Scaling factor [Field 1] = ',g24.12)") vp_scale
583+
write (out,"(t5,' Time delay [Field 1] = ',g24.12)") vp_param(3)
584+
write (out,"(t5,'Scaling factor [Field 2] = ',g24.12)") vp_scale_x
585+
write (out,"(t5,' Time delay [Field 2] = ',g24.12)") vp_param_x(3)
586+
write (out,"()")
587+
!
588+
call init_splines_common(xyz)
589+
end subroutine init_altsplines
590+
591+
subroutine init_splines_common(codes)
592+
character(len=*), intent(in) :: codes(:)
593+
!
594+
integer(ik) :: iu, ios, ispl, npts
595+
real(xk), allocatable :: xy(:,:)
596+
character(len=clen) :: msg
597+
!
537598
error_block: do
538599
msg = "opening " // trim(vp_table)
539600
open(newunit=iu,form='formatted',recl=256,action='read',position='rewind',status='old', &
@@ -548,7 +609,7 @@ subroutine init_splines
548609
allocate (xy(2,npts),stat=ios)
549610
if (ios/=0) exit error_block
550611
!
551-
write (out,"(t5,'spline ',i0,' defining ',a,' contains ',i0,' points.')") ispl, trim(names(ispl)), npts
612+
write (out,"(t5,'spline ',i0,' defining component ',a,' contains ',i0,' points.')") ispl, trim(codes(ispl)), npts
552613
!
553614
if (npts>0) then
554615
write (msg,"('reading data points for spline #',i0,' npts = ',i0)") ispl, npts
@@ -568,7 +629,7 @@ subroutine init_splines
568629
return
569630
end do error_block
570631
!
571-
write (out,"('init_splines: Error ',a,'. ios = ',i0)") trim(msg), ios
572-
stop 'vectorpotential_tools%init_splines - error initializing splines'
573-
end subroutine init_splines
632+
write (out,"('init_splines_common: Error ',a,'. ios = ',i0)") trim(msg), ios
633+
stop 'vectorpotential_tools%init_splines_common - error initializing splines'
634+
end subroutine init_splines_common
574635
end module vectorpotential_tools

0 commit comments

Comments
 (0)