(git:07c9450)
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-2025 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 !> Fermi level or starting Fermi level
62 REAL(kind=dp) :: fermi_level = -1.0_dp
63 !> Fermi level shifted to the common zero-energy level
64 REAL(kind=dp) :: fermi_level_shifted = -1.0_dp
65 !> temperature [in a.u.]
66 REAL(kind=dp) :: temperature = -1.0_dp
67 !> applied electric potential
68 REAL(kind=dp) :: v_external = 0.0_dp
70
71! **************************************************************************************************
72!> \brief Input parameters related to the NEGF run.
73!> \author Sergey Chulkov
74! **************************************************************************************************
76 !> input options for every contact
77 TYPE(negf_control_contact_type), ALLOCATABLE, &
78 DIMENSION(:) :: contacts
79 !> atoms belonging to the scattering region
80 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist_s
81 !> atoms belonging to the scattering region as well as atoms belonging to
82 !> screening regions of all the contacts
83 INTEGER, ALLOCATABLE, DIMENSION(:) :: atomlist_s_screening
84 !> do not keep contact self-energy matrices
85 LOGICAL :: disable_cache = .false.
86 !> convergence criteria for adaptive integration methods
87 REAL(kind=dp) :: conv_density = -1.0_dp
88 !> convergence criteria for iterative Lopez-Sancho algorithm
89 REAL(kind=dp) :: conv_green = -1.0_dp
90 !> convergence criteria for self-consistent iterations
91 REAL(kind=dp) :: conv_scf = -1.0_dp
92 !> accuracy in mapping atoms between different force environments
93 REAL(kind=dp) :: eps_geometry = -1.0_dp
94 !> applied bias [in a.u.]
95 REAL(kind=dp) :: v_bias = -1.0_dp
96 !> integration lower bound [in a.u.]
97 REAL(kind=dp) :: energy_lbound = -1.0_dp
98 !> infinitesimal offset along the imaginary axis [in a.u.]
99 REAL(kind=dp) :: eta = -1.0_dp
100 !> initial guess to determine the actual Fermi level of bulk contacts [in a.u.]
101 REAL(kind=dp) :: homo_lumo_gap = -1.0_dp
102 !> number of residuals (poles of the Fermi function)
103 INTEGER :: delta_npoles = -1
104 !> offset along the x-axis away from the poles of the Fermi function [in units of kT]
105 INTEGER :: gamma_kt = -1
106 !> integration method
107 INTEGER :: integr_method = -1
108 !> minimal number of grid points along the closed contour
109 INTEGER :: integr_min_points = -1
110 !> maximal number of grid points along the closed contour
111 INTEGER :: integr_max_points = -1
112 !> maximal number of SCF iterations
113 INTEGER :: max_scf = -1
114 !> minimal number of MPI processes to be used to compute Green's function per energy point
115 INTEGER :: nprocs = -1
116 !> shift in Hartree potential [in a.u.]
117 REAL(kind=dp) :: v_shift = -1.0_dp
118 !> initial offset to determine the correct shift in Hartree potential [in a.u.]
119 REAL(kind=dp) :: v_shift_offset = -1.0_dp
120 !> maximal number of iteration to determine the shift in Hartree potential
121 INTEGER :: v_shift_maxiters = -1
122 END TYPE negf_control_type
123
124 PRIVATE :: read_negf_atomlist
125
126CONTAINS
127
128! **************************************************************************************************
129!> \brief allocate control options for Non-equilibrium Green's Function calculation
130!> \param negf_control an object to create
131!> \par History
132!> * 02.2017 created [Sergey Chulkov]
133! **************************************************************************************************
134 SUBROUTINE negf_control_create(negf_control)
135 TYPE(negf_control_type), POINTER :: negf_control
136
137 CHARACTER(len=*), PARAMETER :: routinen = 'negf_control_create'
138
139 INTEGER :: handle
140
141 cpassert(.NOT. ASSOCIATED(negf_control))
142 CALL timeset(routinen, handle)
143
144 ALLOCATE (negf_control)
145
146 CALL timestop(handle)
147 END SUBROUTINE negf_control_create
148
149! **************************************************************************************************
150!> \brief release memory allocated for NEGF control options
151!> \param negf_control an object to release
152!> \par History
153!> * 02.2017 created [Sergey Chulkov]
154! **************************************************************************************************
155 SUBROUTINE negf_control_release(negf_control)
156 TYPE(negf_control_type), POINTER :: negf_control
157
158 CHARACTER(len=*), PARAMETER :: routinen = 'negf_control_release'
159
160 INTEGER :: handle, i, j
161
162 CALL timeset(routinen, handle)
163
164 IF (ASSOCIATED(negf_control)) THEN
165 IF (ALLOCATED(negf_control%atomlist_S)) DEALLOCATE (negf_control%atomlist_S)
166 IF (ALLOCATED(negf_control%atomlist_S_screening)) DEALLOCATE (negf_control%atomlist_S_screening)
167
168 IF (ALLOCATED(negf_control%contacts)) THEN
169 DO i = SIZE(negf_control%contacts), 1, -1
170 IF (ALLOCATED(negf_control%contacts(i)%atomlist_bulk)) &
171 DEALLOCATE (negf_control%contacts(i)%atomlist_bulk)
172
173 IF (ALLOCATED(negf_control%contacts(i)%atomlist_screening)) &
174 DEALLOCATE (negf_control%contacts(i)%atomlist_screening)
175
176 IF (ALLOCATED(negf_control%contacts(i)%atomlist_cell)) THEN
177 DO j = SIZE(negf_control%contacts(i)%atomlist_cell), 1, -1
178 IF (ALLOCATED(negf_control%contacts(i)%atomlist_cell(j)%vector)) &
179 DEALLOCATE (negf_control%contacts(i)%atomlist_cell(j)%vector)
180 END DO
181 DEALLOCATE (negf_control%contacts(i)%atomlist_cell)
182 END IF
183 END DO
184
185 DEALLOCATE (negf_control%contacts)
186 END IF
187
188 DEALLOCATE (negf_control)
189 END IF
190
191 CALL timestop(handle)
192 END SUBROUTINE negf_control_release
193
194! **************************************************************************************************
195!> \brief Read NEGF input parameters.
196!> \param negf_control NEGF control parameters
197!> \param input root input section
198!> \param subsys subsystem environment
199! **************************************************************************************************
200 SUBROUTINE read_negf_control(negf_control, input, subsys)
201 TYPE(negf_control_type), POINTER :: negf_control
202 TYPE(section_vals_type), POINTER :: input
203 TYPE(cp_subsys_type), POINTER :: subsys
204
205 CHARACTER(len=*), PARAMETER :: routinen = 'read_negf_control'
206
207 CHARACTER(len=default_string_length) :: contact_id_str, eta_current_str, eta_max_str, &
208 npoles_current_str, npoles_min_str, temp_current_str, temp_min_str
209 INTEGER :: delta_npoles_min, handle, i2_rep, i_rep, &
210 n2_rep, n_rep, natoms_current, &
211 natoms_total, run_type
212 INTEGER, ALLOCATABLE, DIMENSION(:) :: inds
213 LOGICAL :: do_negf, is_explicit
214 REAL(kind=dp) :: eta_max, temp_current, temp_min
215 TYPE(section_vals_type), POINTER :: cell_section, contact_section, &
216 negf_section, region_section
217
218 CALL timeset(routinen, handle)
219
220 CALL section_vals_val_get(input, "GLOBAL%RUN_TYPE", i_val=run_type)
221 do_negf = run_type == negf_run
222
223 negf_section => section_vals_get_subs_vals(input, "NEGF")
224
225 contact_section => section_vals_get_subs_vals(negf_section, "CONTACT")
226 CALL section_vals_get(contact_section, n_repetition=n_rep, explicit=is_explicit)
227 IF ((.NOT. is_explicit) .AND. do_negf) THEN
228 CALL cp_abort(__location__, &
229 "At least one contact is needed for NEGF calculation.")
230 END IF
231
232 ALLOCATE (negf_control%contacts(n_rep))
233 DO i_rep = 1, n_rep
234 region_section => section_vals_get_subs_vals(contact_section, "SCREENING_REGION", i_rep_section=i_rep)
235 CALL section_vals_get(region_section, explicit=is_explicit)
236
237 IF ((.NOT. is_explicit) .AND. do_negf) THEN
238 WRITE (contact_id_str, '(I11)') i_rep
239 CALL cp_abort(__location__, &
240 "The screening region must be defined for the contact "//trim(adjustl(contact_id_str))//".")
241 END IF
242
243 IF (is_explicit) THEN
244 CALL read_negf_atomlist(negf_control%contacts(i_rep)%atomlist_screening, region_section, 1, subsys)
245 END IF
246
247 region_section => section_vals_get_subs_vals(contact_section, "BULK_REGION", i_rep_section=i_rep)
248
249 CALL section_vals_get(region_section, explicit=is_explicit)
250
251 IF ((.NOT. is_explicit) .AND. do_negf) THEN
252 WRITE (contact_id_str, '(I11)') i_rep
253 CALL cp_abort(__location__, &
254 "The bulk region must be defined for the contact "//trim(adjustl(contact_id_str))//".")
255 END IF
256
257 IF (is_explicit) THEN
258 CALL read_negf_atomlist(negf_control%contacts(i_rep)%atomlist_bulk, region_section, 1, subsys)
259 END IF
260
261 CALL section_vals_val_get(contact_section, "FORCE_EVAL_SECTION", &
262 i_val=negf_control%contacts(i_rep)%force_env_index, &
263 i_rep_section=i_rep)
264
265 cell_section => section_vals_get_subs_vals(region_section, "CELL")
266 CALL section_vals_get(cell_section, n_repetition=n2_rep, explicit=is_explicit)
267
268 IF (((.NOT. is_explicit) .OR. n2_rep /= 2) .AND. negf_control%contacts(i_rep)%force_env_index <= 0 .AND. do_negf) THEN
269 WRITE (contact_id_str, '(I11)') i_rep
270 CALL cp_abort(__location__, &
271 "You must either provide indices of atoms belonging to two adjacent bulk unit cells "// &
272 "(BULK_REGION/CELL) for the contact, or the index of the FORCE_EVAL section (FORCE_EVAL_SECTION) "// &
273 "which will be used to construct Kohn-Sham matrix for the bulk contact "// &
274 trim(adjustl(contact_id_str))//".")
275 END IF
276
277 IF (is_explicit .AND. n2_rep > 0) THEN
278 ALLOCATE (negf_control%contacts(i_rep)%atomlist_cell(n2_rep))
279
280 DO i2_rep = 1, n2_rep
281 CALL read_negf_atomlist(negf_control%contacts(i_rep)%atomlist_cell(i2_rep)%vector, cell_section, i2_rep, subsys)
282 END DO
283 END IF
284
285 CALL section_vals_val_get(contact_section, "REFINE_FERMI_LEVEL", &
286 l_val=negf_control%contacts(i_rep)%refine_fermi_level, &
287 i_rep_section=i_rep)
288
289 CALL section_vals_val_get(contact_section, "FERMI_LEVEL", &
290 r_val=negf_control%contacts(i_rep)%fermi_level, &
291 i_rep_section=i_rep, explicit=is_explicit)
292 IF (.NOT. is_explicit) negf_control%contacts(i_rep)%refine_fermi_level = .false.
293 negf_control%contacts(i_rep)%compute_fermi_level = (.NOT. is_explicit) .OR. &
294 negf_control%contacts(i_rep)%refine_fermi_level
295
296 CALL section_vals_val_get(contact_section, "FERMI_LEVEL_SHIFTED", &
297 r_val=negf_control%contacts(i_rep)%fermi_level_shifted, &
298 i_rep_section=i_rep, explicit=is_explicit)
299 IF (is_explicit) negf_control%contacts(i_rep)%shift_fermi_level = .true.
300
301 CALL section_vals_val_get(contact_section, "TEMPERATURE", &
302 r_val=negf_control%contacts(i_rep)%temperature, &
303 i_rep_section=i_rep)
304 IF (negf_control%contacts(i_rep)%temperature <= 0.0_dp) THEN
305 CALL cp_abort(__location__, "Electronic temperature must be > 0")
306 END IF
307
308 CALL section_vals_val_get(contact_section, "ELECTRIC_POTENTIAL", &
309 r_val=negf_control%contacts(i_rep)%v_external, &
310 i_rep_section=i_rep)
311 END DO
312
313 region_section => section_vals_get_subs_vals(negf_section, "SCATTERING_REGION")
314 CALL section_vals_get(region_section, explicit=is_explicit)
315 IF (is_explicit) THEN
316 CALL read_negf_atomlist(negf_control%atomlist_S, region_section, 1, subsys)
317 END IF
318
319 CALL section_vals_val_get(negf_section, "DISABLE_CACHE", l_val=negf_control%disable_cache)
320
321 CALL section_vals_val_get(negf_section, "EPS_DENSITY", r_val=negf_control%conv_density)
322 CALL section_vals_val_get(negf_section, "EPS_GREEN", r_val=negf_control%conv_green)
323 CALL section_vals_val_get(negf_section, "EPS_SCF", r_val=negf_control%conv_scf)
324
325 CALL section_vals_val_get(negf_section, "EPS_GEO", r_val=negf_control%eps_geometry)
326
327 CALL section_vals_val_get(negf_section, "ENERGY_LBOUND", r_val=negf_control%energy_lbound)
328 CALL section_vals_val_get(negf_section, "ETA", r_val=negf_control%eta)
329 CALL section_vals_val_get(negf_section, "HOMO_LUMO_GAP", r_val=negf_control%homo_lumo_gap)
330 CALL section_vals_val_get(negf_section, "DELTA_NPOLES", i_val=negf_control%delta_npoles)
331 CALL section_vals_val_get(negf_section, "GAMMA_KT", i_val=negf_control%gamma_kT)
332
333 CALL section_vals_val_get(negf_section, "INTEGRATION_METHOD", i_val=negf_control%integr_method)
334 CALL section_vals_val_get(negf_section, "INTEGRATION_MIN_POINTS", i_val=negf_control%integr_min_points)
335 CALL section_vals_val_get(negf_section, "INTEGRATION_MAX_POINTS", i_val=negf_control%integr_max_points)
336
337 IF (negf_control%integr_max_points < negf_control%integr_min_points) &
338 negf_control%integr_max_points = negf_control%integr_min_points
339
340 CALL section_vals_val_get(negf_section, "MAX_SCF", i_val=negf_control%max_scf)
341
342 CALL section_vals_val_get(negf_section, "NPROC_POINT", i_val=negf_control%nprocs)
343
344 CALL section_vals_val_get(negf_section, "V_SHIFT", r_val=negf_control%v_shift)
345 CALL section_vals_val_get(negf_section, "V_SHIFT_OFFSET", r_val=negf_control%v_shift_offset)
346 CALL section_vals_val_get(negf_section, "V_SHIFT_MAX_ITERS", i_val=negf_control%v_shift_maxiters)
347
348 ! check consistency
349 IF (negf_control%eta < 0.0_dp) THEN
350 CALL cp_abort(__location__, "ETA must be >= 0")
351 END IF
352
353 IF (n_rep > 0) THEN
354 delta_npoles_min = nint(0.5_dp*(negf_control%eta/(pi*maxval(negf_control%contacts(:)%temperature)) + 1.0_dp))
355 ELSE
356 delta_npoles_min = 1
357 END IF
358
359 IF (negf_control%delta_npoles < delta_npoles_min) THEN
360 IF (n_rep > 0) THEN
361 eta_max = real(2*negf_control%delta_npoles - 1, kind=dp)*pi*maxval(negf_control%contacts(:)%temperature)
362 temp_current = maxval(negf_control%contacts(:)%temperature)*kelvin
363 temp_min = negf_control%eta/(pi*real(2*negf_control%delta_npoles - 1, kind=dp))*kelvin
364
365 WRITE (eta_current_str, '(ES11.4E2)') negf_control%eta
366 WRITE (eta_max_str, '(ES11.4E2)') eta_max
367 WRITE (npoles_current_str, '(I11)') negf_control%delta_npoles
368 WRITE (npoles_min_str, '(I11)') delta_npoles_min
369 WRITE (temp_current_str, '(F11.3)') temp_current
370 WRITE (temp_min_str, '(F11.3)') temp_min
371
372 CALL cp_abort(__location__, &
373 "Parameter DELTA_NPOLES must be at least "//trim(adjustl(npoles_min_str))// &
374 " (instead of "//trim(adjustl(npoles_current_str))// &
375 ") for given TEMPERATURE ("//trim(adjustl(temp_current_str))// &
376 " K) and ETA ("//trim(adjustl(eta_current_str))// &
377 "). Alternatively you can increase TEMPERATURE above "//trim(adjustl(temp_min_str))// &
378 " K, or decrease ETA below "//trim(adjustl(eta_max_str))// &
379 ". Please keep in mind that very tight ETA may result in dramatical precision loss"// &
380 " due to inversion of ill-conditioned matrices.")
381 ELSE
382 ! no leads have been defined, so calculation will abort anyway
383 negf_control%delta_npoles = delta_npoles_min
384 END IF
385 END IF
386
387 ! expand scattering region by adding atoms from contact screening regions
388 n_rep = SIZE(negf_control%contacts)
389 IF (ALLOCATED(negf_control%atomlist_S)) THEN
390 natoms_total = SIZE(negf_control%atomlist_S)
391 ELSE
392 natoms_total = 0
393 END IF
394
395 DO i_rep = 1, n_rep
396 IF (ALLOCATED(negf_control%contacts(i_rep)%atomlist_screening)) THEN
397 IF (ALLOCATED(negf_control%contacts(i_rep)%atomlist_screening)) &
398 natoms_total = natoms_total + SIZE(negf_control%contacts(i_rep)%atomlist_screening)
399 END IF
400 END DO
401
402 IF (natoms_total > 0) THEN
403 ALLOCATE (negf_control%atomlist_S_screening(natoms_total))
404 IF (ALLOCATED(negf_control%atomlist_S)) THEN
405 natoms_total = SIZE(negf_control%atomlist_S)
406 negf_control%atomlist_S_screening(1:natoms_total) = negf_control%atomlist_S(1:natoms_total)
407 ELSE
408 natoms_total = 0
409 END IF
410
411 DO i_rep = 1, n_rep
412 IF (ALLOCATED(negf_control%contacts(i_rep)%atomlist_screening)) THEN
413 natoms_current = SIZE(negf_control%contacts(i_rep)%atomlist_screening)
414
415 negf_control%atomlist_S_screening(natoms_total + 1:natoms_total + natoms_current) = &
416 negf_control%contacts(i_rep)%atomlist_screening(1:natoms_current)
417
418 natoms_total = natoms_total + natoms_current
419 END IF
420 END DO
421
422 ! sort and remove duplicated atoms
423 ALLOCATE (inds(natoms_total))
424 CALL sort(negf_control%atomlist_S_screening, natoms_total, inds)
425 DEALLOCATE (inds)
426
427 natoms_current = 1
428 DO i_rep = natoms_current + 1, natoms_total
429 IF (negf_control%atomlist_S_screening(i_rep) /= negf_control%atomlist_S_screening(natoms_current)) THEN
430 natoms_current = natoms_current + 1
431 negf_control%atomlist_S_screening(natoms_current) = negf_control%atomlist_S_screening(i_rep)
432 END IF
433 END DO
434
435 IF (natoms_current < natoms_total) THEN
436 CALL move_alloc(negf_control%atomlist_S_screening, inds)
437
438 ALLOCATE (negf_control%atomlist_S_screening(natoms_current))
439 negf_control%atomlist_S_screening(1:natoms_current) = inds(1:natoms_current)
440 DEALLOCATE (inds)
441 END IF
442 END IF
443
444 IF (do_negf .AND. SIZE(negf_control%contacts) > 2) THEN
445 CALL cp_abort(__location__, &
446 "General case (> 2 contacts) has not been implemented yet")
447 END IF
448
449 CALL timestop(handle)
450 END SUBROUTINE read_negf_control
451
452! **************************************************************************************************
453!> \brief Read region-specific list of atoms.
454!> \param atomlist list of atoms
455!> \param input_section input section which contains 'LIST' and 'MOLNAME' keywords
456!> \param i_rep_section repetition index of the input_section
457!> \param subsys subsystem environment
458! **************************************************************************************************
459 SUBROUTINE read_negf_atomlist(atomlist, input_section, i_rep_section, subsys)
460 INTEGER, ALLOCATABLE, DIMENSION(:), INTENT(out) :: atomlist
461 TYPE(section_vals_type), POINTER :: input_section
462 INTEGER, INTENT(in) :: i_rep_section
463 TYPE(cp_subsys_type), POINTER :: subsys
464
465 CHARACTER(len=*), PARAMETER :: routinen = 'read_negf_atomlist'
466
467 CHARACTER(len=default_string_length) :: index_str, natoms_str
468 CHARACTER(len=default_string_length), &
469 DIMENSION(:), POINTER :: cptr
470 INTEGER :: first_atom, handle, iatom, ikind, imol, iname, irep, last_atom, natoms_current, &
471 natoms_max, natoms_total, nkinds, nmols, nnames, nrep_list, nrep_molname
472 INTEGER, ALLOCATABLE, DIMENSION(:) :: inds
473 INTEGER, DIMENSION(:), POINTER :: iptr
474 LOGICAL :: is_list, is_molname
475 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
476 TYPE(molecule_kind_type), POINTER :: molecule_kind
477 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
478 TYPE(molecule_type), POINTER :: molecule
479 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
480
481 CALL timeset(routinen, handle)
482
483 CALL cp_subsys_get(subsys, particle_set=particle_set, &
484 molecule_set=molecule_set, &
485 molecule_kind_set=molecule_kind_set)
486 natoms_max = SIZE(particle_set)
487 nkinds = SIZE(molecule_kind_set)
488
489 CALL section_vals_val_get(input_section, "LIST", i_rep_section=i_rep_section, &
490 n_rep_val=nrep_list, explicit=is_list)
491 CALL section_vals_val_get(input_section, "MOLNAME", i_rep_section=i_rep_section, &
492 n_rep_val=nrep_molname, explicit=is_molname)
493
494 ! compute the number of atoms in the NEGF region, and check the validity of given atomic indices
495 natoms_total = 0
496 IF (is_list .AND. nrep_list > 0) THEN
497 DO irep = 1, nrep_list
498 CALL section_vals_val_get(input_section, "LIST", i_rep_section=i_rep_section, i_rep_val=irep, i_vals=iptr)
499
500 natoms_current = SIZE(iptr)
501 DO iatom = 1, natoms_current
502 IF (iptr(iatom) > natoms_max) THEN
503 CALL integer_to_string(iptr(iatom), index_str)
504 CALL integer_to_string(natoms_max, natoms_str)
505 CALL cp_abort(__location__, &
506 "NEGF: Atomic index "//trim(index_str)//" given in section "// &
507 trim(input_section%section%name)//" exceeds the maximum number of atoms ("// &
508 trim(natoms_str)//").")
509 END IF
510 END DO
511
512 natoms_total = natoms_total + natoms_current
513 END DO
514 END IF
515
516 IF (is_molname .AND. nrep_molname > 0) THEN
517 DO irep = 1, nrep_molname
518 CALL section_vals_val_get(input_section, "MOLNAME", i_rep_section=i_rep_section, i_rep_val=irep, c_vals=cptr)
519 nnames = SIZE(cptr)
520
521 DO iname = 1, nnames
522 DO ikind = 1, nkinds
523 IF (molecule_kind_set(ikind)%name == cptr(iname)) EXIT
524 END DO
525
526 IF (ikind <= nkinds) THEN
527 molecule_kind => molecule_kind_set(ikind)
528 CALL get_molecule_kind(molecule_kind, nmolecule=nmols, molecule_list=iptr)
529
530 DO imol = 1, nmols
531 molecule => molecule_set(iptr(imol))
532 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
533 natoms_current = last_atom - first_atom + 1
534 natoms_total = natoms_total + natoms_current
535 END DO
536 ELSE
537 CALL cp_abort(__location__, &
538 "NEGF: A molecule with the name '"//trim(cptr(iname))//"' mentioned in section "// &
539 trim(input_section%section%name)//" has not been defined. Note that names are case sensitive.")
540 END IF
541 END DO
542 END DO
543 END IF
544
545 ! create a list of atomic indices
546 IF (natoms_total > 0) THEN
547 ALLOCATE (atomlist(natoms_total))
548
549 natoms_total = 0
550
551 IF (is_list .AND. nrep_list > 0) THEN
552 DO irep = 1, nrep_list
553 CALL section_vals_val_get(input_section, "LIST", i_rep_section=i_rep_section, i_rep_val=irep, i_vals=iptr)
554
555 natoms_current = SIZE(iptr)
556 atomlist(natoms_total + 1:natoms_total + natoms_current) = iptr(1:natoms_current)
557 natoms_total = natoms_total + natoms_current
558 END DO
559 END IF
560
561 IF (is_molname .AND. nrep_molname > 0) THEN
562 DO irep = 1, nrep_molname
563 CALL section_vals_val_get(input_section, "MOLNAME", i_rep_section=i_rep_section, i_rep_val=irep, c_vals=cptr)
564 nnames = SIZE(cptr)
565
566 DO iname = 1, nnames
567 DO ikind = 1, nkinds
568 IF (molecule_kind_set(ikind)%name == cptr(iname)) EXIT
569 END DO
570
571 IF (ikind <= nkinds) THEN
572 molecule_kind => molecule_kind_set(ikind)
573 CALL get_molecule_kind(molecule_kind, nmolecule=nmols, molecule_list=iptr)
574
575 DO imol = 1, nmols
576 molecule => molecule_set(iptr(imol))
577 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
578
579 DO natoms_current = first_atom, last_atom
580 natoms_total = natoms_total + 1
581 atomlist(natoms_total) = natoms_current
582 END DO
583 END DO
584 END IF
585 END DO
586 END DO
587 END IF
588
589 ! remove duplicated atoms
590 ALLOCATE (inds(natoms_total))
591 CALL sort(atomlist, natoms_total, inds)
592 DEALLOCATE (inds)
593
594 natoms_current = 1
595 DO iatom = natoms_current + 1, natoms_total
596 IF (atomlist(iatom) /= atomlist(natoms_current)) THEN
597 natoms_current = natoms_current + 1
598 atomlist(natoms_current) = atomlist(iatom)
599 END IF
600 END DO
601
602 IF (natoms_current < natoms_total) THEN
603 CALL move_alloc(atomlist, inds)
604
605 ALLOCATE (atomlist(natoms_current))
606 atomlist(1:natoms_current) = inds(1:natoms_current)
607 DEALLOCATE (inds)
608 END IF
609 END IF
610
611 CALL timestop(handle)
612 END SUBROUTINE read_negf_atomlist
613END 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.