The Elk Code
genafieldt.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2014 K. Krieger, J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 !BOP
7 ! !ROUTINE: genafieldt
8 ! !INTERFACE:
9 subroutine genafieldt
10 ! !USES:
11 use modmain
12 use modtddft
13 ! !DESCRIPTION:
14 ! Generates a time-dependent vector potential, ${\bf A}(t)$, representing a
15 ! laser pulse and stores it in {\tt AFIELDT.OUT}. The vector potential is
16 ! constructed from a sum of $n$ sinusoidal waves, each modulated with a
17 ! Gaussian envelope function:
18 ! $$ {\bf A}(t)=\sum_{i=1}^n {\bf A}_0^i\exp
19 ! \left[-(t-t_0^i)^2/2\sigma_i^2\right]
20 ! \sin\left[w_i(t-t_0^i)+\phi_i+r_{\rm c}^i t^2/2\right]. $$
21 ! Eight real numbers have to be specified for each pulse, namely the vector
22 ! amplitude ${\bf A}_0$, frequency $\omega$, phase $\phi$, chirp rate
23 ! $r_{\rm c}$, peak time $t_0$, full-width at half-maximum
24 ! $d=2\sqrt{2\ln 2}\sigma$.
25 !
26 ! !REVISION HISTORY:
27 ! Created May 2012 (K. Krieger)
28 ! Modified, January 2014 (S. Sharma)
29 ! Modified, February 2014 (JKD)
30 ! Added spin-dependent A-fields, January 2023 (E. Harris-Lee)
31 !EOP
32 !BOC
33 implicit none
34 ! local variables
35 integer its,i,j
36 real(8) av0(3),t0,d,w,phi,rc
37 real(8) ft,ppd,s,t
38 real(8) av(3),s0,sv(3)
39 real(8) t1,t2,t3,t4
40 ! conversion factor of power density to W/cm²
41 real(8), parameter :: cpd=ha_si/(t_si*(100.d0*br_si)**2)
42 ! generate the time step grid
43 call gentimes
44 open(50,file='TD_INFO.OUT',form='FORMATTED')
45 write(50,*)
46 write(50,'("(All units are atomic unless otherwise specified)")')
47 write(50,*)
48 write(50,'("1 atomic unit of time is ",G18.10," attoseconds")') t_si*1.d18
49 write(50,*)
50 write(50,'("Total simulation time : ",G18.10)') tstime
51 write(50,'(" in attoseconds : ",G18.10)') tstime*t_si*1.d18
52 write(50,*)
53 write(50,'("Time step length : ",G18.10)') dtimes
54 write(50,'(" in attoseconds : ",G18.10)') dtimes*t_si*1.d18
55 write(50,*)
56 write(50,'("Number of time steps : ",I8)') ntimes
57 write(50,*)
58 write(50,'("Number of laser pulses : ",I6)') npulse
59 write(50,'("Number of ramps : ",I6)') nramp
60 write(50,'("Number of steps : ",I6)') nstep
61 ! allocate and zero time-dependent A-field array
62 if (allocated(afieldt)) deallocate(afieldt)
63 allocate(afieldt(3,ntimes))
64 afieldt(1:3,1:ntimes)=0.d0
65 ! allocate and zero spin- and time-dependent A-field array
66 if (tafspt) then
67  if (allocated(afspt)) deallocate(afspt)
68  allocate(afspt(3,3,ntimes))
69  afspt(1:3,1:3,1:ntimes)=0.d0
70 end if
71 !----------------------!
72 ! laser pulses !
73 !----------------------!
74 do i=1,npulse
75 ! vector amplitude
76  av0(1:3)=pulse(1:3,i)
77 ! frequency
78  w=pulse(4,i)
79 ! phase
80  phi=pulse(5,i)
81 ! chirp rate
82  rc=pulse(6,i)
83 ! peak time
84  t0=pulse(7,i)
85 ! full-width at half-maximum
86  d=pulse(8,i)
87 ! Gaussian sigma
88  s=d/(2.d0*sqrt(2.d0*log(2.d0)))
89 ! write information to TD_INFO.OUT
90  write(50,*)
91  write(50,'("Pulse : ",I6)') i
92  write(50,'(" vector amplitude : ",3G18.10)') av0(:)
93  write(50,'(" laser frequency : ",G18.10)') w
94  write(50,'(" in eV : ",G18.10)') w*ha_ev
95  write(50,'(" laser wavelength (Angstroms) : ",G18.10)') 1.d10/(w*ha_im)
96  write(50,'(" phase (degrees) : ",G18.10)') phi
97  write(50,'(" chirp rate : ",G18.10)') rc
98  write(50,'(" peak time : ",G18.10)') t0
99  write(50,'(" full-width at half-maximum : ",G18.10)') d
100  write(50,'(" Gaussian σ = FWHM / 2√(2ln2) : ",G18.10)') s
101  t1=av0(1)**2+av0(2)**2+av0(3)**2
102  ppd=t1*(w**2)/(8.d0*pi*solsc)
103  write(50,'(" peak laser power density : ",G18.10)') ppd
104  write(50,'(" in W/cm² : ",G18.10)') ppd*cpd
105  if (tafspt) then
106  s0=pulse(9,i)
107  sv(1:3)=pulse(10:12,i)
108  write(50,'(" spin components for σ_0, σ_x, σ_y, σ_z : ")')
109  write(50,'(4G18.10)') s0,sv(:)
110  end if
111 ! loop over time steps
112  do its=1,ntimes
113  t=times(its)
114  t1=t-t0
115  t2=-0.5d0*(t1/s)**2
116  t3=w*t1+phi*pi/180.d0+0.5d0*rc*t**2
117  ft=exp(t2)*sin(t3)
118  if (abs(ft) < 1.d-20) ft=0.d0
119  av(1:3)=ft*av0(1:3)
120 ! spin-dependent vector potential
121  if (tafspt) then
122  do j=1,3
123  afspt(1:3,j,its)=afspt(1:3,j,its)+av(1:3)*sv(j)
124  end do
125  av(1:3)=s0*av(1:3)
126  end if
127  afieldt(1:3,its)=afieldt(1:3,its)+av(1:3)
128  end do
129 end do
130 !---------------!
131 ! ramps !
132 !---------------!
133 do i=1,nramp
134 ! vector amplitude
135  av0(1:3)=ramp(1:3,i)
136 ! ramp start time
137  t0=ramp(4,i)
138 ! linear coefficient
139  t1=ramp(5,i)
140 ! quadratic coefficient
141  t2=ramp(6,i)
142 ! cubic coefficient
143  t3=ramp(7,i)
144 ! quartic coefficient
145  t4=ramp(8,i)
146 ! write information to TD_INFO.OUT
147  write(50,*)
148  write(50,'("Ramp : ",I6)') i
149  write(50,'(" vector amplitude : ",3G18.10)') av0(:)
150  write(50,'(" ramp start time : ",G18.10)') t0
151  write(50,'(" coefficients : ",4G18.10)') t1,t2,t3,t4
152  if (tafspt) then
153  s0=ramp(9,i)
154  sv(1:3)=ramp(10:12,i)
155  write(50,'(" spin components for σ_0, σ_x, σ_y, σ_z : ")')
156  write(50,'(4G18.10)') s0,sv(:)
157  end if
158 ! loop over time steps
159  do its=1,ntimes
160  t=times(its)-t0
161  if (t > 0.d0) then
162  ft=t*(t1+t*(t2+t*(t3+t*t4)))
163  av(1:3)=ft*av0(1:3)
164  if (tafspt) then
165  do j=1,3
166  afspt(1:3,j,its)=afspt(1:3,j,its)+av(1:3)*sv(j)
167  end do
168  av(1:3)=s0*av(1:3)
169  end if
170  afieldt(1:3,its)=afieldt(1:3,its)+av(1:3)
171  end if
172  end do
173 end do
174 !---------------!
175 ! steps !
176 !---------------!
177 do i=1,nstep
178 ! vector amplitude
179  av0(1:3)=step(1:3,i)
180 ! step start time
181  t0=step(4,i)-1.d-14
182 ! step stop time
183  t1=step(5,i)
184 ! write information to TD_INFO.OUT
185  write(50,*)
186  write(50,'("Step : ",I6)') i
187  write(50,'(" vector amplitude : ",3G18.10)') av0(:)
188  write(50,'(" step start and stop times : ",2G18.10)') t0,t1
189  if (tafspt) then
190  s0=step(6,i)
191  sv(1:3)=step(7:9,i)
192  av(1:3)=s0*av0(1:3)
193  write(50,'(" spin components for σ_0, σ_x, σ_y, σ_z :")')
194  write(50,'(4G18.10)') s0,sv(:)
195  else
196  av(1:3)=av0(1:3)
197  end if
198 ! loop over time steps
199  do its=1,ntimes
200  t=times(its)
201  if (t > t1) exit
202  if (t >= t0) then
203  if (tafspt) then
204  do j=1,3
205  afspt(1:3,j,its)=afspt(1:3,j,its)+av0(1:3)*sv(j)
206  end do
207  end if
208  afieldt(1:3,its)=afieldt(1:3,its)+av(1:3)
209  end if
210  end do
211 end do
212 close(50)
213 ! write the vector potential to AFIELDT.OUT
214 open(50,file='AFIELDT.OUT',form='FORMATTED')
215 write(50,'(I8," : number of time steps")') ntimes
216 do its=1,ntimes
217  write(50,'(I8,4G18.10)') its,times(its),afieldt(:,its)
218 end do
219 close(50)
220 ! write the spin-dependent vector potential to AFSPT.OUT
221 if (tafspt) then
222  open(50,file='AFSPT.OUT',form='FORMATTED')
223  write(50,'(I8," : number of time steps")') ntimes
224  do its=1,ntimes
225  write(50,'(I8,10G18.10)') its,times(its),afspt(:,:,its)
226  end do
227  close(50)
228 end if
229 write(*,*)
230 write(*,'("Info(genafieldt):")')
231 write(*,'(" Time-dependent A-field written to AFIELDT.OUT")')
232 if (tafspt) then
233  write(*,'(" Time- and spin-dependent A-field written to AFSPT.OUT")')
234 end if
235 write(*,'(" Laser pulse, ramp and step parameters written to TD_INFO.OUT")')
236 write(*,*)
237 write(*,'(" 1 atomic unit of time is ",G18.10," attoseconds")') t_si*1.d18
238 write(*,'(" Total simulation time : ",G18.10)') tstime
239 write(*,'(" in attoseconds : ",G18.10)') tstime*t_si*1.d18
240 deallocate(times,afieldt)
241 end subroutine
242 !EOC
243 
real(8), parameter ha_si
Definition: modmain.f90:1242
integer ntimes
Definition: modtddft.f90:42
real(8), dimension(:,:), allocatable ramp
Definition: modtddft.f90:32
real(8), parameter pi
Definition: modmain.f90:1219
real(8), parameter t_si
Definition: modmain.f90:1262
integer nramp
Definition: modtddft.f90:29
integer nstep
Definition: modtddft.f90:34
subroutine gentimes
Definition: gentimes.f90:7
real(8) solsc
Definition: modmain.f90:1240
real(8), dimension(:,:), allocatable pulse
Definition: modtddft.f90:27
logical tafspt
Definition: modtddft.f90:60
real(8), dimension(:,:), allocatable afieldt
Definition: modtddft.f90:58
real(8), dimension(:,:), allocatable step
Definition: modtddft.f90:36
real(8), dimension(:), allocatable times
Definition: modtddft.f90:48
real(8), parameter ha_im
Definition: modmain.f90:1246
real(8) dtimes
Definition: modtddft.f90:40
real(8), parameter br_si
Definition: modmain.f90:1254
subroutine genafieldt
Definition: genafieldt.f90:10
real(8) tstime
Definition: modtddft.f90:38
real(8), parameter ha_ev
Definition: modmain.f90:1244
integer npulse
Definition: modtddft.f90:24
real(8), dimension(:,:,:), allocatable afspt
Definition: modtddft.f90:62