Multidip 1.0
Multi-photon matrix elements
Loading...
Searching...
No Matches
multidip_outer.f90
Go to the documentation of this file.
1! Copyright 2023
2!
3! For a comprehensive list of the developers that contributed to these codes
4! see the UK-AMOR website.
5!
6! This file is part of UKRmol-out (UKRmol+ suite).
7!
8! UKRmol-out is free software: you can redistribute it and/or modify
9! it under the terms of the GNU General Public License as published by
10! the Free Software Foundation, either version 3 of the License, or
11! (at your option) any later version.
12!
13! UKRmol-out is distributed in the hope that it will be useful,
14! but WITHOUT ANY WARRANTY; without even the implied warranty of
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16! GNU General Public License for more details.
17!
18! You should have received a copy of the GNU General Public License
19! along with UKRmol-out (in source/COPYING). Alternatively, you can also visit
20! <https://www.gnu.org/licenses/>.
21!
22!> \brief Routines related to outer region asymptotic channels
23!> \authors J Benda
24!> \date 2023
25!>
27
28 use blas_lapack_gbl, only: blasint
29 use phys_const_gbl, only: pi, imu
30 use precisn_gbl, only: wp
31
32 implicit none
33
34contains
35
36 !> \brief Evaluate wfn in channels for inside and outside of the R-matrix sphere
37 !> \authors J Benda
38 !> \date 2023
39 !>
40 !> Obtain the single-electron radial wave function amplitudes in channels by projecting the inner wave function at all sampling
41 !> radii contained in molecular_data. Continue these to twice the R-matrix radius by evaluating the outer expansion in the
42 !> outer region. The outer expansion assumes only outgoing (or exponentially decaying real) radial functions.
43 !>
44 !> The results are saved into a text file, which has the radial distance in the first column and sampled radial wave-functions
45 !> in the remaining columns, one per partial wave channel. Every first column gives real part, every second the imaginary part.
46 !>
47 !> \param[in] filename Name of a text file to write.
48 !> \param[in] moldat Molecular data class.
49 !> \param[in] irr Inde xof irreducible representation in molecular_data.
50 !> \param[in] ck Inner region expansion coefficients (in terms of inner region eigenstates).
51 !> \param[in] ap Outer region expansion coefficients (in terms of partial wave channel eigenfunctions).
52 !> \param[in] Etot Total energy of the system.
53 !>
54 subroutine test_outer_expansion (filename, moldat, irr, ck, ap, Etot)
55
56 use multidip_io, only: moleculardata
57
58 character(len=*), intent(in) :: filename
59 type(moleculardata), intent(in) :: moldat
60 integer, intent(in) :: irr
61 real(wp), intent(in) :: ck(:, :), ap(:, :), Etot
62
63 real(wp), allocatable :: f(:, :), Ek(:), S(:), C(:), dSdr(:), dCdr(:)
64
65 integer :: u, j, nfdm, nchan
66 real(wp) :: r, dr
67
68 nfdm = size(moldat % r_points) - 1
69 nchan = moldat % nchan(irr)
70 dr = 0.1
71
72 allocate (f(nchan, 2), ek(nchan), s(nchan), c(nchan), dsdr(nchan), dcdr(nchan))
73
74 open (newunit = u, file = filename, action = 'write', form = 'formatted')
75
76 do j = 1, nfdm
77 if (.not. associated(moldat % wmat2(j, irr) % mat)) then
78 print '(a)', 'Error: wmat2 has not been read from molecular_data'
79 stop 1
80 else if (moldat % wmat2(j, irr) % distributed) then
81 print '(a)', 'Error: test_outer_expansion not implemented in MPI-IO mode'
82 stop 1
83 end if
84 f = matmul(moldat % wmat2(j, irr) % mat, ck)
85 write (u, '(*(e25.15))') moldat % r_points(j), transpose(f)
86 end do
87
88 ek = etot - moldat % etarg(moldat % ichl(:, irr))
89
90 do j = 0, nint(moldat % rmatr / dr)
91 r = moldat % rmatr + j*dr
92 call evaluate_fundamental_solutions(moldat, r, irr, nchan, ek, s, c, dsdr, dcdr, sqrtknorm = .false.)
93 write (u, '(*(e25.15))') r, cmplx(ap(:, 1), ap(:, 2), wp) * (c + imu*s)
94 end do
95
96 close (u)
97
98 end subroutine test_outer_expansion
99
100
101 !> \brief Evaluate asymptotic solutions at boundary
102 !> \authors J Benda
103 !> \date 2023
104 !>
105 !> Obtain amplitudes and derivatives of the fundamental solutions at region boundary.
106 !>
107 !> The evaluated functions use the same normalization as `ASYWFN` in *cfasym.f*. That is, the amplitudes contain an extra
108 !> factor of 1/sqrt(k) in addition to the standard normalization of Coulomb functions. Similarly, the derivatives contain
109 !> the same factor of 1/sqrt(k). Because the functions are differentiated with respect to 'r', this 1/sqrt(k)
110 !> factor combines with the 'k' coming from derivative of the argument, giving sqrt(k) compared to standard normalization
111 !> of the derivative of the Coulomb functions.
112 !>
113 !> \param[in] moldat Molecular data class.
114 !> \param[in] r Evaluation radius.
115 !> \param[in] irr Irreducible representation index.
116 !> \param[in] nopen Restrict evaluation of solutions to this number of (open or closed) partial wave channels.
117 !> \param[in] Ek Photoelectron kinetic energy in each channel.
118 !> \param[inout] S Regular solution amplitude per partial wave channel.
119 !> \param[inout] C Irregular solution amplitude per partial wave channel.
120 !> \param[inout] Sp Regular solution derivative per partial wave channel.
121 !> \param[inout] Cp Irregular solution derivative per partial wave channel.
122 !> \param[in] sqrtknorm Set to .false. to avoid adding the 1/sqrt(k) factor discussed above.
123 !>
124 subroutine evaluate_fundamental_solutions (moldat, r, irr, nopen, Ek, S, C, Sp, Cp, sqrtknorm)
125
126 use multidip_io, only: moleculardata
127 use multidip_special, only: coul
128
129 type(moleculardata), intent(in) :: moldat
130 real(wp), intent(in) :: r, Ek(:)
131 integer, intent(in) :: irr, nopen
132 real(wp), intent(inout) :: S(:), C(:), Sp(:), Cp(:)
133 logical, optional, intent(in) :: sqrtknorm
134
135 real(wp) :: k, kfactor, Z, F, Fp, G, Gp
136 integer :: ichan, nchan, l
137
138 z = moldat % nz - moldat % nelc
139 nchan = moldat % nchan(irr)
140
141 !$omp parallel do default(none) private(ichan, k, l, kfactor, F, Fp, G, Gp) &
142 !$omp& shared(moldat, irr, Z, r, Ek, S, C, Sp, Cp, sqrtknorm, nchan, nopen)
143 do ichan = 1, min(nchan, nopen)
144
145 k = sqrt(2*abs(ek(ichan)))
146 l = moldat % l2p(ichan, irr)
147
148 ! k-dependent prefactor optionally added to the evaluated solutions
149 kfactor = 1/sqrt(k)
150 if (present(sqrtknorm)) then
151 if (.not. sqrtknorm) then
152 kfactor = 1
153 end if
154 end if
155
156 call coul(z, l, ek(ichan), r, f, fp, g, gp)
157
158 s(ichan) = f * kfactor
159 c(ichan) = g * kfactor
160 sp(ichan) = fp * kfactor
161 cp(ichan) = gp * kfactor
162
163 end do
164
165 end subroutine evaluate_fundamental_solutions
166
167
168 !> \brief Calculate (generalized) K-matrix
169 !> \authors J Benda
170 !> \date 2023
171 !>
172 !> Alternative to RSOLVE. Calculates the K-matrix without propagation, simply by projecting the inner wave function
173 !> on the asymptotic channels.
174 !>
175 !> First, the R-matrix is calculated from boundary amplitudes and R-matrix poles.
176 !> Finally, the generalized K-matrix is obtained by solution of the standard matrix equation
177 !> \f[
178 !> (C - R C') K = R S' - S \,.
179 !> \f]
180 !> In this equation the diagonal matrices S and C consist of the regular and irregular solutions of the dipole-coupled
181 !> outer region asymptotic equations.
182 !>
183 !> \param[in] moldat Molecular data class.
184 !> \param[in] nopen Number of open channels.
185 !> \param[in] irr Irreducible representation index.
186 !> \param[in] Etot Total energy of the whole system.
187 !> \param[in] S Value of the regular asymptotic solution per partial wave channel.
188 !> \param[in] C Value of the irregular asymptotic solution per partial wave channel.
189 !> \param[in] Sp Derivative of the regular asymptotic solution per partial wave channel.
190 !> \param[in] Cp Derivative of the irregular asymptotic solution per partial wave channel.
191 !> \param[inout] Kmat Kmatrix to calculate.
192 !>
193 subroutine calculate_k_matrix (moldat, nopen, irr, Etot, S, C, Sp, Cp, Kmat)
194
195 use multidip_io, only: moleculardata
196 use multidip_params, only: rzero
197 use multidip_special, only: calculate_r_matrix, blas_dgetrf => dgetrf, blas_dgetrs => dgetrs
198
199 type(moleculardata), intent(in) :: moldat
200
201 integer, intent(in) :: nopen, irr
202 real(wp), intent(in) :: Etot
203 real(wp), intent(in) :: S(:), C(:), Sp(:), Cp(:)
204 real(wp), intent(inout) :: Kmat(:, :)
205
206 real(wp), allocatable :: Amat(:, :) ! matrix of equations to be composed and solved
207 real(wp), allocatable :: Rmat(:, :) ! R-matrix in the standard partial wave channels
208 integer(blasint), allocatable :: ipiv(:) ! permutation array for use in zgetrf/s
209
210 integer(blasint) :: ldk, info, n, nrhs
211 integer :: nstat, nchan, ichan, jchan
212
213 nchan = moldat % nchan(irr)
214 nstat = moldat % mnp1(irr)
215
216 ! 1. Calculate the standard R-matrix
217
218 allocate (rmat(nchan, nchan))
219
220 call calculate_r_matrix(nchan, nstat, moldat % wamp(irr) % mat, moldat % eig(1:nstat, irr), etot, rmat)
221
222 ! 2. Solve for the K-matrix
223
224 allocate (amat(nchan, nchan), ipiv(nchan))
225
226 !$omp parallel do collapse(2) private(ichan, jchan)
227 do jchan = 1, nchan
228 do ichan = 1, nchan
229 amat(ichan, jchan) = merge(c(jchan), rzero, ichan == jchan) - rmat(ichan, jchan)*cp(jchan)
230 end do
231 end do
232 !$omp parallel do collapse(2) private(ichan, jchan)
233 do jchan = 1, nopen
234 do ichan = 1, nchan
235 kmat(ichan, jchan) = rmat(ichan, jchan)*sp(jchan) - merge(s(jchan), rzero, ichan == jchan)
236 end do
237 end do
238 !$omp parallel do collapse(2) private(ichan, jchan)
239 do jchan = nopen + 1, nchan
240 do ichan = 1, nchan
241 kmat(ichan, jchan) = rzero
242 end do
243 end do
244
245 n = int(nchan, blasint)
246 nrhs = int(nopen, blasint)
247 ldk = int(size(kmat, 1), blasint)
248
249 call blas_dgetrf(n, n, amat, n, ipiv, info)
250 call blas_dgetrs('N', n, nrhs, amat, n, ipiv, kmat, ldk, info)
251
252 end subroutine calculate_k_matrix
253
254end module multidip_outer
I/O routines used by MULTIDIP.
Routines related to outer region asymptotic channels.
subroutine test_outer_expansion(filename, moldat, irr, ck, ap, etot)
Evaluate wfn in channels for inside and outside of the R-matrix sphere.
subroutine evaluate_fundamental_solutions(moldat, r, irr, nopen, ek, s, c, sp, cp, sqrtknorm)
Evaluate asymptotic solutions at boundary.
Hard-coded parameters of MULTIDIP.
real(wp), parameter rzero
Special functions and objects used by MULTIDIP.
subroutine coul(z, l, ek, r, f, fp, g, gp)
Coulomb functions.