Multidip  1.0
Multi-photon matrix elements
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 !
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 
34 contains
35 
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 
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 
199  subroutine calculate_k_matrix (moldat, nopen, irr, Etot, S, C, Sp, Cp, Kmat)
200 
201  use multidip_io, only: moleculardata
202  use multidip_params, only: rzero
203  use multidip_special, only: calculate_r_matrix, blas_dgetrf => dgetrf, blas_dgetrs => dgetrs
204 
205  type(moleculardata), intent(in) :: moldat
206 
207  integer, intent(in) :: nopen, irr
208  real(wp), intent(in) :: Etot
209  real(wp), intent(in) :: S(:), C(:), Sp(:), Cp(:)
210  real(wp), intent(inout) :: Kmat(:, :)
211 
212  real(wp), allocatable :: Amat(:, :) ! matrix of equations to be composed and solved
213  real(wp), allocatable :: Rmat(:, :) ! R-matrix in the standard partial wave channels
214  integer(blasint), allocatable :: ipiv(:) ! permutation array for use in zgetrf/s
215 
216  integer(blasint) :: ldk, info, n, nrhs
217  integer :: nstat, nchan, ichan, jchan
218 
219  nchan = moldat % nchan(irr)
220  nstat = moldat % mnp1(irr)
221 
222  ! 1. Calculate the standard R-matrix and transform it to the generalized angular momentum basis
223 
224  allocate (rmat(nchan, nchan))
225 
226  call calculate_r_matrix(nchan, nstat, moldat % wamp(irr) % mat, moldat % eig(1:nstat, irr), etot, rmat)
227 
228  ! 2. Solve for the K-matrix
229 
230  allocate (amat(nchan, nchan), ipiv(nchan))
231 
232  !$omp parallel do collapse(2) private(ichan, jchan)
233  do jchan = 1, nchan
234  do ichan = 1, nchan
235  amat(ichan, jchan) = merge(c(jchan), rzero, ichan == jchan) - rmat(ichan, jchan)*cp(jchan)
236  end do
237  end do
238  !$omp parallel do collapse(2) private(ichan, jchan)
239  do jchan = 1, nopen
240  do ichan = 1, nchan
241  kmat(ichan, jchan) = rmat(ichan, jchan)*sp(jchan) - merge(s(jchan), rzero, ichan == jchan)
242  end do
243  end do
244  !$omp parallel do collapse(2) private(ichan, jchan)
245  do jchan = nopen + 1, nchan
246  do ichan = 1, nchan
247  kmat(ichan, jchan) = rzero
248  end do
249  end do
250 
251  n = int(nchan, blasint)
252  nrhs = int(nopen, blasint)
253  ldk = int(size(kmat, 1), blasint)
254 
255  call blas_dgetrf(n, n, amat, n, ipiv, info)
256  call blas_dgetrs('N', n, nrhs, amat, n, ipiv, kmat, ldk, info)
257 
258  end subroutine calculate_k_matrix
259 
260 end module multidip_outer
I/O routines used by MULTIDIP.
Definition: multidip_io.F90:29
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.
subroutine calculate_k_matrix(moldat, nopen, irr, Etot, S, C, Sp, Cp, Kmat)
Calculate (generalized) K-matrix.
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.
subroutine calculate_r_matrix(nchan, nstat, wmat, eig, Etot, Rmat)
Calculate scattering R-matrix.
RMT molecular data file.