(git:9ea9339)
Loading...
Searching...
No Matches
negf_control_types.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 Input control types for NEGF based quantum transport calculations
10! **************************************************************************************************
11
15 USE input_constants, ONLY: negf_run
20 USE kinds, ONLY: default_string_length,&
21 dp
22 USE mathconstants, ONLY: pi
25 USE molecule_types, ONLY: get_molecule,&
29 USE physcon, ONLY: kelvin
31 USE util, ONLY: sort
32#include "./base/base_uses.f90"
33
34 IMPLICIT NONE
35 PRIVATE
36
37 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'negf_control_types'
38 LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .true.
39
42
43! **************************************************************************************************
44!> \brief Input parameters related to a single contact.
45!> \author Sergey Chulkov
46! **************************************************************************************************
48 !> atoms belonging to bulk and screening regions
49 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist_bulk, atomlist_screening
50 !> atoms belonging to the primary and secondary bulk unit cells
51 TYPE(negf_allocatable_ivector), ALLOCATABLE, &
52 DIMENSION(:) :: atomlist_cell
53 !> index of the sub_force_env which should be used for bulk calculation
54 INTEGER :: force_env_index = -1
55 !> contact Fermi level needs to be computed
56 LOGICAL :: compute_fermi_level = .false.
57 !> to refine contact Fermi level using NEGF
58 LOGICAL :: refine_fermi_level = .false.
59 !> to shift energies to common zero level
60 LOGICAL :: shift_fermi_level = .false.
61 !> to read/write H and S from/to file
62 LOGICAL :: read_write_hs = .false.
63 !> if restart from files is really done
64 LOGICAL :: is_restart = .false.
65 !> Fermi level or starting Fermi level
66 REAL(kind=dp) :: fermi_level = -1.0_dp
67 !> Fermi level shifted to the common zero-energy level
68 REAL(kind=dp) :: fermi_level_shifted = -1.0_dp
69 !> temperature [in a.u.]
70 REAL(kind=dp) :: temperature = -1.0_dp
71 !> applied electric potential
72 REAL(kind=dp) :: v_external = 0.0_dp
74
75! **************************************************************************************************
76!> \brief Input parameters related to the NEGF run.
77!> \author Sergey Chulkov
78! **************************************************************************************************
80 !> input options for every contact
81 TYPE(negf_control_contact_type), ALLOCATABLE, &
82 DIMENSION(:) :: contacts
83 !> atoms belonging to the scattering region
84 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist_s
85 !> atoms belonging to the scattering region as well as atoms belonging to
86 !> screening regions of all the contacts
87 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist_s_screening
88 !> to read/write H and S from/to file
89 LOGICAL :: read_write_hs = .false.
90 !> to update the atomic Hamiltonian during NEGF self-consistent cycle
91 LOGICAL :: update_hs = .false.
92 !> if dft of entire system is done
93 LOGICAL :: is_dft_entire = .false.
94 !> if restart from files is really done
95 LOGICAL :: is_restart = .false.
96 !> the common restart file projectname-negf.restart is written if any of is_restart is .TRUE.
97 LOGICAL :: write_common_restart_file = .false.
98 !> do not keep contact self-energy matrices
99 LOGICAL :: disable_cache = .false.
100 !> convergence criteria for adaptive integration methods
101 REAL(kind=dp) :: conv_density = -1.0_dp
102 !> convergence criteria for iterative Lopez-Sancho algorithm
103 REAL(kind=dp) :: conv_green = -1.0_dp
104 !> convergence criteria for self-consistent iterations
105 REAL(kind=dp) :: conv_scf = -1.0_dp
106 !> accuracy in mapping atoms between different force environments
107 REAL(kind=dp) :: eps_geometry = -1.0_dp
108 !> applied bias [in a.u.]
109 REAL(kind=dp) :: v_bias = -1.0_dp
110 !> integration lower bound [in a.u.]
111 REAL(kind=dp) :: energy_lbound = -1.0_dp
112 !> infinitesimal offset along the imaginary axis [in a.u.]
113 REAL(kind=dp) :: eta = -1.0_dp
114 !> initial guess to determine the actual Fermi level of bulk contacts [in a.u.]
115 REAL(kind=dp) :: homo_lumo_gap = -1.0_dp
116 !> number of residuals (poles of the Fermi function)
117 INTEGER :: delta_npoles = -1
118 !> offset along the x-axis away from the poles of the Fermi function [in units of kT]
119 INTEGER :: gamma_kt = -1
120 !> integration method
121 INTEGER :: integr_method = -1
122 !> minimal number of grid points along the closed contour
123 INTEGER :: integr_min_points = -1
124 !> maximal number of grid points along the closed contour
125 INTEGER :: integr_max_points = -1
126 !> maximal number of SCF iterations
127 INTEGER :: max_scf = -1
128 !> minimal number of MPI processes to be used to compute Green's function per energy point
129 INTEGER :: nprocs = -1
130 !> shift in Hartree potential [in a.u.]
131 REAL(kind=dp) :: v_shift = -1.0_dp
132 !> initial offset to determine the correct shift in Hartree potential [in a.u.]
133 REAL(kind=dp) :: v_shift_offset = -1.0_dp
134 !> maximal number of iteration to determine the shift in Hartree potential
135 INTEGER :: v_shift_maxiters = -1
136 END TYPE negf_control_type
137
138 PRIVATE :: read_negf_atomlist
139
140CONTAINS
141
142! **************************************************************************************************
143!> \brief allocate control options for Non-equilibrium Green's Function calculation
144!> \param negf_control an object to create
145!> \par History
146!> * 02.2017 created [Sergey Chulkov]
147! **************************************************************************************************
148 SUBROUTINE negf_control_create(negf_control)
149 TYPE(negf_control_type), POINTER :: negf_control
150
151 CHARACTER(len=*), PARAMETER :: routinen = 'negf_control_create'
152
153 INTEGER :: handle
154
155 cpassert(.NOT. ASSOCIATED(negf_control))
156 CALL timeset(routinen, handle)
157
158 ALLOCATE (negf_control)
159
160 CALL timestop(handle)
161 END SUBROUTINE negf_control_create
162
163! **************************************************************************************************
164!> \brief release memory allocated for NEGF control options
165!> \param negf_control an object to release
166!> \par History
167!> * 02.2017 created [Sergey Chulkov]
168! **************************************************************************************************
169 SUBROUTINE negf_control_release(negf_control)
170 TYPE(negf_control_type), POINTER :: negf_control
171
172 CHARACTER(len=*), PARAMETER :: routinen = 'negf_control_release'
173
174 INTEGER :: handle, i, j
175
176 CALL timeset(routinen, handle)
177
178 IF (ASSOCIATED(negf_control)) THEN
179 IF (ALLOCATED(negf_control%atomlist_S)) DEALLOCATE (negf_control%atomlist_S)
180 IF (ALLOCATED(negf_control%atomlist_S_screening)) DEALLOCATE (negf_control%atomlist_S_screening)
181
182 IF (ALLOCATED(negf_control%contacts)) THEN
183 DO i = SIZE(negf_control%contacts), 1, -1
184 IF (ALLOCATED(negf_control%contacts(i)%atomlist_bulk)) &
185 DEALLOCATE (negf_control%contacts(i)%atomlist_bulk)
186
187 IF (ALLOCATED(negf_control%contacts(i)%atomlist_screening)) &
188 DEALLOCATE (negf_control%contacts(i)%atomlist_screening)
189
190 IF (ALLOCATED(negf_control%contacts(i)%atomlist_cell)) THEN
191 DO j = SIZE(negf_control%contacts(i)%atomlist_cell), 1, -1
192 IF (ALLOCATED(negf_control%contacts(i)%atomlist_cell(j)%vector)) &
193 DEALLOCATE (negf_control%contacts(i)%atomlist_cell(j)%vector)
194 END DO
195 DEALLOCATE (negf_control%contacts(i)%atomlist_cell)
196 END IF
197 END DO
198
199 DEALLOCATE (negf_control%contacts)
200 END IF
201
202 DEALLOCATE (negf_control)
203 END IF
204
205 CALL timestop(handle)
206 END SUBROUTINE negf_control_release
207
208! **************************************************************************************************
209!> \brief Read NEGF input parameters.
210!> \param negf_control NEGF control parameters
211!> \param input root input section
212!> \param subsys subsystem environment
213! **************************************************************************************************
214 SUBROUTINE read_negf_control(negf_control, input, subsys)
215 TYPE(negf_control_type), POINTER :: negf_control
216 TYPE(section_vals_type), POINTER :: input
217 TYPE(cp_subsys_type), POINTER :: subsys
218
219 CHARACTER(len=*), PARAMETER :: routinen = 'read_negf_control'
220
221 CHARACTER(len=default_string_length) :: contact_id_str, eta_current_str, eta_max_str, &
222 npoles_current_str, npoles_min_str, temp_current_str, temp_min_str
223 INTEGER :: delta_npoles_min, handle, i2_rep, i_rep, &
224 n2_rep, n_rep, natoms_current, &
225 natoms_total, run_type
226 INTEGER, ALLOCATABLE, DIMENSION(:) :: inds
227 LOGICAL :: do_negf, is_explicit
228 REAL(kind=dp) :: eta_max, temp_current, temp_min
229 TYPE(section_vals_type), POINTER :: cell_section, contact_section, &
230 negf_section, region_section, &
231 subsection
232
233 CALL timeset(routinen, handle)
234
235 CALL section_vals_val_get(input, "GLOBAL%RUN_TYPE", i_val=run_type)
236 do_negf = run_type == negf_run
237
238 negf_section => section_vals_get_subs_vals(input, "NEGF")
239
240 contact_section => section_vals_get_subs_vals(negf_section, "CONTACT")
241 CALL section_vals_get(contact_section, n_repetition=n_rep, explicit=is_explicit)
242 IF ((.NOT. is_explicit) .AND. do_negf) THEN
243 CALL cp_abort(__location__, &
244 "At least one contact is needed for NEGF calculation.")
245 END IF
246
247 ALLOCATE (negf_control%contacts(n_rep))
248 DO i_rep = 1, n_rep
249 region_section => section_vals_get_subs_vals(contact_section, "SCREENING_REGION", i_rep_section=i_rep)
250 CALL section_vals_get(region_section, explicit=is_explicit)
251
252 IF ((.NOT. is_explicit) .AND. do_negf) THEN
253 WRITE (contact_id_str, '(I11)') i_rep
254 CALL cp_abort(__location__, &
255 "The screening region must be defined for the contact "//trim(adjustl(contact_id_str))//".")
256 END IF
257
258 IF (is_explicit) THEN
259 CALL read_negf_atomlist(negf_control%contacts(i_rep)%atomlist_screening, region_section, 1, subsys)
260 END IF
261
262 region_section => section_vals_get_subs_vals(contact_section, "BULK_REGION", i_rep_section=i_rep)
263
264 CALL section_vals_get(region_section, explicit=is_explicit)
265
266 IF ((.NOT. is_explicit) .AND. do_negf) THEN
267 WRITE (contact_id_str, '(I11)') i_rep
268 CALL cp_abort(__location__, &
269 "The bulk region must be defined for the contact "//trim(adjustl(contact_id_str))//".")
270 END IF
271
272 IF (is_explicit) THEN
273 CALL read_negf_atomlist(negf_control%contacts(i_rep)%atomlist_bulk, region_section, 1, subsys)
274 END IF
275
276 CALL section_vals_val_get(contact_section, "FORCE_EVAL_SECTION", &
277 i_val=negf_control%contacts(i_rep)%force_env_index, &
278 i_rep_section=i_rep)
279
280 cell_section => section_vals_get_subs_vals(region_section, "CELL")
281 CALL section_vals_get(cell_section, n_repetition=n2_rep, explicit=is_explicit)
282
283 IF (((.NOT. is_explicit) .OR. n2_rep /= 2) .AND. negf_control%contacts(i_rep)%force_env_index <= 0 .AND. do_negf) THEN
284 WRITE (contact_id_str, '(I11)') i_rep
285 CALL cp_abort(__location__, &
286 "You must either provide indices of atoms belonging to two adjacent bulk unit cells "// &
287 "(BULK_REGION/CELL) for the contact, or the index of the FORCE_EVAL section (FORCE_EVAL_SECTION) "// &
288 "which will be used to construct Kohn-Sham matrix for the bulk contact "// &
289 trim(adjustl(contact_id_str))//".")
290 END IF
291
292 IF (is_explicit .AND. n2_rep > 0) THEN
293 ALLOCATE (negf_control%contacts(i_rep)%atomlist_cell(n2_rep))
294
295 DO i2_rep = 1, n2_rep
296 CALL read_negf_atomlist(negf_control%contacts(i_rep)%atomlist_cell(i2_rep)%vector, cell_section, i2_rep, subsys)
297 END DO
298 END IF
299
300 CALL section_vals_val_get(contact_section, "REFINE_FERMI_LEVEL", &
301 l_val=negf_control%contacts(i_rep)%refine_fermi_level, &
302 i_rep_section=i_rep)
303
304 CALL section_vals_val_get(contact_section, "FERMI_LEVEL", &
305 r_val=negf_control%contacts(i_rep)%fermi_level, &
306 i_rep_section=i_rep, explicit=is_explicit)
307 IF (.NOT. is_explicit) negf_control%contacts(i_rep)%refine_fermi_level = .false.
308 negf_control%contacts(i_rep)%compute_fermi_level = (.NOT. is_explicit) .OR. &
309 negf_control%contacts(i_rep)%refine_fermi_level
310
311 CALL section_vals_val_get(contact_section, "FERMI_LEVEL_SHIFTED", &
312 r_val=negf_control%contacts(i_rep)%fermi_level_shifted, &
313 i_rep_section=i_rep, explicit=is_explicit)
314 IF (is_explicit) negf_control%contacts(i_rep)%shift_fermi_level = .true.
315
316 CALL section_vals_val_get(contact_section, "TEMPERATURE", &
317 r_val=negf_control%contacts(i_rep)%temperature, &
318 i_rep_section=i_rep)
319 IF (negf_control%contacts(i_rep)%temperature <= 0.0_dp) THEN
320 CALL cp_abort(__location__, "Electronic temperature must be > 0")
321 END IF
322
323 CALL section_vals_val_get(contact_section, "ELECTRIC_POTENTIAL", &
324 r_val=negf_control%contacts(i_rep)%v_external, &
325 i_rep_section=i_rep)
326
327 subsection => section_vals_get_subs_vals(contact_section, "RESTART", i_rep_section=i_rep)
328
329 CALL section_vals_val_get(subsection, "READ_WRITE_HS", &
330 l_val=negf_control%contacts(i_rep)%read_write_HS, &
331 explicit=is_explicit)
332 IF (is_explicit) negf_control%contacts(i_rep)%read_write_HS = .true.
333
334 END DO
335
336 region_section => section_vals_get_subs_vals(negf_section, "SCATTERING_REGION")
337 CALL section_vals_get(region_section, explicit=is_explicit)
338 IF (is_explicit) THEN
339 CALL read_negf_atomlist(negf_control%atomlist_S, region_section, 1, subsys)
340 END IF
341
342 subsection => section_vals_get_subs_vals(negf_section, "SCATTERING_REGION%RESTART")
343 CALL section_vals_val_get(subsection, "READ_WRITE_HS", &
344 l_val=negf_control%read_write_HS, &
345 explicit=is_explicit)
346 IF (is_explicit) negf_control%read_write_HS = .true.
347
348 CALL section_vals_val_get(negf_section, "DISABLE_CACHE", l_val=negf_control%disable_cache)
349
350 CALL section_vals_val_get(negf_section, "EPS_DENSITY", r_val=negf_control%conv_density)
351 CALL section_vals_val_get(negf_section, "EPS_GREEN", r_val=negf_control%conv_green)
352 CALL section_vals_val_get(negf_section, "EPS_SCF", r_val=negf_control%conv_scf)
353
354 CALL section_vals_val_get(negf_section, "EPS_GEO", r_val=negf_control%eps_geometry)
355
356 CALL section_vals_val_get(negf_section, "ENERGY_LBOUND", r_val=negf_control%energy_lbound)
357 CALL section_vals_val_get(negf_section, "ETA", r_val=negf_control%eta)
358 CALL section_vals_val_get(negf_section, "HOMO_LUMO_GAP", r_val=negf_control%homo_lumo_gap)
359 CALL section_vals_val_get(negf_section, "DELTA_NPOLES", i_val=negf_control%delta_npoles)
360 CALL section_vals_val_get(negf_section, "GAMMA_KT", i_val=negf_control%gamma_kT)
361
362 CALL section_vals_val_get(negf_section, "INTEGRATION_METHOD", i_val=negf_control%integr_method)
363 CALL section_vals_val_get(negf_section, "INTEGRATION_MIN_POINTS", i_val=negf_control%integr_min_points)
364 CALL section_vals_val_get(negf_section, "INTEGRATION_MAX_POINTS", i_val=negf_control%integr_max_points)
365
366 IF (negf_control%integr_max_points < negf_control%integr_min_points) &
367 negf_control%integr_max_points = negf_control%integr_min_points
368
369 CALL section_vals_val_get(negf_section, "MAX_SCF", i_val=negf_control%max_scf)
370
371 CALL section_vals_val_get(negf_section, "NPROC_POINT", i_val=negf_control%nprocs)
372
373 CALL section_vals_val_get(negf_section, "V_SHIFT", r_val=negf_control%v_shift)
374 CALL section_vals_val_get(negf_section, "V_SHIFT_OFFSET", r_val=negf_control%v_shift_offset)
375 CALL section_vals_val_get(negf_section, "V_SHIFT_MAX_ITERS", i_val=negf_control%v_shift_maxiters)
376
377 CALL section_vals_val_get(negf_section, "UPDATE_HS", l_val=negf_control%update_HS)
378
379 ! check consistency
380 IF (negf_control%eta < 0.0_dp) THEN
381 CALL cp_abort(__location__, "ETA must be >= 0")
382 END IF
383
384 IF (n_rep > 0) THEN
385 delta_npoles_min = nint(0.5_dp*(negf_control%eta/(pi*maxval(negf_control%contacts(:)%temperature)) + 1.0_dp))
386 ELSE
387 delta_npoles_min = 1
388 END IF
389
390 IF (negf_control%delta_npoles < delta_npoles_min) THEN
391 IF (n_rep > 0) THEN
392 eta_max = real(2*negf_control%delta_npoles - 1, kind=dp)*pi*maxval(negf_control%contacts(:)%temperature)
393 temp_current = maxval(negf_control%contacts(:)%temperature)*kelvin
394 temp_min = negf_control%eta/(pi*real(2*negf_control%delta_npoles - 1, kind=dp))*kelvin
395
396 WRITE (eta_current_str, '(ES11.4E2)') negf_control%eta
397 WRITE (eta_max_str, '(ES11.4E2)') eta_max
398 WRITE (npoles_current_str, '(I11)') negf_control%delta_npoles
399 WRITE (npoles_min_str, '(I11)') delta_npoles_min
400 WRITE (temp_current_str, '(F11.3)') temp_current
401 WRITE (temp_min_str, '(F11.3)') temp_min
402
403 CALL cp_abort(__location__, &
404 "Parameter DELTA_NPOLES must be at least "//trim(adjustl(npoles_min_str))// &
405 " (instead of "//trim(adjustl(npoles_current_str))// &
406 ") for given TEMPERATURE ("//trim(adjustl(temp_current_str))// &
407 " K) and ETA ("//trim(adjustl(eta_current_str))// &
408 "). Alternatively you can increase TEMPERATURE above "//trim(adjustl(temp_min_str))// &
409 " K, or decrease ETA below "//trim(adjustl(eta_max_str))// &
410 ". Please keep in mind that very tight ETA may result in dramatical precision loss"// &
411 " due to inversion of ill-conditioned matrices.")
412 ELSE
413 ! no leads have been defined, so calculation will abort anyway
414 negf_control%delta_npoles = delta_npoles_min
415 END IF
416 END IF
417
418 ! expand scattering region by adding atoms from contact screening regions
419 n_rep = SIZE(negf_control%contacts)
420 IF (ALLOCATED(negf_control%atomlist_S)) THEN
421 natoms_total = SIZE(negf_control%atomlist_S)
422 ELSE
423 natoms_total = 0
424 END IF
425
426 DO i_rep = 1, n_rep
427 IF (ALLOCATED(negf_control%contacts(i_rep)%atomlist_screening)) THEN
428 IF (ALLOCATED(negf_control%contacts(i_rep)%atomlist_screening)) &
429 natoms_total = natoms_total + SIZE(negf_control%contacts(i_rep)%atomlist_screening)
430 END IF
431 END DO
432
433 IF (natoms_total > 0) THEN
434 ALLOCATE (negf_control%atomlist_S_screening(natoms_total))
435 IF (ALLOCATED(negf_control%atomlist_S)) THEN
436 natoms_total = SIZE(negf_control%atomlist_S)
437 negf_control%atomlist_S_screening(1:natoms_total) = negf_control%atomlist_S(1:natoms_total)
438 ELSE
439 natoms_total = 0
440 END IF
441
442 DO i_rep = 1, n_rep
443 IF (ALLOCATED(negf_control%contacts(i_rep)%atomlist_screening)) THEN
444 natoms_current = SIZE(negf_control%contacts(i_rep)%atomlist_screening)
445
446 negf_control%atomlist_S_screening(natoms_total + 1:natoms_total + natoms_current) = &
447 negf_control%contacts(i_rep)%atomlist_screening(1:natoms_current)
448
449 natoms_total = natoms_total + natoms_current
450 END IF
451 END DO
452
453 ! sort and remove duplicated atoms
454 ALLOCATE (inds(natoms_total))
455 CALL sort(negf_control%atomlist_S_screening, natoms_total, inds)
456 DEALLOCATE (inds)
457
458 natoms_current = 1
459 DO i_rep = natoms_current + 1, natoms_total
460 IF (negf_control%atomlist_S_screening(i_rep) /= negf_control%atomlist_S_screening(natoms_current)) THEN
461 natoms_current = natoms_current + 1
462 negf_control%atomlist_S_screening(natoms_current) = negf_control%atomlist_S_screening(i_rep)
463 END IF
464 END DO
465
466 IF (natoms_current < natoms_total) THEN
467 CALL move_alloc(negf_control%atomlist_S_screening, inds)
468
469 ALLOCATE (negf_control%atomlist_S_screening(natoms_current))
470 negf_control%atomlist_S_screening(1:natoms_current) = inds(1:natoms_current)
471 DEALLOCATE (inds)
472 END IF
473 END IF
474
475 IF (do_negf .AND. SIZE(negf_control%contacts) > 2) THEN
476 CALL cp_abort(__location__, &
477 "General case (> 2 contacts) has not been implemented yet")
478 END IF
479
480 CALL timestop(handle)
481 END SUBROUTINE read_negf_control
482
483! **************************************************************************************************
484!> \brief Read region-specific list of atoms.
485!> \param atomlist list of atoms
486!> \param input_section input section which contains 'LIST' and 'MOLNAME' keywords
487!> \param i_rep_section repetition index of the input_section
488!> \param subsys subsystem environment
489! **************************************************************************************************
490 SUBROUTINE read_negf_atomlist(atomlist, input_section, i_rep_section, subsys)
491 INTEGER, ALLOCATABLE, DIMENSION(:), INTENT(out) :: atomlist
492 TYPE(section_vals_type), POINTER :: input_section
493 INTEGER, INTENT(in) :: i_rep_section
494 TYPE(cp_subsys_type), POINTER :: subsys
495
496 CHARACTER(len=*), PARAMETER :: routinen = 'read_negf_atomlist'
497
498 CHARACTER(len=default_string_length) :: index_str, natoms_str
499 CHARACTER(len=default_string_length), &
500 DIMENSION(:), POINTER :: cptr
501 INTEGER :: first_atom, handle, iatom, ikind, imol, iname, irep, last_atom, natoms_current, &
502 natoms_max, natoms_total, nkinds, nmols, nnames, nrep_list, nrep_molname
503 INTEGER, ALLOCATABLE, DIMENSION(:) :: inds
504 INTEGER, DIMENSION(:), POINTER :: iptr
505 LOGICAL :: is_list, is_molname
506 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
507 TYPE(molecule_kind_type), POINTER :: molecule_kind
508 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
509 TYPE(molecule_type), POINTER :: molecule
510 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
511
512 CALL timeset(routinen, handle)
513
514 CALL cp_subsys_get(subsys, particle_set=particle_set, &
515 molecule_set=molecule_set, &
516 molecule_kind_set=molecule_kind_set)
517 natoms_max = SIZE(particle_set)
518 nkinds = SIZE(molecule_kind_set)
519
520 CALL section_vals_val_get(input_section, "LIST", i_rep_section=i_rep_section, &
521 n_rep_val=nrep_list, explicit=is_list)
522 CALL section_vals_val_get(input_section, "MOLNAME", i_rep_section=i_rep_section, &
523 n_rep_val=nrep_molname, explicit=is_molname)
524
525 ! compute the number of atoms in the NEGF region, and check the validity of given atomic indices
526 natoms_total = 0
527 IF (is_list .AND. nrep_list > 0) THEN
528 DO irep = 1, nrep_list
529 CALL section_vals_val_get(input_section, "LIST", i_rep_section=i_rep_section, i_rep_val=irep, i_vals=iptr)
530
531 natoms_current = SIZE(iptr)
532 DO iatom = 1, natoms_current
533 IF (iptr(iatom) > natoms_max) THEN
534 CALL integer_to_string(iptr(iatom), index_str)
535 CALL integer_to_string(natoms_max, natoms_str)
536 CALL cp_abort(__location__, &
537 "NEGF: Atomic index "//trim(index_str)//" given in section "// &
538 trim(input_section%section%name)//" exceeds the maximum number of atoms ("// &
539 trim(natoms_str)//").")
540 END IF
541 END DO
542
543 natoms_total = natoms_total + natoms_current
544 END DO
545 END IF
546
547 IF (is_molname .AND. nrep_molname > 0) THEN
548 DO irep = 1, nrep_molname
549 CALL section_vals_val_get(input_section, "MOLNAME", i_rep_section=i_rep_section, i_rep_val=irep, c_vals=cptr)
550 nnames = SIZE(cptr)
551
552 DO iname = 1, nnames
553 DO ikind = 1, nkinds
554 IF (molecule_kind_set(ikind)%name == cptr(iname)) EXIT
555 END DO
556
557 IF (ikind <= nkinds) THEN
558 molecule_kind => molecule_kind_set(ikind)
559 CALL get_molecule_kind(molecule_kind, nmolecule=nmols, molecule_list=iptr)
560
561 DO imol = 1, nmols
562 molecule => molecule_set(iptr(imol))
563 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
564 natoms_current = last_atom - first_atom + 1
565 natoms_total = natoms_total + natoms_current
566 END DO
567 ELSE
568 CALL cp_abort(__location__, &
569 "NEGF: A molecule with the name '"//trim(cptr(iname))//"' mentioned in section "// &
570 trim(input_section%section%name)//" has not been defined. Note that names are case sensitive.")
571 END IF
572 END DO
573 END DO
574 END IF
575
576 ! create a list of atomic indices
577 IF (natoms_total > 0) THEN
578 ALLOCATE (atomlist(natoms_total))
579
580 natoms_total = 0
581
582 IF (is_list .AND. nrep_list > 0) THEN
583 DO irep = 1, nrep_list
584 CALL section_vals_val_get(input_section, "LIST", i_rep_section=i_rep_section, i_rep_val=irep, i_vals=iptr)
585
586 natoms_current = SIZE(iptr)
587 atomlist(natoms_total + 1:natoms_total + natoms_current) = iptr(1:natoms_current)
588 natoms_total = natoms_total + natoms_current
589 END DO
590 END IF
591
592 IF (is_molname .AND. nrep_molname > 0) THEN
593 DO irep = 1, nrep_molname
594 CALL section_vals_val_get(input_section, "MOLNAME", i_rep_section=i_rep_section, i_rep_val=irep, c_vals=cptr)
595 nnames = SIZE(cptr)
596
597 DO iname = 1, nnames
598 DO ikind = 1, nkinds
599 IF (molecule_kind_set(ikind)%name == cptr(iname)) EXIT
600 END DO
601
602 IF (ikind <= nkinds) THEN
603 molecule_kind => molecule_kind_set(ikind)
604 CALL get_molecule_kind(molecule_kind, nmolecule=nmols, molecule_list=iptr)
605
606 DO imol = 1, nmols
607 molecule => molecule_set(iptr(imol))
608 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
609
610 DO natoms_current = first_atom, last_atom
611 natoms_total = natoms_total + 1
612 atomlist(natoms_total) = natoms_current
613 END DO
614 END DO
615 END IF
616 END DO
617 END DO
618 END IF
619
620 ! remove duplicated atoms
621 ALLOCATE (inds(natoms_total))
622 CALL sort(atomlist, natoms_total, inds)
623 DEALLOCATE (inds)
624
625 natoms_current = 1
626 DO iatom = natoms_current + 1, natoms_total
627 IF (atomlist(iatom) /= atomlist(natoms_current)) THEN
628 natoms_current = natoms_current + 1
629 atomlist(natoms_current) = atomlist(iatom)
630 END IF
631 END DO
632
633 IF (natoms_current < natoms_total) THEN
634 CALL move_alloc(atomlist, inds)
635
636 ALLOCATE (atomlist(natoms_current))
637 atomlist(1:natoms_current) = inds(1:natoms_current)
638 DEALLOCATE (inds)
639 END IF
640 END IF
641
642 CALL timestop(handle)
643 END SUBROUTINE read_negf_atomlist
644END MODULE negf_control_types
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell)
returns information about various attributes of the given subsys
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public negf_run
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_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
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
integer, parameter, public default_string_length
Definition kinds.F:57
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Define the molecule kind structure types and the corresponding functionality.
subroutine, public get_molecule_kind(molecule_kind, atom_list, bond_list, bend_list, ub_list, impr_list, opbend_list, colv_list, fixd_list, g3x3_list, g4x6_list, vsite_list, torsion_list, shell_list, name, mass, charge, kind_number, natom, nbend, nbond, nub, nimpr, nopbend, nconstraint, nconstraint_fixd, nfixd, ncolv, ng3x3, ng4x6, nvsite, nfixd_restraint, ng3x3_restraint, ng4x6_restraint, nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion, molecule_list, nelectron, nelectron_alpha, nelectron_beta, bond_kind_set, bend_kind_set, ub_kind_set, impr_kind_set, opbend_kind_set, torsion_kind_set, molname_generated)
Get informations about a molecule kind.
Define the data structure for the molecule information.
subroutine, public get_molecule(molecule, molecule_kind, lmi, lci, lg3x3, lg4x6, lcolv, first_atom, last_atom, first_shell, last_shell)
Get components from a molecule data set.
Allocatable vectors for NEGF based quantum transport calculations.
Input control types for NEGF based quantum transport calculations.
subroutine, public negf_control_create(negf_control)
allocate control options for Non-equilibrium Green's Function calculation
subroutine, public read_negf_control(negf_control, input, subsys)
Read NEGF input parameters.
subroutine, public negf_control_release(negf_control)
release memory allocated for NEGF control options
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public kelvin
Definition physcon.F:165
Utilities for string manipulations.
subroutine, public integer_to_string(inumber, string)
Converts an integer number to a string. The WRITE statement will return an error message,...
All kind of helpful little routines.
Definition util.F:14
represents a system: atoms, molecules, their pos,vel,...
Allocatable 1-D integer vector.
Input parameters related to a single contact.
Input parameters related to the NEGF run.