56#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rixs_methods'
77 CHARACTER(len=*),
PARAMETER :: routinen =
'rixs'
79 INTEGER :: handle, output_unit
84 CALL timeset(routinen, handle)
86 NULLIFY (rixs_section)
90 qs_env%do_rixs = .true.
94 CALL get_qs_env(qs_env, dft_control=dft_control)
101 IF (output_unit > 0)
THEN
102 WRITE (unit=output_unit, fmt=
"(/,(T2,A79))") &
103 "*******************************************************************************", &
104 "! Normal termination of Resonant Inelastic X-RAY Scattering calculation !", &
105 "*******************************************************************************"
108 CALL timestop(handle)
122 CHARACTER(len=*),
PARAMETER :: routinen =
'rixs_core'
124 INTEGER :: ax, current_state_index, fstate, handle, iatom, ispin, istate, nao, nex_atoms, &
125 nocc_max, nspins, nstates, nvirt, output_unit, td_state
126 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nocc
127 LOGICAL :: do_sc, do_sg, roks, uks
129 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: w_i0, w_if
130 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dip_block, mu_i0
131 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: mu_if
134 dip_f_struct, gs_coeff_struct, &
135 i_dip_0_struct, i_dip_f_struct
137 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: core_evects, dip_f, i_dip_0, i_dip_f, &
139 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: local_gs_coeffs, mo_coeffs
140 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: valence_evects
142 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: dipmat, matrix_s
151 NULLIFY (rixs_control, dft_control, rixs_env)
152 NULLIFY (valence_state, core_state)
153 NULLIFY (para_env, blacs_env)
154 NULLIFY (local_gs_coeffs, mo_coeffs, valence_evects)
155 NULLIFY (dipmat, dip_0_struct, i_dip_0_struct, dip_f_struct, i_dip_f_struct, &
156 core_evect_struct, gs_coeff_struct)
161 dft_control=dft_control, &
174 do_sg = rixs_control%xas_tdp_control%do_singlet
175 do_sc = rixs_control%xas_tdp_control%do_spin_cons
177 IF (rixs_control%xas_tdp_control%check_only)
THEN
178 cpwarn(
"CHECK_ONLY run for XAS_TDP requested, RIXS and TDDFPT will not be performed.")
182 CALL tddfpt(qs_env, calc_forces=.false., rixs_env=rixs_env)
184 IF (output_unit > 0)
THEN
189 CALL timeset(routinen, handle)
196 cpabort(
"RIXS only implemented for singlet and spin-conserving excitations")
199 IF (output_unit > 0)
THEN
200 IF (dft_control%uks)
THEN
202 WRITE (unit=output_unit, fmt=
"(T2,A)")
"RIXS| Unrestricted Open-Shell Kohn-Sham"
203 ELSE IF (dft_control%roks)
THEN
205 WRITE (unit=output_unit, fmt=
"(T2,A)")
"RIXS| Restricted Open-Shell Kohn-Sham"
209 core_state => rixs_env%core_state
210 valence_state => rixs_env%valence_state
213 mo_coeffs => valence_state%mos_occ
215 local_gs_coeffs => core_state%mo_coeff
216 valence_evects => valence_state%evects
218 IF (rixs_control%xas_tdp_control%do_loc)
THEN
219 IF (output_unit > 0)
THEN
220 WRITE (unit=output_unit, fmt=
"(T2,A)") &
221 "RIXS| Found localised XAS_TDP orbitals"
222 WRITE (unit=output_unit, fmt=
"(T2,A)") &
223 "RIXS| Rotating TDDFPT vectors..."
225 CALL rotate_vectors(valence_state%evects, local_gs_coeffs, mo_coeffs, matrix_s(1)%matrix, output_unit)
229 ALLOCATE (nocc(nspins))
231 CALL cp_fm_get_info(matrix=valence_state%mos_occ(ispin), nrow_global=nao, ncol_global=nocc(ispin))
233 nocc_max = maxval(nocc)
235 nex_atoms = core_state%nex_atoms
236 nstates = valence_state%nstates
237 dipmat => core_state%dipmat
239 ALLOCATE (core_evects(nspins), state_gs_coeffs(nspins))
240 nvirt = core_state%nvirt
241 ALLOCATE (dip_block(1, nspins), mu_i0(4, nvirt), mu_if(4, nvirt, nstates), w_i0(nvirt), w_if(nstates))
244 w_if(:) = valence_state%evals(:)*
evolt
245 ALLOCATE (i_dip_0(nspins))
246 ALLOCATE (dip_f(nspins), i_dip_f(nspins))
249 nrow_global=nao, ncol_global=nvirt)
251 nrow_global=nao, ncol_global=1)
254 current_state_index = 1
255 DO iatom = 1, nex_atoms
256 current_state => core_state%donor_states(current_state_index)
257 IF (output_unit > 0)
THEN
258 WRITE (unit=output_unit, fmt=
"(T2,A,A,A,A,A,I5)") &
259 "RIXS| Calculating dipole moment from core-excited state ", &
260 core_state%state_type_char(current_state%state_type),
" of ", trim(current_state%at_symbol), &
261 " with index ", current_state%kind_index
265 target_ex_coeffs => current_state%sg_coeffs
266 w_i0(:) = current_state%sg_evals(:)*
evolt
268 target_ex_coeffs => current_state%sc_coeffs
269 w_i0(:) = current_state%sc_evals(:)*
evolt
274 CALL cp_fm_create(core_evects(ispin), core_evect_struct)
275 CALL cp_fm_to_fm_submat(msource=target_ex_coeffs, mtarget=core_evects(ispin), s_firstrow=1, &
276 s_firstcol=(nvirt*(ispin - 1) + 1), t_firstrow=1, t_firstcol=1, nrow=nao, ncol=nvirt)
279 CALL cp_fm_create(state_gs_coeffs(ispin), gs_coeff_struct)
282 CALL cp_fm_to_fm_submat(msource=current_state%gs_coeffs, mtarget=state_gs_coeffs(ispin), s_firstrow=1, &
283 s_firstcol=1, t_firstrow=1, t_firstcol=1, nrow=nao, ncol=1)
285 CALL cp_fm_to_fm_submat(msource=current_state%gs_coeffs, mtarget=state_gs_coeffs(ispin), s_firstrow=1, &
286 s_firstcol=ispin, t_firstrow=1, t_firstcol=1, nrow=nao, ncol=1)
292 nrow_global=nao, ncol_global=1)
295 nrow_global=nvirt, ncol_global=1)
303 nrow_global=nao, ncol_global=nocc(ispin))
305 nrow_global=nvirt, ncol_global=nocc(ispin))
318 CALL parallel_gemm(
'T',
'N', nvirt, 1, nao, 1.0_dp, core_evects(ispin), dip_0, 0.0_dp, i_dip_0(ispin))
325 start_col=1, n_rows=1, n_cols=1)
326 mu_i0(ax, istate) = dip_block(1, 1)
328 mu_xyz = mu_i0(ax, istate)
329 mu_i0(4, istate) = mu_i0(4, istate) + mu_xyz
335 DO td_state = 1, nstates
337 IF (output_unit > 0)
THEN
338 WRITE (unit=output_unit, fmt=
"(T9,A,I3,A,F10.4)") &
339 "to valence-excited state ", td_state,
" with energy ", w_if(td_state)
348 CALL parallel_gemm(
'T',
'N', nvirt, nocc(ispin), nao, 1.0_dp, core_evects(ispin), &
349 dip_f(ispin), 0.0_dp, i_dip_f(ispin))
353 DO fstate = 1, nocc_max
356 IF (fstate <= nocc(ispin))
THEN
358 start_col=fstate, n_rows=1, n_cols=1)
359 mu_if(ax, istate, td_state) = mu_if(ax, istate, td_state) + dip_block(1, 1)
363 mu_xyz = mu_if(ax, istate, td_state)
364 mu_if(4, istate, td_state) = mu_if(4, istate, td_state) + mu_xyz
371 IF (output_unit > 0)
THEN
372 WRITE (unit=output_unit, fmt=
"(/,T2,A,/)")
"RIXS| Printing spectrum to file"
374 CALL print_rixs_to_file(current_state, mu_i0, mu_if, w_i0, w_if, rixs_env, rixs_section)
376 current_state_index = current_state_index + 1
392 NULLIFY (current_state)
403 NULLIFY (valence_state, core_state)
405 CALL timestop(handle)
418 SUBROUTINE rotate_vectors(evects, mo_ref, mo_occ, overlap_matrix, unit_nr)
420 TYPE(
cp_fm_type),
DIMENSION(:) :: mo_ref, mo_occ
424 INTEGER :: ispin, istate, nactive, ncol, nrow, &
426 REAL(kind=
dp) :: diff
429 TYPE(
cp_fm_type) :: emat, rotated_mo_coeffs, smo
433 NULLIFY (emat_struct, para_env, blacs_env, current_evect)
435 nspins =
SIZE(evects, dim=1)
438 CALL cp_fm_get_info(matrix=mo_occ(ispin), nrow_global=nrow, ncol_global=ncol, &
439 para_env=para_env, context=blacs_env)
446 para_env=para_env, context=blacs_env)
449 CALL parallel_gemm(
'T',
'N', ncol, ncol, nrow, 1.0_dp, mo_ref(ispin), smo, 0.0_dp, emat)
450 CALL cp_fm_create(rotated_mo_coeffs, mo_occ(ispin)%matrix_struct)
452 CALL parallel_gemm(
'N',
'N', nrow, ncol, ncol, 1.0_dp, mo_occ(ispin), emat, 0.0_dp, rotated_mo_coeffs)
454 diff = maxval(abs(rotated_mo_coeffs%local_data - mo_occ(ispin)%local_data))
455 IF (unit_nr > 0)
THEN
456 WRITE (unit_nr, fmt=
"(T9,A,I2,A,F10.6,/)")
"For spin ", ispin,
": Max difference between orbitals = ", diff
463 IF (nactive /= ncol)
THEN
464 CALL cp_warn(__location__,
"RIXS with reduced occupied state TDDFPT not possible")
465 cpabort(
"rotate_vectors in rixs_method")
468 nstates =
SIZE(evects, dim=2)
469 DO istate = 1, nstates
470 associate(current_evect => evects(ispin, istate))
471 CALL parallel_gemm(
'N',
'N', nrow, ncol, ncol, 1.0_dp, current_evect, emat, 0.0_dp, smo)
483 END SUBROUTINE rotate_vectors
495 SUBROUTINE print_rixs_to_file(donor_state, mu_i0, mu_if, w_i0, w_if, &
496 rixs_env, rixs_section)
498 TYPE(donor_state_type),
POINTER :: donor_state
499 REAL(dp),
DIMENSION(:, :) :: mu_i0
500 REAL(dp),
DIMENSION(:, :, :) :: mu_if
501 REAL(dp),
DIMENSION(:) :: w_i0, w_if
502 TYPE(rixs_env_type),
POINTER :: rixs_env
503 TYPE(section_vals_type),
POINTER :: rixs_section
505 INTEGER :: f, i, output_unit, rixs_unit
506 TYPE(cp_logger_type),
POINTER :: logger
509 logger => cp_get_default_logger()
511 rixs_unit = cp_print_key_unit_nr(logger, rixs_section,
"PRINT%SPECTRUM", &
512 extension=
".rixs", file_position=
"APPEND", &
513 file_action=
"WRITE", file_form=
"FORMATTED")
515 output_unit = cp_logger_get_default_io_unit()
517 IF (rixs_unit > 0)
THEN
519 WRITE (rixs_unit, fmt=
"(A,/,T2,A,A,A,A,A,I5,A/,A)") &
520 "====================================================================================", &
521 "Excitation from ground-state (", &
522 rixs_env%core_state%state_type_char(donor_state%state_type),
" of kind ", &
523 trim(donor_state%at_symbol),
" with index ", donor_state%kind_index, &
524 ") to core-excited state i ", &
525 "===================================================================================="
527 WRITE (rixs_unit, fmt=
"(T3,A)") &
528 "w_0i (eV) mu^x_0i (a.u.) mu^y_0i (a.u.) mu^z_0i (a.u.) mu^2_0i (a.u.)"
529 DO i = 1,
SIZE(mu_i0, dim=2)
530 WRITE (rixs_unit, fmt=
"(T2,F10.4,T26,E12.5,T42,E12.5,T58,E12.5,T74,E12.5)") &
531 w_i0(i), mu_i0(1, i), mu_i0(2, i), mu_i0(3, i), mu_i0(4, i)
534 WRITE (rixs_unit, fmt=
"(A,/,T2,A,/,A)") &
535 "====================================================================================", &
536 "Emission from core-excited state i to valence-excited state f ", &
537 "===================================================================================="
539 WRITE (rixs_unit, fmt=
"(T3,A)") &
540 "w_0i (eV) w_if (eV) mu^x_if (a.u.) mu^y_if (a.u.) mu^z_if (a.u.) mu^2_if (a.u.)"
542 DO i = 1,
SIZE(mu_if, dim=2)
543 DO f = 1,
SIZE(mu_if, dim=3)
544 WRITE (rixs_unit, fmt=
"(T2,F10.4,T14,F8.4,T26,E12.5,T42,E12.5,T58,E12.5,T74,E12.5)") &
545 w_i0(i), w_if(f), mu_if(1, i, f), mu_if(2, i, f), mu_if(3, i, f), mu_if(4, i, f)
551 CALL cp_print_key_finished_output(rixs_unit, logger, rixs_section,
"PRINT%SPECTRUM")
553 END SUBROUTINE print_rixs_to_file
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vazdacruz2021
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public rixs_control_release(rixs_control)
Releases the rixs_control_type.
subroutine, public rixs_control_create(rixs_control)
Creates and initializes the rixs_control_type.
Utilities to set up the control types.
subroutine, public read_rixs_control(rixs_control, rixs_section, qs_control)
Reads the input and stores in the rixs_control_type.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Definition of physical constants:
real(kind=dp), parameter, public evolt
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public tddfpt(qs_env, calc_forces, rixs_env)
Perform TDDFPT calculation. If calc_forces then it also builds the response vector for the Z-vector m...
Methods for Resonant Inelastic XRAY Scattering (RIXS) calculations.
subroutine, public rixs_core(rixs_section, qs_env)
Perform RIXS calculation.
subroutine, public rixs(qs_env)
Driver for RIXS calculations.
Define Resonant Inelastic XRAY Scattering (RIXS) control type and associated create,...
subroutine, public rixs_env_create(rixs_env)
Creates a rixs environment type.
subroutine, public rixs_env_release(rixs_env)
Releases the rixs environment type.
Methods for X-Ray absorption spectroscopy (XAS) using TDDFPT.
subroutine, public xas_tdp(qs_env, rixs_env)
Driver for XAS TDDFT calculations.
Define XAS TDP control type and associated create, release, etc subroutines, as well as XAS TDP envir...
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment
Valence state coming from the qs_tddfpt2 routine.
Type containing informations about a single donor state.
Type containing informations such as inputs and results for TDP XAS calculations.