33 USE ieee_arithmetic,
ONLY: ieee_is_finite
62#include "./base/base_uses.f90"
68 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_kubo_transport'
82 SUBROUTINE setup_projected_transport(qs_env, spin, do_soc, energies, current)
83 TYPE(qs_environment_type),
POINTER :: qs_env
84 INTEGER,
INTENT(IN) :: spin
85 LOGICAL,
INTENT(IN) :: do_soc
86 REAL(dp),
INTENT(OUT) :: energies(:)
87 COMPLEX(dp),
INTENT(OUT) :: current(:, :, :)
89 COMPLEX(dp),
ALLOCATABLE :: component(:, :), hd(:, :), sd(:, :), &
91 INTEGER :: axis, n, status
92 TYPE(dbcsr_p_type),
POINTER :: h(:), positions(:), s(:), soc(:, :)
93 TYPE(localizer_matrix_type) :: metric, operators(4)
94 TYPE(mp_para_env_type),
POINTER :: para_env
96 NULLIFY (positions, soc)
97 CALL get_qs_env(qs_env, matrix_ks=h, matrix_s=s, para_env=para_env)
108 ALLOCATE (xd(n, n, 3))
111 xd(:, :, axis) = component
112 DEALLOCATE (component)
115 IF (para_env%is_source())
CALL projected_current(hd, sd, xd, energies, current, status)
116 CALL para_env%bcast(status, para_env%source)
117 IF (status /= 0)
THEN
118 cpabort(
"Kubo projected AO matrices or eigensystem invalid.")
120 CALL para_env%bcast(energies, para_env%source)
121 CALL para_env%bcast(current, para_env%source)
128 END SUBROUTINE setup_projected_transport
137 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_kubo_transport'
139 CHARACTER(LEN=32) :: density_unit, measure_unit, method, &
140 periodic_label, sigma_iso_unit, &
142 CHARACTER(LEN=512) ::
header
143 COMPLEX(KIND=dp),
ALLOCATABLE, &
144 DIMENSION(:, :, :, :) :: dhh
145 INTEGER :: axis, current_operator, hall_status, handle, imu, ispin, max_ao, max_memory_mb, &
146 nao, natom, nelectron_total, neutral_grid, nk, nmu, nperiodic, nspins, nstate, &
147 output_unit, symmetry_backend, transport_ndim
148 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ao_atom
149 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
150 INTEGER,
POINTER :: grid(:)
151 LOGICAL :: allow_mo_reuse, do_hall, do_kpoints, &
152 do_soc, kubo_active, &
153 neutral_mu_explicit, ot_active, &
155 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: reused_mos
156 REAL(
dp),
ALLOCATABLE :: scalar_current(:, :, :)
157 REAL(kind=
dp) :: density_factor, dissipation, emax, emin, eps_operators, eps_symmetry, &
158 iso_factor, measure, measure_m, mu, mu0, mu_step, ne, nh, sigma_iso, temperature, &
160 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: maxocc
161 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: eig, s_dense
162 REAL(kind=
dp),
DIMENSION(3, 3) :: hall, hall_part, projection, sigma, &
164 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energy_range
168 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
175 CALL timeset(routinen, handle)
177 NULLIFY (blacs_env, cell, energy_range, input_section, kubo_section, logger, matrix_ks, matrix_s, &
178 mos, ot_section, para_env, particle_set, row_blk_sizes)
183 IF (.NOT. kubo_active)
THEN
184 CALL timestop(handle)
191 SELECT CASE (trim(method))
192 CASE (
"DIAGONALIZATION")
193 CASE (
"TD",
"CHEBYSHEV")
194 cpabort(
"KUBO_TRANSPORT METHOD "//trim(method)//
" is reserved but not implemented yet.")
196 cpabort(
"Unknown KUBO_TRANSPORT METHOD: "//trim(method))
200 allow_mo_reuse = .NOT. ot_active
205 IF (do_hall .AND. current_operator == 0)
THEN
206 cpabort(
"Kubo HALL_RESPONSE requires CURRENT_OPERATOR PROJECTED_AO or BLOCH.")
209 IF (property_symmetry .AND. current_operator /= 2)
THEN
210 cpabort(
'Kubo property SYMMETRY requires BLOCH.')
212 CALL get_qs_env(qs_env, do_kpoints=do_kpoints, cell=cell)
213 IF (do_kpoints .AND. current_operator /= 2)
THEN
214 cpabort(
"Kubo explicit k-points require CURRENT_OPERATOR BLOCH.")
216 IF (do_soc .AND. current_operator == 0)
THEN
217 cpabort(
"Kubo SOC requires CURRENT_OPERATOR PROJECTED_AO or BLOCH.")
219 IF (current_operator == 1 .AND. any(cell%perd /= 0))
THEN
220 cpabort(
"Kubo PROJECTED_AO requires PERIODIC NONE.")
222 CALL get_qs_env(qs_env, blacs_env=blacs_env, cell=cell, mos=mos, natom=natom, &
223 nelectron_total=nelectron_total, para_env=para_env, particle_set=particle_set)
225 matrix_ks => images(:, 1)
227 matrix_s => images(:, 1)
228 cpassert(
ASSOCIATED(matrix_s))
229 cpassert(
ASSOCIATED(matrix_ks))
230 cpassert(
ASSOCIATED(cell))
231 cpassert(
ASSOCIATED(particle_set))
241 IF (temperature <= 0.0_dp) cpabort(
"KUBO_TRANSPORT TEMPERATURE must be positive.")
242 IF (dissipation <= 0.0_dp) cpabort(
"KUBO_TRANSPORT DISSIPATION must be positive.")
243 IF (nmu < 1) cpabort(
"KUBO_TRANSPORT N_MU must be at least one.")
244 IF (neutral_grid < 10) cpabort(
"KUBO_TRANSPORT NEUTRAL_GRID must be at least ten.")
246 nspins =
SIZE(matrix_ks)
247 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao, row_blk_size=row_blk_sizes)
249 IF (current_operator /= 0)
THEN
251 IF (max_ao < 1 .OR. nao > max_ao) cpabort(
"Kubo AO current exceeds MAX_AO.")
252 IF (.NOT. qs_env%scf_convergence_available .OR. .NOT. qs_env%scf_converged)
THEN
253 cpabort(
"Kubo AO current requires a converged SCF.")
257 IF (nspins /= 1) cpabort(
"Kubo SOC requires a restricted SCF.")
260 CALL build_ao_atom_map(row_blk_sizes, natom, ao_atom)
261 IF (current_operator == 0)
CALL dbcsr_to_dense(matrix_s(1)%matrix, blacs_env, para_env, s_dense)
262 CALL setup_transport_geometry(cell, transport_ndim, nperiodic, periodic_label, projection, &
263 measure, measure_unit)
264 CALL transport_unit_labels(transport_ndim, density_unit, sigma_iso_unit, sigma_tensor_unit)
266 IF (current_operator == 2)
THEN
273 IF (.NOT. ieee_is_finite(eps_symmetry) .OR. eps_symmetry <= 0.0_dp .OR. eps_symmetry >= 1.0_dp)
THEN
274 cpabort(
'Invalid Kubo EPS_SYMMETRY.')
276 IF (.NOT. ieee_is_finite(eps_operators) .OR. eps_operators <= 0.0_dp .OR. eps_operators >= 1.0_dp)
THEN
277 cpabort(
'Invalid Kubo EPS_SYMMETRY_OPERATORS.')
279 IF (count(cell%perd /= 0) == 0) cpabort(
"Kubo BLOCH requires a periodic cell.")
280 IF (any(grid < 1) .OR. any(grid /= 1 .AND. cell%perd == 0)) cpabort(
"Invalid Kubo MP_GRID.")
283 IF (grid(axis) > 1000000/nk) cpabort(
"Kubo MP_GRID exceeds one million points.")
287 property_symmetry, symmetry_backend, eps_symmetry, eps_operators)
288 ALLOCATE (reused_mos(
SIZE(eig, 2)), source=.false.)
290 ALLOCATE (eig(nstate, nspins), dhh(nstate, nstate, 3, nspins), maxocc(nspins), reused_mos(nspins))
292 maxocc(ispin) = mos(ispin)%maxocc
293 IF (do_soc) maxocc(ispin) = 1.0_dp
294 IF (current_operator == 1)
THEN
295 CALL setup_projected_transport(qs_env, ispin, do_soc, eig(:, ispin), dhh(:, :, :, ispin))
296 reused_mos(ispin) = .false.
298 ALLOCATE (scalar_current(nao, nao, 3))
299 CALL setup_spin_transport(matrix_ks(ispin)%matrix, s_dense, blacs_env, para_env, &
300 particle_set, cell, projection, ao_atom, mos(ispin), allow_mo_reuse, &
301 eig(:, ispin), scalar_current, reused_mos(ispin))
302 dhh(:, :, :, ispin) = cmplx(scalar_current, 0.0_dp,
dp)
303 DEALLOCATE (scalar_current)
310 IF (.NOT. neutral_mu_explicit)
THEN
311 CALL find_neutral_mu(eig, maxocc, temperature, real(nelectron_total, kind=
dp), neutral_grid, &
315 IF (energy_range(1) < energy_range(2))
THEN
316 emin = energy_range(1)
317 emax = energy_range(2)
320 measure_m = measure*
a_bohr**transport_ndim
321 density_factor = 1.0_dp/measure_m
322 CALL transport_output_factors(transport_ndim, iso_factor, tensor_factor)
327 IF (output_unit > 0)
THEN
328 WRITE (output_unit,
'(/,T2,A)')
"Kubo-Greenwood finite-volume transport"
329 WRITE (output_unit,
'(T3,A,T38,A)')
"Method:", trim(method)
330 IF (current_operator == 1)
THEN
331 WRITE (output_unit,
'(T3,A)')
"Current: metric-aware projected AO commutator, not continuum velocity."
332 WRITE (output_unit,
'(T3,A,L1)')
"GTH SOC in the complete AO spinor space: ", do_soc
333 ELSE IF (current_operator == 2)
THEN
334 WRITE (output_unit,
'(T3,A)')
"Current: Bloch H/S derivatives and analytic AO connection."
335 WRITE (output_unit,
'(T3,A,3I6)')
"Full property mesh: ", grid
336 WRITE (output_unit,
'(T3,A,L1)')
"GTH SOC in the complete AO spinor space: ", do_soc
338 IF (current_operator /= 0)
THEN
340 WRITE (output_unit,
'(T3,A)')
"Dissipative and antisymmetric DC charge response; scalar relaxation rate."
341 WRITE (output_unit,
'(T3,A)')
"Tensor convention: first index current, second index electric field."
343 WRITE (output_unit,
'(T3,A)')
"Dissipative symmetric conductivity only; no Hall response."
346 WRITE (output_unit,
'(T3,A,T38,A)')
"Cell periodicity:", trim(periodic_label)
347 IF (nperiodic == 0)
THEN
348 WRITE (output_unit,
'(T3,A,T38,A)')
"Transport normalization:",
"3D finite box"
350 WRITE (output_unit,
'(T3,A,T38,I12)')
"Transport dimensionality:", transport_ndim
352 IF (all(reused_mos))
THEN
353 WRITE (output_unit,
'(T3,A,T38,A)')
"Eigensystem source:",
"CP2K canonical MOs"
354 ELSE IF (any(reused_mos))
THEN
355 WRITE (output_unit,
'(T3,A,T38,A)')
"Eigensystem source:",
"mixed canonical/internal"
357 WRITE (output_unit,
'(T3,A,T38,A)')
"Eigensystem source:",
"internal diagonalization"
359 WRITE (output_unit,
'(T3,A,T38,I12)')
"Number of atoms:", natom
360 WRITE (output_unit,
'(T3,A,T38,I12)')
"Number of AO functions:", nao
361 WRITE (output_unit,
'(T3,A,T38,F12.4)')
"Temperature [K]:", temperature*
kelvin
362 WRITE (output_unit,
'(T3,A,T38,F12.4)')
"Dissipation [K]:", dissipation*
kelvin
363 WRITE (output_unit,
'(T3,A,T38,F12.6)')
"Dissipation [eV]:", dissipation*
evolt
364 WRITE (output_unit,
'(T3,A,T38,F12.6)')
"Neutral chemical potential [eV]:", mu0*
evolt
365 WRITE (output_unit,
'(T3,A,T38,ES12.4,1X,A)')
"Transport measure:", &
366 measure*
angstrom**transport_ndim, trim(measure_unit)
367 header =
"mu[Ha] mu-mu0[eV] Ne["//trim(density_unit)//
"] "// &
368 "Nh["//trim(density_unit)//
"] sigma_iso["//trim(sigma_iso_unit)//
"] "// &
369 "sigma_xx["//trim(sigma_tensor_unit)//
"] sigma_xy["// &
370 trim(sigma_tensor_unit)//
"] sigma_xz["//trim(sigma_tensor_unit)// &
371 "] sigma_yx["//trim(sigma_tensor_unit)//
"] sigma_yy["// &
372 trim(sigma_tensor_unit)//
"] sigma_yz["//trim(sigma_tensor_unit)// &
373 "] sigma_zx["//trim(sigma_tensor_unit)//
"] sigma_zy["// &
374 trim(sigma_tensor_unit)//
"] sigma_zz["//trim(sigma_tensor_unit)//
"]"
375 WRITE (output_unit,
'(/,T3,A)') trim(
header)
381 mu_step = (emax - emin)/real(nmu - 1, kind=
dp)
385 mu = emin + real(imu - 1, kind=
dp)*mu_step
386 CALL electron_hole_density(eig, maxocc, mu, mu0, temperature, ne, nh)
387 CALL conductivity_at_mu(eig, dhh, maxocc, mu, temperature, dissipation, measure, &
388 transport_ndim, sigma, current_operator == 2 .OR. do_hall)
391 DO ispin = 1,
SIZE(eig, 2)
392 CALL hall_response(eig(:, ispin), dhh(:, :, :, ispin), mu, temperature, dissipation, &
393 hall_part, hall_status)
394 IF (hall_status /= 0)
THEN
395 cpabort(
"Invalid Kubo Hall current, spectrum, or relaxation parameters.")
397 hall = hall + maxocc(ispin)*hall_part
402 IF (output_unit > 0)
THEN
403 sigma_iso = (sigma(1, 1) + sigma(2, 2) + sigma(3, 3))/ &
404 REAL(transport_ndim, kind=
dp)*iso_factor
405 sigma_out(:, :) = sigma(:, :)*tensor_factor
406 WRITE (output_unit,
'(T3,F12.6,F14.6,2ES16.7,10ES17.8)') mu, (mu - mu0)*
evolt, &
407 ne*density_factor, nh*density_factor, &
409 sigma_out(1, 1), sigma_out(1, 2), sigma_out(1, 3), &
410 sigma_out(2, 1), sigma_out(2, 2), sigma_out(2, 3), &
411 sigma_out(3, 1), sigma_out(3, 2), sigma_out(3, 3)
412 SELECT CASE (transport_ndim)
414 WRITE (output_unit,
'(T3,A,1X,ES17.8)')
"KUBO_TRANSPORT| sigma_iso[S*m]", sigma_iso
416 WRITE (output_unit,
'(T3,A,1X,ES17.8)')
"KUBO_TRANSPORT| sigma_iso[S]", sigma_iso
418 WRITE (output_unit,
'(T3,A,1X,ES17.8)')
"KUBO_TRANSPORT| sigma_iso[S/cm]", sigma_iso
421 WRITE (output_unit,
'(T3,A,1X,A,3ES17.8)')
"KUBO_TRANSPORT| hall_xy_yz_zx", &
422 "["//trim(sigma_tensor_unit)//
"]", &
423 tensor_factor*hall(1, 2), tensor_factor*hall(2, 3), tensor_factor*hall(3, 1)
424 WRITE (output_unit,
'(T3,A,1X,ES17.8)')
"KUBO_TRANSPORT| hall_max", &
425 tensor_factor*maxval(abs(hall))
430 DEALLOCATE (ao_atom, dhh, eig, maxocc, reused_mos)
431 IF (
ALLOCATED(s_dense))
DEALLOCATE (s_dense)
433 CALL timestop(handle)
443 SUBROUTINE build_ao_atom_map(row_blk_sizes, natom, ao_atom)
444 INTEGER,
DIMENSION(:),
INTENT(IN) :: row_blk_sizes
445 INTEGER,
INTENT(IN) :: natom
446 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: ao_atom
448 INTEGER :: iao, iatom, nao, u
450 nao = sum(row_blk_sizes(1:natom))
451 ALLOCATE (ao_atom(nao))
454 DO u = 1, row_blk_sizes(iatom)
460 END SUBROUTINE build_ao_atom_map
469 SUBROUTINE dbcsr_to_dense(matrix, blacs_env, para_env, dense)
473 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :), &
476 INTEGER :: ncol, nrow
482 CALL dbcsr_get_info(matrix, nfullrows_total=nrow, nfullcols_total=ncol)
483 ALLOCATE (dense(nrow, ncol))
485 nrow_global=nrow, ncol_global=ncol)
492 END SUBROUTINE dbcsr_to_dense
504 SUBROUTINE setup_transport_geometry(cell, transport_ndim, nperiodic, periodic_label, projection, &
505 measure, measure_unit)
507 INTEGER,
INTENT(OUT) :: transport_ndim, nperiodic
508 CHARACTER(LEN=*),
INTENT(OUT) :: periodic_label
509 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT) :: projection
510 REAL(kind=
dp),
INTENT(OUT) :: measure
511 CHARACTER(LEN=*),
INTENT(OUT) :: measure_unit
513 INTEGER :: idir, jdir, kdir
514 REAL(kind=
dp) :: detg, invg11, invg12, invg22, norm2
515 REAL(kind=
dp),
DIMENSION(3) :: v1, v2
516 REAL(kind=
dp),
DIMENSION(3, 2) :: basis2
518 cpassert(
ASSOCIATED(cell))
520 nperiodic = count(cell%perd(1:3) == 1)
521 CALL transport_periodicity_label(cell%perd, periodic_label)
524 SELECT CASE (nperiodic)
529 projection(idir, idir) = 1.0_dp
531 measure_unit =
"Angstrom^3"
536 IF (cell%perd(idir) == 1) kdir = idir
538 v1(:) = cell%hmat(:, kdir)
539 norm2 = dot_product(v1, v1)
540 IF (norm2 <= 0.0_dp) cpabort(
"KUBO_TRANSPORT periodic cell vector has zero length.")
541 measure = sqrt(norm2)
544 projection(idir, jdir) = v1(idir)*v1(jdir)/norm2
547 measure_unit =
"Angstrom"
552 IF (cell%perd(idir) == 1)
THEN
554 basis2(:, kdir) = cell%hmat(:, idir)
559 norm2 = dot_product(v1, v1)
560 invg22 = dot_product(v2, v2)
561 invg12 = dot_product(v1, v2)
562 detg = norm2*invg22 - invg12*invg12
563 IF (detg <= 0.0_dp) cpabort(
"KUBO_TRANSPORT periodic cell vectors are linearly dependent.")
567 invg12 = -invg12/detg
570 projection(idir, jdir) = basis2(idir, 1)*invg11*basis2(jdir, 1) + &
571 basis2(idir, 1)*invg12*basis2(jdir, 2) + &
572 basis2(idir, 2)*invg12*basis2(jdir, 1) + &
573 basis2(idir, 2)*invg22*basis2(jdir, 2)
576 measure_unit =
"Angstrom^2"
581 projection(idir, idir) = 1.0_dp
583 measure_unit =
"Angstrom^3"
586 IF (measure <= 0.0_dp) cpabort(
"KUBO_TRANSPORT transport normalization measure is not positive.")
588 END SUBROUTINE setup_transport_geometry
595 SUBROUTINE transport_periodicity_label(perd, label)
596 INTEGER,
DIMENSION(3),
INTENT(IN) :: perd
597 CHARACTER(LEN=*),
INTENT(OUT) :: label
600 IF (perd(1) == 1) label = trim(label)//
"X"
601 IF (perd(2) == 1) label = trim(label)//
"Y"
602 IF (perd(3) == 1) label = trim(label)//
"Z"
603 IF (len_trim(label) == 0) label =
"NONE"
605 END SUBROUTINE transport_periodicity_label
614 SUBROUTINE transport_unit_labels(transport_ndim, density_unit, sigma_iso_unit, sigma_tensor_unit)
615 INTEGER,
INTENT(IN) :: transport_ndim
616 CHARACTER(LEN=*),
INTENT(OUT) :: density_unit, sigma_iso_unit, &
619 SELECT CASE (transport_ndim)
621 density_unit =
"m^-1"
622 sigma_iso_unit =
"S*m"
623 sigma_tensor_unit =
"S*m"
625 density_unit =
"m^-2"
627 sigma_tensor_unit =
"S"
629 density_unit =
"m^-3"
630 sigma_iso_unit =
"S/cm"
631 sigma_tensor_unit =
"S/m"
634 END SUBROUTINE transport_unit_labels
642 SUBROUTINE transport_output_factors(transport_ndim, iso_factor, tensor_factor)
643 INTEGER,
INTENT(IN) :: transport_ndim
644 REAL(kind=
dp),
INTENT(OUT) :: iso_factor, tensor_factor
646 SELECT CASE (transport_ndim)
648 iso_factor = 1.0e-10_dp
649 tensor_factor = 1.0e-10_dp
652 tensor_factor = 1.0_dp
654 iso_factor = 1.0e8_dp
655 tensor_factor = 1.0e10_dp
658 END SUBROUTINE transport_output_factors
676 SUBROUTINE setup_spin_transport(ks_matrix, s_dense, blacs_env, para_env, particle_set, cell, &
677 projection, ao_atom, mo_set, allow_mo_reuse, eig, dHH, reused_mos)
679 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: s_dense
684 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: projection
685 INTEGER,
DIMENSION(:),
INTENT(IN) :: ao_atom
687 LOGICAL,
INTENT(IN) :: allow_mo_reuse
688 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eig
689 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(OUT) :: dhh
690 LOGICAL,
INTENT(OUT) :: reused_mos
692 INTEGER :: idir, mo_nao, nao, nmo
693 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: coeff_dense, gmat, h_dense, horth, op, &
695 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
698 NULLIFY (mo_coeff, mo_eigenvalues)
699 nao =
SIZE(s_dense, 1)
702 CALL dbcsr_to_dense(ks_matrix, blacs_env, para_env, h_dense)
703 ALLOCATE (op(nao, nao), work(nao, nao))
705 IF (allow_mo_reuse)
THEN
706 CALL get_mo_set(mo_set=mo_set, nao=mo_nao, nmo=nmo, eigenvalues=mo_eigenvalues, &
708 reused_mos = mo_nao == nao .AND. nmo >= nao .AND.
ASSOCIATED(mo_eigenvalues) .AND. &
710 IF (reused_mos) reused_mos =
SIZE(mo_eigenvalues) >= nao
714 ALLOCATE (coeff_dense(nao, nao))
715 eig(:) = mo_eigenvalues(1:nao)
718 CALL build_commutator_kernel(h_dense, particle_set, cell, projection, ao_atom, idir, op)
719 CALL transform_to_eigenbasis(op, coeff_dense, dhh(:, :, idir), work)
721 DEALLOCATE (coeff_dense)
723 ALLOCATE (gmat(nao, nao), horth(nao, nao), op_orth(nao, nao), uvec(nao, nao))
724 CALL inverse_sqrt_symmetric(s_dense, gmat)
726 work(:, :) = matmul(h_dense, gmat)
727 horth(:, :) = matmul(gmat, work)
728 CALL symmetrize(horth)
731 CALL diagonalize_symmetric(uvec, eig)
734 CALL build_commutator_kernel(h_dense, particle_set, cell, projection, ao_atom, idir, op)
735 work(:, :) = matmul(op, gmat)
736 op_orth(:, :) = matmul(gmat, work)
737 CALL transform_to_eigenbasis(op_orth, uvec, dhh(:, :, idir), work)
739 DEALLOCATE (gmat, horth, op_orth, uvec)
742 DEALLOCATE (h_dense, op, work)
744 END SUBROUTINE setup_spin_transport
751 SUBROUTINE inverse_sqrt_symmetric(matrix, inverse_sqrt)
752 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: matrix
753 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: inverse_sqrt
755 INTEGER :: i, info, lwork, n
756 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eig, work
757 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: scaled, vectors
761 ALLOCATE (eig(n), scaled(n, n), vectors(n, n), work(lwork))
763 vectors(:, :) = matrix
764 CALL dsyev(
"V",
"L", n, vectors, n, eig, work, lwork, info)
765 IF (info /= 0) cpabort(
"Diagonalization of the overlap matrix failed.")
766 IF (minval(eig) <= 0.0_dp) cpabort(
"Overlap matrix is not positive definite.")
768 scaled(:, :) = vectors
770 scaled(:, i) = scaled(:, i)/sqrt(eig(i))
772 CALL dgemm(
"N",
"T", n, n, n, 1.0_dp, scaled, n, vectors, n, 0.0_dp, inverse_sqrt, n)
774 DEALLOCATE (eig, scaled, vectors, work)
776 END SUBROUTINE inverse_sqrt_symmetric
783 SUBROUTINE diagonalize_symmetric(matrix, eig)
784 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: matrix
785 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eig
787 INTEGER :: info, lwork, n
788 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work
792 ALLOCATE (work(lwork))
793 CALL dsyev(
"V",
"L", n, matrix, n, eig, work, lwork, info)
794 IF (info /= 0) cpabort(
"Diagonalization of the orthogonalized KS matrix failed.")
797 END SUBROUTINE diagonalize_symmetric
803 SUBROUTINE symmetrize(matrix)
804 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: matrix
807 REAL(kind=
dp) ::
value
812 value = 0.5_dp*(matrix(i, j) + matrix(j, i))
818 END SUBROUTINE symmetrize
830 SUBROUTINE build_commutator_kernel(matrix, particle_set, cell, projection, ao_atom, idir, op)
831 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: matrix
834 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: projection
835 INTEGER,
DIMENSION(:),
INTENT(IN) :: ao_atom
836 INTEGER,
INTENT(IN) :: idir
837 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: op
840 REAL(kind=
dp),
DIMENSION(3) :: dr, projected_dr
845 dr(:) =
pbc(particle_set(ao_atom(j))%r(:) - particle_set(ao_atom(i))%r(:), cell)
846 projected_dr(:) = matmul(projection, dr)
847 op(i, j) = projected_dr(idir)*matrix(i, j)
851 END SUBROUTINE build_commutator_kernel
860 SUBROUTINE transform_to_eigenbasis(op, uvec, transformed, work)
861 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: op, uvec
862 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: transformed
863 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: work
868 CALL dgemm(
"N",
"N", n, n, n, 1.0_dp, op, n, uvec, n, 0.0_dp, work, n)
869 CALL dgemm(
"T",
"N", n, n, n, 1.0_dp, uvec, n, work, n, 0.0_dp, transformed, n)
871 END SUBROUTINE transform_to_eigenbasis
881 PURE FUNCTION fermi_occ(eig, mu, kT, maxocc)
RESULT(occ)
882 REAL(kind=
dp),
INTENT(IN) :: eig, mu, kt, maxocc
888 IF (x > 80.0_dp)
THEN
890 ELSE IF (x < -80.0_dp)
THEN
893 occ = maxocc/(1.0_dp + exp(x))
896 END FUNCTION fermi_occ
906 PURE FUNCTION fermi_hole(eig, mu, kT, maxocc)
RESULT(hole)
907 REAL(kind=
dp),
INTENT(IN) :: eig, mu, kt, maxocc
908 REAL(kind=
dp) :: hole
910 hole = maxocc - fermi_occ(eig, mu, kt, maxocc)
912 END FUNCTION fermi_hole
922 PURE FUNCTION electron_count(eig, maxocc, mu, kT)
RESULT(count)
923 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: eig
924 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: maxocc
925 REAL(kind=
dp),
INTENT(IN) :: mu, kt
926 REAL(kind=
dp) :: count
931 DO ispin = 1,
SIZE(eig, 2)
932 DO n = 1,
SIZE(eig, 1)
933 count = count + fermi_occ(eig(n, ispin), mu, kt, maxocc(ispin))
937 END FUNCTION electron_count
950 SUBROUTINE find_neutral_mu(eig, maxocc, kT, neutral_electrons, neutral_grid, emin, emax, mu0)
951 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: eig
952 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: maxocc
953 REAL(kind=
dp),
INTENT(IN) :: kt, neutral_electrons
954 INTEGER,
INTENT(IN) :: neutral_grid
955 REAL(kind=
dp),
INTENT(IN) :: emin, emax
956 REAL(kind=
dp),
INTENT(OUT) :: mu0
959 REAL(kind=
dp) :: best, count, mu, mup, ne, nh, &
962 mup = 0.5_dp*(emin + emax)
963 previous_count = electron_count(eig, maxocc, emin, kt)
964 DO i = 1, neutral_grid
965 mu = emin + (emax - emin)*real(i, kind=
dp)/real(neutral_grid, kind=
dp)
966 count = electron_count(eig, maxocc, mu, kt)
967 IF ((count - neutral_electrons)*(previous_count - neutral_electrons) <= 0.0_dp) mup = mu
968 previous_count = count
973 DO i = 1, neutral_grid
974 mu = emin + (emax - emin)*real(i, kind=
dp)/real(neutral_grid, kind=
dp)
975 CALL electron_hole_density(eig, maxocc, mu, mup, kt, ne, nh)
976 IF (abs(nh - ne) <= best)
THEN
982 END SUBROUTINE find_neutral_mu
994 SUBROUTINE electron_hole_density(eig, maxocc, mu, mu0, kT, ne, nh)
995 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: eig
996 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: maxocc
997 REAL(kind=
dp),
INTENT(IN) :: mu, mu0, kt
998 REAL(kind=
dp),
INTENT(OUT) :: ne, nh
1004 DO ispin = 1,
SIZE(eig, 2)
1005 DO n = 1,
SIZE(eig, 1)
1006 IF (eig(n, ispin) <= mu0) nh = nh + fermi_hole(eig(n, ispin), mu, kt, maxocc(ispin))
1007 IF (eig(n, ispin) >= mu0) ne = ne + fermi_occ(eig(n, ispin), mu, kt, maxocc(ispin))
1011 END SUBROUTINE electron_hole_density
1026 SUBROUTINE conductivity_at_mu(eig, dHH, maxocc, mu, kT, dissipation, measure, transport_ndim, sigma, bloch)
1027 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: eig
1028 COMPLEX(KIND=dp),
DIMENSION(:, :, :, :), &
1030 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: maxocc
1031 REAL(kind=
dp),
INTENT(IN) :: mu, kt, dissipation, measure
1032 INTEGER,
INTENT(IN) :: transport_ndim
1033 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT) :: sigma
1034 LOGICAL,
INTENT(IN) :: bloch
1036 INTEGER :: idir, ispin, jdir, m, n, nao
1037 REAL(kind=
dp) :: delta, eps, factor, g0
1038 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: occ
1047 DO ispin = 1,
SIZE(eig, 2)
1049 occ(n) = fermi_occ(eig(n, ispin), mu, kt, maxocc(ispin))
1056 delta = eig(n, ispin) - eig(m, ispin)
1058 factor = maxocc(ispin)*
fermi_slope(eig(n, ispin), eig(m, ispin), mu, kt)* &
1059 dissipation/(dissipation**2 + delta**2)
1061 factor = (occ(n) - occ(m))/(delta + eps)*dissipation/(dissipation**2 + delta**2)
1063 sigma(jdir, idir) = sigma(jdir, idir) + &
1064 REAL(dhh(m, n, jdir, ispin)*dhh(n, m, idir, ispin),
dp)*factor
1071 sigma =
pi*g0*sigma*
angstrom**(2 - transport_ndim)/measure
1075 END SUBROUTINE conductivity_at_mu
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public esteveparedes2023
integer, save, public kuhneheskeprodan2020
Handles all functions related to the CELL.
methods related to the blacs parallel environment
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS 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, 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 ...
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
Defines the basic variable types.
integer, parameter, public dp
Metric-aware Bloch velocities without eigenvector derivatives or band-gap divisions.
pure real(dp) function, public fermi_slope(ea, eb, mu, kt)
Stable Fermi divided difference including the intraband and degenerate limits.
Antisymmetric DC charge response with a scalar relaxation rate.
subroutine, public hall_response(energies, current, mu, kt, gamma, hall, status)
Hall tensor, with first index the current and second index the electric field.
Finite projected-Hamiltonian current in a nonorthogonal, possibly spinor AO basis.
subroutine, public projected_current(h, s, positions, energies, current, status)
Compute C^dagger (H S^-1 X - X S^-1 H) C without forming S^-1.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Interface to the message passing library MPI.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public a_bohr
real(kind=dp), parameter, public e_charge
real(kind=dp), parameter, public kelvin
real(kind=dp), parameter, public h_bar
real(kind=dp), parameter, public evolt
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.
Shared finite-system AO position and SOC operators for post-SCF analyses.
subroutine, public finite_ao_soc(qs_env, soc_matrices)
Validate and construct post-SCF GTH SOC components shared by finite AO analyses.
subroutine, public finite_ao_positions(qs_env, positions)
Analytic covariant first moments in the coordinate frame of SUBSYS/COORD.
Full-mesh scalar/spinor Bloch currents from CP2K image operators and analytic AO moments.
subroutine, public setup_bloch_transport(qs_env, grid, do_soc, projection, max_memory_mb, energies, current, occupations, symmetry, backend, eps_symmetry, eps_operators)
Build a full Gamma-centered property mesh, independent of SCF reduction.
Finite-volume Kubo-Greenwood transport from converged Quickstep matrices.
subroutine, public qs_scf_post_kubo_transport(qs_env)
Compute and print the finite-volume Kubo-Greenwood conductivity tensor.
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.
Distributed block-sparse finite localizers, retaining the covariant AO metric.
subroutine, public localizer_ao_operators(h, s, positions, operators, metric, soc)
Shared AO Hamiltonian, Hermitian scalar observables and optional GTH physical-spin SOC.
subroutine, public localizer_dbcsr_dense(matrix, para_env, dense)
Collect the size-limited dense oracle; sparse solvers must not call this routine.
subroutine, public localizer_dbcsr_release(matrix)
Release both real components of a complex sparse operator.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Type defining parameters related to the simulation cell.
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