111#include "./base/base_uses.f90"
125 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mixed_cdft_utils'
147 INTEGER :: i, iatom, iforce_eval, igroup, &
149 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: constraint_type
150 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: array_sizes
162 NULLIFY (dft_control, qs_env, pw_env, auxbas_pw_pool, force_env_qs, &
165 settings%max_nkinds = 30
166 nforce_eval =
SIZE(force_env%sub_force_env)
167 ALLOCATE (settings%grid_span(nforce_eval))
168 ALLOCATE (settings%npts(3, nforce_eval))
169 ALLOCATE (settings%cutoff(nforce_eval))
170 ALLOCATE (settings%rel_cutoff(nforce_eval))
171 ALLOCATE (settings%spherical(nforce_eval))
172 ALLOCATE (settings%rs_dims(2, nforce_eval))
173 ALLOCATE (settings%odd(nforce_eval))
174 ALLOCATE (settings%atoms(natom, nforce_eval))
176 ALLOCATE (settings%coeffs(natom, nforce_eval))
177 settings%coeffs = 0.0_dp
182 ALLOCATE (settings%si(6, nforce_eval))
183 ALLOCATE (settings%sb(8, nforce_eval))
184 ALLOCATE (settings%sr(5, nforce_eval))
185 ALLOCATE (settings%cutoffs(settings%max_nkinds, nforce_eval))
186 ALLOCATE (settings%radii(settings%max_nkinds, nforce_eval))
187 settings%grid_span = 0
189 settings%cutoff = 0.0_dp
190 settings%rel_cutoff = 0.0_dp
191 settings%spherical = 0
192 settings%is_spherical = .false.
195 settings%is_odd = .false.
199 settings%sb = .false.
200 settings%cutoffs = 0.0_dp
201 settings%radii = 0.0_dp
203 DO iforce_eval = 1, nforce_eval
204 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
205 force_env_qs => force_env%sub_force_env(iforce_eval)%force_env
206 IF (mixed_env%do_mixed_qmmm_cdft)
THEN
207 qs_env => force_env_qs%qmmm_env%qs_env
211 CALL get_qs_env(qs_env, pw_env=pw_env, dft_control=dft_control)
212 IF (.NOT. dft_control%qs_control%cdft)
THEN
213 CALL cp_abort(__location__, &
214 "A mixed CDFT simulation with multiple force_evals was requested, "// &
215 "but CDFT constraints were not active in the QS section of all force_evals!")
217 cdft_control => dft_control%qs_control%cdft_control
218 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
219 settings%bo = auxbas_pw_pool%pw_grid%bounds_local
221 IF (force_env_qs%para_env%is_source())
THEN
223 settings%grid_span(iforce_eval) = auxbas_pw_pool%pw_grid%grid_span
224 settings%npts(:, iforce_eval) = auxbas_pw_pool%pw_grid%npts
225 settings%cutoff(iforce_eval) = auxbas_pw_pool%pw_grid%cutoff
226 settings%rel_cutoff(iforce_eval) = dft_control%qs_control%relative_cutoff
227 IF (auxbas_pw_pool%pw_grid%spherical) settings%spherical(iforce_eval) = 1
228 settings%rs_dims(:, iforce_eval) = auxbas_pw_pool%pw_grid%para%group%num_pe_cart
229 IF (auxbas_pw_pool%pw_grid%grid_span ==
halfspace) settings%odd(iforce_eval) = 1
231 IF (cdft_control%natoms >
SIZE(settings%atoms, 1))
THEN
232 CALL cp_abort(__location__, &
233 "More CDFT constraint atoms than defined in mixed section. "// &
234 "Use default values for MIXED\MAPPING.")
236 settings%atoms(1:cdft_control%natoms, iforce_eval) = cdft_control%atoms
238 settings%coeffs(1:cdft_control%natoms, iforce_eval) = cdft_control%group(1)%coeff
242 settings%si(1, iforce_eval) = cdft_control%becke_control%cutoff_type
243 settings%si(2, iforce_eval) = cdft_control%becke_control%cavity_shape
245 settings%si(3, iforce_eval) = dft_control%multiplicity
246 settings%si(4, iforce_eval) =
SIZE(cdft_control%group)
247 settings%si(5, iforce_eval) = cdft_control%type
249 settings%si(6, iforce_eval) = cdft_control%hirshfeld_control%shape_function
250 settings%si(6, iforce_eval) = cdft_control%hirshfeld_control%gaussian_shape
254 settings%sb(1, iforce_eval) = cdft_control%becke_control%cavity_confine
255 settings%sb(2, iforce_eval) = cdft_control%becke_control%should_skip
256 settings%sb(3, iforce_eval) = cdft_control%becke_control%print_cavity
257 settings%sb(4, iforce_eval) = cdft_control%becke_control%in_memory
258 settings%sb(5, iforce_eval) = cdft_control%becke_control%adjust
259 settings%sb(8, iforce_eval) = cdft_control%becke_control%use_bohr
262 settings%sb(8, iforce_eval) = cdft_control%hirshfeld_control%use_bohr
264 settings%sb(6, iforce_eval) = cdft_control%atomic_charges
265 settings%sb(7, iforce_eval) = qs_env%has_unit_metric
268 settings%sr(1, iforce_eval) = cdft_control%becke_control%rcavity
269 settings%sr(2, iforce_eval) = cdft_control%becke_control%rglobal
270 settings%sr(3, iforce_eval) = cdft_control%becke_control%eps_cavity
273 settings%sr(2, iforce_eval) = cdft_control%hirshfeld_control%radius
275 settings%sr(4, iforce_eval) = dft_control%qs_control%eps_rho_rspace
276 settings%sr(5, iforce_eval) = pw_env%cube_info(pw_env%auxbas_grid)%max_rad_ga
279 nkinds =
SIZE(cdft_control%becke_control%cutoffs_tmp)
280 IF (nkinds > settings%max_nkinds)
THEN
281 CALL cp_abort(__location__, &
282 "More than "//trim(
cp_to_string(settings%max_nkinds))// &
283 " unique elements were defined in BECKE_CONSTRAINT\ELEMENT_CUTOFF. Are you sure"// &
284 " your input is correct? If yes, please increase max_nkinds and recompile.")
286 settings%cutoffs(1:nkinds, iforce_eval) = cdft_control%becke_control%cutoffs_tmp(:)
288 IF (cdft_control%becke_control%adjust)
THEN
289 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
290 IF (.NOT.
SIZE(atomic_kind_set) ==
SIZE(cdft_control%becke_control%radii_tmp))
THEN
291 CALL cp_abort(__location__, &
292 "Length of keyword BECKE_CONSTRAINT\ATOMIC_RADII does not "// &
293 "match number of atomic kinds in the input coordinate file.")
295 nkinds =
SIZE(cdft_control%becke_control%radii_tmp)
296 IF (nkinds > settings%max_nkinds)
THEN
297 CALL cp_abort(__location__, &
298 "More than "//trim(
cp_to_string(settings%max_nkinds))// &
299 " unique elements were defined in BECKE_CONSTRAINT\ATOMIC_RADII. Are you sure"// &
300 " your input is correct? If yes, please increase max_nkinds and recompile.")
302 settings%radii(1:nkinds, iforce_eval) = cdft_control%becke_control%radii_tmp(:)
306 IF (
ASSOCIATED(cdft_control%hirshfeld_control%radii))
THEN
307 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
308 IF (.NOT.
SIZE(atomic_kind_set) ==
SIZE(cdft_control%hirshfeld_control%radii))
THEN
309 CALL cp_abort(__location__, &
310 "Length of keyword HIRSHFELD_CONSTRAINT&RADII does not "// &
311 "match number of atomic kinds in the input coordinate file.")
313 nkinds =
SIZE(cdft_control%hirshfeld_control%radii)
314 IF (nkinds > settings%max_nkinds)
THEN
315 CALL cp_abort(__location__, &
316 "More than "//trim(
cp_to_string(settings%max_nkinds))// &
317 " unique elements were defined in HIRSHFELD_CONSTRAINT&RADII. Are you sure"// &
318 " your input is correct? If yes, please increase max_nkinds and recompile.")
320 settings%radii(1:nkinds, iforce_eval) = cdft_control%hirshfeld_control%radii(:)
326 CALL force_env%para_env%sum(settings%grid_span)
327 CALL force_env%para_env%sum(settings%npts)
328 CALL force_env%para_env%sum(settings%cutoff)
329 CALL force_env%para_env%sum(settings%rel_cutoff)
330 CALL force_env%para_env%sum(settings%spherical)
331 CALL force_env%para_env%sum(settings%rs_dims)
332 CALL force_env%para_env%sum(settings%odd)
334 DO iforce_eval = 2, nforce_eval
335 is_match = is_match .AND. (settings%grid_span(1) == settings%grid_span(iforce_eval))
336 is_match = is_match .AND. (settings%npts(1, 1) == settings%npts(1, iforce_eval))
337 is_match = is_match .AND. (settings%cutoff(1) == settings%cutoff(iforce_eval))
338 is_match = is_match .AND. (settings%rel_cutoff(1) == settings%rel_cutoff(iforce_eval))
339 is_match = is_match .AND. (settings%spherical(1) == settings%spherical(iforce_eval))
340 is_match = is_match .AND. (settings%rs_dims(1, 1) == settings%rs_dims(1, iforce_eval))
341 is_match = is_match .AND. (settings%rs_dims(2, 1) == settings%rs_dims(2, iforce_eval))
342 is_match = is_match .AND. (settings%odd(1) == settings%odd(iforce_eval))
344 IF (.NOT. is_match)
THEN
345 CALL cp_abort(__location__, &
346 "Mismatch detected in the &MGRID settings of the CDFT force_evals.")
348 IF (settings%spherical(1) == 1) settings%is_spherical = .true.
349 IF (settings%odd(1) == 1) settings%is_odd = .true.
351 CALL force_env%para_env%sum(settings%atoms)
353 CALL force_env%para_env%sum(settings%coeffs)
356 DO i = 1,
SIZE(settings%atoms, 1)
357 DO iforce_eval = 2, nforce_eval
359 IF (settings%atoms(i, 1) /= settings%atoms(i, iforce_eval)) is_match = .false.
360 IF (settings%coeffs(i, 1) /= settings%coeffs(i, iforce_eval)) is_match = .false.
363 IF (settings%atoms(i, 1) /= 0) settings%ncdft = settings%ncdft + 1
366 CALL cp_abort(__location__, &
367 "Mismatch detected in the &CDFT section of the CDFT force_evals. "// &
368 "Parallel mode mixed CDFT requires identical constraint definitions in both CDFT states. "// &
369 "Switch to serial mode or disable keyword PARALLEL_BUILD if you "// &
370 "want to use nonidentical constraint definitions.")
372 CALL force_env%para_env%sum(settings%si)
373 CALL force_env%para_env%sum(settings%sr)
374 DO i = 1,
SIZE(settings%sb, 1)
375 CALL force_env%para_env%sum(settings%sb(i, 1))
376 DO iforce_eval = 2, nforce_eval
377 CALL force_env%para_env%sum(settings%sb(i, iforce_eval))
378 IF (settings%sb(i, 1) .NEQV. settings%sb(i, iforce_eval)) is_match = .false.
381 DO i = 1,
SIZE(settings%si, 1)
382 DO iforce_eval = 2, nforce_eval
383 IF (settings%si(i, 1) /= settings%si(i, iforce_eval)) is_match = .false.
386 DO i = 1,
SIZE(settings%sr, 1)
387 DO iforce_eval = 2, nforce_eval
388 IF (settings%sr(i, 1) /= settings%sr(i, iforce_eval)) is_match = .false.
391 IF (.NOT. is_match)
THEN
392 CALL cp_abort(__location__, &
393 "Mismatch detected in the &CDFT settings of the CDFT force_evals.")
396 IF (mixed_cdft%dlb .AND. .NOT. settings%sb(1, 1))
THEN
397 CALL cp_abort(__location__, &
398 "Parallel mode mixed CDFT load balancing requires Gaussian cavity confinement.")
403 ALLOCATE (array_sizes(nforce_eval, settings%si(4, 1), 2))
404 array_sizes(:, :, :) = 0
405 DO iforce_eval = 1, nforce_eval
406 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
407 force_env_qs => force_env%sub_force_env(iforce_eval)%force_env
408 IF (mixed_env%do_mixed_qmmm_cdft)
THEN
409 qs_env => force_env_qs%qmmm_env%qs_env
413 CALL get_qs_env(qs_env, dft_control=dft_control)
414 cdft_control => dft_control%qs_control%cdft_control
415 IF (force_env_qs%para_env%is_source())
THEN
416 DO igroup = 1,
SIZE(cdft_control%group)
417 array_sizes(iforce_eval, igroup, 1) =
SIZE(cdft_control%group(igroup)%atoms)
418 array_sizes(iforce_eval, igroup, 2) =
SIZE(cdft_control%group(igroup)%coeff)
423 CALL force_env%para_env%sum(array_sizes)
424 IF (any(array_sizes(:, :, 1) /= array_sizes(1, 1, 1)) .OR. &
425 any(array_sizes(:, :, 2) /= array_sizes(1, 1, 2)))
THEN
426 mixed_cdft%identical_constraints = .false.
429 IF (mixed_cdft%identical_constraints)
THEN
431 ALLOCATE (atoms(nforce_eval, settings%si(4, 1)))
432 ALLOCATE (coeff(nforce_eval, settings%si(4, 1)))
433 ALLOCATE (constraint_type(nforce_eval, settings%si(4, 1)))
434 constraint_type(:, :) = 0
435 DO iforce_eval = 1, nforce_eval
436 DO i = 1, settings%si(4, 1)
437 NULLIFY (atoms(iforce_eval, i)%array)
438 NULLIFY (coeff(iforce_eval, i)%array)
439 ALLOCATE (atoms(iforce_eval, i)%array(array_sizes(iforce_eval, i, 1)))
440 ALLOCATE (coeff(iforce_eval, i)%array(array_sizes(iforce_eval, i, 1)))
441 atoms(iforce_eval, i)%array(:) = 0
442 coeff(iforce_eval, i)%array(:) = 0
445 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
446 force_env_qs => force_env%sub_force_env(iforce_eval)%force_env
447 IF (mixed_env%do_mixed_qmmm_cdft)
THEN
448 qs_env => force_env_qs%qmmm_env%qs_env
452 CALL get_qs_env(qs_env, dft_control=dft_control)
453 cdft_control => dft_control%qs_control%cdft_control
454 IF (force_env_qs%para_env%is_source())
THEN
455 DO i = 1, settings%si(4, 1)
456 atoms(iforce_eval, i)%array(:) = cdft_control%group(i)%atoms
457 coeff(iforce_eval, i)%array(:) = cdft_control%group(i)%coeff
458 constraint_type(iforce_eval, i) = cdft_control%group(i)%constraint_type
463 DO i = 1, settings%si(4, 1)
464 DO iforce_eval = 1, nforce_eval
465 CALL force_env%para_env%sum(atoms(iforce_eval, i)%array)
466 CALL force_env%para_env%sum(coeff(iforce_eval, i)%array)
467 CALL force_env%para_env%sum(constraint_type(iforce_eval, i))
469 DO iforce_eval = 2, nforce_eval
470 DO iatom = 1,
SIZE(atoms(1, i)%array)
471 IF (atoms(1, i)%array(iatom) /= atoms(iforce_eval, i)%array(iatom))
THEN
472 mixed_cdft%identical_constraints = .false.
474 IF (coeff(1, i)%array(iatom) /= coeff(iforce_eval, i)%array(iatom))
THEN
475 mixed_cdft%identical_constraints = .false.
477 IF (.NOT. mixed_cdft%identical_constraints)
EXIT
479 IF (constraint_type(1, i) /= constraint_type(iforce_eval, i))
THEN
480 mixed_cdft%identical_constraints = .false.
482 IF (.NOT. mixed_cdft%identical_constraints)
EXIT
484 IF (.NOT. mixed_cdft%identical_constraints)
EXIT
487 DO iforce_eval = 1, nforce_eval
488 DO i = 1, settings%si(4, 1)
489 DEALLOCATE (atoms(iforce_eval, i)%array)
490 DEALLOCATE (coeff(iforce_eval, i)%array)
495 DEALLOCATE (constraint_type)
497 DEALLOCATE (array_sizes)
501 DO iforce_eval = 1, nforce_eval
502 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
503 force_env_qs => force_env%sub_force_env(iforce_eval)%force_env
504 IF (mixed_env%do_mixed_qmmm_cdft)
THEN
505 qs_env => force_env_qs%qmmm_env%qs_env
509 CALL get_qs_env(qs_env, dft_control=dft_control)
510 cdft_control => dft_control%qs_control%cdft_control
512 IF (.NOT. dft_control%qs_control%gapw)
THEN
513 DO i = 1,
SIZE(cdft_control%group)
514 DEALLOCATE (cdft_control%group(i)%coeff)
515 DEALLOCATE (cdft_control%group(i)%atoms)
517 IF (.NOT. cdft_control%atomic_charges)
DEALLOCATE (cdft_control%atoms)
520 IF (iforce_eval == 1) cycle
521 DO igroup = 1,
SIZE(cdft_control%group)
522 IF (.NOT. dft_control%qs_control%gapw)
THEN
523 DEALLOCATE (cdft_control%group(igroup)%coeff)
524 DEALLOCATE (cdft_control%group(igroup)%atoms)
528 IF (.NOT. cdft_control%atomic_charges)
DEALLOCATE (cdft_control%atoms)
529 IF (cdft_control%becke_control%cavity_confine)
THEN
533 DEALLOCATE (cdft_control%becke_control%cutoffs_tmp)
535 IF (cdft_control%becke_control%adjust)
THEN
536 DEALLOCATE (cdft_control%becke_control%radii_tmp)
562 NULLIFY (cdft_control)
565 mixed_cdft%multiplicity = settings%si(3, 1)
566 mixed_cdft%has_unit_metric = settings%sb(7, 1)
567 mixed_cdft%eps_rho_rspace = settings%sr(4, 1)
568 mixed_cdft%nconstraint = settings%si(4, 1)
569 settings%radius = settings%sr(5, 1)
572 IF (settings%sb(6, 1))
THEN
573 CALL cp_abort(__location__, &
574 "Calculation of atomic Becke charges not supported with parallel mode mixed CDFT")
576 IF (mixed_cdft%nconstraint /= 1)
THEN
577 CALL cp_abort(__location__, &
578 "Parallel mode mixed CDFT does not yet support multiple constraints.")
582 CALL cp_abort(__location__, &
583 "Parallel mode mixed CDFT does not support Hirshfeld constraints.")
586 ALLOCATE (mixed_cdft%cdft_control)
588 cdft_control => mixed_cdft%cdft_control
589 ALLOCATE (cdft_control%atoms(settings%ncdft))
590 cdft_control%atoms = settings%atoms(1:settings%ncdft, 1)
591 ALLOCATE (cdft_control%group(1))
592 ALLOCATE (cdft_control%group(1)%atoms(settings%ncdft))
593 ALLOCATE (cdft_control%group(1)%coeff(settings%ncdft))
594 NULLIFY (cdft_control%group(1)%weight)
595 NULLIFY (cdft_control%group(1)%gradients)
596 NULLIFY (cdft_control%group(1)%integrated)
597 cdft_control%group(1)%atoms = cdft_control%atoms
598 cdft_control%group(1)%coeff = settings%coeffs(1:settings%ncdft, 1)
599 cdft_control%natoms = settings%ncdft
600 cdft_control%atomic_charges = settings%sb(6, 1)
601 cdft_control%becke_control%cutoff_type = settings%si(1, 1)
602 cdft_control%becke_control%cavity_confine = settings%sb(1, 1)
603 cdft_control%becke_control%should_skip = settings%sb(2, 1)
604 cdft_control%becke_control%print_cavity = settings%sb(3, 1)
605 cdft_control%becke_control%in_memory = settings%sb(4, 1)
606 cdft_control%becke_control%adjust = settings%sb(5, 1)
607 cdft_control%becke_control%cavity_shape = settings%si(2, 1)
608 cdft_control%becke_control%use_bohr = settings%sb(8, 1)
609 cdft_control%becke_control%rcavity = settings%sr(1, 1)
610 cdft_control%becke_control%rglobal = settings%sr(2, 1)
611 cdft_control%becke_control%eps_cavity = settings%sr(3, 1)
614 CALL force_env%para_env%sum(settings%cutoffs)
615 DO i = 1,
SIZE(settings%cutoffs, 1)
616 IF (settings%cutoffs(i, 1) /= settings%cutoffs(i, 2)) is_match = .false.
617 IF (settings%cutoffs(i, 1) /= 0.0_dp) nkinds = nkinds + 1
619 IF (.NOT. is_match)
THEN
620 CALL cp_abort(__location__, &
621 "Mismatch detected in the &BECKE_CONSTRAINT "// &
622 "&ELEMENT_CUTOFF settings of the two force_evals.")
624 ALLOCATE (cdft_control%becke_control%cutoffs_tmp(nkinds))
625 cdft_control%becke_control%cutoffs_tmp = settings%cutoffs(1:nkinds, 1)
628 IF (cdft_control%becke_control%adjust)
THEN
629 CALL force_env%para_env%sum(settings%radii)
630 DO i = 1,
SIZE(settings%radii, 1)
631 IF (settings%radii(i, 1) /= settings%radii(i, 2)) is_match = .false.
632 IF (settings%radii(i, 1) /= 0.0_dp) nkinds = nkinds + 1
634 IF (.NOT. is_match)
THEN
635 CALL cp_abort(__location__, &
636 "Mismatch detected in the &BECKE_CONSTRAINT "// &
637 "&ATOMIC_RADII settings of the two force_evals.")
639 ALLOCATE (cdft_control%becke_control%radii(nkinds))
640 cdft_control%becke_control%radii = settings%radii(1:nkinds, 1)
662 CHARACTER(len=default_path_length) :: c_val, input_file_path, output_file_path
663 INTEGER :: i, imap, iounit, j, lp, n_force_eval, &
664 ncpu, nforce_eval, ntargets, offset, &
666 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: bounds
667 INTEGER,
DIMENSION(2, 3) :: bo, bo_mixed
668 INTEGER,
DIMENSION(3) :: higher_grid_layout
669 INTEGER,
DIMENSION(:),
POINTER :: i_force_eval, mixed_rs_dims, recvbuffer, &
670 recvbuffer2, sendbuffer
683 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
688 TYPE(
section_vals_type),
POINTER :: force_env_section, force_env_sections, kind_section, &
689 print_section, root_section, rs_grid_section, subsys_section
691 NULLIFY (cell_mix, subsys_mix, force_env_section, subsys_section, &
692 print_section, root_section, kind_section, force_env_sections, &
693 rs_grid_section, auxbas_pw_pool, pw_env, pw_pools, pw_grid, &
694 sendbuffer, qs_env, mixed_rs_dims, i_force_eval, recvbuffer, &
695 recvbuffer2, globenv, atomic_kind_set, qs_kind_set, rs_descs, &
699 CALL force_env_get(force_env=force_env, force_env_section=force_env_section)
703 nforce_eval =
SIZE(force_env%sub_force_env)
704 ncpu = force_env%para_env%num_pe
706 IF (.NOT. mixed_env%do_mixed_qmmm_cdft)
THEN
710 CALL get_qs_env(force_env_qs%qmmm_env%qs_env, &
711 cp_subsys=subsys_mix)
730 mixed_cdft%is_pencil = .false.
731 mixed_cdft%is_special = .false.
734 IF (ncpu/2 > settings%npts(1, 1))
THEN
735 cpabort(
"ncpu/2 => nx: decrease ncpu or disable xc_smoothing")
738 ALLOCATE (mixed_rs_dims(2))
739 IF (settings%rs_dims(2, 1) /= 1) mixed_cdft%is_pencil = .true.
740 IF (.NOT. mixed_cdft%is_pencil .AND. ncpu > settings%npts(1, 1)) mixed_cdft%is_special = .true.
741 IF (mixed_cdft%is_special)
THEN
742 mixed_rs_dims = [-1, -1]
743 ELSE IF (mixed_cdft%is_pencil)
THEN
744 mixed_rs_dims = [settings%rs_dims(1, 1), 2*settings%rs_dims(2, 1)]
746 mixed_rs_dims = [2*settings%rs_dims(1, 1), 1]
748 IF (.NOT. mixed_env%do_mixed_qmmm_cdft)
THEN
752 CALL get_qs_env(force_env_qs%qmmm_env%qs_env, &
755 CALL pw_grid_create(pw_grid, force_env%para_env, cell_mix%hmat, grid_span=settings%grid_span(1), &
756 npts=settings%npts(:, 1), cutoff=settings%cutoff(1), &
757 spherical=settings%is_spherical, odd=settings%is_odd, &
758 fft_usage=.true., ncommensurate=0, icommensurate=1, &
762 IF (mixed_cdft%is_special)
THEN
763 IF (.NOT. pw_grid%para%group%num_pe_cart(2) /= 1) is_match = .false.
764 ELSE IF (mixed_cdft%is_pencil)
THEN
765 IF (.NOT. pw_grid%para%group%num_pe_cart(1) == mixed_rs_dims(1)) is_match = .false.
767 IF (.NOT. pw_grid%para%group%num_pe_cart(2) == 1) is_match = .false.
769 IF (.NOT. is_match)
THEN
770 CALL cp_abort(__location__, &
771 "Unable to create a suitable grid distribution "// &
772 "for mixed CDFT calculations. Try decreasing the total number "// &
773 "of processors or disabling xc_smoothing.")
775 DEALLOCATE (mixed_rs_dims)
777 bo_mixed = pw_grid%bounds_local
778 ALLOCATE (pw_pools(1))
779 NULLIFY (pw_pools(1)%pool)
782 IF (mixed_cdft%cdft_control%becke_control%cavity_confine)
THEN
786 radius_type=mixed_cdft%cdft_control%becke_control%cavity_shape, &
787 use_bohr=mixed_cdft%cdft_control%becke_control%use_bohr)
791 IF (mixed_cdft%cdft_control%becke_control%cavity_confine .OR. &
792 mixed_cdft%wfn_overlap_method)
THEN
794 "PRINT%GRID_INFORMATION")
795 ALLOCATE (mixed_cdft%pw_env%gridlevel_info)
797 ngrid_levels=1, cutoff=settings%cutoff, &
798 rel_cutoff=settings%rel_cutoff(1), &
799 print_section=print_section)
800 ALLOCATE (rs_descs(1))
801 ALLOCATE (rs_grids(1))
802 ALLOCATE (mixed_cdft%pw_env%cube_info(1))
803 higher_grid_layout = [-1, -1, -1]
806 pw_grid%dr(:), pw_grid%dh(:, :), &
807 pw_grid%dh_inv(:, :), &
808 pw_grid%orthorhombic, settings%radius)
809 NULLIFY (root_section, force_env_section, force_env_sections, rs_grid_section)
812 CALL multiple_fe_list(force_env_sections, root_section, i_force_eval, n_force_eval)
814 i_force_eval(2), i_force_eval(2))
818 rs_grid_section=rs_grid_section, ilevel=1, &
819 higher_grid_layout=higher_grid_layout)
820 NULLIFY (rs_descs(1)%rs_desc)
822 IF (rs_descs(1)%rs_desc%distributed) higher_grid_layout = rs_descs(1)%rs_desc%group_dim
825 mixed_cdft%pw_env%rs_descs => rs_descs
826 mixed_cdft%pw_env%rs_grids => rs_grids
829 i_rep_section=i_force_eval(1))
831 NULLIFY (qs_kind_set)
832 CALL cp_subsys_get(subsys_mix, atomic_kind_set=atomic_kind_set)
834 force_env%para_env, force_env_section, silent=.false.)
835 mixed_cdft%qs_kind_set => qs_kind_set
836 DEALLOCATE (i_force_eval)
840 force_env_section=force_env_section)
842 mixed_cdft%pw_env%auxbas_grid = 1
843 NULLIFY (mixed_cdft%pw_env%pw_pools)
844 mixed_cdft%pw_env%pw_pools => pw_pools
847 IF (.NOT. mixed_cdft%is_special)
THEN
848 ALLOCATE (mixed_cdft%dest_list(2))
849 ALLOCATE (mixed_cdft%source_list(2))
850 imap = force_env%para_env%mepos/2
851 mixed_cdft%dest_list = [imap, imap + force_env%para_env%num_pe/2]
852 imap = mod(force_env%para_env%mepos, force_env%para_env%num_pe/2) + &
853 modulo(force_env%para_env%mepos, force_env%para_env%num_pe/2)
854 mixed_cdft%source_list = [imap, imap + 1]
856 ALLOCATE (mixed_cdft%recv_bo(4))
857 ALLOCATE (sendbuffer(2), recvbuffer(2), recvbuffer2(2))
858 IF (mixed_cdft%is_pencil)
THEN
859 sendbuffer = [bo_mixed(1, 2), bo_mixed(2, 2)]
861 sendbuffer = [bo_mixed(1, 1), bo_mixed(2, 1)]
864 CALL force_env%para_env%isend(msgin=sendbuffer, dest=mixed_cdft%dest_list(1), &
866 CALL force_env%para_env%irecv(msgout=recvbuffer, source=mixed_cdft%source_list(1), &
868 CALL force_env%para_env%irecv(msgout=recvbuffer2, source=mixed_cdft%source_list(2), &
871 CALL force_env%para_env%isend(msgin=sendbuffer, dest=mixed_cdft%dest_list(2), &
874 mixed_cdft%recv_bo(1:2) = recvbuffer
875 mixed_cdft%recv_bo(3:4) = recvbuffer2
876 DEALLOCATE (sendbuffer, recvbuffer, recvbuffer2)
878 IF (mixed_env%do_mixed_qmmm_cdft)
THEN
879 qs_env => force_env_qs%qmmm_env%qs_env
884 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
887 ALLOCATE (bounds(0:auxbas_pw_pool%pw_grid%para%group%num_pe - 1, 1:2))
888 DO i = 0, auxbas_pw_pool%pw_grid%para%group%num_pe - 1
889 bounds(i, 1:2) = auxbas_pw_pool%pw_grid%para%bo(1:2, 1, i, 1)
890 bounds(i, 1:2) = bounds(i, 1:2) - auxbas_pw_pool%pw_grid%npts(1)/2 - 1
896 DO i = 0, auxbas_pw_pool%pw_grid%para%group%num_pe - 1
897 IF ((bounds(i, 1) >= bo_mixed(1, 1) .AND. bounds(i, 1) <= bo_mixed(2, 1)) .OR. &
898 (bounds(i, 2) >= bo_mixed(1, 1) .AND. bounds(i, 2) <= bo_mixed(2, 1)))
THEN
899 ntargets = ntargets + 1
900 IF (offset == -1) offset = i
901 ELSE IF (bounds(i, 2) > bo_mixed(2, 1))
THEN
907 ALLOCATE (mixed_cdft%dest_list(ntargets))
908 ALLOCATE (mixed_cdft%dest_list_bo(2, ntargets))
911 DO i = offset, offset + ntargets - 1
912 mixed_cdft%dest_list(j) = i
913 mixed_cdft%dest_list_bo(:, j) = [bo_mixed(1, 1) + (bounds(i, 1) - bo_mixed(1, 1)), &
914 bo_mixed(2, 1) + (bounds(i, 2) - bo_mixed(2, 1))]
917 ALLOCATE (mixed_cdft%dest_list_save(ntargets), mixed_cdft%dest_bo_save(2, ntargets))
919 mixed_cdft%dest_list_save = mixed_cdft%dest_list
920 mixed_cdft%dest_bo_save = mixed_cdft%dest_list_bo
924 ALLOCATE (bounds(0:pw_pools(1)%pool%pw_grid%para%group%num_pe - 1, 1:4))
925 DO i = 0, pw_pools(1)%pool%pw_grid%para%group%num_pe - 1
926 bounds(i, 1:2) = pw_pools(1)%pool%pw_grid%para%bo(1:2, 1, i, 1)
927 bounds(i, 3:4) = pw_pools(1)%pool%pw_grid%para%bo(1:2, 2, i, 1)
928 bounds(i, 1:2) = bounds(i, 1:2) - pw_pools(1)%pool%pw_grid%npts(1)/2 - 1
929 bounds(i, 3:4) = bounds(i, 3:4) - pw_pools(1)%pool%pw_grid%npts(2)/2 - 1
933 DO i = 0, pw_pools(1)%pool%pw_grid%para%group%num_pe - 1
934 IF ((bo(1, 1) >= bounds(i, 1) .AND. bo(1, 1) <= bounds(i, 2)) .OR. &
935 (bo(2, 1) >= bounds(i, 1) .AND. bo(2, 1) <= bounds(i, 2)))
THEN
936 ntargets = ntargets + 1
937 IF (offset == -1) offset = i
938 ELSE IF (bo(2, 1) < bounds(i, 1))
THEN
944 ALLOCATE (mixed_cdft%source_list(ntargets))
945 ALLOCATE (mixed_cdft%source_list_bo(4, ntargets))
947 DO i = offset, offset + ntargets - 1
948 mixed_cdft%source_list(j) = i
949 IF (bo(1, 1) >= bounds(i, 1) .AND. bo(2, 1) <= bounds(i, 2))
THEN
950 mixed_cdft%source_list_bo(:, j) = [bo(1, 1), bo(2, 1), &
951 bounds(i, 3), bounds(i, 4)]
952 ELSE IF (bo(1, 1) >= bounds(i, 1) .AND. bo(1, 1) <= bounds(i, 2))
THEN
953 mixed_cdft%source_list_bo(:, j) = [bo(1, 1), bounds(i, 2), &
954 bounds(i, 3), bounds(i, 4)]
956 mixed_cdft%source_list_bo(:, j) = [bounds(i, 1), bo(2, 1), &
957 bounds(i, 3), bounds(i, 4)]
961 ALLOCATE (mixed_cdft%source_list_save(ntargets), mixed_cdft%source_bo_save(4, ntargets))
963 mixed_cdft%source_list_save = mixed_cdft%source_list
964 mixed_cdft%source_bo_save = mixed_cdft%source_list_bo
972 ALLOCATE (mixed_cdft%sub_logger(nforce_eval - 1))
973 DO i = 1, nforce_eval - 1
974 IF (force_env%para_env%is_source())
THEN
976 c_val=input_file_path)
977 lp = len_trim(input_file_path)
978 input_file_path(lp + 1:len(input_file_path)) =
"-r-"//adjustl(
cp_to_string(i + 1))
979 lp = len_trim(input_file_path)
980 output_file_path = input_file_path(1:lp)//
".out"
981 CALL open_file(file_name=output_file_path, file_status=
"UNKNOWN", &
982 file_action=
"WRITE", file_position=
"APPEND", &
988 para_env=force_env%para_env, &
989 default_global_unit_nr=unit_nr, &
990 close_global_unit_on_dealloc=.false.)
994 IF (c_val /=
"")
THEN
996 local_filename=trim(c_val)//
"_localLog")
999 IF (c_val /=
"")
THEN
1001 local_filename=trim(c_val)//
"_localLog")
1004 cpwarn(
"The mixed CDFT project name will be truncated.")
1006 mixed_cdft%sub_logger(i)%p%iter_info%project_name = trim(c_val)
1008 i_val=mixed_cdft%sub_logger(i)%p%iter_info%print_level)
1010 IF (mixed_cdft%wfn_overlap_method)
THEN
1012 NULLIFY (root_section, force_env_section, force_env_sections, rs_grid_section)
1015 CALL multiple_fe_list(force_env_sections, root_section, i_force_eval, n_force_eval)
1017 i_force_eval(2), i_force_eval(2))
1019 i_rep_section=i_force_eval(1))
1021 NULLIFY (qs_kind_set)
1022 CALL cp_subsys_get(subsys_mix, atomic_kind_set=atomic_kind_set)
1024 force_env%para_env, force_env_section, silent=.false.)
1025 mixed_cdft%qs_kind_set => qs_kind_set
1026 DEALLOCATE (i_force_eval)
1028 mixed_cdft%qs_kind_set => qs_kind_set
1031 force_env_section=force_env_section)
1034 DEALLOCATE (settings%grid_span)
1035 DEALLOCATE (settings%npts)
1036 DEALLOCATE (settings%spherical)
1037 DEALLOCATE (settings%rs_dims)
1038 DEALLOCATE (settings%odd)
1039 DEALLOCATE (settings%atoms)
1041 DEALLOCATE (settings%coeffs)
1043 DEALLOCATE (settings%cutoffs)
1044 DEALLOCATE (settings%radii)
1045 DEALLOCATE (settings%si)
1046 DEALLOCATE (settings%sr)
1047 DEALLOCATE (settings%sb)
1048 DEALLOCATE (settings%cutoff)
1049 DEALLOCATE (settings%rel_cutoff)
1051 IF (mixed_env%do_mixed_et)
THEN
1052 NULLIFY (root_section)
1053 CALL force_env_get(force_env, globenv=globenv, root_section=root_section)
1054 CALL cp_blacs_env_create(mixed_cdft%blacs_env, force_env%para_env, globenv%blacs_grid_layout, &
1055 globenv%blacs_repeatable)
1058 "MIXED%MIXED_CDFT%PRINT%PROGRAM_RUN_INFO")
1073 INTEGER :: iforce_eval, ispin, ivar, ncol_overlap, &
1074 ncol_wmat, nforce_eval, nrow_overlap, &
1075 nrow_wmat, nspins, nvar
1076 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: ncol_mo, nrow_mo
1077 LOGICAL :: uniform_occupation
1078 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: has_occupation_numbers
1082 fm_struct_tmp, fm_struct_wmat
1083 TYPE(
cp_fm_type) :: matrix_s_tmp, mixed_matrix_s_tmp
1084 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: matrix_p_tmp, mixed_matrix_p_tmp, &
1085 mixed_wmat_tmp, mo_coeff_tmp, wmat_tmp
1086 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: mixed_mo_coeff
1087 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: density_matrix, w_matrix
1096 NULLIFY (mixed_env, mixed_cdft, qs_env, dft_control, fm_struct_mo, &
1097 fm_struct_wmat, fm_struct_overlap, fm_struct_tmp, &
1098 mixed_mo_coeff, mixed_matrix_s, density_matrix, blacs_env, w_matrix, force_env_qs)
1099 cpassert(
ASSOCIATED(force_env))
1100 mixed_env => force_env%mixed_env
1101 nforce_eval =
SIZE(force_env%sub_force_env)
1103 cpassert(
ASSOCIATED(mixed_cdft))
1106 ALLOCATE (has_occupation_numbers(nforce_eval))
1107 has_occupation_numbers = .false.
1108 DO iforce_eval = 1, nforce_eval
1109 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1110 force_env_qs => force_env%sub_force_env(iforce_eval)%force_env
1111 IF (force_env%mixed_env%do_mixed_qmmm_cdft)
THEN
1112 qs_env => force_env_qs%qmmm_env%qs_env
1116 CALL get_qs_env(qs_env, dft_control=dft_control)
1117 cpassert(
ASSOCIATED(dft_control))
1118 nspins = dft_control%nspins
1119 IF (force_env_qs%para_env%is_source())
THEN
1120 has_occupation_numbers(iforce_eval) =
ALLOCATED(dft_control%qs_control%cdft_control%occupations)
1123 CALL force_env%para_env%sum(has_occupation_numbers(1))
1124 DO iforce_eval = 2, nforce_eval
1125 CALL force_env%para_env%sum(has_occupation_numbers(iforce_eval))
1126 IF (has_occupation_numbers(1) .NEQV. has_occupation_numbers(iforce_eval))
THEN
1127 CALL cp_abort(__location__, &
1128 "Mixing of uniform and non-uniform occupations is not allowed.")
1131 uniform_occupation = .NOT. has_occupation_numbers(1)
1132 DEALLOCATE (has_occupation_numbers)
1134 nvar =
SIZE(dft_control%qs_control%cdft_control%target)
1135 IF (.NOT.
ALLOCATED(mixed_cdft%constraint_type))
THEN
1136 ALLOCATE (mixed_cdft%constraint_type(nvar, nforce_eval))
1137 mixed_cdft%constraint_type(:, :) = 0
1138 IF (mixed_cdft%identical_constraints)
THEN
1140 mixed_cdft%constraint_type(ivar, :) = &
1141 dft_control%qs_control%cdft_control%group(ivar)%constraint_type
1145 DO iforce_eval = 1, nforce_eval
1146 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1147 IF (force_env%mixed_env%do_mixed_qmmm_cdft)
THEN
1148 qs_env => force_env%sub_force_env(iforce_eval)%force_env%qmmm_env%qs_env
1150 CALL force_env_get(force_env%sub_force_env(iforce_eval)%force_env, qs_env=qs_env)
1152 CALL get_qs_env(qs_env, dft_control=dft_control)
1153 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
1155 mixed_cdft%constraint_type(ivar, iforce_eval) = &
1156 dft_control%qs_control%cdft_control%group(ivar)%constraint_type
1160 CALL force_env%para_env%sum(mixed_cdft%constraint_type)
1164 ALLOCATE (mixed_cdft%matrix%mixed_mo_coeff(nforce_eval, nspins))
1165 mixed_mo_coeff => mixed_cdft%matrix%mixed_mo_coeff
1166 ALLOCATE (mixed_cdft%matrix%w_matrix(nforce_eval, nvar))
1167 w_matrix => mixed_cdft%matrix%w_matrix
1169 mixed_matrix_s => mixed_cdft%matrix%mixed_matrix_s
1170 IF (mixed_cdft%calculate_metric)
THEN
1171 ALLOCATE (mixed_cdft%matrix%density_matrix(nforce_eval, nspins))
1172 density_matrix => mixed_cdft%matrix%density_matrix
1174 ALLOCATE (mo_coeff_tmp(nforce_eval, nspins), wmat_tmp(nforce_eval, nvar))
1175 ALLOCATE (nrow_mo(nspins), ncol_mo(nspins))
1176 IF (mixed_cdft%calculate_metric)
ALLOCATE (matrix_p_tmp(nforce_eval, nspins))
1177 IF (.NOT. uniform_occupation)
THEN
1178 ALLOCATE (mixed_cdft%occupations(nforce_eval, nspins))
1179 ALLOCATE (occno_tmp(nforce_eval, nspins))
1181 DO iforce_eval = 1, nforce_eval
1183 DO ispin = 1, nspins
1187 IF (.NOT. uniform_occupation)
THEN
1188 NULLIFY (occno_tmp(iforce_eval, ispin)%array)
1191 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1194 force_env_qs => force_env%sub_force_env(iforce_eval)%force_env
1195 IF (force_env%mixed_env%do_mixed_qmmm_cdft)
THEN
1196 qs_env => force_env_qs%qmmm_env%qs_env
1200 CALL get_qs_env(qs_env, dft_control=dft_control, blacs_env=blacs_env)
1202 CALL dbcsr_get_info(dft_control%qs_control%cdft_control%matrix_s%matrix, &
1203 nfullrows_total=nrow_overlap, nfullcols_total=ncol_overlap)
1204 CALL dbcsr_get_info(dft_control%qs_control%cdft_control%wmat(1)%matrix, &
1205 nfullrows_total=nrow_wmat, nfullcols_total=ncol_wmat)
1207 DO ispin = 1, nspins
1208 CALL cp_fm_get_info(dft_control%qs_control%cdft_control%mo_coeff(ispin), &
1209 ncol_global=ncol_mo(ispin), nrow_global=nrow_mo(ispin))
1210 CALL cp_fm_create(matrix=mo_coeff_tmp(iforce_eval, ispin), &
1211 matrix_struct=dft_control%qs_control%cdft_control%mo_coeff(ispin)%matrix_struct, &
1212 name=
"MO_COEFF_"//trim(adjustl(
cp_to_string(iforce_eval)))//
"_" &
1214 CALL cp_fm_to_fm(dft_control%qs_control%cdft_control%mo_coeff(ispin), &
1215 mo_coeff_tmp(iforce_eval, ispin))
1217 CALL cp_fm_release(dft_control%qs_control%cdft_control%mo_coeff)
1219 CALL cp_fm_struct_create(fm_struct_tmp, nrow_global=nrow_wmat, ncol_global=ncol_wmat, context=blacs_env, &
1220 para_env=force_env%sub_force_env(iforce_eval)%force_env%para_env, &
1221 square_blocks=.true.)
1223 CALL cp_fm_create(wmat_tmp(iforce_eval, ivar), fm_struct_tmp, name=
"w_matrix")
1224 CALL dbcsr_desymmetrize(dft_control%qs_control%cdft_control%wmat(ivar)%matrix, desymm_tmp)
1227 CALL dbcsr_release_p(dft_control%qs_control%cdft_control%wmat(ivar)%matrix)
1229 DEALLOCATE (dft_control%qs_control%cdft_control%wmat)
1232 IF (iforce_eval == 1)
THEN
1234 ncol_global=ncol_overlap, context=blacs_env, &
1235 para_env=force_env%sub_force_env(iforce_eval)%force_env%para_env)
1236 CALL cp_fm_create(matrix_s_tmp, fm_struct_tmp, name=
"s_matrix")
1238 CALL dbcsr_desymmetrize(dft_control%qs_control%cdft_control%matrix_s%matrix, desymm_tmp)
1242 CALL dbcsr_release_p(dft_control%qs_control%cdft_control%matrix_s%matrix)
1244 IF (mixed_cdft%calculate_metric)
THEN
1245 DO ispin = 1, nspins
1248 ncol_global=ncol_overlap, context=blacs_env, &
1249 para_env=force_env%sub_force_env(iforce_eval)%force_env%para_env)
1250 CALL cp_fm_create(matrix_p_tmp(iforce_eval, ispin), fm_struct_tmp, name=
"dm_matrix")
1252 CALL dbcsr_desymmetrize(dft_control%qs_control%cdft_control%matrix_p(ispin)%matrix, desymm_tmp)
1255 CALL dbcsr_release_p(dft_control%qs_control%cdft_control%matrix_p(ispin)%matrix)
1257 DEALLOCATE (dft_control%qs_control%cdft_control%matrix_p)
1260 IF (.NOT. uniform_occupation)
THEN
1261 DO ispin = 1, nspins
1262 IF (ncol_mo(ispin) /=
SIZE(dft_control%qs_control%cdft_control%occupations(ispin)%array))
THEN
1263 cpabort(
"Array dimensions dont match.")
1265 IF (force_env_qs%para_env%is_source())
THEN
1266 ALLOCATE (occno_tmp(iforce_eval, ispin)%array(ncol_mo(ispin)))
1267 occno_tmp(iforce_eval, ispin)%array = dft_control%qs_control%cdft_control%occupations(ispin)%array
1269 DEALLOCATE (dft_control%qs_control%cdft_control%occupations(ispin)%array)
1271 DEALLOCATE (dft_control%qs_control%cdft_control%occupations)
1276 context=mixed_cdft%blacs_env, para_env=force_env%para_env)
1277 CALL cp_fm_struct_create(fm_struct_overlap, nrow_global=nrow_overlap, ncol_global=ncol_overlap, &
1278 context=mixed_cdft%blacs_env, para_env=force_env%para_env)
1282 ALLOCATE (mixed_wmat_tmp(nforce_eval, nvar))
1283 IF (mixed_cdft%calculate_metric)
THEN
1284 ALLOCATE (mixed_matrix_p_tmp(nforce_eval, nspins))
1286 DO iforce_eval = 1, nforce_eval
1288 DO ispin = 1, nspins
1289 NULLIFY (fm_struct_mo)
1290 CALL cp_fm_struct_create(fm_struct_mo, nrow_global=nrow_mo(ispin), ncol_global=ncol_mo(ispin), &
1291 context=mixed_cdft%blacs_env, para_env=force_env%para_env)
1292 CALL cp_fm_create(matrix=mixed_mo_coeff(iforce_eval, ispin), &
1293 matrix_struct=fm_struct_mo, &
1294 name=
"MO_COEFF_"//trim(adjustl(
cp_to_string(iforce_eval)))//
"_" &
1297 mixed_mo_coeff(iforce_eval, ispin), &
1298 mixed_cdft%blacs_env%para_env)
1304 NULLIFY (w_matrix(iforce_eval, ivar)%matrix)
1306 CALL cp_fm_create(matrix=mixed_wmat_tmp(iforce_eval, ivar), &
1307 matrix_struct=fm_struct_wmat, &
1308 name=
"WEIGHT_"//trim(adjustl(
cp_to_string(iforce_eval)))//
"_MATRIX")
1310 mixed_wmat_tmp(iforce_eval, ivar), &
1311 mixed_cdft%blacs_env%para_env)
1315 w_matrix(iforce_eval, ivar)%matrix)
1319 IF (mixed_cdft%calculate_metric)
THEN
1320 DO ispin = 1, nspins
1321 NULLIFY (density_matrix(iforce_eval, ispin)%matrix)
1322 CALL dbcsr_init_p(density_matrix(iforce_eval, ispin)%matrix)
1323 CALL cp_fm_create(matrix=mixed_matrix_p_tmp(iforce_eval, ispin), &
1324 matrix_struct=fm_struct_overlap, &
1325 name=
"DENSITY_"//trim(adjustl(
cp_to_string(iforce_eval)))//
"_"// &
1328 mixed_matrix_p_tmp(iforce_eval, ispin), &
1329 mixed_cdft%blacs_env%para_env)
1332 density_matrix(iforce_eval, ispin)%matrix)
1338 DEALLOCATE (mo_coeff_tmp, wmat_tmp, mixed_wmat_tmp)
1339 IF (mixed_cdft%calculate_metric)
THEN
1340 DEALLOCATE (matrix_p_tmp)
1341 DEALLOCATE (mixed_matrix_p_tmp)
1345 matrix_struct=fm_struct_overlap, &
1346 name=
"OVERLAP_MATRIX")
1349 mixed_matrix_s_tmp, &
1350 mixed_cdft%blacs_env%para_env)
1355 IF (.NOT. uniform_occupation)
THEN
1356 DO iforce_eval = 1, nforce_eval
1357 DO ispin = 1, nspins
1358 ALLOCATE (mixed_cdft%occupations(iforce_eval, ispin)%array(ncol_mo(ispin)))
1359 mixed_cdft%occupations(iforce_eval, ispin)%array = 0.0_dp
1360 IF (
ASSOCIATED(occno_tmp(iforce_eval, ispin)%array))
THEN
1361 mixed_cdft%occupations(iforce_eval, ispin)%array = occno_tmp(iforce_eval, ispin)%array
1362 DEALLOCATE (occno_tmp(iforce_eval, ispin)%array)
1364 CALL force_env%para_env%sum(mixed_cdft%occupations(iforce_eval, ispin)%array)
1367 DEALLOCATE (occno_tmp)
1369 DEALLOCATE (ncol_mo, nrow_mo)
1381 INTEGER :: iounit, ipermutation, istate, ivar, &
1382 jstate, nforce_eval, npermutations, &
1388 NULLIFY (print_section, mixed_cdft)
1391 cpassert(
ASSOCIATED(force_env))
1393 force_env_section=force_env_section)
1394 CALL get_mixed_env(force_env%mixed_env, cdft_control=mixed_cdft)
1395 cpassert(
ASSOCIATED(mixed_cdft))
1399 cpassert(
ALLOCATED(mixed_cdft%results%strength))
1400 cpassert(
ALLOCATED(mixed_cdft%results%W_diagonal))
1401 cpassert(
ALLOCATED(mixed_cdft%results%S))
1402 cpassert(
ALLOCATED(mixed_cdft%results%energy))
1403 nforce_eval =
SIZE(force_env%sub_force_env)
1404 nvar =
SIZE(mixed_cdft%results%strength, 1)
1405 npermutations = nforce_eval*(nforce_eval - 1)/2
1406 IF (iounit > 0)
THEN
1407 WRITE (iounit,
'(/,T3,A,T66)') &
1408 '------------------------- CDFT coupling information --------------------------'
1409 WRITE (iounit,
'(T3,A,T66,(3X,F12.2))') &
1410 'Information at step (fs):', mixed_cdft%sim_step*mixed_cdft%sim_dt
1411 DO ipermutation = 1, npermutations
1413 WRITE (iounit,
'(/,T3,A)') repeat(
'#', 44)
1414 WRITE (iounit,
'(T3,A,I3,A,I3,A)')
'###### CDFT states I =', istate,
' and J = ', jstate,
' ######'
1415 WRITE (iounit,
'(T3,A)') repeat(
'#', 44)
1418 WRITE (iounit,
'(A)')
''
1420 WRITE (iounit,
'(T3,A,T60,(3X,I18))')
'Atomic group:', ivar
1421 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1422 'Strength of constraint I:', mixed_cdft%results%strength(ivar, istate)
1423 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1424 'Strength of constraint J:', mixed_cdft%results%strength(ivar, jstate)
1425 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1426 'Final value of constraint I:', mixed_cdft%results%W_diagonal(ivar, istate)
1427 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1428 'Final value of constraint J:', mixed_cdft%results%W_diagonal(ivar, jstate)
1430 WRITE (iounit,
'(/,T3,A,T60,(3X,F18.12))') &
1431 'Overlap between states I and J:', mixed_cdft%results%S(istate, jstate)
1432 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1433 'Charge transfer energy (J-I) (Hartree):', (mixed_cdft%results%energy(jstate) - mixed_cdft%results%energy(istate))
1435 IF (
ALLOCATED(mixed_cdft%results%rotation))
THEN
1436 IF (abs(mixed_cdft%results%rotation(ipermutation))*1.0e3_dp >= 0.1_dp)
THEN
1437 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1438 'Diabatic electronic coupling (rotation, mHartree):', &
1439 abs(mixed_cdft%results%rotation(ipermutation)*1.0e3_dp)
1441 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1442 'Diabatic electronic coupling (rotation, microHartree):', &
1443 abs(mixed_cdft%results%rotation(ipermutation)*1.0e6_dp)
1446 IF (
ALLOCATED(mixed_cdft%results%lowdin))
THEN
1447 IF (abs(mixed_cdft%results%lowdin(ipermutation))*1.0e3_dp >= 0.1_dp)
THEN
1448 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1449 'Diabatic electronic coupling (Lowdin, mHartree):', &
1450 abs(mixed_cdft%results%lowdin(ipermutation)*1.0e3_dp)
1452 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1453 'Diabatic electronic coupling (Lowdin, microHartree):', &
1454 abs(mixed_cdft%results%lowdin(ipermutation)*1.0e6_dp)
1457 IF (
ALLOCATED(mixed_cdft%results%wfn))
THEN
1458 IF (mixed_cdft%results%wfn(ipermutation)*1.0e3_dp >= 0.1_dp)
THEN
1459 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1460 'Diabatic electronic coupling (wfn overlap, mHartree):', &
1461 abs(mixed_cdft%results%wfn(ipermutation)*1.0e3_dp)
1463 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1464 'Diabatic electronic coupling (wfn overlap, microHartree):', &
1465 abs(mixed_cdft%results%wfn(ipermutation)*1.0e6_dp)
1468 IF (
ALLOCATED(mixed_cdft%results%nonortho))
THEN
1469 WRITE (iounit,
'(T3,A,T60,(3X,F18.12))') &
1470 'Diabatic electronic coupling (nonorthogonal, Hartree):', mixed_cdft%results%nonortho(ipermutation)
1472 IF (
ALLOCATED(mixed_cdft%results%metric))
THEN
1474 IF (
SIZE(mixed_cdft%results%metric, 2) == 1)
THEN
1475 WRITE (iounit,
'(T3,A,T66,(3X,F12.6))') &
1476 'Coupling reliability metric (0 is ideal):', mixed_cdft%results%metric(ipermutation, 1)
1478 WRITE (iounit,
'(T3,A,T54,(3X,2F12.6))') &
1479 'Coupling reliability metric (0 is ideal):', &
1480 mixed_cdft%results%metric(ipermutation, 1), mixed_cdft%results%metric(ipermutation, 2)
1484 WRITE (iounit,
'(T3,A)') &
1485 '------------------------------------------------------------------------------'
1488 "MIXED%MIXED_CDFT%PRINT%PROGRAM_RUN_INFO")
1503 NULLIFY (mixed_cdft)
1505 cpassert(
ASSOCIATED(force_env))
1506 CALL get_mixed_env(force_env%mixed_env, cdft_control=mixed_cdft)
1507 cpassert(
ASSOCIATED(mixed_cdft))
1522 INTEGER,
INTENT(IN) :: n, ipermutation
1523 INTEGER,
INTENT(OUT) :: i, j
1525 INTEGER :: kcol, kpermutation, krow, npermutations
1527 npermutations = n*(n - 1)/2
1528 IF (ipermutation > npermutations)
THEN
1529 cpabort(
"Permutation index out of bounds")
1533 DO kcol = krow + 1, n
1534 kpermutation = kpermutation + 1
1535 IF (kpermutation == ipermutation)
THEN
1556 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: fun
1557 REAL(kind=
dp),
INTENT(IN) :: th
1558 LOGICAL :: just_zero
1559 INTEGER,
OPTIONAL :: bounds(2), work
1561 INTEGER :: i1, i2, i3, lb, n1, n2, n3, nzeroed, &
1563 LOGICAL :: lb_final, ub_final
1569 IF (.NOT. just_zero)
THEN
1570 cpassert(
PRESENT(bounds))
1571 cpassert(
PRESENT(work))
1577 IF (.NOT. just_zero) nzeroed = 0
1580 IF (fun(i1, i2, i3) < th)
THEN
1581 IF (.NOT. just_zero)
THEN
1582 nzeroed = nzeroed + 1
1583 nzeroed_total = nzeroed_total + 1
1585 fun(i1, i2, i3) = 0.0_dp
1590 IF (.NOT. just_zero)
THEN
1591 IF (nzeroed == (n2*n1))
THEN
1592 IF (.NOT. lb_final)
THEN
1594 ELSE IF (.NOT. ub_final)
THEN
1599 IF (.NOT. lb_final) lb_final = .true.
1600 IF (ub_final) ub_final = .false.
1604 IF (.NOT. just_zero)
THEN
1605 IF (.NOT. ub_final) ub = n3
1608 bounds = bounds - (n3/2) - 1
1609 work = n3*n2*n1 - nzeroed_total
1628 INTENT(OUT) :: blocks
1629 LOGICAL,
INTENT(OUT) :: ignore_excited
1630 INTEGER,
INTENT(OUT) :: nrecursion
1632 INTEGER :: i, j, k, l, nblk, nforce_eval
1633 INTEGER,
DIMENSION(:),
POINTER :: tmplist
1634 LOGICAL :: do_recursive, explicit, has_duplicates
1639 NULLIFY (force_env_section, block_section)
1640 cpassert(
ASSOCIATED(force_env))
1641 nforce_eval =
SIZE(force_env%sub_force_env)
1644 force_env_section=force_env_section)
1648 IF (.NOT. explicit)
THEN
1649 CALL cp_abort(__location__, &
1650 "Block diagonalization of CDFT Hamiltonian was requested, but the "// &
1651 "corresponding input section is missing!")
1655 ALLOCATE (blocks(nblk))
1657 NULLIFY (blocks(i)%array)
1659 IF (
SIZE(tmplist) < 1)
THEN
1660 cpabort(
"Each BLOCK must contain at least 1 state.")
1662 ALLOCATE (blocks(i)%array(
SIZE(tmplist)))
1663 blocks(i)%array(:) = tmplist(:)
1669 DO j = 1,
SIZE(blocks(i)%array)
1670 IF (blocks(i)%array(j) < 1 .OR. blocks(i)%array(j) > nforce_eval)
THEN
1671 cpabort(
"Requested state does not exist.")
1676 has_duplicates = .false.
1679 DO j = 1,
SIZE(blocks(i)%array)
1680 DO k = j + 1,
SIZE(blocks(i)%array)
1681 IF (blocks(i)%array(j) == blocks(i)%array(k)) has_duplicates = .true.
1686 DO k = 1,
SIZE(blocks(i)%array)
1687 DO l = 1,
SIZE(blocks(j)%array)
1688 IF (blocks(i)%array(k) == blocks(j)%array(l)) has_duplicates = .true.
1693 IF (has_duplicates) cpabort(
"Duplicate states are not allowed.")
1695 IF (do_recursive)
THEN
1696 IF (
modulo(nblk, 2) /= 0)
THEN
1697 CALL cp_warn(__location__, &
1698 "Number of blocks not divisible with 2. Recursive diagonalization not possible. "// &
1699 "Calculation proceeds without.")
1704 IF (nrecursion /= 1 .AND. .NOT. ignore_excited)
THEN
1705 CALL cp_abort(__location__, &
1706 "Keyword IGNORE_EXCITED must be active for recursive diagonalization.")
1725 INTENT(OUT) :: h_block, s_block
1727 INTEGER :: i, icol, irow, j, k, nblk
1731 cpassert(
ASSOCIATED(mixed_cdft))
1734 ALLOCATE (h_block(nblk), s_block(nblk))
1736 NULLIFY (h_block(i)%array)
1737 NULLIFY (s_block(i)%array)
1738 ALLOCATE (h_block(i)%array(
SIZE(blocks(i)%array),
SIZE(blocks(i)%array)))
1739 ALLOCATE (s_block(i)%array(
SIZE(blocks(i)%array),
SIZE(blocks(i)%array)))
1741 DO j = 1,
SIZE(blocks(i)%array)
1744 DO k = 1,
SIZE(blocks(i)%array)
1746 h_block(i)%array(irow, icol) = mixed_cdft%results%H(blocks(i)%array(k), blocks(i)%array(j))
1747 s_block(i)%array(irow, icol) = mixed_cdft%results%S(blocks(i)%array(k), blocks(i)%array(j))
1751 IF (any(h_block(i)%array >= 0.0_dp))
THEN
1752 CALL cp_abort(__location__, &
1753 "At least one of the interaction energies within block "//trim(adjustl(
cp_to_string(i)))// &
1771 TYPE(
cp_2d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: h_block, s_block
1773 INTENT(OUT) :: eigenvalues
1775 INTEGER :: i, info, nblk, work_array_size
1776 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work
1777 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: h_mat_copy, s_mat_copy
1782 ALLOCATE (eigenvalues(nblk))
1784 NULLIFY (eigenvalues(i)%array)
1785 ALLOCATE (eigenvalues(i)%array(
SIZE(blocks(i)%array)))
1786 eigenvalues(i)%array = 0.0_dp
1790 ALLOCATE (h_mat_copy(
SIZE(blocks(i)%array),
SIZE(blocks(i)%array)))
1791 ALLOCATE (s_mat_copy(
SIZE(blocks(i)%array),
SIZE(blocks(i)%array)))
1792 h_mat_copy(:, :) = h_block(i)%array(:, :)
1793 s_mat_copy(:, :) = s_block(i)%array(:, :)
1794 CALL dsygv(1,
'V',
'U',
SIZE(blocks(i)%array), h_mat_copy,
SIZE(blocks(i)%array), &
1795 s_mat_copy,
SIZE(blocks(i)%array), eigenvalues(i)%array, work, -1, info)
1796 work_array_size = nint(work(1))
1797 DEALLOCATE (h_mat_copy, s_mat_copy)
1800 ALLOCATE (work(work_array_size))
1804 CALL dsygv(1,
'V',
'U',
SIZE(blocks(i)%array), h_block(i)%array,
SIZE(blocks(i)%array), &
1805 s_block(i)%array,
SIZE(blocks(i)%array), eigenvalues(i)%array, work, work_array_size, info)
1807 IF (info >
SIZE(blocks(i)%array))
THEN
1808 cpabort(
"Matrix S is not positive definite")
1810 cpabort(
"Diagonalization of H matrix failed.")
1835 INTEGER :: n, iounit
1837 CHARACTER(LEN=20) :: ilabel, jlabel
1838 CHARACTER(LEN=3) :: tmp
1839 INTEGER :: i, icol, ipermutation, irow, j, k, l, &
1841 LOGICAL :: ignore_excited
1842 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: h_mat, h_offdiag, s_mat, s_offdiag
1846 ALLOCATE (h_mat(n, n), s_mat(n, n))
1848 ignore_excited = (nblk == n)
1850 IF (iounit > 0)
WRITE (iounit,
'(/,T3,A)')
"Eigenvalues of the block diagonalized states"
1851 h_mat(:, :) = 0.0_dp
1852 s_mat(:, :) = 0.0_dp
1855 IF (iounit > 0)
WRITE (iounit,
'(T6,A,I3)')
"Block", i
1856 DO j = 1,
SIZE(eigenvalues(i)%array)
1857 h_mat(k, k) = eigenvalues(i)%array(j)
1858 s_mat(k, k) = 1.0_dp
1860 IF (iounit > 0)
THEN
1862 WRITE (iounit,
'(T9,A,T58,(3X,F20.14))')
'Ground state energy:', eigenvalues(i)%array(j)
1864 WRITE (iounit,
'(T9,A,I2,A,T58,(3X,F20.14))') &
1865 'Excited state (', j - 1,
' ) energy:', eigenvalues(i)%array(j)
1868 IF (ignore_excited .AND. j == 1)
EXIT
1872 npermutations = nblk*(nblk - 1)/2
1873 IF (iounit > 0)
WRITE (iounit,
'(/,T3,A)')
"Interactions between block diagonalized states"
1874 DO ipermutation = 1, npermutations
1877 ALLOCATE (h_offdiag(
SIZE(blocks(i)%array),
SIZE(blocks(j)%array)))
1878 ALLOCATE (s_offdiag(
SIZE(blocks(i)%array),
SIZE(blocks(j)%array)))
1880 DO k = 1,
SIZE(blocks(j)%array)
1883 DO l = 1,
SIZE(blocks(i)%array)
1885 h_offdiag(irow, icol) = mixed_cdft%results%H(blocks(i)%array(l), blocks(j)%array(k))
1886 s_offdiag(irow, icol) = mixed_cdft%results%S(blocks(i)%array(l), blocks(j)%array(k))
1890 IF (any(h_offdiag >= 0.0_dp))
THEN
1891 CALL cp_abort(__location__, &
1892 "At least one of the interaction energies between blocks "//trim(adjustl(
cp_to_string(i)))// &
1893 " and "//trim(adjustl(
cp_to_string(j)))//
" is repulsive.")
1896 h_offdiag(:, :) = matmul(h_offdiag, h_block(j)%array)
1897 h_offdiag(:, :) = matmul(transpose(h_block(i)%array), h_offdiag)
1898 s_offdiag(:, :) = matmul(s_offdiag, h_block(j)%array)
1899 s_offdiag(:, :) = matmul(transpose(h_block(i)%array), s_offdiag)
1904 IF (any(s_offdiag < 0.0_dp))
THEN
1905 DO l = 1,
SIZE(s_offdiag, 2)
1906 DO k = 1,
SIZE(s_offdiag, 1)
1907 IF (s_offdiag(k, l) < 0.0_dp)
THEN
1908 s_offdiag(k, l) = -1.0_dp*s_offdiag(k, l)
1909 h_offdiag(k, l) = -1.0_dp*h_offdiag(k, l)
1914 IF (ignore_excited)
THEN
1915 h_mat(i, j) = h_offdiag(1, 1)
1916 h_mat(j, i) = h_mat(i, j)
1917 s_mat(i, j) = s_offdiag(1, 1)
1918 s_mat(j, i) = s_mat(i, j)
1923 irow = irow +
SIZE(blocks(k)%array)
1926 icol = icol +
SIZE(blocks(k)%array)
1928 h_mat(irow:irow +
SIZE(h_offdiag, 1) - 1, icol:icol +
SIZE(h_offdiag, 2) - 1) = h_offdiag(:, :)
1929 h_mat(icol:icol +
SIZE(h_offdiag, 2) - 1, irow:irow +
SIZE(h_offdiag, 1) - 1) = transpose(h_offdiag)
1930 s_mat(irow:irow +
SIZE(h_offdiag, 1) - 1, icol:icol +
SIZE(h_offdiag, 2) - 1) = s_offdiag(:, :)
1931 s_mat(icol:icol +
SIZE(h_offdiag, 2) - 1, irow:irow +
SIZE(h_offdiag, 1) - 1) = transpose(s_offdiag)
1933 IF (iounit > 0)
THEN
1934 WRITE (iounit,
'(/,T3,A)') repeat(
'#', 39)
1935 WRITE (iounit,
'(T3,A,I3,A,I3,A)')
'###### Blocks I =', i,
' and J = ', j,
' ######'
1936 WRITE (iounit,
'(T3,A)') repeat(
'#', 39)
1937 WRITE (iounit,
'(T3,A)')
'Interaction energies'
1938 DO irow = 1,
SIZE(h_offdiag, 1)
1939 ilabel =
"(ground state)"
1941 IF (ignore_excited)
EXIT
1942 WRITE (tmp,
'(I3)') irow - 1
1943 ilabel =
"(excited state "//trim(adjustl(tmp))//
")"
1945 DO icol = 1,
SIZE(h_offdiag, 2)
1946 jlabel =
"(ground state)"
1948 IF (ignore_excited)
EXIT
1949 WRITE (tmp,
'(I3)') icol - 1
1950 jlabel =
"(excited state "//trim(adjustl(tmp))//
")"
1952 WRITE (iounit,
'(T6,A,T58,(3X,F20.14))') trim(ilabel)//
'-'//trim(jlabel)//
':', h_offdiag(irow, icol)
1955 WRITE (iounit,
'(T3,A)')
'Overlaps'
1956 DO irow = 1,
SIZE(h_offdiag, 1)
1957 ilabel =
"(ground state)"
1959 IF (ignore_excited)
EXIT
1960 ilabel =
"(excited state)"
1961 WRITE (tmp,
'(I3)') irow - 1
1962 ilabel =
"(excited state "//trim(adjustl(tmp))//
")"
1964 DO icol = 1,
SIZE(h_offdiag, 2)
1965 jlabel =
"(ground state)"
1967 IF (ignore_excited)
EXIT
1968 WRITE (tmp,
'(I3)') icol - 1
1969 jlabel =
"(excited state "//trim(adjustl(tmp))//
")"
1971 WRITE (iounit,
'(T6,A,T58,(3X,F20.14))') trim(ilabel)//
'-'//trim(jlabel)//
':', s_offdiag(irow, icol)
1975 DEALLOCATE (h_offdiag, s_offdiag)
1979 DEALLOCATE (h_mat, s_mat)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_create(blacs_env, para_env, blacs_grid_layout, blacs_repeatable, row_major, grid_2d)
allocates and initializes a type that represent a blacs context
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_release_p(matrix)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
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)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_release(matrix)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr_bc(fm, bc_mat)
Copy a BLACS matrix to a dbcsr matrix with a special block-cyclic distribution, which requires no com...
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_copy_general(source, destination, para_env)
General copy of a fm matrix to another fm matrix. Uses non-blocking MPI rather than ScaLAPACK.
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
subroutine, public cp_logger_set(logger, local_filename, global_filename)
sets various attributes of the given logger
subroutine, public cp_logger_create(logger, para_env, print_level, default_global_unit_nr, default_local_unit_nr, global_filename, local_filename, close_global_unit_on_dealloc, iter_info, close_local_unit_on_dealloc, suffix, template_logger)
initializes a logger
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
subroutine, public init_input_type(input_settings, nsmax, rs_grid_section, ilevel, higher_grid_layout)
parses an input section to assign the proper values to the input type
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, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
for a given dr()/dh(r) this will provide the bounds to be used if one wants to go over a sphere-subre...
integer function, public return_cube_max_iradius(info)
...
subroutine, public init_cube_info(info, dr, dh, dh_inv, ortho, max_radius)
...
Routines to efficiently handle dense polynomial in 3 variables up to a given degree....
subroutine, public init_d3_poly_module()
initialization of the cache, is called by functions in this module that use cached values
Interface for the force calculations.
subroutine, public multiple_fe_list(force_env_sections, root_section, i_force_eval, nforce_eval)
returns the order of the multiple force_env
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
subroutine, public init_gaussian_gridlevel(gridlevel_info, ngrid_levels, cutoff, rel_cutoff, print_section)
...
Define type storing the global information of a run. Keep the amount of stored data small....
The types needed for the calculation of Hirshfeld charges and related functions.
subroutine, public create_hirshfeld_type(hirshfeld_env)
...
subroutine, public set_hirshfeld_info(hirshfeld_env, shape_function_type, iterative, ref_charge, fnorm, radius_type, use_bohr)
Set values of a Hirshfeld env.
subroutine, public release_hirshfeld_type(hirshfeld_env)
...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Interface to the message passing library MPI.
Types for mixed CDFT calculations.
subroutine, public mixed_cdft_result_type_set(results, lowdin, wfn, nonortho, metric, rotation, h, s, wad, wda, w_diagonal, energy, strength, s_minushalf)
Updates arrays within the mixed CDFT result container.
subroutine, public mixed_cdft_result_type_release(results)
Releases all arrays within the mixed CDFT result container.
subroutine, public mixed_cdft_work_type_init(matrix)
Initializes the mixed_cdft_work_type.
Utility subroutines for mixed CDFT calculations.
subroutine, public map_permutation_to_states(n, ipermutation, i, j)
Given the size of a symmetric matrix and a permutation index, returns indices (i, j) of the off-diago...
subroutine, public mixed_cdft_init_structures(force_env, force_env_qs, mixed_env, mixed_cdft, settings)
Initialize all the structures needed for a mixed CDFT calculation.
subroutine, public mixed_cdft_transfer_settings(force_env, mixed_cdft, settings)
Transfer settings to mixed_cdft.
subroutine, public mixed_cdft_diagonalize_blocks(blocks, h_block, s_block, eigenvalues)
Diagonalizes each of the matrix blocks.
subroutine, public mixed_cdft_print_couplings(force_env)
Routine to print out the electronic coupling(s) between CDFT states.
subroutine, public mixed_cdft_read_block_diag(force_env, blocks, ignore_excited, nrecursion)
Read input section related to block diagonalization of the mixed CDFT Hamiltonian matrix.
subroutine, public mixed_cdft_redistribute_arrays(force_env)
Redistribute arrays needed for an ET coupling calculation from individual CDFT states to the mixed CD...
subroutine, public mixed_cdft_assemble_block_diag(mixed_cdft, blocks, h_block, eigenvalues, n, iounit)
Assembles the new block diagonalized mixed CDFT Hamiltonian and overlap matrices.
subroutine, public hfun_zero(fun, th, just_zero, bounds, work)
Determine confinement bounds along confinement dir (hardcoded to be z) and determine the number of no...
subroutine, public mixed_cdft_get_blocks(mixed_cdft, blocks, h_block, s_block)
Assembles the matrix blocks from the mixed CDFT Hamiltonian.
subroutine, public mixed_cdft_release_work(force_env)
Release storage reserved for mixed CDFT matrices.
subroutine, public mixed_cdft_parse_settings(force_env, mixed_env, mixed_cdft, settings, natom)
Parse settings for mixed cdft calculation and check their consistency.
subroutine, public get_mixed_env(mixed_env, atomic_kind_set, particle_set, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, mixed_energy, para_env, sub_para_env, subsys, input, results, cdft_control)
Get the MIXED environment.
methods of pw_env that have dependence on qs_env
subroutine, public pw_env_create(pw_env)
creates a pw_env, if qs_env is given calls pw_env_rebuild
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
integer, parameter, public halfspace
This module defines the grid data type and some basic operations on it.
integer, parameter, public do_pw_grid_blocked_false
subroutine, public pw_grid_release(pw_grid)
releases the given pw grid
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public pw_pool_create(pool, pw_grid, max_cache)
creates a pool for pw
Defines CDFT control structures.
subroutine, public cdft_control_create(cdft_control)
create the cdft_control_type
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.
Define the quickstep kind type and their sub types.
subroutine, public create_qs_kind_set(qs_kind_set, atomic_kind_set, kind_section, para_env, force_env_section, silent)
Read an atomic kind set data set from the input file.
subroutine, public rs_grid_print(rs, iounit)
Print information on grids to output.
subroutine, public rs_grid_create(rs, desc)
...
subroutine, public rs_grid_create_descriptor(desc, pw_grid, input_settings, border_points)
Determine the setup of real space grids - this is divided up into the creation of a descriptor and th...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represent a pointer to a 1d array
represent a pointer to a 1d array
represent a pointer to a 2d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
Container for constraint settings to check consistency of force_evals.
Main mixed CDFT control type.
contained for different pw related things
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.