(git:27c966b)
Loading...
Searching...
No Matches
qs_kubo_transport.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Finite-volume Kubo-Greenwood transport from converged Quickstep matrices.
10! **************************************************************************************************
14 cite_reference
15 USE cell_types, ONLY: cell_type,&
16 pbc
18 USE cp_dbcsr_api, ONLY: dbcsr_get_info,&
26 USE cp_fm_types, ONLY: cp_fm_create,&
33 USE ieee_arithmetic, ONLY: ieee_is_finite
37 USE kinds, ONLY: dp
38 USE kubo_bloch, ONLY: fermi_slope
39 USE kubo_hall, ONLY: hall_response
41 USE mathconstants, ONLY: pi
44 USE physcon, ONLY: a_bohr,&
45 angstrom,&
46 e_charge,&
47 evolt,&
48 h_bar,&
49 kelvin
55 USE qs_mo_types, ONLY: get_mo_set,&
62#include "./base/base_uses.f90"
63
64 IMPLICIT NONE
65
66 PRIVATE
67
68 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_kubo_transport'
69
71
72CONTAINS
73
74! **************************************************************************************************
75!> \brief Share full finite AO/SOC operators with the localizer, retaining complex matrix elements.
76!> \param qs_env Converged finite Quickstep environment
77!> \param spin Scalar spin channel, one for SOC
78!> \param do_soc Include GTH SOC
79!> \param energies Complete scalar/spinor eigenvalues
80!> \param current Three projected commutators in the eigenbasis
81! **************************************************************************************************
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(:, :, :)
88
89 COMPLEX(dp), ALLOCATABLE :: component(:, :), hd(:, :), sd(:, :), &
90 xd(:, :, :)
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
95
96 NULLIFY (positions, soc)
97 CALL get_qs_env(qs_env, matrix_ks=h, matrix_s=s, para_env=para_env)
98 CALL finite_ao_positions(qs_env, positions)
99 IF (do_soc) THEN
100 CALL finite_ao_soc(qs_env, soc)
101 CALL localizer_ao_operators(h(spin)%matrix, s(1)%matrix, positions, operators, metric, soc)
102 ELSE
103 CALL localizer_ao_operators(h(spin)%matrix, s(1)%matrix, positions, operators, metric)
104 END IF
105 CALL localizer_dbcsr_dense(operators(1), para_env, hd)
106 CALL localizer_dbcsr_dense(metric, para_env, sd)
107 n = SIZE(hd, 1)
108 ALLOCATE (xd(n, n, 3))
109 DO axis = 1, 3
110 CALL localizer_dbcsr_dense(operators(axis + 1), para_env, component)
111 xd(:, :, axis) = component
112 DEALLOCATE (component)
113 END DO
114 status = 0
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.")
119 END IF
120 CALL para_env%bcast(energies, para_env%source)
121 CALL para_env%bcast(current, para_env%source)
122 CALL dbcsr_deallocate_matrix_set(positions)
123 IF (do_soc) CALL dbcsr_deallocate_matrix_set(soc)
124 DO axis = 1, 4
125 CALL localizer_dbcsr_release(operators(axis))
126 END DO
127 CALL localizer_dbcsr_release(metric)
128 END SUBROUTINE setup_projected_transport
129
130! **************************************************************************************************
131!> \brief Compute and print the finite-volume Kubo-Greenwood conductivity tensor.
132!> \param qs_env Quickstep environment
133! **************************************************************************************************
134 SUBROUTINE qs_scf_post_kubo_transport(qs_env)
135 TYPE(qs_environment_type), POINTER :: qs_env
136
137 CHARACTER(len=*), PARAMETER :: routinen = 'qs_scf_post_kubo_transport'
138
139 CHARACTER(LEN=32) :: density_unit, measure_unit, method, &
140 periodic_label, sigma_iso_unit, &
141 sigma_tensor_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, &
154 property_symmetry
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, &
159 tensor_factor
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, &
163 sigma_out
164 REAL(kind=dp), DIMENSION(:), POINTER :: energy_range
165 TYPE(cell_type), POINTER :: cell
166 TYPE(cp_blacs_env_type), POINTER :: blacs_env
167 TYPE(cp_logger_type), POINTER :: logger
168 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_s
169 TYPE(dbcsr_p_type), POINTER :: images(:, :)
170 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
171 TYPE(mp_para_env_type), POINTER :: para_env
172 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
173 TYPE(section_vals_type), POINTER :: input_section, kubo_section, ot_section
174
175 CALL timeset(routinen, handle)
176
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)
179
180 CALL get_qs_env(qs_env, input=input_section)
181 kubo_section => section_vals_get_subs_vals(input_section, "PROPERTIES%KUBO_TRANSPORT")
182 CALL section_vals_val_get(kubo_section, "_SECTION_PARAMETERS_", l_val=kubo_active)
183 IF (.NOT. kubo_active) THEN
184 CALL timestop(handle)
185 RETURN
186 END IF
187 CALL cite_reference(kuhneheskeprodan2020)
188
189 CALL section_vals_val_get(kubo_section, "METHOD", c_val=method)
190 CALL uppercase(method)
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.")
195 CASE DEFAULT
196 cpabort("Unknown KUBO_TRANSPORT METHOD: "//trim(method))
197 END SELECT
198 ot_section => section_vals_get_subs_vals(input_section, "DFT%SCF%OT")
199 CALL section_vals_val_get(ot_section, "_SECTION_PARAMETERS_", l_val=ot_active)
200 allow_mo_reuse = .NOT. ot_active
201
202 CALL section_vals_val_get(kubo_section, "CURRENT_OPERATOR", i_val=current_operator)
203 CALL section_vals_val_get(kubo_section, "SOC", l_val=do_soc)
204 CALL section_vals_val_get(kubo_section, "HALL_RESPONSE", l_val=do_hall)
205 IF (do_hall .AND. current_operator == 0) THEN
206 cpabort("Kubo HALL_RESPONSE requires CURRENT_OPERATOR PROJECTED_AO or BLOCH.")
207 END IF
208 CALL section_vals_val_get(kubo_section, "SYMMETRY", l_val=property_symmetry)
209 IF (property_symmetry .AND. current_operator /= 2) THEN
210 cpabort('Kubo property SYMMETRY requires BLOCH.')
211 END IF
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.")
215 END IF
216 IF (do_soc .AND. current_operator == 0) THEN
217 cpabort("Kubo SOC requires CURRENT_OPERATOR PROJECTED_AO or BLOCH.")
218 END IF
219 IF (current_operator == 1 .AND. any(cell%perd /= 0)) THEN
220 cpabort("Kubo PROJECTED_AO requires PERIODIC NONE.")
221 END IF
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)
224 CALL get_qs_env(qs_env, matrix_ks_kp=images)
225 matrix_ks => images(:, 1)
226 CALL get_qs_env(qs_env, matrix_s_kp=images)
227 matrix_s => images(:, 1)
228 cpassert(ASSOCIATED(matrix_s))
229 cpassert(ASSOCIATED(matrix_ks))
230 cpassert(ASSOCIATED(cell))
231 cpassert(ASSOCIATED(particle_set))
232
233 CALL section_vals_val_get(kubo_section, "TEMPERATURE", r_val=temperature)
234 CALL section_vals_val_get(kubo_section, "DISSIPATION", r_val=dissipation)
235 CALL section_vals_val_get(kubo_section, "ENERGY_RANGE", r_vals=energy_range)
236 CALL section_vals_val_get(kubo_section, "NEUTRAL_MU", explicit=neutral_mu_explicit)
237 IF (neutral_mu_explicit) CALL section_vals_val_get(kubo_section, "NEUTRAL_MU", r_val=mu0)
238 CALL section_vals_val_get(kubo_section, "N_MU", i_val=nmu)
239 CALL section_vals_val_get(kubo_section, "NEUTRAL_GRID", i_val=neutral_grid)
240
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.")
245
246 nspins = SIZE(matrix_ks)
247 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao, row_blk_size=row_blk_sizes)
248 nstate = nao
249 IF (current_operator /= 0) THEN
250 CALL section_vals_val_get(kubo_section, "MAX_AO", i_val=max_ao)
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.")
254 END IF
255 END IF
256 IF (do_soc) THEN
257 IF (nspins /= 1) cpabort("Kubo SOC requires a restricted SCF.")
258 nstate = 2*nao
259 END IF
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)
265
266 IF (current_operator == 2) THEN
267 CALL cite_reference(esteveparedes2023)
268 CALL section_vals_val_get(kubo_section, "MP_GRID", i_vals=grid)
269 CALL section_vals_val_get(kubo_section, "MAX_MEMORY_MB", i_val=max_memory_mb)
270 CALL section_vals_val_get(kubo_section, "SYMMETRY_BACKEND", i_val=symmetry_backend)
271 CALL section_vals_val_get(kubo_section, "EPS_SYMMETRY", r_val=eps_symmetry)
272 CALL section_vals_val_get(kubo_section, "EPS_SYMMETRY_OPERATORS", r_val=eps_operators)
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.')
275 END IF
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.')
278 END IF
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.")
281 nk = 1
282 DO axis = 1, 3
283 IF (grid(axis) > 1000000/nk) cpabort("Kubo MP_GRID exceeds one million points.")
284 nk = nk*grid(axis)
285 END DO
286 CALL setup_bloch_transport(qs_env, grid, do_soc, projection, max_memory_mb, eig, dhh, maxocc, &
287 property_symmetry, symmetry_backend, eps_symmetry, eps_operators)
288 ALLOCATE (reused_mos(SIZE(eig, 2)), source=.false.)
289 ELSE
290 ALLOCATE (eig(nstate, nspins), dhh(nstate, nstate, 3, nspins), maxocc(nspins), reused_mos(nspins))
291 DO ispin = 1, 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.
297 ELSE
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)
304 END IF
305 END DO
306 END IF
307
308 emin = minval(eig)
309 emax = maxval(eig)
310 IF (.NOT. neutral_mu_explicit) THEN
311 CALL find_neutral_mu(eig, maxocc, temperature, real(nelectron_total, kind=dp), neutral_grid, &
312 emin, emax, mu0)
313 END IF
314
315 IF (energy_range(1) < energy_range(2)) THEN
316 emin = energy_range(1)
317 emax = energy_range(2)
318 END IF
319
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)
323
324 logger => cp_get_default_logger()
325 output_unit = cp_logger_get_default_io_unit(logger)
326
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
337 END IF
338 IF (current_operator /= 0) THEN
339 IF (do_hall) 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."
342 ELSE
343 WRITE (output_unit, '(T3,A)') "Dissipative symmetric conductivity only; no Hall response."
344 END IF
345 END IF
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"
349 ELSE
350 WRITE (output_unit, '(T3,A,T38,I12)') "Transport dimensionality:", transport_ndim
351 END IF
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"
356 ELSE
357 WRITE (output_unit, '(T3,A,T38,A)') "Eigensystem source:", "internal diagonalization"
358 END IF
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)
376 END IF
377
378 IF (nmu == 1) THEN
379 mu_step = 0.0_dp
380 ELSE
381 mu_step = (emax - emin)/real(nmu - 1, kind=dp)
382 END IF
383
384 DO imu = 1, nmu
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)
389 IF (do_hall) THEN
390 hall = 0.0_dp
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.")
396 END IF
397 hall = hall + maxocc(ispin)*hall_part
398 END DO
399 hall = (e_charge**2/h_bar)*hall*angstrom**(2 - transport_ndim)/measure
400 sigma = sigma + hall
401 END IF
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, &
408 sigma_iso, &
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)
413 CASE (1)
414 WRITE (output_unit, '(T3,A,1X,ES17.8)') "KUBO_TRANSPORT| sigma_iso[S*m]", sigma_iso
415 CASE (2)
416 WRITE (output_unit, '(T3,A,1X,ES17.8)') "KUBO_TRANSPORT| sigma_iso[S]", sigma_iso
417 CASE DEFAULT
418 WRITE (output_unit, '(T3,A,1X,ES17.8)') "KUBO_TRANSPORT| sigma_iso[S/cm]", sigma_iso
419 END SELECT
420 IF (do_hall) THEN
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))
426 END IF
427 END IF
428 END DO
429
430 DEALLOCATE (ao_atom, dhh, eig, maxocc, reused_mos)
431 IF (ALLOCATED(s_dense)) DEALLOCATE (s_dense)
432
433 CALL timestop(handle)
434
435 END SUBROUTINE qs_scf_post_kubo_transport
436
437! **************************************************************************************************
438!> \brief Build a global AO -> atom map from DBCSR atomic block sizes.
439!> \param row_blk_sizes ...
440!> \param natom ...
441!> \param ao_atom ...
442! **************************************************************************************************
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
447
448 INTEGER :: iao, iatom, nao, u
449
450 nao = sum(row_blk_sizes(1:natom))
451 ALLOCATE (ao_atom(nao))
452 iao = 0
453 DO iatom = 1, natom
454 DO u = 1, row_blk_sizes(iatom)
455 iao = iao + 1
456 ao_atom(iao) = iatom
457 END DO
458 END DO
459
460 END SUBROUTINE build_ao_atom_map
461
462! **************************************************************************************************
463!> \brief Copy a DBCSR matrix to a replicated dense matrix.
464!> \param matrix ...
465!> \param blacs_env ...
466!> \param para_env ...
467!> \param dense ...
468! **************************************************************************************************
469 SUBROUTINE dbcsr_to_dense(matrix, blacs_env, para_env, dense)
470 TYPE(dbcsr_type), INTENT(IN) :: matrix
471 TYPE(cp_blacs_env_type), POINTER :: blacs_env
472 TYPE(mp_para_env_type), POINTER :: para_env
473 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :), &
474 INTENT(OUT) :: dense
475
476 INTEGER :: ncol, nrow
477 TYPE(cp_fm_struct_type), POINTER :: fm_struct
478 TYPE(cp_fm_type) :: fm
479
480 NULLIFY (fm_struct)
481
482 CALL dbcsr_get_info(matrix, nfullrows_total=nrow, nfullcols_total=ncol)
483 ALLOCATE (dense(nrow, ncol))
484 CALL cp_fm_struct_create(fm_struct, context=blacs_env, para_env=para_env, &
485 nrow_global=nrow, ncol_global=ncol)
486 CALL cp_fm_create(fm, fm_struct)
487 CALL copy_dbcsr_to_fm(matrix, fm)
488 CALL cp_fm_get_submatrix(fm, dense, n_rows=nrow, n_cols=ncol)
489 CALL cp_fm_release(fm)
490 CALL cp_fm_struct_release(fm_struct)
491
492 END SUBROUTINE dbcsr_to_dense
493
494! **************************************************************************************************
495!> \brief Set up the periodic transport subspace and its normalization measure.
496!> \param cell ...
497!> \param transport_ndim ...
498!> \param nperiodic ...
499!> \param periodic_label ...
500!> \param projection ...
501!> \param measure ...
502!> \param measure_unit ...
503! **************************************************************************************************
504 SUBROUTINE setup_transport_geometry(cell, transport_ndim, nperiodic, periodic_label, projection, &
505 measure, measure_unit)
506 TYPE(cell_type), POINTER :: cell
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
512
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
517
518 cpassert(ASSOCIATED(cell))
519
520 nperiodic = count(cell%perd(1:3) == 1)
521 CALL transport_periodicity_label(cell%perd, periodic_label)
522 projection = 0.0_dp
523
524 SELECT CASE (nperiodic)
525 CASE (0)
526 transport_ndim = 3
527 measure = cell%deth
528 DO idir = 1, 3
529 projection(idir, idir) = 1.0_dp
530 END DO
531 measure_unit = "Angstrom^3"
532 CASE (1)
533 transport_ndim = 1
534 kdir = 0
535 DO idir = 1, 3
536 IF (cell%perd(idir) == 1) kdir = idir
537 END DO
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)
542 DO jdir = 1, 3
543 DO idir = 1, 3
544 projection(idir, jdir) = v1(idir)*v1(jdir)/norm2
545 END DO
546 END DO
547 measure_unit = "Angstrom"
548 CASE (2)
549 transport_ndim = 2
550 kdir = 0
551 DO idir = 1, 3
552 IF (cell%perd(idir) == 1) THEN
553 kdir = kdir + 1
554 basis2(:, kdir) = cell%hmat(:, idir)
555 END IF
556 END DO
557 v1(:) = basis2(:, 1)
558 v2(:) = basis2(:, 2)
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.")
564 measure = sqrt(detg)
565 invg11 = invg22/detg
566 invg22 = norm2/detg
567 invg12 = -invg12/detg
568 DO jdir = 1, 3
569 DO idir = 1, 3
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)
574 END DO
575 END DO
576 measure_unit = "Angstrom^2"
577 CASE DEFAULT
578 transport_ndim = 3
579 measure = cell%deth
580 DO idir = 1, 3
581 projection(idir, idir) = 1.0_dp
582 END DO
583 measure_unit = "Angstrom^3"
584 END SELECT
585
586 IF (measure <= 0.0_dp) cpabort("KUBO_TRANSPORT transport normalization measure is not positive.")
587
588 END SUBROUTINE setup_transport_geometry
589
590! **************************************************************************************************
591!> \brief Human-readable periodicity label.
592!> \param perd ...
593!> \param label ...
594! **************************************************************************************************
595 SUBROUTINE transport_periodicity_label(perd, label)
596 INTEGER, DIMENSION(3), INTENT(IN) :: perd
597 CHARACTER(LEN=*), INTENT(OUT) :: label
598
599 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"
604
605 END SUBROUTINE transport_periodicity_label
606
607! **************************************************************************************************
608!> \brief Output unit labels for a transport dimensionality.
609!> \param transport_ndim ...
610!> \param density_unit ...
611!> \param sigma_iso_unit ...
612!> \param sigma_tensor_unit ...
613! **************************************************************************************************
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, &
617 sigma_tensor_unit
618
619 SELECT CASE (transport_ndim)
620 CASE (1)
621 density_unit = "m^-1"
622 sigma_iso_unit = "S*m"
623 sigma_tensor_unit = "S*m"
624 CASE (2)
625 density_unit = "m^-2"
626 sigma_iso_unit = "S"
627 sigma_tensor_unit = "S"
628 CASE DEFAULT
629 density_unit = "m^-3"
630 sigma_iso_unit = "S/cm"
631 sigma_tensor_unit = "S/m"
632 END SELECT
633
634 END SUBROUTINE transport_unit_labels
635
636! **************************************************************************************************
637!> \brief Output conversion factors from internal dimensional transport units.
638!> \param transport_ndim ...
639!> \param iso_factor ...
640!> \param tensor_factor ...
641! **************************************************************************************************
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
645
646 SELECT CASE (transport_ndim)
647 CASE (1)
648 iso_factor = 1.0e-10_dp
649 tensor_factor = 1.0e-10_dp
650 CASE (2)
651 iso_factor = 1.0_dp
652 tensor_factor = 1.0_dp
653 CASE DEFAULT
654 iso_factor = 1.0e8_dp
655 tensor_factor = 1.0e10_dp
656 END SELECT
657
658 END SUBROUTINE transport_output_factors
659
660! **************************************************************************************************
661!> \brief Prepare eigenvalues and the transformed [X,H] matrices for one spin channel.
662!> \param ks_matrix ...
663!> \param s_dense ...
664!> \param blacs_env ...
665!> \param para_env ...
666!> \param particle_set ...
667!> \param cell ...
668!> \param projection ...
669!> \param ao_atom ...
670!> \param mo_set ...
671!> \param allow_mo_reuse ...
672!> \param eig ...
673!> \param dHH ...
674!> \param reused_mos ...
675! **************************************************************************************************
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)
678 TYPE(dbcsr_type), INTENT(IN) :: ks_matrix
679 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: s_dense
680 TYPE(cp_blacs_env_type), POINTER :: blacs_env
681 TYPE(mp_para_env_type), POINTER :: para_env
682 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
683 TYPE(cell_type), POINTER :: cell
684 REAL(kind=dp), DIMENSION(3, 3), INTENT(IN) :: projection
685 INTEGER, DIMENSION(:), INTENT(IN) :: ao_atom
686 TYPE(mo_set_type), INTENT(IN) :: mo_set
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
691
692 INTEGER :: idir, mo_nao, nao, nmo
693 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: coeff_dense, gmat, h_dense, horth, op, &
694 op_orth, uvec, work
695 REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
696 TYPE(cp_fm_type), POINTER :: mo_coeff
697
698 NULLIFY (mo_coeff, mo_eigenvalues)
699 nao = SIZE(s_dense, 1)
700 reused_mos = .false.
701
702 CALL dbcsr_to_dense(ks_matrix, blacs_env, para_env, h_dense)
703 ALLOCATE (op(nao, nao), work(nao, nao))
704
705 IF (allow_mo_reuse) THEN
706 CALL get_mo_set(mo_set=mo_set, nao=mo_nao, nmo=nmo, eigenvalues=mo_eigenvalues, &
707 mo_coeff=mo_coeff)
708 reused_mos = mo_nao == nao .AND. nmo >= nao .AND. ASSOCIATED(mo_eigenvalues) .AND. &
709 ASSOCIATED(mo_coeff)
710 IF (reused_mos) reused_mos = SIZE(mo_eigenvalues) >= nao
711 END IF
712
713 IF (reused_mos) THEN
714 ALLOCATE (coeff_dense(nao, nao))
715 eig(:) = mo_eigenvalues(1:nao)
716 CALL cp_fm_get_submatrix(mo_coeff, coeff_dense, n_rows=nao, n_cols=nao)
717 DO idir = 1, 3
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)
720 END DO
721 DEALLOCATE (coeff_dense)
722 ELSE
723 ALLOCATE (gmat(nao, nao), horth(nao, nao), op_orth(nao, nao), uvec(nao, nao))
724 CALL inverse_sqrt_symmetric(s_dense, gmat)
725
726 work(:, :) = matmul(h_dense, gmat)
727 horth(:, :) = matmul(gmat, work)
728 CALL symmetrize(horth)
729
730 uvec(:, :) = horth
731 CALL diagonalize_symmetric(uvec, eig)
732
733 DO idir = 1, 3
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)
738 END DO
739 DEALLOCATE (gmat, horth, op_orth, uvec)
740 END IF
741
742 DEALLOCATE (h_dense, op, work)
743
744 END SUBROUTINE setup_spin_transport
745
746! **************************************************************************************************
747!> \brief Symmetric inverse square root via dense diagonalization.
748!> \param matrix ...
749!> \param inverse_sqrt ...
750! **************************************************************************************************
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
754
755 INTEGER :: i, info, lwork, n
756 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eig, work
757 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: scaled, vectors
758
759 n = SIZE(matrix, 1)
760 lwork = max(1, 8*n)
761 ALLOCATE (eig(n), scaled(n, n), vectors(n, n), work(lwork))
762
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.")
767
768 scaled(:, :) = vectors
769 DO i = 1, n
770 scaled(:, i) = scaled(:, i)/sqrt(eig(i))
771 END DO
772 CALL dgemm("N", "T", n, n, n, 1.0_dp, scaled, n, vectors, n, 0.0_dp, inverse_sqrt, n)
773
774 DEALLOCATE (eig, scaled, vectors, work)
775
776 END SUBROUTINE inverse_sqrt_symmetric
777
778! **************************************************************************************************
779!> \brief Dense symmetric diagonalization.
780!> \param matrix ...
781!> \param eig ...
782! **************************************************************************************************
783 SUBROUTINE diagonalize_symmetric(matrix, eig)
784 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: matrix
785 REAL(kind=dp), DIMENSION(:), INTENT(OUT) :: eig
786
787 INTEGER :: info, lwork, n
788 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: work
789
790 n = SIZE(matrix, 1)
791 lwork = max(1, 8*n)
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.")
795 DEALLOCATE (work)
796
797 END SUBROUTINE diagonalize_symmetric
798
799! **************************************************************************************************
800!> \brief Enforce exact symmetry after dense products.
801!> \param matrix ...
802! **************************************************************************************************
803 SUBROUTINE symmetrize(matrix)
804 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: matrix
805
806 INTEGER :: i, j, n
807 REAL(kind=dp) :: value
808
809 n = SIZE(matrix, 1)
810 DO j = 1, n
811 DO i = j + 1, n
812 value = 0.5_dp*(matrix(i, j) + matrix(j, i))
813 matrix(i, j) = value
814 matrix(j, i) = value
815 END DO
816 END DO
817
818 END SUBROUTINE symmetrize
819
820! **************************************************************************************************
821!> \brief Build element-wise kernel (P*(r_col-r_row))_idir * matrix(row,col).
822!> \param matrix ...
823!> \param particle_set ...
824!> \param cell ...
825!> \param projection ...
826!> \param ao_atom ...
827!> \param idir ...
828!> \param op ...
829! **************************************************************************************************
830 SUBROUTINE build_commutator_kernel(matrix, particle_set, cell, projection, ao_atom, idir, op)
831 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: matrix
832 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
833 TYPE(cell_type), POINTER :: cell
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
838
839 INTEGER :: i, j, n
840 REAL(kind=dp), DIMENSION(3) :: dr, projected_dr
841
842 n = SIZE(matrix, 1)
843 DO j = 1, n
844 DO i = 1, n
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)
848 END DO
849 END DO
850
851 END SUBROUTINE build_commutator_kernel
852
853! **************************************************************************************************
854!> \brief Transform an AO matrix to the eigenvector basis.
855!> \param op ...
856!> \param uvec ...
857!> \param transformed ...
858!> \param work ...
859! **************************************************************************************************
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
864
865 INTEGER :: n
866
867 n = SIZE(op, 1)
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)
870
871 END SUBROUTINE transform_to_eigenbasis
872
873! **************************************************************************************************
874!> \brief Fermi occupation with overflow protection.
875!> \param eig ...
876!> \param mu ...
877!> \param kT ...
878!> \param maxocc ...
879!> \return ...
880! **************************************************************************************************
881 PURE FUNCTION fermi_occ(eig, mu, kT, maxocc) RESULT(occ)
882 REAL(kind=dp), INTENT(IN) :: eig, mu, kt, maxocc
883 REAL(kind=dp) :: occ
884
885 REAL(kind=dp) :: x
886
887 x = (eig - mu)/kt
888 IF (x > 80.0_dp) THEN
889 occ = 0.0_dp
890 ELSE IF (x < -80.0_dp) THEN
891 occ = maxocc
892 ELSE
893 occ = maxocc/(1.0_dp + exp(x))
894 END IF
895
896 END FUNCTION fermi_occ
897
898! **************************************************************************************************
899!> \brief Fermi vacancy below the neutral point.
900!> \param eig ...
901!> \param mu ...
902!> \param kT ...
903!> \param maxocc ...
904!> \return ...
905! **************************************************************************************************
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
909
910 hole = maxocc - fermi_occ(eig, mu, kt, maxocc)
911
912 END FUNCTION fermi_hole
913
914! **************************************************************************************************
915!> \brief Total electron count at a chemical potential.
916!> \param eig ...
917!> \param maxocc ...
918!> \param mu ...
919!> \param kT ...
920!> \return ...
921! **************************************************************************************************
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
927
928 INTEGER :: ispin, n
929
930 count = 0.0_dp
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))
934 END DO
935 END DO
936
937 END FUNCTION electron_count
938
939! **************************************************************************************************
940!> \brief Determine the neutral chemical potential using the legacy two-step definition.
941!> \param eig ...
942!> \param maxocc ...
943!> \param kT ...
944!> \param neutral_electrons ...
945!> \param neutral_grid ...
946!> \param emin ...
947!> \param emax ...
948!> \param mu0 ...
949! **************************************************************************************************
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
957
958 INTEGER :: i
959 REAL(kind=dp) :: best, count, mu, mup, ne, nh, &
960 previous_count
961
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
969 END DO
970
971 mu0 = mup
972 best = huge(1.0_dp)
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
977 mu0 = mu
978 best = abs(nh - ne)
979 END IF
980 END DO
981
982 END SUBROUTINE find_neutral_mu
983
984! **************************************************************************************************
985!> \brief Electron and hole counts relative to a neutral point.
986!> \param eig ...
987!> \param maxocc ...
988!> \param mu ...
989!> \param mu0 ...
990!> \param kT ...
991!> \param ne ...
992!> \param nh ...
993! **************************************************************************************************
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
999
1000 INTEGER :: ispin, n
1001
1002 ne = 0.0_dp
1003 nh = 0.0_dp
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))
1008 END DO
1009 END DO
1010
1011 END SUBROUTINE electron_hole_density
1012
1013! **************************************************************************************************
1014!> \brief Conductivity tensor at one chemical potential.
1015!> \param eig ...
1016!> \param dHH ...
1017!> \param maxocc ...
1018!> \param mu ...
1019!> \param kT ...
1020!> \param dissipation ...
1021!> \param measure ...
1022!> \param transport_ndim ...
1023!> \param sigma ...
1024!> \param bloch Use the stable Fermi limit for Bloch currents or the complete DC tensor
1025! **************************************************************************************************
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(:, :, :, :), &
1029 INTENT(IN) :: dhh
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
1035
1036 INTEGER :: idir, ispin, jdir, m, n, nao
1037 REAL(kind=dp) :: delta, eps, factor, g0
1038 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: occ
1039
1040 nao = SIZE(eig, 1)
1041 eps = 1.0e-12_dp
1042 g0 = e_charge**2/(pi*h_bar)
1043 sigma = 0.0_dp
1044
1045 ALLOCATE (occ(nao))
1046
1047 DO ispin = 1, SIZE(eig, 2)
1048 DO n = 1, nao
1049 occ(n) = fermi_occ(eig(n, ispin), mu, kt, maxocc(ispin))
1050 END DO
1051
1052 DO idir = 1, 3
1053 DO jdir = 1, 3
1054 DO n = 1, nao
1055 DO m = 1, nao
1056 delta = eig(n, ispin) - eig(m, ispin)
1057 IF (bloch) THEN
1058 factor = maxocc(ispin)*fermi_slope(eig(n, ispin), eig(m, ispin), mu, kt)* &
1059 dissipation/(dissipation**2 + delta**2)
1060 ELSE
1061 factor = (occ(n) - occ(m))/(delta + eps)*dissipation/(dissipation**2 + delta**2)
1062 END IF
1063 sigma(jdir, idir) = sigma(jdir, idir) + &
1064 REAL(dhh(m, n, jdir, ispin)*dhh(n, m, idir, ispin), dp)*factor
1065 END DO
1066 END DO
1067 END DO
1068 END DO
1069 END DO
1070
1071 sigma = pi*g0*sigma*angstrom**(2 - transport_ndim)/measure
1072
1073 DEALLOCATE (occ)
1074
1075 END SUBROUTINE conductivity_at_mu
1076
1077END MODULE qs_kubo_transport
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.
Definition cell_types.F:15
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
Definition cp_fm_types.F:15
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
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Metric-aware Bloch velocities without eigenvector derivatives or band-gap divisions.
Definition kubo_bloch.F:12
pure real(dp) function, public fermi_slope(ea, eb, mu, kt)
Stable Fermi divided difference including the intraband and degenerate limits.
Definition kubo_bloch.F:163
Antisymmetric DC charge response with a scalar relaxation rate.
Definition kubo_hall.F:12
subroutine, public hall_response(energies, current, mu, kt, gamma, hall, status)
Hall tensor, with first index the current and second index the electric field.
Definition kubo_hall.F:37
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:
Definition physcon.F:68
real(kind=dp), parameter, public a_bohr
Definition physcon.F:136
real(kind=dp), parameter, public e_charge
Definition physcon.F:106
real(kind=dp), parameter, public kelvin
Definition physcon.F:165
real(kind=dp), parameter, public h_bar
Definition physcon.F:103
real(kind=dp), parameter, public evolt
Definition physcon.F:183
real(kind=dp), parameter, public angstrom
Definition physcon.F:144
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.
Definition qs_mo_types.F:22
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.
Definition cell_types.F:60
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
represent 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