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) &
187 cpabort(
"READ XAS RESTART: restart with different XAS method is not possible.")
188 IF (nexc_atoms_read /= nexc_atoms) &
189 CALL cp_abort(__location__, &
190 "READ XAS RESTART: restart with different excited atoms "// &
191 "is not possible. Start instead a new XAS run with the new set of atoms.")
194 CALL para_env%bcast(xas_estate_read)
195 CALL set_xas_env(xas_env=xas_env, xas_estate=xas_estate_read)
196 estate = xas_estate_read
199 ALLOCATE (vecbuffer(1, nao))
201 DO ispin = 1,
SIZE(mos)
202 CALL get_mo_set(mo_set=mos(ispin), nmo=nmo, eigenvalues=eigenvalues, &
203 occupation_numbers=occupation_numbers, mo_coeff=mo_coeff, nelectron=nelectron)
205 occupation_numbers = 0.0_dp
207 IF (para_env%is_source())
THEN
208 READ (rst_unit) nao_read, nmo_read
209 IF (nao /= nao_read) &
210 cpabort(
"To change basis is not possible. ")
211 ALLOCATE (eig_read(nmo_read), occ_read(nmo_read))
214 nmo = min(nmo, nmo_read)
215 READ (rst_unit) eig_read(1:nmo_read), occ_read(1:nmo_read)
216 eigenvalues(1:nmo) = eig_read(1:nmo)
217 occupation_numbers(1:nmo) = occ_read(1:nmo)
218 IF (nmo_read > nmo)
THEN
219 IF (occupation_numbers(nmo) >= epsilon(0.0_dp)) &
220 CALL cp_warn(__location__, &
221 "The number of occupied MOs on the restart unit is larger than "// &
222 "the allocated MOs.")
225 DEALLOCATE (eig_read, occ_read)
227 CALL para_env%bcast(eigenvalues)
228 CALL para_env%bcast(occupation_numbers)
231 IF (para_env%is_source())
THEN
232 READ (rst_unit) vecbuffer
234 vecbuffer(1, :) = 0.0_dp
236 CALL para_env%bcast(vecbuffer)
238 vecbuffer, 1, i, nao, 1, transpose=.true.)
241 IF (para_env%is_source())
THEN
242 DO i = nmo + 1, nmo_read
243 READ (rst_unit) vecbuffer
249 DEALLOCATE (vecbuffer)
260 IF (para_env%is_source())
THEN
264 CALL timestop(handle)
282 INTEGER,
INTENT(IN) :: xas_method, iatom, istate
284 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xas_write_restart'
286 CHARACTER(LEN=default_path_length) :: filename
287 CHARACTER(LEN=default_string_length) :: my_middle
288 INTEGER :: handle, ispin, nao, nexc_atoms, &
289 nexc_search, nmo, output_unit, &
291 REAL(
dp) :: occ_estate, xas_nelectron
292 REAL(
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation_numbers
297 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
300 CALL timeset(routinen, handle)
301 NULLIFY (mos, logger, print_key, particle_set, qs_kind_set)
304 CALL get_xas_env(xas_env=xas_env, occ_estate=occ_estate, xas_estate=xas_estate, &
305 xas_nelectron=xas_nelectron, nexc_search=nexc_search, nexc_atoms=nexc_atoms)
308 xas_section,
"PRINT%RESTART", used_print_key=print_key), &
312 "PRINT%PROGRAM_RUN_INFO", extension=
".Log")
320 extension=
".rst", file_status=
"REPLACE", file_action=
"WRITE", &
321 file_form=
"UNFORMATTED", middle_name=trim(my_middle))
324 middle_name=trim(my_middle), extension=
".rst", &
327 IF (output_unit > 0)
THEN
328 WRITE (unit=output_unit, fmt=
"(/,T10,A,I5,A,A,/)") &
329 "Xas orbitals for the absorbing atom ", iatom, &
330 " are written in ", trim(filename)
335 IF (rst_unit > 0)
THEN
336 WRITE (rst_unit) xas_method
337 WRITE (rst_unit) nexc_search, nexc_atoms, occ_estate, xas_nelectron
338 WRITE (rst_unit) xas_estate
340 DO ispin = 1,
SIZE(mos)
341 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo, &
342 eigenvalues=eigenvalues, occupation_numbers=occupation_numbers)
343 IF ((rst_unit > 0))
THEN
344 WRITE (rst_unit) nao, nmo
345 WRITE (rst_unit) eigenvalues(1:nmo), &
346 occupation_numbers(1:nmo)
357 xas_section,
"PRINT%FULL_RESTART", used_print_key=print_key), &
360 extension=
"_full.rst", file_status=
"REPLACE", file_action=
"WRITE", &
361 file_form=
"UNFORMATTED", middle_name=trim(my_middle))
363 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set)
365 qs_kind_set=qs_kind_set, ires=rst_unit)
370 CALL timestop(handle)
392 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xas_initialize_rho'
394 INTEGER :: handle, ispin, my_spin, nelectron
403 CALL timeset(routinen, handle)
405 NULLIFY (mos, rho, xas_env, para_env, rho_ao)
413 my_spin = xas_env%spin_channel
415 DO ispin = 1,
SIZE(mos)
416 IF (ispin == my_spin)
THEN
417 IF (xas_env%homo_occ == 0)
THEN
418 CALL get_mo_set(mos(ispin), nelectron=nelectron)
419 nelectron = nelectron - 1
420 CALL set_mo_set(mos(ispin), nelectron=nelectron)
428 density_matrix=rho_ao(ispin)%matrix)
434 IF (scf_env%mixing_method > 1)
THEN
435 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
436 IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
437 cpabort(
'TB Code not available')
438 ELSE IF (dft_control%qs_control%semi_empirical)
THEN
439 cpabort(
'SE Code not possible')
441 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom)
442 CALL mixing_init(scf_env%mixing_method, rho, scf_env%mixing_store, &
443 para_env, rho_atom=rho_atom)
447 CALL timestop(handle)
467 INTEGER :: i, ic_max, ir_max, m, my_spin, n, nao, &
468 nexc_search, nmo, xas_estate
469 INTEGER,
DIMENSION(:),
POINTER :: col_indices
470 REAL(
dp) :: a_max, b_max, ip_energy, occ_estate
471 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation_numbers
472 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: vecbuffer, vecbuffer2
474 TYPE(
cp_fm_type),
POINTER :: excvec_coeff, excvec_overlap, mo_coeff
476 NULLIFY (excvec_coeff, excvec_overlap, mo_coeff)
478 CALL get_xas_env(xas_env=xas_env, excvec_coeff=excvec_coeff, &
479 excvec_overlap=excvec_overlap, nexc_search=nexc_search, &
480 xas_estate=xas_estate, occ_estate=occ_estate, spin_channel=my_spin)
481 cpassert(
ASSOCIATED(excvec_overlap))
483 CALL get_mo_set(mos(my_spin), mo_coeff=mo_coeff, nao=nao, nmo=nmo, &
484 eigenvalues=eigenvalues, occupation_numbers=occupation_numbers)
485 ALLOCATE (vecbuffer(1, nao))
487 ALLOCATE (vecbuffer2(1, nexc_search))
493 CALL parallel_gemm(
"T",
"N", 1, xas_env%nexc_search, nao, 1.0_dp, excvec_coeff, &
494 fm_work, 0.0_dp, excvec_overlap, b_first_col=1)
495 CALL cp_fm_get_info(matrix=excvec_overlap, col_indices=col_indices, &
496 nrow_global=m, ncol_global=n)
498 1, nexc_search, transpose=.false.)
503 DO i = 1, nexc_search
504 a_max = abs(vecbuffer2(1, i))
505 IF (a_max > b_max)
THEN
512 IF (ic_max /= xas_estate)
THEN
515 occupation_numbers(xas_estate) = occ_estate
516 occupation_numbers(ir_max) = 1.0_dp
520 ip_energy = eigenvalues(xas_estate)
521 CALL set_xas_env(xas_env=xas_env, xas_estate=xas_estate, ip_energy=ip_energy)
524 nao, 1, transpose=.true.)
526 nao, 1, transpose=.true.)
528 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_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,...
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
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)
...
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.