(git:b195825)
xas_restart.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 ! **************************************************************************************************
9 !> \brief Initialize the XAS orbitals for specific core excitations
10 !> Either the GS orbitals are used as initial guess, or the
11 !> xas mos are read from a previous calculation.
12 !> In the latter case, the core-hole potetial should be the same.
13 !> \note
14 !> The restart with the same core-hole potential should be checked
15 !> and a wrong restart should stop the program
16 !> \par History
17 !> created 09.2006
18 !> \author MI (09.2006)
19 ! **************************************************************************************************
21 
22  USE cp_control_types, ONLY: dft_control_type
24  USE cp_files, ONLY: close_file,&
25  open_file
26  USE cp_fm_types, ONLY: cp_fm_create,&
29  cp_fm_release,&
32  cp_fm_type,&
35  cp_logger_type,&
36  cp_to_string
37  USE cp_output_handling, ONLY: cp_p_file,&
42  USE dbcsr_api, ONLY: dbcsr_p_type
43  USE input_section_types, ONLY: section_vals_type
44  USE kinds, ONLY: default_path_length,&
46  dp
47  USE message_passing, ONLY: mp_para_env_type
48  USE parallel_gemm_api, ONLY: parallel_gemm
49  USE particle_types, ONLY: particle_type
50  USE qs_density_matrices, ONLY: calculate_density_matrix
51  USE qs_environment_types, ONLY: get_qs_env,&
52  qs_environment_type
53  USE qs_kind_types, ONLY: qs_kind_type
54  USE qs_ks_types, ONLY: qs_ks_did_change
55  USE qs_mixing_utils, ONLY: mixing_init
56  USE qs_mo_io, ONLY: wfn_restart_file_name,&
58  USE qs_mo_occupation, ONLY: set_mo_occupation
59  USE qs_mo_types, ONLY: get_mo_set,&
60  mo_set_type,&
62  USE qs_rho_atom_types, ONLY: rho_atom_type
64  USE qs_rho_types, ONLY: qs_rho_get,&
65  qs_rho_type
66  USE qs_scf_types, ONLY: qs_scf_env_type
67  USE scf_control_types, ONLY: scf_control_type
68  USE string_utilities, ONLY: xstring
69  USE xas_env_types, ONLY: get_xas_env,&
70  set_xas_env,&
71  xas_environment_type
72 #include "./base/base_uses.f90"
73 
74  IMPLICIT NONE
75  PRIVATE
76 
77  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xas_restart'
78 
79 ! *** Public subroutines ***
80 
82 
83 CONTAINS
84 
85 ! **************************************************************************************************
86 !> \brief Set up for reading the restart
87 !> corresponding to the excitation of iatom
88 !> If the corresponding restart file does not exist
89 !> the GS orbitals are used as initial guess
90 !> \param xas_env ...
91 !> \param xas_section input section for XAS calculations
92 !> qs_env:
93 !> \param qs_env ...
94 !> \param xas_method ...
95 !> \param iatom index of the absorbing atom
96 !> \param estate index of the core-hole orbital
97 !> \param istate counter of excited states per atom
98 !> error:
99 !> \par History
100 !> 09.2006 created [MI]
101 !> \author MI
102 ! **************************************************************************************************
103  SUBROUTINE xas_read_restart(xas_env, xas_section, qs_env, xas_method, iatom, estate, istate)
104 
105  TYPE(xas_environment_type), POINTER :: xas_env
106  TYPE(section_vals_type), POINTER :: xas_section
107  TYPE(qs_environment_type), POINTER :: qs_env
108  INTEGER, INTENT(IN) :: xas_method, iatom
109  INTEGER, INTENT(OUT) :: estate
110  INTEGER, INTENT(IN) :: istate
111 
112  CHARACTER(LEN=*), PARAMETER :: routinen = 'xas_read_restart'
113 
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
118  LOGICAL :: file_exists
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
124  TYPE(cp_fm_type), POINTER :: mo_coeff
125  TYPE(cp_logger_type), POINTER :: logger
126  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
127  TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
128  TYPE(mp_para_env_type), POINTER :: para_env
129 
130  CALL timeset(routinen, handle)
131 
132  file_exists = .false.
133  rst_unit = -1
134 
135  NULLIFY (eigenvalues, matrix_s, mos, occupation_numbers, vecbuffer)
136  NULLIFY (logger)
137  logger => cp_get_default_logger()
138 
139  output_unit = cp_print_key_unit_nr(logger, xas_section, &
140  "PRINT%PROGRAM_RUN_INFO", extension=".Log")
141 
142  CALL get_qs_env(qs_env=qs_env, para_env=para_env)
143 
144  IF (para_env%is_source()) THEN
145  CALL wfn_restart_file_name(filename, file_exists, xas_section, logger, &
146  xas=.true.)
147 
148  CALL xstring(filename, ia, ie)
149  filename = filename(ia:ie)//'-at'//trim(adjustl(cp_to_string(iatom)))// &
150  '_st'//trim(adjustl(cp_to_string(istate)))//'.rst'
151 
152  INQUIRE (file=filename, exist=file_exists)
153  ! open file
154  IF (file_exists) THEN
155 
156  CALL open_file(file_name=trim(filename), &
157  file_action="READ", &
158  file_form="UNFORMATTED", &
159  file_position="REWIND", &
160  file_status="OLD", &
161  unit_number=rst_unit)
162 
163  IF (output_unit > 0) WRITE (unit=output_unit, fmt="(/,T20,A,I5,/)") &
164  "Read restart file for atom ", iatom
165 
166  ELSE IF (.NOT. file_exists) THEN
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"
170  END IF
171  END IF
172  CALL para_env%bcast(file_exists)
173 
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)
177 
178  IF (file_exists) THEN
179  CALL get_qs_env(qs_env=qs_env, mos=mos, matrix_s=matrix_s)
180 
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
185 
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.")
192  END IF
193 
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
197 
198  CALL get_mo_set(mo_set=mos(my_spin), nao=nao)
199  ALLOCATE (vecbuffer(1, nao))
200 
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)
204  eigenvalues = 0.0_dp
205  occupation_numbers = 0.0_dp
206  CALL cp_fm_set_all(mo_coeff, 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))
212  eig_read = 0.0_dp
213  occ_read = 0.0_dp
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.")
223 
224  END IF
225  DEALLOCATE (eig_read, occ_read)
226  END IF
227  CALL para_env%bcast(eigenvalues)
228  CALL para_env%bcast(occupation_numbers)
229 
230  DO i = 1, nmo
231  IF (para_env%is_source()) THEN
232  READ (rst_unit) vecbuffer
233  ELSE
234  vecbuffer(1, :) = 0.0_dp
235  END IF
236  CALL para_env%bcast(vecbuffer)
237  CALL cp_fm_set_submatrix(mo_coeff, &
238  vecbuffer, 1, i, nao, 1, transpose=.true.)
239  END DO
240  ! Skip extra MOs if there any
241  IF (para_env%is_source()) THEN
242  DO i = nmo + 1, nmo_read
243  READ (rst_unit) vecbuffer
244  END DO
245  END IF
246 
247  END DO ! ispin
248 
249  DEALLOCATE (vecbuffer)
250 
251 ! nspin = SIZE(mos,1)
252 ! DO ispin = 1,nspin
253 ! ! ortho so that one can restart for different positions (basis sets?)
254 ! NULLIFY(mo_coeff)
255 ! CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff,homo=homo)
256 ! CALL make_basis_sm(mo_coeff,homo,matrix_s(1)%matrix)
257 ! END DO
258  END IF !file_exist
259 
260  IF (para_env%is_source()) THEN
261  IF (file_exists) CALL close_file(unit_number=rst_unit)
262  END IF
263 
264  CALL timestop(handle)
265 
266  END SUBROUTINE xas_read_restart
267 
268 ! **************************************************************************************************
269 !> \brief ...
270 !> \param xas_env ...
271 !> \param xas_section ...
272 !> \param qs_env ...
273 !> \param xas_method ...
274 !> \param iatom ...
275 !> \param istate ...
276 ! **************************************************************************************************
277  SUBROUTINE xas_write_restart(xas_env, xas_section, qs_env, xas_method, iatom, istate)
278 
279  TYPE(xas_environment_type), POINTER :: xas_env
280  TYPE(section_vals_type), POINTER :: xas_section
281  TYPE(qs_environment_type), POINTER :: qs_env
282  INTEGER, INTENT(IN) :: xas_method, iatom, istate
283 
284  CHARACTER(LEN=*), PARAMETER :: routinen = 'xas_write_restart'
285 
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, &
290  rst_unit, xas_estate
291  REAL(dp) :: occ_estate, xas_nelectron
292  REAL(dp), DIMENSION(:), POINTER :: eigenvalues, occupation_numbers
293  TYPE(cp_fm_type), POINTER :: mo_coeff
294  TYPE(cp_logger_type), POINTER :: logger
295  TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
296  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
297  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
298  TYPE(section_vals_type), POINTER :: print_key
299 
300  CALL timeset(routinen, handle)
301  NULLIFY (mos, logger, print_key, particle_set, qs_kind_set)
302  logger => cp_get_default_logger()
303 
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)
306 
307  IF (btest(cp_print_key_should_output(logger%iter_info, &
308  xas_section, "PRINT%RESTART", used_print_key=print_key), &
309  cp_p_file)) THEN
310 
311  output_unit = cp_print_key_unit_nr(logger, xas_section, &
312  "PRINT%PROGRAM_RUN_INFO", extension=".Log")
313 
314  CALL get_qs_env(qs_env=qs_env, mos=mos)
315 
316  ! Open file
317  rst_unit = -1
318  my_middle = 'at'//trim(adjustl(cp_to_string(iatom)))//'_st'//trim(adjustl(cp_to_string(istate)))
319  rst_unit = cp_print_key_unit_nr(logger, xas_section, "PRINT%RESTART", &
320  extension=".rst", file_status="REPLACE", file_action="WRITE", &
321  file_form="UNFORMATTED", middle_name=trim(my_middle))
322 
323  filename = cp_print_key_generate_filename(logger, print_key, &
324  middle_name=trim(my_middle), extension=".rst", &
325  my_local=.false.)
326 
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)
331 
332  END IF
333 
334  ! Write mos
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
339  END IF
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)
347  END IF
348  CALL cp_fm_write_unformatted(mo_coeff, rst_unit)
349  END DO
350 
351 ! Close file
352  CALL cp_print_key_finished_output(rst_unit, logger, xas_section, &
353  "PRINT%RESTART")
354  END IF
355 
356  IF (btest(cp_print_key_should_output(logger%iter_info, &
357  xas_section, "PRINT%FULL_RESTART", used_print_key=print_key), &
358  cp_p_file)) THEN
359  rst_unit = cp_print_key_unit_nr(logger, xas_section, "PRINT%FULL_RESTART", &
360  extension="_full.rst", file_status="REPLACE", file_action="WRITE", &
361  file_form="UNFORMATTED", middle_name=trim(my_middle))
362 
363  CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set)
364  CALL write_mo_set_low(mos, particle_set=particle_set, &
365  qs_kind_set=qs_kind_set, ires=rst_unit)
366  CALL cp_print_key_finished_output(rst_unit, logger, xas_section, "PRINT%FULL_RESTART")
367 
368  END IF
369 
370  CALL timestop(handle)
371 
372  END SUBROUTINE xas_write_restart
373 
374 !****f* xas_restart/xas_initialize_rho [1.0] *
375 
376 ! **************************************************************************************************
377 !> \brief Once the mos and the occupation numbers are initialized
378 !> the electronic density of the excited state can be calclated
379 !> \param qs_env ...
380 !> \param scf_env ...
381 !> \param scf_control ...
382 !> \par History
383 !> 09-2006 MI created
384 !> \author MI
385 ! **************************************************************************************************
386  SUBROUTINE xas_initialize_rho(qs_env, scf_env, scf_control)
387 
388  TYPE(qs_environment_type), POINTER :: qs_env
389  TYPE(qs_scf_env_type), POINTER :: scf_env
390  TYPE(scf_control_type), POINTER :: scf_control
391 
392  CHARACTER(LEN=*), PARAMETER :: routinen = 'xas_initialize_rho'
393 
394  INTEGER :: handle, ispin, my_spin, nelectron
395  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
396  TYPE(dft_control_type), POINTER :: dft_control
397  TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
398  TYPE(mp_para_env_type), POINTER :: para_env
399  TYPE(qs_rho_type), POINTER :: rho
400  TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom
401  TYPE(xas_environment_type), POINTER :: xas_env
402 
403  CALL timeset(routinen, handle)
404 
405  NULLIFY (mos, rho, xas_env, para_env, rho_ao)
406 
407  CALL get_qs_env(qs_env, &
408  mos=mos, &
409  rho=rho, &
410  xas_env=xas_env, &
411  para_env=para_env)
412 
413  my_spin = xas_env%spin_channel
414  CALL qs_rho_get(rho, rho_ao=rho_ao)
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)
421  END IF
422  CALL set_mo_occupation(mo_set=qs_env%mos(ispin), smear=scf_control%smear, &
423  xas_env=xas_env)
424  ELSE
425  CALL set_mo_occupation(mo_set=qs_env%mos(ispin), smear=scf_control%smear)
426  END IF
427  CALL calculate_density_matrix(mo_set=mos(ispin), &
428  density_matrix=rho_ao(ispin)%matrix)
429  END DO
430 
431  CALL qs_rho_update_rho(rho, qs_env=qs_env)
432  CALL qs_ks_did_change(qs_env%ks_env, rho_changed=.true.)
433 
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')
440  ELSE
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)
444  END IF
445  END IF
446 
447  CALL timestop(handle)
448 
449  END SUBROUTINE xas_initialize_rho
450 
451 ! **************************************************************************************************
452 !> \brief Find the index of the core orbital that has been excited by XAS
453 !> \param xas_env ...
454 !> \param mos ...
455 !> \param matrix_s ...
456 !> \par History
457 !> 03-2010 MI created
458 !> \author MI
459 ! **************************************************************************************************
460 
461  SUBROUTINE find_excited_core_orbital(xas_env, mos, matrix_s)
462 
463  TYPE(xas_environment_type), POINTER :: xas_env
464  TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
465  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
466 
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
473  TYPE(cp_fm_type) :: fm_work
474  TYPE(cp_fm_type), POINTER :: excvec_coeff, excvec_overlap, mo_coeff
475 
476  NULLIFY (excvec_coeff, excvec_overlap, mo_coeff)
477  ! Some elements from the xas_env
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))
482 
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))
486  vecbuffer = 0.0_dp
487  ALLOCATE (vecbuffer2(1, nexc_search))
488  vecbuffer2 = 0.0_dp
489 
490  ! ** use the maximum overlap criterion to find the index of the excited orbital
491  CALL cp_fm_create(fm_work, mo_coeff%matrix_struct)
492  CALL cp_dbcsr_sm_fm_multiply(matrix_s(1)%matrix, mo_coeff, fm_work, ncol=nmo)
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)
497  CALL cp_fm_get_submatrix(excvec_overlap, vecbuffer2, 1, 1, &
498  1, nexc_search, transpose=.false.)
499  CALL cp_fm_release(fm_work)
500 
501  b_max = 0.0_dp
502  ic_max = xas_estate
503  DO i = 1, nexc_search
504  a_max = abs(vecbuffer2(1, i))
505  IF (a_max > b_max) THEN
506  ic_max = i
507 
508  b_max = a_max
509  END IF
510  END DO
511 
512  IF (ic_max /= xas_estate) THEN
513  ir_max = xas_estate
514  xas_estate = ic_max
515  occupation_numbers(xas_estate) = occ_estate
516  occupation_numbers(ir_max) = 1.0_dp
517  END IF
518 
519  ! Ionization Potential
520  ip_energy = eigenvalues(xas_estate)
521  CALL set_xas_env(xas_env=xas_env, xas_estate=xas_estate, ip_energy=ip_energy)
522 
523  CALL cp_fm_get_submatrix(mo_coeff, vecbuffer, 1, xas_estate, &
524  nao, 1, transpose=.true.)
525  CALL cp_fm_set_submatrix(excvec_coeff, vecbuffer, 1, 1, &
526  nao, 1, transpose=.true.)
527 
528  DEALLOCATE (vecbuffer, vecbuffer2)
529 
530  END SUBROUTINE find_excited_core_orbital
531 
532 END MODULE xas_restart
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.
Definition: cp_files.F:16
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.
Definition: cp_files.F:308
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.
Definition: cp_files.F:119
represent a full matrix distributed on many processors
Definition: cp_fm_types.F:15
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
Definition: cp_fm_types.F:1016
subroutine, public cp_fm_write_unformatted(fm, unit)
...
Definition: cp_fm_types.F:2147
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...
Definition: cp_fm_types.F:768
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
Definition: cp_fm_types.F:535
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,...
Definition: cp_fm_types.F:901
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Definition: cp_fm_types.F:167
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...
objects that represent the structure of input sections and the data contained in an input section
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
integer, parameter, public default_string_length
Definition: kinds.F:57
integer, parameter, public default_path_length
Definition: kinds.F:58
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_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, 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, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Definition: qs_kind_types.F:23
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...
Definition: qs_ks_types.F:919
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.
Definition: qs_mo_io.F:21
subroutine, public wfn_restart_file_name(filename, exist, section, logger, kp, xas, rtp)
...
Definition: qs_mo_io.F:428
subroutine, public write_mo_set_low(mo_array, qs_kind_set, particle_set, ires, rt_mos)
...
Definition: qs_mo_io.F:285
Set occupation of molecular orbitals.
Definition and initialisation of the mo data type.
Definition: qs_mo_types.F:22
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.
Definition: qs_mo_types.F:452
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.
Definition: qs_mo_types.F:397
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...
Definition: qs_rho_types.F:18
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...
Definition: qs_rho_types.F:229
module that contains the definitions of the scf types
Definition: qs_scf_types.F:14
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
Definition: xas_env_types.F:15
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 ...
Definition: xas_restart.F:20
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...
Definition: xas_restart.F:387
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 ...
Definition: xas_restart.F:104
subroutine, public xas_write_restart(xas_env, xas_section, qs_env, xas_method, iatom, istate)
...
Definition: xas_restart.F:278
subroutine, public find_excited_core_orbital(xas_env, mos, matrix_s)
Find the index of the core orbital that has been excited by XAS.
Definition: xas_restart.F:462