68#include "./base/base_uses.f90"
76 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_linres_polar_utils'
90 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_env_init'
92 INTEGER :: handle, idir, iounit, ispin, m, nao, &
104 CALL timeset(routinen, handle)
106 NULLIFY (dft_control)
107 NULLIFY (linres_control)
112 NULLIFY (lr_section, polar_section)
118 extension=
".linresLog")
121 WRITE (iounit,
"(/,(T2,A))")
"POLAR| Starting polarizability calculation", &
122 "POLAR| Initialization of the polar environment"
126 "PROPERTIES%LINRES%POLAR")
129 polar_env=polar_env, &
130 dft_control=dft_control, &
132 linres_control=linres_control, &
136 IF (.NOT.
ASSOCIATED(polar_env))
THEN
138 CALL set_qs_env(qs_env=qs_env, polar_env=polar_env)
141 nspins = dft_control%nspins
144 CALL section_vals_val_get(polar_section,
"PERIODIC_DIPOLE_OPERATOR", l_val=polar_env%do_periodic)
147 IF (.NOT.
ASSOCIATED(polar_env%polar))
THEN
148 ALLOCATE (polar_env%polar(3, 3))
149 polar_env%polar(:, :) = 0.0_dp
151 IF (.NOT.
ASSOCIATED(polar_env%dBerry_psi0))
THEN
152 ALLOCATE (polar_env%dBerry_psi0(3, nspins))
161 IF (.NOT.
ASSOCIATED(polar_env%psi1_dBerry))
THEN
162 ALLOCATE (polar_env%psi1_dBerry(3, nspins))
172 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
174 NULLIFY (tmp_fm_struct)
177 context=mo_coeff%matrix_struct%context)
179 CALL cp_fm_create(polar_env%dBerry_psi0(idir, ispin), tmp_fm_struct)
180 CALL cp_fm_create(polar_env%psi1_dBerry(idir, ispin), tmp_fm_struct)
186 "PRINT%PROGRAM_RUN_INFO")
188 CALL timestop(handle)
202 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_polar'
204 INTEGER :: handle, i, iounit, ispin, nspins, z
205 LOGICAL :: do_periodic, do_raman, run_stopped
207 REAL(
dp),
DIMENSION(:, :),
POINTER :: polar, polar_tmp
209 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0, psi1_dberry
215 CALL timeset(routinen, handle)
217 NULLIFY (cell, dft_control, polar, psi1_dberry, logger)
218 NULLIFY (mos, dberry_psi0)
224 dft_control=dft_control, &
228 nspins = dft_control%nspins
232 run_stopped=run_stopped)
234 IF (.NOT. run_stopped .AND. do_raman)
THEN
239 do_periodic=do_periodic, &
240 dberry_psi0=dberry_psi0, &
242 psi1_dberry=psi1_dberry)
245 ALLOCATE (polar_tmp(3, 3))
246 polar_tmp(:, :) = 0.0_dp
250 DO ispin = 1, dft_control%nspins
253 CALL cp_fm_trace(psi1_dberry(i, ispin), dberry_psi0(z, ispin), ptmp)
254 polar_tmp(i, z) = polar_tmp(i, z) - 2.0_dp*ptmp
259 IF (do_periodic)
THEN
260 polar(:, :) = matmul(matmul(cell%hmat, polar_tmp), transpose(cell%hmat))/(
twopi*
twopi)
262 polar(:, :) = polar_tmp(:, :)
265 IF (dft_control%nspins == 1)
THEN
266 polar(:, :) = 2.0_dp*polar(:, :)
269 IF (
ASSOCIATED(polar_tmp))
THEN
270 DEALLOCATE (polar_tmp)
275 CALL timestop(handle)
289 CHARACTER(LEN=default_string_length) :: description
290 INTEGER :: iounit, unit_p
291 LOGICAL :: do_raman, run_stopped
292 REAL(
dp),
DIMENSION(:, :),
POINTER :: polar
300 NULLIFY (logger, dft_control, para_env, results)
303 dft_control=dft_control, &
304 polar_env=polar_env, &
316 run_stopped=run_stopped)
318 IF (.NOT. run_stopped .AND. do_raman)
THEN
320 description =
"[POLAR]"
322 CALL put_results(results, description=description, values=polar(:, :))
328 extension=
".data", middle_name=
"raman", log_filename=.false.)
330 IF (unit_p /= iounit)
THEN
332 WRITE (unit_p,
'(T10,A)')
'POLARIZABILITY TENSOR (atomic units):'
333 WRITE (unit_p,
'(T10,A,3F15.5)')
"xx,yy,zz", polar(1, 1), polar(2, 2), polar(3, 3)
334 WRITE (unit_p,
'(T10,A,3F15.5)')
"xy,xz,yz", polar(1, 2), polar(1, 3), polar(2, 3)
335 WRITE (unit_p,
'(T10,A,3F15.5)')
"yx,zx,zy", polar(2, 1), polar(3, 1), polar(3, 2)
336 WRITE (unit_p,
'(T10,A)')
'POLARIZABILITY TENSOR (Angstrom^3):'
337 WRITE (unit_p,
'(T10,A,3F15.5)')
"xx,yy,zz", polar(1, 1)*
angstrom**3, &
339 WRITE (unit_p,
'(T10,A,3F15.5)')
"xy,xz,yz", polar(1, 2)*
angstrom**3, &
341 WRITE (unit_p,
'(T10,A,3F15.5)')
"yx,zx,zy", polar(2, 1)*
angstrom**3, &
344 "PRINT%POLAR_MATRIX")
349 WRITE (iounit,
'(/,T2,A)') &
350 'POLAR| Polarizability tensor [a.u.]'
351 WRITE (iounit,
'(T2,A,T24,3(1X,F18.12))') &
352 'POLAR| xx,yy,zz', polar(1, 1), polar(2, 2), polar(3, 3)
353 WRITE (iounit,
'(T2,A,T24,3(1X,F18.12))') &
354 'POLAR| xy,xz,yz', polar(1, 2), polar(1, 3), polar(2, 3)
355 WRITE (iounit,
'(T2,A,T24,3(1X,F18.12))') &
356 'POLAR| yx,zx,zy', polar(2, 1), polar(3, 1), polar(3, 2)
357 WRITE (iounit,
'(/,T2,A)') &
358 'POLAR| Polarizability tensor [ang^3]'
359 WRITE (iounit,
'(T2,A,T24,3(1X,F18.12))') &
361 WRITE (iounit,
'(T2,A,T24,3(1X,F18.12))') &
363 WRITE (iounit,
'(T2,A,T24,3(1X,F18.12))') &
367 WRITE (unit=iounit, fmt=
"(T2,A,T61,E20.12)")
' POLAR : CheckSum =', sum(polar)
385 CHARACTER(LEN=*),
PARAMETER :: routinen =
'polar_response'
387 INTEGER :: handle, idir, iounit, ispin, nao, nmo, &
389 LOGICAL :: do_periodic, do_raman, should_stop
391 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: h1_psi0, psi0_order, psi1
392 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: dberry_psi0, psi1_dberry
403 CALL timeset(routinen, handle)
405 NULLIFY (dft_control, linres_control, lr_section, polar_section)
406 NULLIFY (logger, mpools, mo_coeff, para_env)
407 NULLIFY (tmp_fm_struct, psi1_dberry, dberry_psi0)
412 "PROPERTIES%LINRES%POLAR")
415 extension=
".linresLog")
417 WRITE (unit=iounit, fmt=
"(T2,A,/)") &
418 "POLAR| Self consistent optimization of the response wavefunctions"
422 dft_control=dft_control, &
424 linres_control=linres_control, &
426 polar_env=polar_env, &
429 nspins = dft_control%nspins
431 CALL get_polar_env(polar_env=polar_env, do_raman=do_raman, do_periodic=do_periodic)
434 ALLOCATE (psi0_order(nspins))
435 ALLOCATE (psi1(nspins), h1_psi0(nspins))
437 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
438 psi0_order(ispin) = mo_coeff
440 NULLIFY (tmp_fm_struct)
443 context=mo_coeff%matrix_struct%context)
451 psi1_dberry=psi1_dberry, &
452 dberry_psi0=dberry_psi0)
459 IF (linres_control%linres_restart)
THEN
464 loop_idir:
DO idir = 1, 3
466 IF (do_periodic)
THEN
467 WRITE (iounit,
"(/,T2,A)") &
468 "POLAR| Response to the perturbation operator Berry phase_"//achar(idir + 119)
470 WRITE (iounit,
"(/,T2,A)") &
471 "POLAR| Response to the perturbation operator R_"//achar(idir + 119)
476 CALL cp_fm_to_fm(psi1_dberry(idir, ispin), psi1(ispin))
477 CALL cp_fm_to_fm(dberry_psi0(idir, ispin), h1_psi0(ispin))
480 linres_control%lr_triplet = .false.
481 linres_control%do_kernel = .true.
482 linres_control%converged = .false.
483 CALL linres_solver(p_env, qs_env, psi1, h1_psi0, psi0_order, iounit, should_stop)
487 CALL cp_fm_to_fm(psi1(ispin), psi1_dberry(idir, ispin))
491 IF (linres_control%linres_restart)
THEN
503 DEALLOCATE (psi0_order)
506 "PRINT%PROGRAM_RUN_INFO")
508 CALL timestop(handle)
528 INTEGER,
INTENT(IN) :: itimes
529 REAL(kind=
dp),
INTENT(IN) :: time
530 CHARACTER(LEN=default_string_length),
INTENT(IN), &
533 CHARACTER(LEN=default_string_length) :: my_act, my_pos
535 LOGICAL :: do_raman, new_file, run_stopped
536 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: polar
544 IF (
ASSOCIATED(qs_env))
THEN
546 CALL get_qs_env(qs_env=qs_env, polar_env=polar_env)
547 IF (
ASSOCIATED(polar_env))
THEN
551 run_stopped=run_stopped)
552 IF (.NOT. run_stopped .AND. do_raman)
THEN
557 IF (
PRESENT(pos)) my_pos = pos
558 IF (
PRESENT(act)) my_act = act
560 extension=
".polar", file_position=my_pos, &
561 file_action=my_act, file_form=
"FORMATTED", &
562 is_new_file=new_file)
568 WRITE (unit=iounit, fmt=
'(A,9(11X,A2," [a.u.]"),6X,A)') &
569 "# Step Time [fs]",
"xx",
"xy",
"xz",
"yx",
"yy",
"yz",
"zx",
"zy",
"zz"
571 WRITE (unit=iounit, fmt=
'(I8,F12.3,9(1X,F19.8))') itimes, time, &
572 polar(1, 1), polar(1, 2), polar(1, 3), &
573 polar(2, 1), polar(2, 2), polar(2, 3), &
574 polar(3, 1), polar(3, 2), polar(3, 3)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public luber2014
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Basic linear algebra operations for full matrices.
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_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_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
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,...
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...
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_results_erase(results, description, nval)
erase a part of result_list
set of type/routines to handle the storage of results in force_envs
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
Definition of physical constants:
real(kind=dp), parameter, public angstrom
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.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
localize wavefunctions linear response scf
subroutine, public linres_solver(p_env, qs_env, psi1, h1_psi0, psi0_order, iounit, should_stop, silent)
scf loop to optimize the first order wavefunctions (psi1) given a perturbation as an operator applied...
subroutine, public linres_write_restart(qs_env, linres_section, vec, ivec, tag, ind)
...
subroutine, public linres_read_restart(qs_env, linres_section, vec, ivec, tag, ind)
...
Polarizability calculation by dfpt Initialization of the polar_env, Perturbation Hamiltonian by appli...
subroutine, public write_polarisability_tensor(force_env, motion_section, itimes, time, pos, act)
Prints the polarisability tensor to a file during MD runs.
subroutine, public polar_polar(qs_env)
...
subroutine, public polar_print(qs_env)
Print information related to the polarisability tensor.
subroutine, public polar_env_init(qs_env)
Initialize the polar environment.
subroutine, public polar_response(p_env, qs_env)
Calculate the polarisability tensor using response theory.
Type definitiona for linear response calculations.
subroutine, public set_polar_env(polar_env, do_raman, do_periodic, dberry_psi0, polar, psi1_dberry, run_stopped)
...
subroutine, public get_polar_env(polar_env, do_raman, do_periodic, dberry_psi0, polar, psi1_dberry, run_stopped)
...
wrapper for the pools of matrixes
Definition and initialisation of the mo data type.
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, cmo_coeff)
Get the components of a MO set data structure.
basis types for the calculation of the perturbation of density theory.
Type defining parameters related to the simulation cell.
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...
contains arbitrary information which need to be stored
wrapper to abstract the force evaluation of the various methods
stores all the informations relevant to an mpi environment
General settings for linear response calculations.
container for the pools of matrixes used by qs
Represent a qs system that is perturbed. Can calculate the linear operator and the rhs of the system ...