72#include "./base/base_uses.f90"
77 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xas_restart'
103 SUBROUTINE xas_read_restart(xas_env, xas_section, qs_env, xas_method, iatom, estate, istate)
108 INTEGER,
INTENT(IN) :: xas_method, iatom
109 INTEGER,
INTENT(OUT) :: estate
110 INTEGER,
INTENT(IN) :: istate
112 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xas_read_restart'
114 CHARACTER(LEN=default_path_length) :: filename
115 INTEGER :: handle, i, ia, ie, ispin, my_spin, nao, nao_read, nelectron, nexc_atoms, &
116 nexc_atoms_read, nexc_search, nexc_search_read, nmo, nmo_read, output_unit, rst_unit, &
117 xas_estate, xas_estate_read, xas_method_read
119 REAL(
dp) :: occ_estate, occ_estate_read, &
120 xas_nelectron, xas_nelectron_read
121 REAL(
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation_numbers
122 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eig_read, occ_read
123 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: vecbuffer
130 CALL timeset(routinen, handle)
135 NULLIFY (eigenvalues, matrix_s, mos, occupation_numbers, vecbuffer)
140 "PRINT%PROGRAM_RUN_INFO", extension=
".Log")
142 CALL get_qs_env(qs_env=qs_env, para_env=para_env)
144 IF (para_env%is_source())
THEN
149 filename = filename(ia:ie)//
'-at'//trim(adjustl(
cp_to_string(iatom)))// &
156 CALL open_file(file_name=trim(filename), &
157 file_action=
"READ", &
158 file_form=
"UNFORMATTED", &
159 file_position=
"REWIND", &
161 unit_number=rst_unit)
163 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
"(/,T20,A,I5,/)") &
164 "Read restart file for atom ", iatom
167 IF (output_unit > 0)
WRITE (unit=output_unit, fmt=
"(/,T10,A,I5,A,/)") &
168 "Restart file for atom ", iatom, &
169 " not available. Initialization done with GS orbitals"
174 CALL get_xas_env(xas_env=xas_env, occ_estate=occ_estate, xas_estate=xas_estate, &
175 xas_nelectron=xas_nelectron, nexc_search=nexc_search, &
176 nexc_atoms=nexc_atoms, spin_channel=my_spin)
179 CALL get_qs_env(qs_env=qs_env, mos=mos, matrix_s=matrix_s)
181 IF (rst_unit > 0)
THEN
182 READ (rst_unit) xas_method_read
183 READ (rst_unit) nexc_search_read, nexc_atoms_read, occ_estate_read, xas_nelectron_read
184 READ (rst_unit) xas_estate_read
186 IF (xas_method_read /= xas_method)
THEN
187 cpabort(
"READ XAS RESTART: restart with different XAS method is not possible.")
189 IF (nexc_atoms_read /= nexc_atoms)
THEN
190 CALL cp_abort(__location__, &
191 "READ XAS RESTART: restart with different excited atoms "// &
192 "is not possible. Start instead a new XAS run with the new set of atoms.")
196 CALL para_env%bcast(xas_estate_read)
197 CALL set_xas_env(xas_env=xas_env, xas_estate=xas_estate_read)
198 estate = xas_estate_read
201 ALLOCATE (vecbuffer(1, nao))
203 DO ispin = 1,
SIZE(mos)
204 CALL get_mo_set(mo_set=mos(ispin), nmo=nmo, eigenvalues=eigenvalues, &
205 occupation_numbers=occupation_numbers, mo_coeff=mo_coeff, nelectron=nelectron)
207 occupation_numbers = 0.0_dp
209 IF (para_env%is_source())
THEN
210 READ (rst_unit) nao_read, nmo_read
211 IF (nao /= nao_read)
THEN
212 cpabort(
"To change basis is not possible. ")
214 ALLOCATE (eig_read(nmo_read), occ_read(nmo_read))
217 nmo = min(nmo, nmo_read)
218 READ (rst_unit) eig_read(1:nmo_read), occ_read(1:nmo_read)
219 eigenvalues(1:nmo) = eig_read(1:nmo)
220 occupation_numbers(1:nmo) = occ_read(1:nmo)
221 IF (nmo_read > nmo)
THEN
222 IF (occupation_numbers(nmo) >= epsilon(0.0_dp))
THEN
223 CALL cp_warn(__location__, &
224 "The number of occupied MOs on the restart unit is larger than "// &
225 "the allocated MOs.")
229 DEALLOCATE (eig_read, occ_read)
231 CALL para_env%bcast(eigenvalues)
232 CALL para_env%bcast(occupation_numbers)
235 IF (para_env%is_source())
THEN
236 READ (rst_unit) vecbuffer
238 vecbuffer(1, :) = 0.0_dp
240 CALL para_env%bcast(vecbuffer)
242 vecbuffer, 1, i, nao, 1, transpose=.true.)
245 IF (para_env%is_source())
THEN
246 DO i = nmo + 1, nmo_read
247 READ (rst_unit) vecbuffer
253 DEALLOCATE (vecbuffer)
264 IF (para_env%is_source())
THEN
268 CALL timestop(handle)
286 INTEGER,
INTENT(IN) :: xas_method, iatom, istate
288 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xas_write_restart'
290 CHARACTER(LEN=default_path_length) :: filename
291 CHARACTER(LEN=default_string_length) :: my_middle
292 INTEGER :: handle, ispin, nao, nexc_atoms, &
293 nexc_search, nmo, output_unit, &
295 REAL(
dp) :: occ_estate, xas_nelectron
296 REAL(
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation_numbers
301 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
304 CALL timeset(routinen, handle)
305 NULLIFY (mos, logger, print_key, particle_set, qs_kind_set)
308 CALL get_xas_env(xas_env=xas_env, occ_estate=occ_estate, xas_estate=xas_estate, &
309 xas_nelectron=xas_nelectron, nexc_search=nexc_search, nexc_atoms=nexc_atoms)
312 xas_section,
"PRINT%RESTART", used_print_key=print_key), &
316 "PRINT%PROGRAM_RUN_INFO", extension=
".Log")
324 extension=
".rst", file_status=
"REPLACE", file_action=
"WRITE", &
325 file_form=
"UNFORMATTED", middle_name=trim(my_middle))
328 middle_name=trim(my_middle), extension=
".rst", &
331 IF (output_unit > 0)
THEN
332 WRITE (unit=output_unit, fmt=
"(/,T10,A,I5,A,A,/)") &
333 "Xas orbitals for the absorbing atom ", iatom, &
334 " are written in ", trim(filename)
339 IF (rst_unit > 0)
THEN
340 WRITE (rst_unit) xas_method
341 WRITE (rst_unit) nexc_search, nexc_atoms, occ_estate, xas_nelectron
342 WRITE (rst_unit) xas_estate
344 DO ispin = 1,
SIZE(mos)
345 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo, &
346 eigenvalues=eigenvalues, occupation_numbers=occupation_numbers)
347 IF ((rst_unit > 0))
THEN
348 WRITE (rst_unit) nao, nmo
349 WRITE (rst_unit) eigenvalues(1:nmo), &
350 occupation_numbers(1:nmo)
361 xas_section,
"PRINT%FULL_RESTART", used_print_key=print_key), &
364 extension=
"_full.rst", file_status=
"REPLACE", file_action=
"WRITE", &
365 file_form=
"UNFORMATTED", middle_name=trim(my_middle))
367 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set)
369 qs_kind_set=qs_kind_set, ires=rst_unit)
374 CALL timestop(handle)
396 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xas_initialize_rho'
398 INTEGER :: handle, ispin, my_spin, nelectron
407 CALL timeset(routinen, handle)
409 NULLIFY (mos, rho, xas_env, para_env, rho_ao)
417 my_spin = xas_env%spin_channel
419 DO ispin = 1,
SIZE(mos)
420 IF (ispin == my_spin)
THEN
421 IF (xas_env%homo_occ == 0)
THEN
422 CALL get_mo_set(mos(ispin), nelectron=nelectron)
423 nelectron = nelectron - 1
424 CALL set_mo_set(mos(ispin), nelectron=nelectron)
432 density_matrix=rho_ao(ispin)%matrix)
438 IF (scf_env%mixing_method > 1)
THEN
439 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
440 IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
441 cpabort(
'TB Code not available')
442 ELSE IF (dft_control%qs_control%semi_empirical)
THEN
443 cpabort(
'SE Code not possible')
445 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom)
446 CALL mixing_init(scf_env%mixing_method, rho, scf_env%mixing_store, &
447 para_env, rho_atom=rho_atom)
451 CALL timestop(handle)
471 INTEGER :: i, ic_max, ir_max, m, my_spin, n, nao, &
472 nexc_search, nmo, xas_estate
473 INTEGER,
DIMENSION(:),
POINTER :: col_indices
474 REAL(
dp) :: a_max, b_max, ip_energy, occ_estate
475 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation_numbers
476 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: vecbuffer, vecbuffer2
478 TYPE(
cp_fm_type),
POINTER :: excvec_coeff, excvec_overlap, mo_coeff
480 NULLIFY (excvec_coeff, excvec_overlap, mo_coeff)
482 CALL get_xas_env(xas_env=xas_env, excvec_coeff=excvec_coeff, &
483 excvec_overlap=excvec_overlap, nexc_search=nexc_search, &
484 xas_estate=xas_estate, occ_estate=occ_estate, spin_channel=my_spin)
485 cpassert(
ASSOCIATED(excvec_overlap))
487 CALL get_mo_set(mos(my_spin), mo_coeff=mo_coeff, nao=nao, nmo=nmo, &
488 eigenvalues=eigenvalues, occupation_numbers=occupation_numbers)
489 ALLOCATE (vecbuffer(1, nao))
491 ALLOCATE (vecbuffer2(1, nexc_search))
497 CALL parallel_gemm(
"T",
"N", 1, xas_env%nexc_search, nao, 1.0_dp, excvec_coeff, &
498 fm_work, 0.0_dp, excvec_overlap, b_first_col=1)
499 CALL cp_fm_get_info(matrix=excvec_overlap, col_indices=col_indices, &
500 nrow_global=m, ncol_global=n)
502 1, nexc_search, transpose=.false.)
507 DO i = 1, nexc_search
508 a_max = abs(vecbuffer2(1, i))
509 IF (a_max > b_max)
THEN
516 IF (ic_max /= xas_estate)
THEN
519 occupation_numbers(xas_estate) = occ_estate
520 occupation_numbers(ir_max) = 1.0_dp
524 ip_energy = eigenvalues(xas_estate)
525 CALL set_xas_env(xas_env=xas_env, xas_estate=xas_estate, ip_energy=ip_energy)
528 nao, 1, transpose=.true.)
530 nao, 1, transpose=.true.)
532 DEALLOCATE (vecbuffer, vecbuffer2)
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
represent a full matrix distributed on many processors
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_write_unformatted(fm, unit)
...
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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 ...
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)
...
character(len=default_path_length) function, public cp_print_key_generate_filename(logger, print_key, middle_name, extension, my_local)
Utility function that returns a unit number to write the print key. Might open a file with a unique f...
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,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
collects routines that calculate density matrices
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, mimic, 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, matrix_vhxc, 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, xcint_weights, 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.
Define the quickstep kind type and their sub types.
subroutine, public qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
subroutine, public mixing_init(mixing_method, rho, mixing_store, para_env, rho_atom)
initialiation needed when gspace mixing is used
Definition and initialisation of the mo data type.
subroutine, public wfn_restart_file_name(filename, exist, section, logger, kp, xas, rtp)
...
subroutine, public write_mo_set_low(mo_array, qs_kind_set, particle_set, ires, rt_mos, matrix_ks)
...
Set occupation of molecular orbitals.
Definition and initialisation of the mo data type.
subroutine, public set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, uniform_occupation, kts, mu, flexible_electron_count)
Set the components of a MO set data structure.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
module that contains the definitions of the scf types
parameters that control an scf iteration
Utilities for string manipulations.
elemental subroutine, public xstring(string, ia, ib)
...
define create destroy get and put information in xas_env to calculate the x-ray absorption spectra
subroutine, public set_xas_env(xas_env, nexc_search, spin_channel, nexc_atoms, nvirtual, nvirtual2, ip_energy, occ_estate, qs_loc_env, xas_estate, xas_nelectron, homo_occ, scf_env, scf_control)
...
subroutine, public get_xas_env(xas_env, exc_state, nao, nvirtual, nvirtual2, centers_wfn, atom_of_state, exc_atoms, nexc_states, type_of_state, mykind_of_atom, mykind_of_kind, state_of_atom, spectrum, groundstate_coeff, ostrength_sm, dip_fm_set, excvec_coeff, excvec_overlap, unoccupied_orbs, unoccupied_evals, unoccupied_max_iter, unoccupied_eps, all_vectors, all_evals, my_gto_basis, qs_loc_env, stogto_overlap, occ_estate, xas_nelectron, xas_estate, nexc_atoms, nexc_search, spin_channel, scf_env, scf_control)
...
Initialize the XAS orbitals for specific core excitations Either the GS orbitals are used as initial ...
subroutine, public xas_initialize_rho(qs_env, scf_env, scf_control)
Once the mos and the occupation numbers are initialized the electronic density of the excited state c...
subroutine, public xas_read_restart(xas_env, xas_section, qs_env, xas_method, iatom, estate, istate)
Set up for reading the restart corresponding to the excitation of iatom If the corresponding restart ...
subroutine, public xas_write_restart(xas_env, xas_section, qs_env, xas_method, iatom, istate)
...
subroutine, public find_excited_core_orbital(xas_env, mos, matrix_s)
Find the index of the core orbital that has been excited by XAS.
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
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.