34 use blas_lapack_gbl,
only: blasint
35 use cdenprop_defs,
only: civect
36 use precisn,
only: shortint, wp
56 integer :: maxchan = 10000
65 real(wp),
allocatable :: r_points(:)
66 type(civect),
allocatable :: wamp(:)
68 integer,
allocatable :: idtarg(:)
69 integer,
allocatable :: irrchl(:)
70 integer,
allocatable :: ichl(:)
71 integer,
allocatable :: lchl(:)
72 integer,
allocatable :: mchl(:)
73 integer,
allocatable :: qchl(:)
74 real(wp),
allocatable :: echl(:)
75 real(wp),
allocatable :: a(:,:)
105 use class_molecular_properties_data,
only: molecular_properties_data
112 type(molecular_properties_data) :: properties_all
135 use mpi_gbl,
only: mpiint, myrank, mpi_mod_bcast
144 integer(mpiint) :: srcrank
145 integer :: i, nnuc, nstat
148 if (grid % sequential)
return
151 do i = 1,
size(scatci_input % opts)
152 if (iand(scatci_input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
157 srcrank = grid % group_master_world_rank(grid % which_group_is_work(i))
159 call mpi_mod_bcast(solutions(i) % core_energy, srcrank)
160 call mpi_mod_bcast(solutions(i) % vec_dimen, srcrank)
162 call mpi_mod_bcast(solutions(i) % ci_vec % nstat, srcrank)
163 call mpi_mod_bcast(solutions(i) % ci_vec % mgvn, srcrank)
164 call mpi_mod_bcast(solutions(i) % ci_vec % s, srcrank)
165 call mpi_mod_bcast(solutions(i) % ci_vec % sz, srcrank)
166 call mpi_mod_bcast(solutions(i) % ci_vec % nnuc, srcrank)
167 call mpi_mod_bcast(solutions(i) % ci_vec % e0, srcrank)
168 call mpi_mod_bcast(solutions(i) % ci_vec % CV_is_scalapack, srcrank)
169 call mpi_mod_bcast(solutions(i) % ci_vec % mat_dimen_r, srcrank)
170 call mpi_mod_bcast(solutions(i) % ci_vec % mat_dimen_c, srcrank)
172 nnuc = solutions(i) % ci_vec % nnuc
173 nstat = solutions(i) % ci_vec % nstat
175 if (.not.
allocated(solutions(i) % ci_vec % ei))
then
176 allocate (solutions(i) % ci_vec % ei(nstat))
179 call mpi_mod_bcast(solutions(i) % ci_vec % cname(1:nnuc), srcrank)
180 call mpi_mod_bcast(solutions(i) % ci_vec % charge(1:nnuc), srcrank)
181 call mpi_mod_bcast(solutions(i) % ci_vec % xnuc(1:nnuc), srcrank)
182 call mpi_mod_bcast(solutions(i) % ci_vec % ynuc(1:nnuc), srcrank)
183 call mpi_mod_bcast(solutions(i) % ci_vec % znuc(1:nnuc), srcrank)
184 call mpi_mod_bcast(solutions(i) % ci_vec % ei(1:nstat), srcrank)
188 oldsolution = solutions(i)
190 if (.not. grid % is_my_group_work(i))
then
191 oldsolution % ci_vec % blacs_context = -1
192 oldsolution % ci_vec % descr_CV_mat = -1
197 solutions(i) % ci_vec % blacs_context = grid % wcntxt
198 solutions(i) % ci_vec % nprow = grid % wprows
199 solutions(i) % ci_vec % npcol = grid % wpcols
201 call solutions(i) % ci_vec % init_CV(int(oldsolution % ci_vec % mat_dimen_r), &
202 int(oldsolution % ci_vec % mat_dimen_c))
203 call solutions(i) % ci_vec % redistribute(oldsolution % ci_vec)
227 use class_molecular_properties_data,
only: molecular_properties_data
228 use class_namelists,
only: cdenprop_namelists
230 use cdenprop_procs,
only: cdenprop_drv
231 use cdenprop_defs,
only: ir_max
232 use mpi_gbl,
only: myrank, master, mpi_reduceall_sum_cfp
238 type(molecular_properties_data),
intent(inout) :: properties_all
240 type(cdenprop_namelists) :: namelist_ij
241 type(civect) :: oldblock
243 integer :: i, j, ntgsym, ninputs, maxpole, nblock, mxstat
245 ninputs =
size(scatci_input % opts)
249 if (.not. scatci_input % write_dip .and. .not. scatci_input % write_rmt)
return
252 call properties_all % clean
253 call properties_all % preallocate_property_blocks(ninputs**2 * (maxpole + 1)**2)
256 sym_i_loop:
do i = 1, ninputs
257 if (iand(scatci_input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
260 sym_j_loop:
do j = i, ninputs
261 if (iand(scatci_input % opts(j) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
265 if (i == j .and. .not. scatci_input % all_props) cycle
268 call namelist_ij % init(2)
271 namelist_ij % lucsf(1:2) = (/ scatci_input % opts(i) % megul, &
272 scatci_input % opts(j) % megul /)
273 namelist_ij % nciset(1:2) = (/ scatci_input % opts(i) % output_ci_set_number, &
274 scatci_input % opts(j) % output_ci_set_number /)
275 namelist_ij % nstat = 0
276 namelist_ij % lupropw = 0
277 namelist_ij % lucivec = 0
278 namelist_ij % ukrmolp_ints = scatci_input % opts(i) % use_UKRMOL_integrals
279 namelist_ij % luprop = merge(scatci_input % opts(i) % integral_unit, &
280 scatci_input % luprop, &
281 scatci_input % luprop < 0)
283 ntgsym = scatci_input % opts(i) % num_target_sym
286 if (scatci_input % opts(i) % ci_target_flag ==
no_ci_target)
then
287 namelist_ij % numtgt(1:ir_max) = 0
288 namelist_ij % max_multipole = 2
290 namelist_ij % max_multipole = 1
291 namelist_ij % numtgt(1:ir_max) = 0
292 namelist_ij % numtgt(1:ntgsym) = scatci_input % opts(i) % num_target_state_sym(1:ntgsym)
296 solutions(j) % ci_vec % blacs_context = solutions(i) % ci_vec % blacs_context
297 solutions(j) % ci_vec % descr_CV_mat(2) = solutions(i) % ci_vec % descr_CV_mat(2)
300 call cdenprop_drv(solutions(i) % ci_vec, solutions(j) % ci_vec, namelist_ij, properties_all)
303 call namelist_ij % dealloc
312 properties_all % swintf_format = .true.
315 if (scatci_input % write_dip .and. properties_all % no_symmetries > 0)
then
316 if (scatci_input % all_props)
call properties_all % sort_by_energy
317 call properties_all % write_properties(624, scatci_input % opts(1) % use_UKRMOL_integrals)
321 if (scatci_input % write_rmt)
then
322 nblock = properties_all % no_blocks
323 mxstat = max(maxval(properties_all % dense_blocks(1:nblock) % mat_dimen_r), &
324 maxval(properties_all % dense_blocks(1:nblock) % mat_dimen_c))
326 associate(d => properties_all % dense_blocks(i))
327 if (d % mat_dimen_r /= mxstat .or. d % mat_dimen_c /= mxstat)
then
329 call d % init_CV(mxstat, mxstat)
331 call d % redistribute(oldblock)
332 call oldblock % final_CV
359 use class_molecular_properties_data,
only: molecular_properties_data
366 type(molecular_properties_data),
intent(in) :: inner_properties
368 type(molecular_properties_data) :: target_properties
371 integer :: i, nsym, nset
374 nsym =
size(scatci_input % opts)
376 if (.not. scatci_input % write_amp .and. .not. scatci_input % write_rmt)
return
378 allocate (intf(nsym))
380 call target_properties % read_properties(24, 1)
384 call intf(i) % init(scatci_input)
385 if (iand(scatci_input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
388 call intf(i) % setup_amplitudes(scatci_input % opts(i))
389 call intf(i) % extract_data(scatci_input % opts(i), target_properties, solutions(i))
390 if (scatci_input % write_amp)
then
391 call intf(i) % write_data(i, scatci_input, target_properties, solutions(i))
396 if (scatci_input % write_rmt)
then
397 call write_rmt_data(scatci_input, inner_properties, target_properties, solutions, intf)
412 use mpi_gbl,
only: mpi_xermsg
425 this % nfdm = input % nfdm
426 this % rmatr = input % rmatr
428 allocate (this % r_points(this % nfdm + 1))
430 do i = 1, this % nfdm + 1
431 this % r_points(i) = this % rmatr - (this % nfdm + 1 - i) * input % delta_r
434 allocate (this % irrchl(this % maxchan), &
435 this % ichl(this % maxchan), &
436 this % lchl(this % maxchan), &
437 this % mchl(this % maxchan), &
438 this % qchl(this % maxchan), &
439 this % echl(this % maxchan), stat = ierr)
442 call mpi_xermsg(
'OuterInterface',
'init_outer_interface',
'Failed to allocate memory for channel data.', 1, 1)
445 if (
allocated(input % idtarg))
then
446 this % ntarg =
size(input % idtarg)
447 this % idtarg = input % idtarg
466 if (
allocated(this % wamp))
then
467 do i = 1,
size(this % wamp)
468 call this % wamp(i) % final_CV
469 #if defined(usempi) && defined(scalapack)
470 if (i == 1 .and. this % wamp(this % nfdm + 1) % blacs_context >= 0)
then
471 call blacs_gridexit(this % wamp(this % nfdm + 1) % blacs_context)
475 deallocate (this % wamp)
478 if (
allocated(this % irrchl))
deallocate (this % irrchl)
479 if (
allocated(this % ichl))
deallocate (this % ichl)
480 if (
allocated(this % lchl))
deallocate (this % lchl)
481 if (
allocated(this % mchl))
deallocate (this % mchl)
482 if (
allocated(this % qchl))
deallocate (this % qchl)
483 if (
allocated(this % echl))
deallocate (this % echl)
484 if (
allocated(this % a))
deallocate (this % a)
485 if (
allocated(this % r_points))
deallocate (this % r_points)
505 use ukrmol_interface_gbl,
only: read_ukrmolp_basis, eval_amplitudes
508 type(
options),
intent(in) :: opts
510 if (opts % use_UKRMOL_integrals)
then
511 call read_ukrmolp_basis(opts % integral_unit)
512 call eval_amplitudes(this % rmatr, .true.)
536 use class_molecular_properties_data,
only: molecular_properties_data
541 type(molecular_properties_data),
intent(in) :: prop
542 type(
options),
intent(in) :: opts
545 integer,
parameter :: ismax = 2
546 real(wp),
parameter :: alpha0 = 0
547 real(wp),
parameter :: alpha2 = 0
555 if (alpha0 /= 0 .or. alpha2 /= 0)
then
557 lamax = max(ismax, 3)
562 call this % get_channel_info(opts, prop)
563 call this % get_channel_couplings(lamax, prop % no_states, prop, alpha0, alpha2, use_pol)
564 call this % get_boundary_data(opts, prop, solution)
567 this % mchl(1:this % nchan) = this % mchl(1:this % nchan) * this % qchl(1:this % nchan)
586 use class_molecular_properties_data,
only: molecular_properties_data
587 use mpi_gbl,
only: myrank, master
592 type(molecular_properties_data),
intent(in) :: prop
595 integer,
intent(in) :: i
597 if (myrank == master)
then
598 call this % write_channel_info(i, opts % opts(i), opts % cform, prop)
599 call this % write_boundary_data(i, opts % opts(i), opts % rform, prop, solution)
618 use algorithms,
only: findloc
619 use class_molecular_properties_data,
only: molecular_properties_data
620 use const_gbl,
only: stdout
621 use global_utils,
only: mprod
622 use mpi_gbl,
only: mpi_xermsg
624 use precisn,
only: wp
625 use ukrmol_interface_gbl,
only: ukp_preamp
628 type(
options),
intent(in) :: opts
629 type(molecular_properties_data),
intent(in) :: prop
631 integer :: i, j, k, mgvn, spin, tgt_stat, tgt_symm, tgt_mgvn, tgt_spin, nch, prj_mgvn, congen_tgt_id, denprop_tgt_id, isym
632 real(wp) :: tgt_enrg, ebase
634 ebase = prop % energies(1)
636 spin = nint(2 * opts % spin + 1)
638 this % maxnmo = sum(opts % num_orbitals_sym)
642 if (.not.
allocated(this % idtarg))
then
643 this % ntarg = opts % total_num_target_states
644 allocate (this % idtarg(this % ntarg))
646 congen_symm_loop:
do j = 1,
size(opts % num_target_state_sym)
647 congen_targ_loop:
do k = 1, opts % num_target_state_sym(j)
648 congen_tgt_id = congen_tgt_id + 1
650 tgt_mgvn = opts % target_spatial(congen_tgt_id)
651 tgt_spin = opts % target_multiplicity(congen_tgt_id)
652 denprop_targ_loop:
do i = 1, this % ntarg
653 isym = prop % energies_index(2, i)
654 if (prop % symmetries_index(1, isym) == tgt_mgvn .and. &
655 prop % symmetries_index(2, isym) == tgt_spin)
then
656 denprop_tgt_id = denprop_tgt_id + 1
658 if (denprop_tgt_id == k)
then
659 this % idtarg(congen_tgt_id) = i
660 exit denprop_targ_loop
662 end do denprop_targ_loop
663 end do congen_targ_loop
664 end do congen_symm_loop
667 write (stdout,
'(/,1x,"Target state indices sorted by energy (IDTARG): ")')
668 write (stdout,
'( 1x,20I4)') this % idtarg
670 do i = 1, prop % no_states
673 if (findloc(this % idtarg, i, 1) == 0) cycle
676 tgt_stat = prop % energies_index(1, i)
677 tgt_symm = prop % energies_index(2, i)
678 tgt_mgvn = prop % symmetries_index(1, tgt_symm)
679 tgt_spin = prop % symmetries_index(2, tgt_symm)
680 tgt_enrg = prop % energies(i)
683 if (abs(spin - tgt_spin) /= 1) cycle
686 prj_mgvn = mprod(tgt_mgvn + 1, mgvn + 1, 0, stdout)
689 if (opts % use_UKRMOL_integrals)
then
690 call ukp_preamp(prj_mgvn, this % nchan + 1, this % lchl, this % mchl, this % qchl, nch, this % maxnmo)
692 call mpi_xermsg(
'Postprocessing_module',
'get_channel_info', &
693 'Interface for SWINTERF integrals not implemented.', 1, 1)
698 this % ichl(this % nchan + j) = tgt_stat
699 this % echl(this % nchan + j) = 2 * (tgt_enrg - ebase)
700 this % irrchl(this % nchan + j) = prj_mgvn
704 this % nchan = this % nchan + nch
708 write (stdout,
'(/," Channel Target l m q Irr Energy Energy(eV)")')
710 do i = 1, this % nchan
711 write (stdout,
'(I5,I8,I5,2I3,2x,A4,I3,2F10.6)') i, this % ichl(i), this % lchl(i), this % mchl(i), this % qchl(i), &
712 'N/A', this % irrchl(i), this % echl(i), this % echl(i) / 0.073500d0
736 use class_molecular_properties_data,
only: molecular_properties_data
737 use const_gbl,
only: stdout
738 use global_utils,
only: mprod
739 use mpi_gbl,
only: master, myrank
742 use ukrmol_interface_gbl,
only: eval_amplitudes, ukp_readamp
745 type(
options),
intent(in) :: opts
746 type(molecular_properties_data),
intent(in) :: prop
749 type(civect) :: orb_amps, dist_orb_amps, sol_amps
751 integer,
allocatable :: mcont(:), idchl(:)
752 real(wp),
allocatable :: ampls(:)
754 integer :: i, j, k, ir, ncontmo(8), iprnt = 0, nchan, nstat, ierr, nnoncontmo, norbs, morbs, ncnt, offs, nvo(8) = 0
757 nstat = solution % ci_vec % nstat
758 morbs = maxval(opts % num_orbitals_sym)
759 norbs = dot_product(opts % num_target_state_sym, opts % num_continuum_orbitals_target)
761 allocate(ampls(morbs), idchl(nchan))
765 do j = 1, this % ntarg
767 if (this % ichl(i) == this % idtarg(j))
then
774 write (stdout,
'(/,1x,"Channel target state energy map (IDCHL): ")')
775 write (stdout,
'( 1x,20I4)') idchl
780 orb_amps % blacs_context = -1
781 orb_amps % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
782 #if defined(usempi) && defined(scalapack)
783 if (orb_amps % CV_is_scalapack)
then
784 call blacs_get(-1_blasint, 0_blasint, orb_amps % blacs_context)
785 call blacs_gridinit(orb_amps % blacs_context,
'R', 1_blasint, 1_blasint)
788 call orb_amps % init_CV(nchan, norbs)
791 if (.not.
allocated(this % wamp))
then
792 allocate (this % wamp(this % nfdm + 1))
796 this % wamp(:) % nprow = solution % ci_vec % nprow
797 this % wamp(:) % npcol = solution % ci_vec % npcol
798 this % wamp(:) % blacs_context = solution % ci_vec % blacs_context
799 this % wamp(:) % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
802 this % wamp(this % nfdm + 1) % nprow = 1
803 this % wamp(this % nfdm + 1) % npcol = 1
804 this % wamp(this % nfdm + 1) % blacs_context = orb_amps % blacs_context
807 do ir = 1, this % nfdm + 1
808 call this % wamp(ir) % init_CV(nchan, nstat)
812 do ir = 1, this % nfdm + 1
815 if (myrank == master)
then
817 call eval_amplitudes(this % r_points(ir), .false.)
818 call ukp_readamp(orb_amps % CV, this % nchan, this % irrchl, this % lchl, this % mchl, this % qchl, ncontmo, &
819 opts % lambda_continuum_orbitals_target, iprnt)
829 if (this % ichl(j) /= this % ichl(idchl(i - 1)))
then
830 offs = offs + ncnt + nvo(this % irrchl(j))
833 ncnt = ncontmo(this % irrchl(j))
834 ampls(1:ncnt) = orb_amps % CV(j, 1:ncnt)
835 orb_amps % CV(j, 1:norbs) = 0
836 orb_amps % CV(j, offs + 1:offs + ncnt) = ampls(1:ncnt)
841 if (.not. solution % ci_vec % CV_is_scalapack)
then
842 call this % wamp(ir) % A_B_matmul(orb_amps, solution % ci_vec,
'N',
'N')
845 dist_orb_amps % nprow = solution % ci_vec % nprow
846 dist_orb_amps % npcol = solution % ci_vec % npcol
847 dist_orb_amps % blacs_context = solution % ci_vec % blacs_context
848 dist_orb_amps % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
849 call dist_orb_amps % init_CV(nchan, norbs)
850 call dist_orb_amps % redistribute(orb_amps)
853 if (ir < this % nfdm + 1)
then
854 call this % wamp(ir) % A_B_matmul(dist_orb_amps, solution % ci_vec,
'N',
'N')
857 sol_amps % nprow = solution % ci_vec % nprow
858 sol_amps % npcol = solution % ci_vec % npcol
859 sol_amps % blacs_context = solution % ci_vec % blacs_context
860 sol_amps % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
861 call sol_amps % init_CV(nchan, nstat)
862 call sol_amps % A_B_matmul(dist_orb_amps, solution % ci_vec,
'N',
'N')
863 call this % wamp(ir) % redistribute(sol_amps, solution % ci_vec % blacs_context)
868 this % wamp(ir) % CV = sqrt(2.0_wp) * this % wamp(ir) % CV
890 use algorithms,
only: findloc
891 use class_molecular_properties_data,
only: molecular_properties_data
892 use consts,
only: amu
897 integer,
intent(in) :: nchset
898 type(
options),
intent(in) :: opts
899 character(len=1),
intent(in) :: cform
901 type(molecular_properties_data),
intent(in) :: prop
903 integer,
parameter :: luchan = 10, keych = 10
905 integer :: i, k, nvd, nrec, ninfo, ndata, nvib, ndis, stot, gutot, ntarg, ivtarg(1), iv(1), ion, mtarg, starg, gutarg, nnuc
907 real(wp) :: r, rmass, xmass, etarg
909 nnuc = prop % no_nuclei
913 ion = nint(sum(prop % charge(1:nnuc))) - (opts % num_electrons - 1)
916 stot = nint(2 * opts % spin + 1)
917 rmass = sum(1 / prop % mass(1:nnuc), prop % mass(1:nnuc) > 0)
924 nrec = 3 + ntarg + this % nchan + nvd
928 if (cform ==
'F')
then
929 write (luchan,
'(16I5)') keych, nchset, nrec, ninfo, ndata
930 write (luchan,
'(A80)') opts % diag_name
931 write (luchan,
'(16I5)') ntarg, nvib, ndis, this % nchan
932 write (luchan,
'(4I5,2D20.12)') opts % lambda, stot, gutot, ion, r, rmass
935 do i = 1, prop % no_states
936 if (findloc(this % idtarg, i, 1) /= 0)
then
938 isymm = prop % energies_index(2, i)
939 mtarg = prop % symmetries_index(1, isymm)
940 starg = prop % symmetries_index(2, isymm)
942 etarg = prop % energies(i)
943 write (luchan,
'(4I5,2D20.12)') k, mtarg, starg, gutarg, etarg
946 do i = 1, this % nchan
947 write (luchan,
'(4I5,2D20.12)') i, this % ichl(i), this % lchl(i), this % mchl(i), this % echl(i)
950 write (luchan,
'(16I5)') i, ivtarg(i), iv(i)
953 write (luchan) keych, nchset, nrec, ninfo, ndata
954 write (luchan) opts % diag_name
955 write (luchan) ntarg, nvib, ndis, this % nchan
956 write (luchan) opts % lambda, stot, gutot, ion, r, rmass
959 do i = 1, prop % no_states
960 if (findloc(this % idtarg, i, 1) > 0)
then
962 isymm = prop % energies_index(2, i)
963 mtarg = prop % symmetries_index(1, isymm)
964 starg = prop % symmetries_index(2, isymm)
966 etarg = prop % energies(i)
967 write (luchan) k, mtarg, starg, gutarg, etarg
970 do i = 1, this % nchan
971 write (luchan) i, this % ichl(i), this % lchl(i), this % mchl(i), this % echl(i)
974 write (luchan) i, ivtarg(i), iv(i)
1009 use cdenprop_defs,
only: amass
1010 use class_molecular_properties_data,
only: molecular_properties_data
1011 use consts,
only: amu
1017 integer,
intent(in) :: nrmset
1018 type(
options),
intent(in) :: opts
1019 character(len=1),
intent(in) :: rform
1020 type(molecular_properties_data),
intent(in) :: prop
1023 integer,
parameter :: keyrm = 11
1024 integer,
parameter :: lurmt = 21
1026 integer :: i, j, k, nchsq, nrec, ninfo, ndata, ntarg, nvib, ndis, nchan, stot, gutot, ion, ibut, iex, nocsf, npole, nnuc
1027 integer :: ismax, nstat
1028 real(wp) :: r, rmass, rmatr
1030 nnuc = prop % no_nuclei
1036 rmatr = this % rmatr
1037 ntarg = this % ntarg
1038 nstat = solution % ci_vec % nstat
1041 nchan = this % nchan
1042 stot = nint(2 * opts % spin + 1)
1044 ion = nint(sum(prop % charge(1:nnuc))) - (opts % num_electrons - 1)
1046 nchsq = nchan * (nchan + 1) / 2
1048 rmass = sum(1 / prop % mass(1:nnuc), prop % mass(1:nnuc) > 0)
1054 if (rform ==
'F')
then
1055 if (ismax > 0) nrec = nrec + (nchsq * ismax + 3) / 4
1056 nrec = nrec + (nstat + 3) / 4
1057 nrec = nrec + (nchan * nstat + 3) / 4
1058 if (npole > 0) nrec = nrec + (nocsf * npole + 3) / 4
1059 if (ibut > 0) nrec = nrec + (3 * nchan + 3) / 4
1060 if (abs(ibut) > 1) nrec = nrec + 1 + (nchan + 3) / 4 + (iex + 3) / 4 + (nchan * iex + 3) / 4
1063 if (ismax > 0) nrec = nrec + 1
1064 if (npole > 0) nrec = nrec + 1
1065 if (ibut > 0) nrec = nrec + 1
1066 if (abs(ibut) > 1) nrec = nrec + 4
1070 ndata = nrec - ninfo
1072 if (rform ==
'F')
then
1073 write (lurmt,
'(10I7)') keyrm, nrmset, nrec, ninfo, ndata
1074 write (lurmt,
'(A80)') opts % diag_name
1075 write (lurmt,
'(16I5)') ntarg, nvib, ndis, nchan
1076 write (lurmt,
'(4I5,2D20.13)') opts % lambda, stot, gutot, ion, r, rmass
1077 write (lurmt,
'(4I5,2D20.13)') ismax, nstat, npole, ibut, rmatr
1079 if (ismax > 0)
write(lurmt,
'(4D20.13)') ((this % a(i,k),i=1,nchsq),k=1,ismax)
1080 write (lurmt,
'(4D20.13)') (solution % ci_vec % ei(i) + solution % core_energy,i=1,nstat)
1081 write (lurmt,
'(4D20.13)') ((this % wamp(this % nfdm + 1) % cv(i,j)/sqrt(2.0_wp),i=1,nchan),j=1,nstat)
1082 if (npole > 0)
write (lurmt,
'(4D20.13)') ((solution % ci_vec % cv(i,j),i=1,nocsf),j=1,npole)
1088 write(lurmt) keyrm, nrmset, nrec, ninfo, ndata
1089 write(lurmt) opts % diag_name
1090 write(lurmt) ntarg, nvib, ndis, nchan
1091 write(lurmt) opts % lambda, stot, gutot, ion, r, rmass
1092 write(lurmt) ismax, nstat, npole, ibut, rmatr
1094 if (ismax > 0)
write(lurmt) ((this % a(i,k),i=1,nchsq),k=1,ismax)
1095 write (lurmt) (solution % ci_vec % ei(i) + solution % core_energy,i=1,nstat)
1096 write (lurmt) ((this % wamp(this % nfdm + 1) % cv(i,j)/sqrt(2.0_wp),i=1,nchan),j=1,nstat)
1097 if (npole > 0)
write (lurmt) ((solution % ci_vec % cv(i,j),i=1,nocsf),j=1,npole)
1142 use coupling_obj_gbl,
only: couplings_type
1143 use class_molecular_properties_data,
only: molecular_properties_data
1144 use mpi_gbl,
only: mpi_xermsg
1145 use precisn,
only: wp
1148 type(molecular_properties_data),
intent(in) :: target_properties
1150 integer,
intent(in) :: ismax, ntarg
1151 real(wp),
intent(in) :: alpha0, alpha2
1152 logical,
intent(in) :: use_pol
1154 real(wp),
parameter :: fourpi = 12.5663706143591729538505735331180115_wp
1155 real(wp),
parameter :: roneh = 0.70710678118654752440084436210484903_wp
1156 real(wp),
parameter :: rothree = 0.57735026918962576450914878050195745_wp
1162 real(wp),
parameter :: x2_X00 = 0.282094791773878e+00_wp
1163 real(wp),
parameter :: x2_X20 = -0.126156626101008e+00_wp
1164 real(wp),
parameter :: x2_X22 = 0.218509686118416e+00_wp
1166 real(wp),
parameter :: y2_X00 = 0.282094791773878e+00_wp
1167 real(wp),
parameter :: y2_X20 = -0.126156626101008e+00_wp
1168 real(wp),
parameter :: y2_X22 = -0.218509686118416e+00_wp
1170 real(wp),
parameter :: z2_X00 = 0.282094791773878e+00_wp
1171 real(wp),
parameter :: z2_X20 = 0.252313252202016e+00_wp
1173 type(couplings_type) :: couplings
1175 real(wp),
allocatable :: prop(:,:,:)
1177 real(wp) :: cpl, sph_cpl, fac
1178 integer :: l1, m1, q1, l2, m2, q2, no_cpl, lqt, isq, it1, it2
1179 integer :: ch_1, ch_2, lambda, mlambda, lmin, lmax
1180 logical :: use_alpha2
1182 if (use_pol .and. ntarg > 1)
then
1183 write (*,
'("WARNING: adding polarization potential while more than one target state is present in the outer region.")')
1187 call target_properties % decompress(1, ismax, prop)
1190 use_alpha2 = (use_pol .and. alpha2 /= 0.0_wp)
1191 lmax = merge(max(ismax, 3), ismax, use_pol)
1192 no_cpl = this % nchan * (this % nchan + 1) / 2
1195 if (
allocated(this % a))
deallocate (this % a)
1196 allocate (this % a(no_cpl, lmax))
1197 this % a(:,:) = 0.0_wp
1199 do ch_1 = 1, this % nchan
1201 l1 = this % lchl(ch_1)
1202 m1 = this % mchl(ch_1)
1203 q1 = this % qchl(ch_1)
1205 it1 = this % ichl(ch_1)
1209 l2 = this % lchl(ch_2)
1210 m2 = this % mchl(ch_2)
1211 q2 = this % qchl(ch_2)
1213 it2 = this % ichl(ch_2)
1217 call couplings % bounds_rg(l1, l2, m1, m2, lmin, lmax)
1220 if (lmax > ismax) lmax = ismax
1224 if (lmin == 0) lmin = 2
1227 lqt = ch_1 * (ch_1 - 1) / 2 + ch_2
1231 do lambda = lmin, lmax, 2
1235 fac = sqrt(fourpi / (2 * lambda + 1.0_wp))
1237 do mlambda = -lambda, lambda
1243 cpl = 2.0_wp * fac * couplings % rgaunt(l1, lambda, l2, m1, mlambda, m2)
1247 isq = lambda * lambda + lambda + mlambda
1251 this % a(lqt, lambda) = this % a(lqt, lambda) + cpl * prop(it1, it2, isq)
1258 if (use_pol .and. it1 == 1 .and. it2 == 1)
then
1264 if (l1 == l2 .and. m1 == m2)
then
1266 write(*,
'("Spherical part of the polarization potential will be added to the &
1267 &channel (target state,l,m), coefficient value: (",3i5,") ",e25.15)') &
1268 it1, l1, m1, -sph_cpl * alpha0
1269 this % a(lqt, lambda) = this % a(lqt, lambda) - sph_cpl * alpha0
1279 if (use_alpha2)
then
1281 write(*,
'("Non-spherical part of the polarization potential &
1282 &(target state,l1,m2,l2,m2): ",5i5)') it1, l1, m1, l2, m2
1285 cpl = x2_x00 * couplings % rgaunt(l1, 0, l2, m1, 0, m2) + &
1286 x2_x20 * couplings % rgaunt(l1, 2, l2, m1, 0, m2) + &
1287 x2_x22 * couplings % rgaunt(l1, 2, l2, m1, 2, m2)
1288 write(*,
'("x^2 coefficient: ",e25.15)') -cpl * alpha2
1289 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1292 cpl = y2_x00 * couplings % rgaunt(l1, 0, l2, m1, 0, m2) + &
1293 y2_x20 * couplings % rgaunt(l1, 2, l2, m1, 0, m2) + &
1294 y2_x22 * couplings % rgaunt(l1, 2, l2, m1, 2, m2)
1295 write(*,
'("y^2 coefficient: ",e25.15)') -cpl * alpha2
1296 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1299 cpl = z2_x00 * couplings % rgaunt(l1, 0, l2, m1, 0, m2) + &
1300 z2_x20 * couplings % rgaunt(l1, 2, l2, m1, 0, m2)
1301 write(*,
'("z^2 coefficient: ",e25.15)') -cpl * alpha2
1302 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1305 cpl = couplings % rgaunt(l1, 2, l2, m1, 1, m2) * rothree
1306 write(*,
'("xz coefficient: ",e25.15)') -cpl * alpha2
1307 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1310 cpl = couplings % rgaunt(l1, 2, l2, m1, -1, m2) * rothree
1311 write(*,
'("yz coefficient: ",e25.15)') -cpl * alpha2
1312 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1315 cpl = couplings % rgaunt(l1, 2, l2, m1, -2, m2) * rothree
1316 write(*,
'("xy coefficient: ",e25.15)') -cpl * alpha2
1317 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1374 subroutine write_rmt_data (input, inner_properties, target_properties, solutions, intf)
1376 use algorithms,
only: findloc, insertion_sort
1377 use class_molecular_properties_data,
only: molecular_properties_data
1378 use const_gbl,
only: stdout
1380 use mpi_gbl,
only: myrank, master, mpiint, mpi_xermsg, mpi_mod_file_open_write, &
1381 mpi_mod_file_close, mpi_mod_file_set_size, mpi_mod_file_write, mpi_mod_barrier
1386 type(molecular_properties_data),
intent(in) :: inner_properties
1387 type(molecular_properties_data),
intent(in) :: target_properties
1391 real(rmt_real),
allocatable :: cf(:,:,:), wmat(:,:), crlv(:,:), etarg(:), rg(:), eig(:), r_points(:)
1392 integer(rmt_int),
allocatable :: iidip(:), ifdip(:), lm_rg(:,:), ltarg(:), starg(:), nconat(:), l2p(:), m2p(:), ichl(:), &
1394 integer,
allocatable :: ions(:)
1396 real(rmt_real) :: bbloch = 0, prop, rmatr, delta_r
1397 integer :: i, j, k, l, nsym, m, irr_map(8,8), iblock, u, v, nsymm, ind, ip, irr1, irr2, it1, it2, lu, neig, nnuc, &
1398 ierr, nblock, sym1, sym2, ref
1399 integer(mpiint) :: fh
1400 integer(rmt_int) :: s, s1, s2, ntarg, n_rg, nelc, nz, lran2, lamax, inast, nchmx, nstmx, lmaxp1, nchan, lrgl, nspn, npty, &
1401 mnp1, mxstat, lrang2, lmax, nfdm
1404 inast = count(iand(input % opts(:) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
1407 ref = maxloc(intf(:) % ntarg, 1)
1408 nnuc = target_properties % no_nuclei
1410 delta_r = input % delta_r
1411 rmatr = input % rmatr
1412 nsymm =
size(input % opts(:))
1413 ntarg = intf(ref) % ntarg
1414 nelc = input % opts(1) % num_electrons - 1
1415 nz = sum(target_properties % charge(1:nnuc))
1417 mxstat = maxval(inner_properties % dense_blocks(1:inner_properties % no_blocks) % mat_dimen)
1420 if (nsymm == 0 .or. inast == 0 .or. ntarg == 0 .or. mxstat <= 0)
then
1421 write (stdout, *)
'Nothing to do in RMT interface'
1431 ions = intf(ref) % idtarg
1432 call insertion_sort(ions)
1435 call mpi_mod_file_open_write(
'molecular_data', fh, ierr)
1436 call mpi_mod_file_set_size(fh, 0)
1438 allocate (propblocks(inner_properties % no_blocks))
1440 write (stdout,
'(/,"Writing RMT data file")')
1441 write (stdout,
'( "=====================")')
1442 write (stdout,
'(/," Inner region dipole block max size: ",I0)') mxstat
1443 write (stdout,
'(/," Ionic states used in outer region: ")')
1444 write (stdout,
'(/," ",20I5)') ions
1452 do ip = 1, inner_properties % no_blocks
1453 if (inner_properties % dense_index(3, ip) == 1 .and. &
1454 inner_properties % dense_index(4, ip) == m)
then
1455 sym1 = inner_properties % dense_index(1, ip)
1456 sym2 = inner_properties % dense_index(2, ip)
1457 irr1 = inner_properties % symmetries_index(1, sym1) + 1
1458 irr2 = inner_properties % symmetries_index(1, sym2) + 1
1460 propblocks(nblock) = ip
1461 irr_map(irr1, irr2) = nblock
1466 if (
allocated(iidip))
deallocate (iidip)
1467 if (
allocated(ifdip))
deallocate (ifdip)
1468 allocate (iidip(nblock))
1469 allocate (ifdip(nblock))
1475 sym1 = inner_properties % dense_index(1, propblocks(ip))
1476 sym2 = inner_properties % dense_index(2, propblocks(ip))
1477 irr1 = inner_properties % symmetries_index(1, sym1) + 1
1478 irr2 = inner_properties % symmetries_index(1, sym2) + 1
1484 call mpi_mod_file_write(fh, int(nblock,
rmt_int))
1485 call mpi_mod_file_write(fh, mxstat)
1486 call mpi_mod_file_write(fh, mxstat)
1487 call mpi_mod_file_write(fh, iidip, nblock)
1488 call mpi_mod_file_write(fh, ifdip, nblock)
1492 associate(d => inner_properties % dense_blocks(propblocks(ip)))
1493 if (d % CV_is_scalapack)
then
1494 call mpi_mod_file_write(fh, int(d % mat_dimen_r), int(d % mat_dimen_c), int(d % nprow), int(d % npcol), &
1495 int(d % scal_block_size), int(d % scal_block_size), d % CV, &
1496 int(d % local_row_dimen), int(d % local_col_dimen))
1497 call mpi_mod_barrier(ierr)
1499 call mpi_mod_file_write(fh, d % CV, int(d % mat_dimen_r), int(d % mat_dimen_c))
1507 if (iand(input % opts(i) % vector_storage_method, pass_to_cdenprop) /= 0 .and. &
1508 input % opts(i) % diagonalization_flag /= no_diagonalization)
then
1509 if (intf(i) % nchan > 0)
then
1510 lrang2 = max(int(lrang2), maxval(intf(i) % lchl(1:intf(i) % nchan)))
1511 lamax = max(int(lamax), intf(i) % ismax)
1512 nchmx = max(int(nchmx), intf(i) % nchan)
1515 nstmx = max(int(nstmx), solutions(i) % vec_dimen)
1520 call mpi_mod_file_write(fh, ntarg)
1523 allocate (etarg(ntarg), ltarg(ntarg), starg(ntarg), nconat(ntarg), l2p(nchmx), m2p(nchmx), eig(nstmx), &
1524 wmat(nchmx, nstmx), cf(nchmx, nchmx, lamax), ichl(nchmx), crlv(ntarg, ntarg), r_points(nfdm + 1), stat = ierr)
1526 call mpi_xermsg(
'Postprocessing_module',
'write_rmt_data',
'Memory allocation failure.', 1, 1)
1531 etarg(i) = target_properties % energies(ions(i))
1532 ltarg(i) = target_properties % symmetries_index(1, target_properties % energies_index(2, ions(i))) + 1
1533 starg(i) = target_properties % symmetries_index(2, target_properties % energies_index(2, ions(i)))
1538 r_points(i) = rmatr - (nfdm + 1 - i) * delta_r
1544 do ip = 1, target_properties % non_zero_properties
1545 if (target_properties % properties_index(3, ip) == 1 .and. &
1546 target_properties % properties_index(4, ip) == m)
then
1548 it1 = target_properties % properties_index(1, ip)
1549 it2 = target_properties % properties_index(2, ip)
1550 prop = target_properties % properties(ip)
1552 it1 = findloc(ions, it1, 1)
1553 it2 = findloc(ions, it2, 1)
1554 if (it1 > 0 .and. it2 > 0)
then
1555 crlv(it1, it2) = prop
1556 crlv(it2, it1) = prop
1561 call mpi_mod_file_write(fh, crlv, int(ntarg), int(ntarg))
1567 if (iand(input % opts(i) % vector_storage_method, pass_to_cdenprop) /= 0 .and. &
1568 input % opts(i) % diagonalization_flag /= no_diagonalization)
then
1569 if (intf(i) % nchan > 0)
then
1570 lmax = max(int(lmax), maxval(intf(i) % lchl(1:intf(i) % nchan)))
1576 call mpi_mod_file_write(fh, n_rg)
1577 call mpi_mod_file_write(fh, rg, int(n_rg))
1578 call mpi_mod_file_write(fh, lm_rg, 6, int(n_rg))
1579 call mpi_mod_file_write(fh, nelc)
1580 call mpi_mod_file_write(fh, nz)
1581 call mpi_mod_file_write(fh, lrang2)
1582 call mpi_mod_file_write(fh, lamax)
1583 call mpi_mod_file_write(fh, ntarg)
1584 call mpi_mod_file_write(fh, inast)
1585 call mpi_mod_file_write(fh, nchmx)
1586 call mpi_mod_file_write(fh, nstmx)
1587 call mpi_mod_file_write(fh, lmaxp1)
1588 call mpi_mod_file_write(fh, rmatr)
1589 call mpi_mod_file_write(fh, bbloch)
1590 call mpi_mod_file_write(fh, etarg, int(ntarg))
1591 call mpi_mod_file_write(fh, ltarg, int(ntarg))
1592 call mpi_mod_file_write(fh, starg, int(ntarg))
1593 call mpi_mod_file_write(fh, nfdm)
1594 call mpi_mod_file_write(fh, delta_r)
1595 call mpi_mod_file_write(fh, r_points, int(nfdm + 1))
1599 if (iand(input % opts(i) % vector_storage_method, pass_to_cdenprop) /= 0 .and. &
1600 input % opts(i) % diagonalization_flag /= no_diagonalization)
then
1602 lrgl = 1 + input % opts(i) % lambda
1603 nspn = int(2 * input % opts(i) % spin + 1,
rmt_int)
1605 nchan = intf(i) % nchan
1606 mnp1 = solutions(i) % vec_dimen
1609 nconat(j) = count(intf(i) % ichl(1:nchan) == j)
1617 l2p(j) = intf(i) % lchl(j)
1618 m2p(j) = intf(i) % mchl(j)
1619 ichl(j) = intf(i) % ichl(j)
1622 call mpi_mod_file_write(fh, lrgl)
1623 call mpi_mod_file_write(fh, nspn)
1624 call mpi_mod_file_write(fh, npty)
1625 call mpi_mod_file_write(fh, nchan)
1626 call mpi_mod_file_write(fh, mnp1)
1627 call mpi_mod_file_write(fh, nconat, int(ntarg))
1628 call mpi_mod_file_write(fh, l2p, int(nchmx))
1629 call mpi_mod_file_write(fh, m2p, int(nchmx))
1632 eig(1:mnp1) = solutions(i) % ci_vec % ei(1:mnp1) + solutions(i) % core_energy
1635 if (myrank == master) wmat(1:nchan, 1:mnp1) = intf(i) % wamp(nfdm + 1) % CV(1:nchan, 1:mnp1)
1637 call mpi_mod_file_write(fh, eig, int(nstmx))
1638 call mpi_mod_file_write(fh, wmat, int(nchmx), int(nstmx))
1641 do l = 1, intf(i) % ismax
1646 ind = u * (u - 1) / 2 + v
1647 cf(j, k, l) = intf(i) % a(ind, l)
1652 call mpi_mod_file_write(fh, cf, int(nchmx), int(nchmx), int(lamax))
1653 call mpi_mod_file_write(fh, ichl, int(nchmx))
1655 s1 = intf(i) % wamp(1) % mat_dimen_r
1656 s2 = intf(i) % wamp(1) % mat_dimen_c
1658 call mpi_mod_file_write(fh, s1)
1659 call mpi_mod_file_write(fh, s2)
1663 associate(w => intf(i) % wamp(j))
1664 if (w % CV_is_scalapack)
then
1665 call mpi_mod_file_write(fh, int(w % mat_dimen_r), int(w % mat_dimen_c), &
1666 int(w % nprow), int(w % npcol), &
1667 int(w % scal_block_size), int(w % scal_block_size), w % CV, &
1668 int(w % local_row_dimen), int(w % local_col_dimen))
1670 call mpi_mod_file_write(fh, w % CV, int(w % mat_dimen_r), int(w % mat_dimen_c))
1678 call mpi_mod_file_close(fh, ierr)
1696 use coupling_obj_gbl,
only: couplings_type
1698 integer(rmt_int),
intent(in) :: maxl
1699 integer(rmt_int),
intent(out) :: n_rg
1700 real(rmt_real),
allocatable,
intent(inout) :: rg(:)
1701 integer(rmt_int),
allocatable,
intent(inout) :: lm_rg(:,:)
1703 type(couplings_type) :: cpl
1705 integer :: l1, l2, l3, m1, m2, m3, err
1708 call cpl % prec_cgaunt(int(maxl))
1719 tmp = cpl % rgaunt(l1, l2, l3, m1, m2, m3)
1720 if (tmp /= 0) n_rg = n_rg + 1
1727 if (
allocated(rg))
deallocate (rg)
1728 if (
allocated(lm_rg))
deallocate (lm_rg)
1729 n_rg = max(n_rg, 1_rmt_int)
1730 allocate (rg(n_rg), lm_rg(6, n_rg), stat = err)
1741 tmp = cpl % rgaunt(l1, l2, l3, m1, m2, m3)
1745 lm_rg(1:6, n_rg) = (/ l1, m1, l2, m2, l3, m3 /)