162#include "./base/base_uses.f90"
168 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'force_env_methods'
174 INTEGER,
SAVE,
PRIVATE :: last_force_env_id = 0
194 consistent_energies, skip_external_control, eval_energy_forces, &
195 require_consistent_energy_force, linres, calc_stress_tensor)
198 LOGICAL,
INTENT(IN),
OPTIONAL :: calc_force, consistent_energies, skip_external_control, &
199 eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor
201 REAL(kind=
dp),
PARAMETER :: ateps = 1.0e-6_dp
203 CHARACTER(LEN=default_string_length) :: unit_string
204 INTEGER :: ikind, nat, ndigits, nfixed_atoms, &
205 nfixed_atoms_total, nkind, &
206 output_unit, print_forces, print_grrm, &
208 LOGICAL :: calculate_forces, calculate_stress_tensor, energy_consistency, eval_ef, &
209 linres_run, my_skip, print_components
210 REAL(kind=
dp) :: checksum, e_entropy, e_gap, e_pot, &
212 REAL(kind=
dp),
DIMENSION(3) :: grand_total_force, total_force
224 NULLIFY (logger, virial, subsys, atprop_env, cell)
228 calculate_forces = .true.
229 energy_consistency = .false.
235 IF (
PRESENT(eval_energy_forces)) eval_ef = eval_energy_forces
236 IF (
PRESENT(skip_external_control)) my_skip = skip_external_control
237 IF (
PRESENT(calc_force)) calculate_forces = calc_force
238 IF (
PRESENT(calc_stress_tensor))
THEN
239 calculate_stress_tensor = calc_stress_tensor
241 calculate_stress_tensor = calculate_forces
243 IF (
PRESENT(consistent_energies)) energy_consistency = consistent_energies
244 IF (
PRESENT(linres)) linres_run = linres
246 cpassert(
ASSOCIATED(force_env))
247 cpassert(force_env%ref_count > 0)
250 CALL cp_subsys_get(subsys, virial=virial, atprop=atprop_env, cell=cell)
251 IF (virial%pv_availability)
CALL zero_virial(virial, reset=.false.)
256 SELECT CASE (force_env%in_use)
262 IF (virial%pv_availability .AND. calculate_stress_tensor)
THEN
267 e_gap = force_env%pwdft_env%energy%band_gap
268 e_entropy = force_env%pwdft_env%energy%entropy
277 calculate_forces, energy_consistency, linres=linres_run)
280 calculate_forces, energy_consistency, linres=linres_run, &
281 require_consistent_energy_force=require_consistent_energy_force)
283 CALL mixed_energy_forces(force_env, calculate_forces)
288 CALL embed_energy(force_env)
296 IF (virial%pv_availability)
THEN
297 IF (virial%pv_numer .AND. calculate_stress_tensor)
THEN
301 IF (calculate_forces)
THEN
305 IF (calculate_stress_tensor)
THEN
306 CALL cp_warn(__location__,
"The calculation of the stress tensor "// &
307 "requires the calculation of the forces")
317 IF (.NOT. my_skip)
THEN
319 IF (
ASSOCIATED(force_env%fp_env))
THEN
320 IF (force_env%fp_env%use_fp)
THEN
321 CALL fp_eval(force_env%fp_env, subsys, cell)
339 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%PROGRAM_RUN_INFO", &
341 IF (output_unit > 0)
THEN
345 WRITE (unit=output_unit, fmt=
"(/,T2,A,T55,F26.15)") &
346 "ENERGY| Total FORCE_EVAL ( "//trim(adjustl(
use_prog_name(force_env%in_use)))// &
347 " ) energy ["//trim(adjustl(unit_string))//
"]", e_pot*fconv
348 IF (e_gap > -0.1_dp)
THEN
349 WRITE (unit=output_unit, fmt=
"(/,T2,A,T55,F26.15)") &
350 "ENERGY| Total FORCE_EVAL ( "//trim(adjustl(
use_prog_name(force_env%in_use)))// &
351 " ) gap ["//trim(adjustl(unit_string))//
"]", e_gap*fconv
353 IF (e_entropy > -0.1_dp)
THEN
354 WRITE (unit=output_unit, fmt=
"(/,T2,A,T55,F26.15)") &
355 "ENERGY| Total FORCE_EVAL ( "//trim(adjustl(
use_prog_name(force_env%in_use)))// &
356 " ) free energy ["//trim(adjustl(unit_string))//
"]", (e_pot - e_entropy)*fconv
360 "PRINT%PROGRAM_RUN_INFO")
364 cpabort(
"Potential energy is an abnormal value (NaN/Inf).")
369 IF ((print_forces > 0) .AND. calculate_forces)
THEN
372 core_particles=core_particles, &
373 particles=particles, &
374 shell_particles=shell_particles)
380 IF (
ASSOCIATED(core_particles) .OR.
ASSOCIATED(shell_particles))
THEN
381 CALL write_forces(particles, print_forces,
"Atomic", ndigits, unit_string, &
382 total_force, zero_force_core_shell_atom=.true.)
383 grand_total_force(1:3) = total_force(1:3)
384 IF (
ASSOCIATED(core_particles))
THEN
385 CALL write_forces(core_particles, print_forces,
"Core particle", ndigits, &
386 unit_string, total_force, zero_force_core_shell_atom=.false.)
387 grand_total_force(:) = grand_total_force(:) + total_force(:)
389 IF (
ASSOCIATED(shell_particles))
THEN
390 CALL write_forces(shell_particles, print_forces,
"Shell particle", ndigits, &
391 unit_string, total_force, zero_force_core_shell_atom=.false., &
392 grand_total_force=grand_total_force)
395 CALL write_forces(particles, print_forces,
"Atomic", ndigits, unit_string, total_force)
401 IF (virial%pv_availability)
THEN
404 IF (calculate_forces .AND. calculate_stress_tensor)
THEN
405 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%STRESS_TENSOR", &
406 extension=
".stress_tensor")
407 IF (output_unit > 0)
THEN
409 l_val=print_components)
412 IF (print_components)
THEN
413 IF ((.NOT. virial%pv_numer) .AND. (force_env%in_use ==
use_qs_force))
THEN
417 CALL write_stress_tensor(virial%pv_virial, output_unit, cell, unit_string, virial%pv_numer)
420 "PRINT%STRESS_TENSOR")
425 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%STRESS_TENSOR", &
426 extension=
".stress_tensor")
427 IF (output_unit > 0)
THEN
428 CALL cp_warn(__location__,
"To print the stress tensor switch on the "// &
429 "virial evaluation with the keyword: STRESS_TENSOR")
432 "PRINT%STRESS_TENSOR")
436 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%PROGRAM_RUN_INFO", &
438 IF (atprop_env%energy)
THEN
439 CALL force_env%para_env%sum(atprop_env%atener)
441 IF (output_unit > 0)
THEN
444 CALL write_atener(output_unit, particles, atprop_env%atener,
"Mulliken Atomic Energies")
447 checksum = abs(e_pot - sum_energy)
448 WRITE (unit=output_unit, fmt=
"(/,(T2,A,T56,F25.13))") &
449 "Potential energy (Atomic):", sum_energy, &
450 "Potential energy (Total) :", e_pot, &
451 "Difference :", checksum
452 cpassert((checksum < ateps*abs(e_pot)))
455 "PRINT%PROGRAM_RUN_INFO")
460 file_position=
"REWIND", extension=
".rrm")
461 IF (print_grrm > 0)
THEN
464 molecule_kinds=molecule_kinds)
466 nfixed_atoms_total = 0
467 nkind = molecule_kinds%n_els
468 molecule_kind_set => molecule_kinds%els
470 molecule_kind => molecule_kind_set(ikind)
472 nfixed_atoms_total = nfixed_atoms_total + nfixed_atoms
475 CALL write_grrm(print_grrm, force_env, particles%els, e_pot, fixed_atoms=nfixed_atoms_total)
480 file_position=
"REWIND", extension=
".scine")
481 IF (print_scine > 0)
THEN
485 CALL write_scine(print_scine, force_env, particles%els, e_pot)
504 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: dx
506 REAL(kind=
dp),
PARAMETER :: default_dx = 0.001_dp
508 CHARACTER(LEN=default_string_length) :: unit_string
509 INTEGER :: i, ip, iq, j, k, natom, ncore, nshell, &
510 output_unit, symmetry_id
511 REAL(kind=
dp) :: dx_w
512 REAL(kind=
dp),
DIMENSION(2) :: numer_energy
513 REAL(kind=
dp),
DIMENSION(3) :: s
514 REAL(kind=
dp),
DIMENSION(3, 3) :: numer_stress
515 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: ref_pos_atom, ref_pos_core, ref_pos_shell
516 TYPE(
cell_type),
POINTER :: cell, cell_local
525 NULLIFY (core_particles)
527 NULLIFY (shell_particles)
528 NULLIFY (ref_pos_atom)
529 NULLIFY (ref_pos_core)
530 NULLIFY (ref_pos_shell)
534 numer_stress = 0.0_dp
539 IF (
PRESENT(dx)) dx_w = dx
540 CALL force_env_get(force_env, subsys=subsys, globenv=globenv)
542 core_particles=core_particles, &
543 particles=particles, &
544 shell_particles=shell_particles, &
546 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%STRESS_TENSOR", &
547 extension=
".stress_tensor")
548 IF (output_unit > 0)
THEN
549 WRITE (output_unit,
"(/A,A/)")
" **************************** ", &
550 "NUMERICAL STRESS ********************************"
554 natom = particles%n_els
555 ALLOCATE (ref_pos_atom(natom, 3))
557 ref_pos_atom(i, :) = particles%els(i)%r
559 IF (
ASSOCIATED(core_particles))
THEN
560 ncore = core_particles%n_els
561 ALLOCATE (ref_pos_core(ncore, 3))
563 ref_pos_core(i, :) = core_particles%els(i)%r
566 IF (
ASSOCIATED(shell_particles))
THEN
567 nshell = shell_particles%n_els
568 ALLOCATE (ref_pos_shell(nshell, 3))
570 ref_pos_shell(i, :) = shell_particles%els(i)%r
575 symmetry_id = cell%symmetry_id
583 IF (virial%pv_diagonal .AND. (ip /= iq)) cycle
585 cell%hmat(ip, iq) = cell_local%hmat(ip, iq) - (-1.0_dp)**k*dx_w
602 calc_force=.false., &
603 consistent_energies=.true., &
604 calc_stress_tensor=.false.)
605 CALL force_env_get(force_env, potential_energy=numer_energy(k))
607 cell%hmat(ip, iq) = cell_local%hmat(ip, iq)
610 numer_stress(ip, iq) = 0.5_dp*(numer_energy(1) - numer_energy(2))/dx_w
611 IF (output_unit > 0)
THEN
612 IF (globenv%run_type_id ==
debug_run)
THEN
613 WRITE (unit=output_unit, fmt=
"(/,T2,A,T19,A,F7.4,A,T44,A,F7.4,A,T69,A)") &
614 "DEBUG|",
"E("//achar(119 + ip)//achar(119 + iq)//
" +", dx_w,
")", &
615 "E("//achar(119 + ip)//achar(119 + iq)//
" -", dx_w,
")", &
617 WRITE (unit=output_unit, fmt=
"(T2,A,2(1X,F24.8),1X,F22.8)") &
618 "DEBUG|", numer_energy(1:2), numer_stress(ip, iq)
620 WRITE (unit=output_unit, fmt=
"(/,T7,A,F7.4,A,T27,A,F7.4,A,T49,A)") &
621 "E("//achar(119 + ip)//achar(119 + iq)//
" +", dx_w,
")", &
622 "E("//achar(119 + ip)//achar(119 + iq)//
" -", dx_w,
")", &
624 WRITE (unit=output_unit, fmt=
"(3(1X,F19.8))") &
625 numer_energy(1:2), numer_stress(ip, iq)
632 cell%symmetry_id = symmetry_id
635 particles%els(i)%r = ref_pos_atom(i, :)
638 core_particles%els(i)%r = ref_pos_core(i, :)
641 shell_particles%els(i)%r = ref_pos_shell(i, :)
644 calc_force=.false., &
645 consistent_energies=.true., &
646 calc_stress_tensor=.false.)
649 virial%pv_virial = 0.0_dp
653 virial%pv_virial(i, j) = virial%pv_virial(i, j) - &
654 0.5_dp*(numer_stress(i, k)*cell_local%hmat(j, k) + &
655 numer_stress(j, k)*cell_local%hmat(i, k))
660 IF (output_unit > 0)
THEN
661 IF (globenv%run_type_id ==
debug_run)
THEN
664 CALL write_stress_tensor(virial%pv_virial, output_unit, cell, unit_string, virial%pv_numer)
666 WRITE (output_unit,
"(/,A,/)")
" **************************** "// &
667 "NUMERICAL STRESS END *****************************"
671 "PRINT%STRESS_TENSOR")
674 IF (
ASSOCIATED(ref_pos_atom))
THEN
675 DEALLOCATE (ref_pos_atom)
677 IF (
ASSOCIATED(ref_pos_core))
THEN
678 DEALLOCATE (ref_pos_core)
680 IF (
ASSOCIATED(ref_pos_shell))
THEN
681 DEALLOCATE (ref_pos_shell)
683 IF (
ASSOCIATED(cell_local))
CALL cell_release(cell_local)
712 qs_env, meta_env, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, force_env_section, &
713 mixed_env, embed_env, nnp_env, ipi_env)
723 POINTER :: sub_force_env
731 TYPE(
nnp_type),
OPTIONAL,
POINTER :: nnp_env
735 NULLIFY (force_env%fist_env, force_env%qs_env, &
736 force_env%para_env, force_env%globenv, &
737 force_env%meta_env, force_env%sub_force_env, &
738 force_env%qmmm_env, force_env%qmmmx_env, force_env%fp_env, &
739 force_env%force_env_section, force_env%eip_env, force_env%mixed_env, &
740 force_env%embed_env, force_env%pwdft_env, force_env%nnp_env, &
741 force_env%root_section)
742 last_force_env_id = last_force_env_id + 1
743 force_env%ref_count = 1
745 force_env%additional_potential = 0.0_dp
747 force_env%globenv => globenv
750 force_env%root_section => root_section
753 force_env%para_env => para_env
754 CALL force_env%para_env%retain()
757 force_env%force_env_section => force_env_section
759 IF (
PRESENT(fist_env))
THEN
760 cpassert(
ASSOCIATED(fist_env))
761 cpassert(force_env%in_use == 0)
763 force_env%fist_env => fist_env
765 IF (
PRESENT(eip_env))
THEN
766 cpassert(
ASSOCIATED(eip_env))
767 cpassert(force_env%in_use == 0)
769 force_env%eip_env => eip_env
771 IF (
PRESENT(pwdft_env))
THEN
772 cpassert(
ASSOCIATED(pwdft_env))
773 cpassert(force_env%in_use == 0)
775 force_env%pwdft_env => pwdft_env
777 IF (
PRESENT(qs_env))
THEN
778 cpassert(
ASSOCIATED(qs_env))
779 cpassert(force_env%in_use == 0)
781 force_env%qs_env => qs_env
783 IF (
PRESENT(qmmm_env))
THEN
784 cpassert(
ASSOCIATED(qmmm_env))
785 cpassert(force_env%in_use == 0)
787 force_env%qmmm_env => qmmm_env
789 IF (
PRESENT(qmmmx_env))
THEN
790 cpassert(
ASSOCIATED(qmmmx_env))
791 cpassert(force_env%in_use == 0)
793 force_env%qmmmx_env => qmmmx_env
795 IF (
PRESENT(mixed_env))
THEN
796 cpassert(
ASSOCIATED(mixed_env))
797 cpassert(force_env%in_use == 0)
799 force_env%mixed_env => mixed_env
801 IF (
PRESENT(embed_env))
THEN
802 cpassert(
ASSOCIATED(embed_env))
803 cpassert(force_env%in_use == 0)
805 force_env%embed_env => embed_env
807 IF (
PRESENT(nnp_env))
THEN
808 cpassert(
ASSOCIATED(nnp_env))
809 cpassert(force_env%in_use == 0)
811 force_env%nnp_env => nnp_env
813 IF (
PRESENT(ipi_env))
THEN
814 cpassert(
ASSOCIATED(ipi_env))
815 cpassert(force_env%in_use == 0)
817 force_env%ipi_env => ipi_env
819 cpassert(force_env%in_use /= 0)
821 IF (
PRESENT(sub_force_env))
THEN
822 force_env%sub_force_env => sub_force_env
825 IF (
PRESENT(meta_env))
THEN
826 force_env%meta_env => meta_env
828 NULLIFY (force_env%meta_env)
849 SUBROUTINE mixed_energy_forces(force_env, calculate_forces)
852 LOGICAL,
INTENT(IN) :: calculate_forces
854 CHARACTER(LEN=default_path_length) :: coupling_function
855 CHARACTER(LEN=default_string_length) :: def_error, description, this_error
856 INTEGER :: iforce_eval, iparticle, istate(2), &
857 jparticle, mixing_type, my_group, &
858 natom, nforce_eval, source, unit_nr
859 INTEGER,
DIMENSION(:),
POINTER :: glob_natoms, itmplist, map_index
860 LOGICAL :: dip_exists
861 REAL(kind=
dp) :: coupling_parameter, dedf, der_1, der_2, &
862 dx, energy, err, lambda, lerr, &
863 restraint_strength, restraint_target, &
865 REAL(kind=
dp),
DIMENSION(3) :: dip_mix
866 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energies
878 mapping_section, mixed_section, &
881 TYPE(
virial_type),
POINTER :: loc_virial, virial_mix
884 cpassert(
ASSOCIATED(force_env))
888 force_env_section=force_env_section, &
889 root_section=root_section, &
892 particles=particles_mix, &
895 NULLIFY (map_index, glob_natoms, global_forces, itmplist)
897 nforce_eval =
SIZE(force_env%sub_force_env)
901 ALLOCATE (subsystems(nforce_eval))
902 ALLOCATE (particles(nforce_eval))
904 ALLOCATE (global_forces(nforce_eval))
905 ALLOCATE (energies(nforce_eval))
906 ALLOCATE (glob_natoms(nforce_eval))
907 ALLOCATE (virials(nforce_eval))
908 ALLOCATE (results(nforce_eval))
915 IF (.NOT. force_env%mixed_env%do_mixed_cdft)
THEN
916 DO iforce_eval = 1, nforce_eval
917 NULLIFY (subsystems(iforce_eval)%subsys, particles(iforce_eval)%list)
918 NULLIFY (results(iforce_eval)%results, virials(iforce_eval)%virial)
919 ALLOCATE (virials(iforce_eval)%virial)
921 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
923 my_group = force_env%mixed_env%group_distribution(force_env%para_env%mepos)
924 my_logger => force_env%mixed_env%sub_logger(my_group + 1)%p
930 CALL force_env_get(force_env=force_env%sub_force_env(iforce_eval)%force_env, &
931 subsys=subsystems(iforce_eval)%subsys)
934 CALL cp_subsys_set(subsystems(iforce_eval)%subsys, cell=cell_mix)
938 particles=particles(iforce_eval)%list)
941 natom =
SIZE(particles(iforce_eval)%list%els)
947 DO iparticle = 1, natom
948 jparticle = map_index(iparticle)
949 particles(iforce_eval)%list%els(iparticle)%r = particles_mix%els(jparticle)%r
954 calc_force=calculate_forces, &
955 skip_external_control=.true.)
958 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
959 CALL force_env_get(force_env%sub_force_env(iforce_eval)%force_env, &
960 potential_energy=energy)
962 virial=loc_virial, results=loc_results)
963 energies(iforce_eval) = energy
964 glob_natoms(iforce_eval) = natom
965 virials(iforce_eval)%virial = loc_virial
969 IF (
ASSOCIATED(map_index))
THEN
970 DEALLOCATE (map_index)
975 CALL mixed_cdft_energy_forces(force_env, calculate_forces, particles, energies, &
976 glob_natoms, virials, results)
979 CALL force_env%para_env%sync()
981 CALL mixed_cdft_post_energy_forces(force_env)
983 CALL force_env%para_env%sum(energies)
984 CALL force_env%para_env%sum(glob_natoms)
986 DO iforce_eval = 1, nforce_eval
987 ALLOCATE (global_forces(iforce_eval)%forces(3, glob_natoms(iforce_eval)))
988 global_forces(iforce_eval)%forces = 0.0_dp
989 IF (
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env))
THEN
990 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
992 DO iparticle = 1, glob_natoms(iforce_eval)
993 global_forces(iforce_eval)%forces(:, iparticle) = &
994 particles(iforce_eval)%list%els(iparticle)%f
998 CALL force_env%para_env%sum(global_forces(iforce_eval)%forces)
1000 CALL force_env%para_env%sum(virials(iforce_eval)%virial%pv_total)
1001 CALL force_env%para_env%sum(virials(iforce_eval)%virial%pv_kinetic)
1002 CALL force_env%para_env%sum(virials(iforce_eval)%virial%pv_virial)
1003 CALL force_env%para_env%sum(virials(iforce_eval)%virial%pv_xc)
1004 CALL force_env%para_env%sum(virials(iforce_eval)%virial%pv_fock_4c)
1005 CALL force_env%para_env%sum(virials(iforce_eval)%virial%pv_constraint)
1008 IF (
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env))
THEN
1009 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source()) &
1010 source = force_env%para_env%mepos
1012 CALL force_env%para_env%sum(source)
1016 force_env%mixed_env%energies = energies
1019 mixed_energy=mixed_energy)
1023 DO iparticle = 1,
SIZE(particles_mix%els)
1024 particles_mix%els(iparticle)%f(:) = 0.0_dp
1028 SELECT CASE (mixing_type)
1031 cpassert(nforce_eval == 2)
1033 mixed_energy%pot = lambda*energies(1) + (1.0_dp - lambda)*energies(2)
1035 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1036 lambda, 1, nforce_eval, map_index, mapping_section, .true.)
1037 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1038 (1.0_dp - lambda), 2, nforce_eval, map_index, mapping_section, .false.)
1041 cpassert(nforce_eval == 2)
1042 IF (energies(1) < energies(2))
THEN
1043 mixed_energy%pot = energies(1)
1044 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1045 1.0_dp, 1, nforce_eval, map_index, mapping_section, .true.)
1047 mixed_energy%pot = energies(2)
1048 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1049 1.0_dp, 2, nforce_eval, map_index, mapping_section, .true.)
1053 cpassert(nforce_eval == 2)
1055 r_val=coupling_parameter)
1056 sd = sqrt((energies(1) - energies(2))**2 + 4.0_dp*coupling_parameter**2)
1057 der_1 = (1.0_dp - (1.0_dp/(2.0_dp*sd))*2.0_dp*(energies(1) - energies(2)))/2.0_dp
1058 der_2 = (1.0_dp + (1.0_dp/(2.0_dp*sd))*2.0_dp*(energies(1) - energies(2)))/2.0_dp
1059 mixed_energy%pot = (energies(1) + energies(2) - sd)/2.0_dp
1061 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1062 der_1, 1, nforce_eval, map_index, mapping_section, .true.)
1063 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1064 der_2, 2, nforce_eval, map_index, mapping_section, .false.)
1067 cpassert(nforce_eval == 2)
1069 r_val=restraint_target)
1071 r_val=restraint_strength)
1072 mixed_energy%pot = energies(1) + restraint_strength*(energies(1) - energies(2) - restraint_target)**2
1073 der_2 = -2.0_dp*restraint_strength*(energies(1) - energies(2) - restraint_target)
1074 der_1 = 1.0_dp - der_2
1076 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1077 der_1, 1, nforce_eval, map_index, mapping_section, .true.)
1078 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1079 der_2, 2, nforce_eval, map_index, mapping_section, .false.)
1083 CALL get_generic_info(gen_section,
"MIXING_FUNCTION", coupling_function, force_env%mixed_env%par, &
1084 force_env%mixed_env%val, energies)
1086 CALL parsef(1, trim(coupling_function), force_env%mixed_env%par)
1088 mixed_energy%pot =
evalf(1, force_env%mixed_env%val)
1092 DO iforce_eval = 1, nforce_eval
1095 dedf =
evalfd(1, iforce_eval, force_env%mixed_env%val, dx, err)
1096 IF (abs(err) > lerr)
THEN
1097 WRITE (this_error,
"(A,G12.6,A)")
"(", err,
")"
1098 WRITE (def_error,
"(A,G12.6,A)")
"(", lerr,
")"
1101 CALL cp_warn(__location__, &
1102 'ASSERTION (cond) failed at line '//
cp_to_string(__line__)// &
1103 ' Error '//trim(this_error)//
' in computing numerical derivatives larger then'// &
1104 trim(def_error)//
' .')
1107 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1108 dedf, iforce_eval, nforce_eval, map_index, mapping_section, .false.)
1109 force_env%mixed_env%val(iforce_eval) = energies(iforce_eval)
1112 force_env%mixed_env%dx = dx
1113 force_env%mixed_env%lerr = lerr
1114 force_env%mixed_env%coupling_function = trim(coupling_function)
1121 IF (
SIZE(itmplist) /= 2) &
1122 CALL cp_abort(__location__, &
1123 "Keyword FORCE_STATES takes exactly two input values.")
1124 IF (any(itmplist .LT. 0)) &
1125 cpabort(
"Invalid force_eval index.")
1127 IF (istate(1) > nforce_eval .OR. istate(2) > nforce_eval) &
1128 cpabort(
"Invalid force_eval index.")
1129 mixed_energy%pot = lambda*energies(istate(1)) + (1.0_dp - lambda)*energies(istate(2))
1131 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1132 lambda, istate(1), nforce_eval, map_index, mapping_section, .true.)
1133 CALL mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, &
1134 (1.0_dp - lambda), istate(2), nforce_eval, map_index, mapping_section, .false.)
1139 DO iforce_eval = 1, nforce_eval
1140 DEALLOCATE (global_forces(iforce_eval)%forces)
1141 IF (
ASSOCIATED(virials(iforce_eval)%virial))
DEALLOCATE (virials(iforce_eval)%virial)
1144 DEALLOCATE (global_forces)
1145 DEALLOCATE (subsystems)
1146 DEALLOCATE (particles)
1147 DEALLOCATE (energies)
1148 DEALLOCATE (glob_natoms)
1149 DEALLOCATE (virials)
1150 DEALLOCATE (results)
1153 extension=
".data", middle_name=
"MIXED_DIPOLE", log_filename=.false.)
1154 IF (unit_nr > 0)
THEN
1155 description =
'[DIPOLE]'
1156 dip_exists =
test_for_result(results=results_mix, description=description)
1157 IF (dip_exists)
THEN
1158 CALL get_results(results=results_mix, description=description, values=dip_mix)
1159 WRITE (unit_nr,
'(/,1X,A,T48,3F21.16)')
"MIXED ENV| DIPOLE ( A.U.)|", dip_mix
1160 WRITE (unit_nr,
'( 1X,A,T48,3F21.16)')
"MIXED ENV| DIPOLE (Debye)|", dip_mix*
debye
1162 WRITE (unit_nr, *)
"NO FORCE_EVAL section calculated the dipole"
1166 END SUBROUTINE mixed_energy_forces
1181 SUBROUTINE mixed_cdft_energy_forces(force_env, calculate_forces, particles, energies, &
1182 glob_natoms, virials, results)
1184 LOGICAL,
INTENT(IN) :: calculate_forces
1186 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energies
1187 INTEGER,
DIMENSION(:),
POINTER :: glob_natoms
1191 INTEGER :: iforce_eval, iparticle, jparticle, &
1192 my_group, natom, nforce_eval
1193 INTEGER,
DIMENSION(:),
POINTER :: map_index
1194 REAL(kind=
dp) :: energy
1202 mixed_section, root_section
1203 TYPE(
virial_type),
POINTER :: loc_virial, virial_mix
1206 cpassert(
ASSOCIATED(force_env))
1209 subsys=subsys_mix, &
1210 force_env_section=force_env_section, &
1211 root_section=root_section, &
1214 particles=particles_mix, &
1215 virial=virial_mix, &
1216 results=results_mix)
1218 nforce_eval =
SIZE(force_env%sub_force_env)
1221 ALLOCATE (subsystems(nforce_eval))
1222 DO iforce_eval = 1, nforce_eval
1223 NULLIFY (subsystems(iforce_eval)%subsys, particles(iforce_eval)%list)
1224 NULLIFY (results(iforce_eval)%results, virials(iforce_eval)%virial)
1225 ALLOCATE (virials(iforce_eval)%virial)
1227 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1229 CALL force_env_get(force_env=force_env%sub_force_env(iforce_eval)%force_env, &
1230 subsys=subsystems(iforce_eval)%subsys)
1233 CALL cp_subsys_set(subsystems(iforce_eval)%subsys, cell=cell_mix)
1237 particles=particles(iforce_eval)%list)
1240 natom =
SIZE(particles(iforce_eval)%list%els)
1242 IF (
ASSOCIATED(map_index)) &
1243 DEALLOCATE (map_index)
1248 DO iparticle = 1, natom
1249 jparticle = map_index(iparticle)
1250 particles(iforce_eval)%list%els(iparticle)%r = particles_mix%els(jparticle)%r
1253 IF (force_env%mixed_env%do_mixed_qmmm_cdft) &
1260 DO iforce_eval = 1, nforce_eval
1261 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1263 IF (force_env%mixed_env%cdft_control%run_type ==
mixed_cdft_serial .AND. iforce_eval .GE. 2)
THEN
1264 my_logger => force_env%mixed_env%cdft_control%sub_logger(iforce_eval - 1)%p
1266 my_group = force_env%mixed_env%group_distribution(force_env%para_env%mepos)
1267 my_logger => force_env%mixed_env%sub_logger(my_group + 1)%p
1276 calc_force=calculate_forces, &
1277 skip_external_control=.true.)
1279 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
1280 CALL force_env_get(force_env%sub_force_env(iforce_eval)%force_env, &
1281 potential_energy=energy)
1283 virial=loc_virial, results=loc_results)
1284 energies(iforce_eval) = energy
1285 glob_natoms(iforce_eval) = natom
1286 virials(iforce_eval)%virial = loc_virial
1290 IF (
ASSOCIATED(map_index))
THEN
1291 DEALLOCATE (map_index)
1295 DEALLOCATE (subsystems)
1297 END SUBROUTINE mixed_cdft_energy_forces
1307 SUBROUTINE mixed_cdft_post_energy_forces(force_env)
1310 INTEGER :: iforce_eval, nforce_eval, nvar
1314 cpassert(
ASSOCIATED(force_env))
1315 NULLIFY (qs_env, dft_control)
1316 IF (force_env%mixed_env%do_mixed_cdft)
THEN
1317 nforce_eval =
SIZE(force_env%sub_force_env)
1318 nvar = force_env%mixed_env%cdft_control%nconstraint
1320 IF (.NOT.
ASSOCIATED(force_env%mixed_env%strength)) &
1321 ALLOCATE (force_env%mixed_env%strength(nforce_eval, nvar))
1322 force_env%mixed_env%strength = 0.0_dp
1323 DO iforce_eval = 1, nforce_eval
1324 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1325 IF (force_env%mixed_env%do_mixed_qmmm_cdft)
THEN
1326 qs_env => force_env%sub_force_env(iforce_eval)%force_env%qmmm_env%qs_env
1328 CALL force_env_get(force_env%sub_force_env(iforce_eval)%force_env, qs_env=qs_env)
1330 CALL get_qs_env(qs_env, dft_control=dft_control)
1331 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source()) &
1332 force_env%mixed_env%strength(iforce_eval, :) = dft_control%qs_control%cdft_control%strength(:)
1334 CALL force_env%para_env%sum(force_env%mixed_env%strength)
1336 IF (force_env%mixed_env%do_mixed_et)
THEN
1337 IF (
modulo(force_env%mixed_env%cdft_control%sim_step, force_env%mixed_env%et_freq) == 0) &
1342 END SUBROUTINE mixed_cdft_post_energy_forces
1349 SUBROUTINE embed_energy(force_env)
1353 INTEGER :: iforce_eval, iparticle, jparticle, &
1354 my_group, natom, nforce_eval
1355 INTEGER,
DIMENSION(:),
POINTER :: glob_natoms, map_index
1356 LOGICAL :: converged_embed
1357 REAL(kind=
dp) :: energy
1358 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energies
1372 mapping_section, root_section
1375 cpassert(
ASSOCIATED(force_env))
1378 subsys=subsys_embed, &
1379 force_env_section=force_env_section, &
1380 root_section=root_section, &
1383 particles=particles_embed, &
1384 results=results_embed)
1385 NULLIFY (map_index, glob_natoms)
1387 nforce_eval =
SIZE(force_env%sub_force_env)
1391 ALLOCATE (subsystems(nforce_eval))
1392 ALLOCATE (particles(nforce_eval))
1394 ALLOCATE (energies(nforce_eval))
1395 ALLOCATE (glob_natoms(nforce_eval))
1396 ALLOCATE (results(nforce_eval))
1400 DO iforce_eval = 1, nforce_eval
1401 NULLIFY (subsystems(iforce_eval)%subsys, particles(iforce_eval)%list)
1402 NULLIFY (results(iforce_eval)%results)
1404 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
1406 my_group = force_env%embed_env%group_distribution(force_env%para_env%mepos)
1407 my_logger => force_env%embed_env%sub_logger(my_group + 1)%p
1413 CALL force_env_get(force_env=force_env%sub_force_env(iforce_eval)%force_env, &
1414 subsys=subsystems(iforce_eval)%subsys)
1418 IF (
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env%qs_env))
THEN
1419 NULLIFY (dft_control)
1420 CALL get_qs_env(force_env%sub_force_env(iforce_eval)%force_env%qs_env, dft_control=dft_control)
1421 IF (dft_control%qs_control%ref_embed_subsys)
THEN
1422 IF (iforce_eval .EQ. 2) cpabort(
"Density importing force_eval can't be the first.")
1427 CALL cp_subsys_set(subsystems(iforce_eval)%subsys, cell=cell_embed)
1431 particles=particles(iforce_eval)%list)
1434 natom =
SIZE(particles(iforce_eval)%list%els)
1440 DO iparticle = 1, natom
1441 jparticle = map_index(iparticle)
1442 particles(iforce_eval)%list%els(iparticle)%r = particles_embed%els(jparticle)%r
1447 calc_force=.false., &
1448 skip_external_control=.true.)
1451 IF (
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env%qs_env))
THEN
1452 NULLIFY (dft_control)
1453 CALL get_qs_env(force_env%sub_force_env(iforce_eval)%force_env%qs_env, dft_control=dft_control)
1454 IF (dft_control%qs_control%ref_embed_subsys)
THEN
1456 CALL dft_embedding(force_env, iforce_eval, energies, converged_embed)
1457 IF (.NOT. converged_embed) cpabort(
"Embedding potential optimization not converged.")
1460 IF (dft_control%qs_control%high_level_embed_subsys)
THEN
1461 CALL get_qs_env(qs_env=force_env%sub_force_env(iforce_eval)%force_env%qs_env, &
1462 embed_pot=embed_pot, spin_embed_pot=spin_embed_pot, pw_env=pw_env)
1463 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
1464 CALL auxbas_pw_pool%give_back_pw(embed_pot)
1465 IF (
ASSOCIATED(embed_pot))
THEN
1466 CALL embed_pot%release()
1467 DEALLOCATE (embed_pot)
1469 IF (
ASSOCIATED(spin_embed_pot))
THEN
1470 CALL auxbas_pw_pool%give_back_pw(spin_embed_pot)
1471 CALL spin_embed_pot%release()
1472 DEALLOCATE (spin_embed_pot)
1478 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
1479 CALL force_env_get(force_env%sub_force_env(iforce_eval)%force_env, &
1480 potential_energy=energy)
1482 results=loc_results)
1483 energies(iforce_eval) = energy
1484 glob_natoms(iforce_eval) = natom
1488 IF (
ASSOCIATED(map_index))
THEN
1489 DEALLOCATE (map_index)
1495 CALL force_env%para_env%sync()
1497 CALL force_env%para_env%sum(energies)
1498 CALL force_env%para_env%sum(glob_natoms)
1500 force_env%embed_env%energies = energies
1503 DO iparticle = 1,
SIZE(particles_embed%els)
1504 particles_embed%els(iparticle)%f(:) = 0.0_dp
1508 force_env%embed_env%pot_energy = energies(3) + energies(4) - energies(2)
1511 DO iforce_eval = 1, nforce_eval
1514 DEALLOCATE (subsystems)
1515 DEALLOCATE (particles)
1516 DEALLOCATE (energies)
1517 DEALLOCATE (glob_natoms)
1518 DEALLOCATE (results)
1520 END SUBROUTINE embed_energy
1529 SUBROUTINE dft_embedding(force_env, ref_subsys_number, energies, converged_embed)
1531 INTEGER :: ref_subsys_number
1532 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energies
1533 LOGICAL :: converged_embed
1535 INTEGER :: embed_method
1540 force_env_section=force_env_section)
1544 SELECT CASE (embed_method)
1547 CALL dfet_embedding(force_env, ref_subsys_number, energies, converged_embed)
1550 CALL dmfet_embedding(force_env, ref_subsys_number, energies, converged_embed)
1553 END SUBROUTINE dft_embedding
1562 SUBROUTINE dfet_embedding(force_env, ref_subsys_number, energies, converged_embed)
1564 INTEGER :: ref_subsys_number
1565 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energies
1566 LOGICAL :: converged_embed
1568 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dfet_embedding'
1570 INTEGER :: cluster_subsys_num, handle, &
1571 i_force_eval, i_iter, i_spin, &
1572 nforce_eval, nspins, nspins_subsys, &
1574 REAL(kind=
dp) :: cluster_energy
1575 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rhs
1582 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r_ref, rho_r_subsys
1584 spin_embed_pot, spin_embed_pot_subsys
1588 force_env_section, input, &
1589 mapping_section, opt_embed_section
1591 CALL timeset(routinen, handle)
1596 CALL get_qs_env(qs_env=force_env%sub_force_env(ref_subsys_number)%force_env%qs_env)
1601 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%PROGRAM_RUN_INFO", &
1604 NULLIFY (dft_section, input, opt_embed_section)
1605 NULLIFY (energy, dft_control)
1607 CALL get_qs_env(qs_env=force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, &
1608 pw_env=pw_env, dft_control=dft_control, rho=rho, energy=energy, &
1610 nspins = dft_control%nspins
1616 CALL qs_rho_get(rho_struct=rho, rho_r=rho_r_ref)
1619 CALL understand_spin_states(force_env, ref_subsys_number, opt_embed%change_spin, opt_embed%open_shell_embed, &
1620 opt_embed%all_nspins)
1623 CALL prepare_embed_opt(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, opt_embed, &
1627 CALL init_embed_pot(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, embed_pot, &
1628 opt_embed%add_const_pot, opt_embed%Fermi_Amaldi, opt_embed%const_pot, &
1629 opt_embed%open_shell_embed, spin_embed_pot, &
1630 opt_embed%pot_diff, opt_embed%Coulomb_guess, opt_embed%grid_opt)
1633 IF (opt_embed%read_embed_pot .OR. opt_embed%read_embed_pot_cube)
CALL read_embed_pot( &
1634 force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, embed_pot, spin_embed_pot, &
1635 opt_embed_section, opt_embed)
1638 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
1639 CALL auxbas_pw_pool%create_pw(diff_rho_r)
1641 IF (opt_embed%open_shell_embed)
THEN
1642 CALL auxbas_pw_pool%create_pw(diff_rho_spin)
1647 DO i_spin = 1, nspins
1648 CALL pw_axpy(rho_r_ref(i_spin), diff_rho_r, -1.0_dp)
1650 IF (opt_embed%open_shell_embed)
THEN
1651 IF (nspins .EQ. 2)
THEN
1652 CALL pw_axpy(rho_r_ref(1), diff_rho_spin, -1.0_dp)
1653 CALL pw_axpy(rho_r_ref(2), diff_rho_spin, 1.0_dp)
1657 DO i_force_eval = 1, ref_subsys_number - 1
1658 NULLIFY (subsys_rho, rho_r_subsys, dft_control)
1659 CALL get_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, rho=subsys_rho, energy=energy, &
1660 dft_control=dft_control)
1661 nspins_subsys = dft_control%nspins
1663 CALL qs_rho_get(rho_struct=subsys_rho, rho_r=rho_r_subsys)
1664 DO i_spin = 1, nspins_subsys
1665 CALL pw_axpy(rho_r_subsys(i_spin), diff_rho_r, allow_noncompatible_grids=.true.)
1667 IF (opt_embed%open_shell_embed)
THEN
1668 IF (nspins_subsys .EQ. 2)
THEN
1670 IF ((i_force_eval .EQ. 2) .AND. (opt_embed%change_spin))
THEN
1671 CALL pw_axpy(rho_r_subsys(1), diff_rho_spin, -1.0_dp, allow_noncompatible_grids=.true.)
1672 CALL pw_axpy(rho_r_subsys(2), diff_rho_spin, 1.0_dp, allow_noncompatible_grids=.true.)
1675 CALL pw_axpy(rho_r_subsys(1), diff_rho_spin, 1.0_dp, allow_noncompatible_grids=.true.)
1676 CALL pw_axpy(rho_r_subsys(2), diff_rho_spin, -1.0_dp, allow_noncompatible_grids=.true.)
1683 CALL print_rho_diff(diff_rho_r, 0, force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, .false.)
1684 IF (opt_embed%open_shell_embed)
THEN
1685 CALL print_rho_spin_diff(diff_rho_spin, 0, force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, .false.)
1689 IF (opt_embed%Coulomb_guess)
THEN
1691 nforce_eval =
SIZE(force_env%sub_force_env)
1693 CALL get_qs_env(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, rhs=rhs)
1696 force_env_section=force_env_section)
1700 DO i_force_eval = 1, ref_subsys_number - 1
1701 IF (i_force_eval .EQ. 1)
THEN
1703 force_env%sub_force_env(i_force_eval)%force_env%qs_env, nforce_eval, i_force_eval, opt_embed%eta)
1705 CALL coulomb_guess(opt_embed%pot_diff, rhs, mapping_section, &
1706 force_env%sub_force_env(i_force_eval)%force_env%qs_env, nforce_eval, i_force_eval, opt_embed%eta)
1709 CALL pw_axpy(opt_embed%pot_diff, embed_pot)
1710 IF (.NOT. opt_embed%grid_opt)
CALL pw_copy(embed_pot, opt_embed%const_pot)
1715 IF (opt_embed%diff_guess)
THEN
1716 CALL pw_copy(diff_rho_r, embed_pot)
1717 IF (.NOT. opt_embed%grid_opt)
CALL pw_copy(embed_pot, opt_embed%const_pot)
1719 IF (opt_embed%open_shell_embed)
CALL pw_copy(diff_rho_spin, spin_embed_pot)
1723 DO i_iter = 1, opt_embed%n_iter
1724 opt_embed%i_iter = i_iter
1728 CALL get_qs_env(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, dft_control=dft_control)
1729 nspins = dft_control%nspins
1730 DO i_spin = 1, nspins
1731 CALL pw_axpy(rho_r_ref(i_spin), diff_rho_r, -1.0_dp)
1733 IF (opt_embed%open_shell_embed)
THEN
1735 IF (nspins .EQ. 2)
THEN
1736 CALL pw_axpy(rho_r_ref(1), diff_rho_spin, -1.0_dp)
1737 CALL pw_axpy(rho_r_ref(2), diff_rho_spin, 1.0_dp)
1741 DO i_force_eval = 1, ref_subsys_number - 1
1742 NULLIFY (dft_control)
1743 CALL get_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, dft_control=dft_control)
1744 nspins_subsys = dft_control%nspins
1746 IF ((i_force_eval .EQ. 2) .AND. (opt_embed%change_spin))
THEN
1750 embed_pot, embed_pot_subsys, spin_embed_pot, spin_embed_pot_subsys, &
1751 opt_embed%open_shell_embed, .true.)
1754 embed_pot, embed_pot_subsys, spin_embed_pot, spin_embed_pot_subsys, &
1755 opt_embed%open_shell_embed, .false.)
1759 dft_control%apply_embed_pot = .true.
1762 CALL set_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, embed_pot=embed_pot_subsys)
1763 IF ((opt_embed%open_shell_embed) .AND. (nspins_subsys .EQ. 2))
THEN
1764 CALL set_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, &
1765 spin_embed_pot=spin_embed_pot_subsys)
1769 CALL get_prev_density(opt_embed, force_env%sub_force_env(i_force_eval)%force_env, i_force_eval)
1773 calc_force=.false., &
1774 skip_external_control=.true.)
1776 CALL get_max_subsys_diff(opt_embed, force_env%sub_force_env(i_force_eval)%force_env, i_force_eval)
1779 NULLIFY (rho_r_subsys, energy)
1781 CALL get_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, rho=subsys_rho, &
1783 opt_embed%w_func(i_iter) = opt_embed%w_func(i_iter) + energy%total
1786 IF (dft_control%qs_control%cluster_embed_subsys)
THEN
1787 cluster_subsys_num = i_force_eval
1788 cluster_energy = energy%total
1792 CALL qs_rho_get(rho_struct=subsys_rho, rho_r=rho_r_subsys)
1793 DO i_spin = 1, nspins_subsys
1794 CALL pw_axpy(rho_r_subsys(i_spin), diff_rho_r, allow_noncompatible_grids=.true.)
1796 IF (opt_embed%open_shell_embed)
THEN
1797 IF (nspins_subsys .EQ. 2)
THEN
1799 IF ((i_force_eval .EQ. 2) .AND. (opt_embed%change_spin))
THEN
1800 CALL pw_axpy(rho_r_subsys(1), diff_rho_spin, -1.0_dp, allow_noncompatible_grids=.true.)
1801 CALL pw_axpy(rho_r_subsys(2), diff_rho_spin, 1.0_dp, allow_noncompatible_grids=.true.)
1804 CALL pw_axpy(rho_r_subsys(1), diff_rho_spin, 1.0_dp, allow_noncompatible_grids=.true.)
1805 CALL pw_axpy(rho_r_subsys(2), diff_rho_spin, -1.0_dp, allow_noncompatible_grids=.true.)
1811 CALL embed_pot_subsys%release()
1812 DEALLOCATE (embed_pot_subsys)
1813 IF (opt_embed%open_shell_embed)
THEN
1814 CALL spin_embed_pot_subsys%release()
1815 DEALLOCATE (spin_embed_pot_subsys)
1822 opt_embed%dimen_aux, opt_embed%embed_pot_coef, embed_pot, i_iter, &
1823 spin_embed_pot, opt_embed%open_shell_embed, opt_embed%grid_opt, .false.)
1825 embed_pot, spin_embed_pot, i_iter, opt_embed%open_shell_embed, .false., &
1826 force_env%sub_force_env(cluster_subsys_num)%force_env%qs_env)
1829 DO i_spin = 1, nspins
1830 opt_embed%w_func(i_iter) = opt_embed%w_func(i_iter) -
pw_integral_ab(embed_pot, rho_r_ref(i_spin))
1833 IF (opt_embed%open_shell_embed)
THEN
1835 IF (nspins .EQ. 2)
THEN
1836 opt_embed%w_func(i_iter) = opt_embed%w_func(i_iter) &
1842 opt_embed%w_func(i_iter) = opt_embed%w_func(i_iter) + opt_embed%reg_term
1847 IF (opt_embed%converged)
EXIT
1850 IF ((i_iter .GT. 1) .AND. (.NOT. opt_embed%steep_desc))
CALL step_control(opt_embed)
1853 CALL print_rho_diff(diff_rho_r, i_iter, force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, .false.)
1854 IF (opt_embed%open_shell_embed)
THEN
1855 CALL print_rho_spin_diff(diff_rho_spin, i_iter, force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, .false.)
1860 IF (opt_embed%accept_step .AND. (.NOT. opt_embed%grid_opt)) &
1862 diff_rho_r, diff_rho_spin, opt_embed)
1864 CALL opt_embed_step(diff_rho_r, diff_rho_spin, opt_embed, embed_pot, spin_embed_pot, rho_r_ref, &
1865 force_env%sub_force_env(ref_subsys_number)%force_env%qs_env)
1871 opt_embed%dimen_aux, opt_embed%embed_pot_coef, embed_pot, i_iter, &
1872 spin_embed_pot, opt_embed%open_shell_embed, opt_embed%grid_opt, .true.)
1874 embed_pot, spin_embed_pot, i_iter, opt_embed%open_shell_embed, .true., &
1875 force_env%sub_force_env(cluster_subsys_num)%force_env%qs_env)
1879 IF (opt_embed%open_shell_embed)
THEN
1880 CALL print_rho_spin_diff(diff_rho_spin, i_iter, force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, .true.)
1884 CALL diff_rho_r%release()
1885 IF (opt_embed%open_shell_embed)
THEN
1886 CALL diff_rho_spin%release()
1890 "PRINT%PROGRAM_RUN_INFO")
1893 IF (opt_embed%converged)
THEN
1894 CALL get_qs_env(force_env%sub_force_env(ref_subsys_number + 1)%force_env%qs_env, dft_control=dft_control, &
1896 nspins_subsys = dft_control%nspins
1897 dft_control%apply_embed_pot = .true.
1900 embed_pot, embed_pot_subsys, spin_embed_pot, spin_embed_pot_subsys, &
1901 opt_embed%open_shell_embed, opt_embed%change_spin)
1903 IF (opt_embed%Coulomb_guess)
THEN
1904 CALL pw_axpy(opt_embed%pot_diff, embed_pot_subsys, -1.0_dp, allow_noncompatible_grids=.true.)
1907 CALL set_qs_env(force_env%sub_force_env(ref_subsys_number + 1)%force_env%qs_env, embed_pot=embed_pot_subsys)
1909 IF ((opt_embed%open_shell_embed) .AND. (nspins_subsys .EQ. 2))
THEN
1910 CALL set_qs_env(force_env%sub_force_env(ref_subsys_number + 1)%force_env%qs_env, &
1911 spin_embed_pot=spin_embed_pot_subsys)
1915 IF (force_env%sub_force_env(cluster_subsys_num)%force_env%para_env%is_source())
THEN
1916 energies(cluster_subsys_num) = cluster_energy
1924 CALL embed_pot%release()
1925 DEALLOCATE (embed_pot)
1926 IF (opt_embed%open_shell_embed)
THEN
1927 CALL spin_embed_pot%release()
1928 DEALLOCATE (spin_embed_pot)
1931 converged_embed = opt_embed%converged
1933 CALL timestop(handle)
1935 END SUBROUTINE dfet_embedding
1945 SUBROUTINE dmfet_embedding(force_env, ref_subsys_number, energies, converged_embed)
1947 INTEGER :: ref_subsys_number
1948 REAL(kind=
dp),
DIMENSION(:),
POINTER :: energies
1949 LOGICAL :: converged_embed
1951 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dmfet_embedding'
1953 INTEGER :: cluster_subsys_num, handle, &
1954 i_force_eval, i_iter, output_unit
1955 LOGICAL :: subsys_open_shell
1956 REAL(kind=
dp) :: cluster_energy
1964 CALL timeset(routinen, handle)
1966 CALL get_qs_env(qs_env=force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, &
1972 output_unit =
cp_print_key_unit_nr(logger, force_env%force_env_section,
"PRINT%PROGRAM_RUN_INFO", &
1975 NULLIFY (dft_section, input, opt_dmfet_section)
1978 CALL get_qs_env(qs_env=force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, &
1979 energy=energy, input=input)
1986 CALL understand_spin_states(force_env, ref_subsys_number, opt_dmfet%change_spin, opt_dmfet%open_shell_embed, &
1987 opt_dmfet%all_nspins)
1990 CALL prepare_dmfet_opt(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, &
1991 opt_dmfet, opt_dmfet_section)
1994 subsys_open_shell =
subsys_spin(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env)
1995 CALL build_full_dm(force_env%sub_force_env(ref_subsys_number)%force_env%qs_env, &
1996 opt_dmfet%dm_total, subsys_open_shell, opt_dmfet%open_shell_embed, opt_dmfet%dm_total_beta)
2001 opt_dmfet%dm_diff_beta, para_env)
2003 DO i_force_eval = 1, ref_subsys_number - 1
2006 subsys_open_shell =
subsys_spin(force_env%sub_force_env(i_force_eval)%force_env%qs_env)
2008 CALL build_full_dm(force_env%sub_force_env(i_force_eval)%force_env%qs_env, &
2009 opt_dmfet%dm_subsys, subsys_open_shell, opt_dmfet%open_shell_embed, &
2010 opt_dmfet%dm_subsys_beta)
2014 IF (opt_dmfet%open_shell_embed)
CALL cp_fm_scale_and_add(-1.0_dp, opt_dmfet%dm_diff_beta, &
2015 1.0_dp, opt_dmfet%dm_subsys_beta)
2020 DO i_iter = 1, opt_dmfet%n_iter
2022 opt_dmfet%i_iter = i_iter
2028 opt_dmfet%dm_diff_beta, para_env)
2031 DO i_force_eval = 1, ref_subsys_number - 1
2034 NULLIFY (dft_control)
2035 CALL get_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, dft_control=dft_control)
2036 dft_control%apply_dmfet_pot = .true.
2040 calc_force=.false., &
2041 skip_external_control=.true.)
2046 CALL get_qs_env(force_env%sub_force_env(i_force_eval)%force_env%qs_env, energy=energy)
2047 opt_dmfet%w_func(i_iter) = opt_dmfet%w_func(i_iter) + energy%total
2050 IF (dft_control%qs_control%cluster_embed_subsys)
THEN
2051 cluster_subsys_num = i_force_eval
2052 cluster_energy = energy%total
2056 subsys_open_shell =
subsys_spin(force_env%sub_force_env(i_force_eval)%force_env%qs_env)
2058 CALL build_full_dm(force_env%sub_force_env(i_force_eval)%force_env%qs_env, &
2059 opt_dmfet%dm_subsys, subsys_open_shell, opt_dmfet%open_shell_embed, &
2060 opt_dmfet%dm_subsys_beta)
2062 IF (opt_dmfet%open_shell_embed)
THEN
2064 IF ((i_force_eval .EQ. 2) .AND. (opt_dmfet%change_spin))
THEN
2069 CALL cp_fm_scale_and_add(-1.0_dp, opt_dmfet%dm_diff_beta, 1.0_dp, opt_dmfet%dm_subsys_beta)
2077 CALL check_dmfet(opt_dmfet, force_env%sub_force_env(ref_subsys_number)%force_env%qs_env)
2082 IF (force_env%sub_force_env(cluster_subsys_num)%force_env%para_env%is_source())
THEN
2083 energies(cluster_subsys_num) = cluster_energy
2088 converged_embed = .false.
2090 END SUBROUTINE dmfet_embedding
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Holds information on atomic properties.
subroutine, public atprop_init(atprop_env, natom)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public huang2011
integer, save, public heaton_burgess2007
Handles all functions related to the CELL.
subroutine, public init_cell(cell, hmat, periodic)
Initialise/readjust a simulation cell after hmat has been changed.
subroutine, public cell_create(cell, hmat, periodic, tag)
allocates and initializes a cell
Handles all functions related to the CELL.
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
integer, parameter, public cell_sym_triclinic
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
subroutine, public cell_clone(cell_in, cell_out, tag)
Clone cell variable.
subroutine, public fix_atom_control(force_env, w)
allows for fix atom constraints
Routines to handle the virtual site constraint/restraint.
subroutine, public vsite_force_control(force_env)
control force distribution for virtual sites
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
basic linear algebra operations for full matrices
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
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.
Collection of routines to handle the iteration info.
subroutine, public cp_iteration_info_copy_iter(iteration_info_in, iteration_info_out)
Copies iterations info of an iteration info into another iteration info.
various routines to log and control the output. The idea is that decisions about where to log should ...
subroutine, public cp_rm_default_logger()
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has ...
subroutine, public cp_add_default_logger(logger)
adds a default logger. MUST be called before logging occours
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)
...
integer, parameter, public low_print_level
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,...
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_results_mp_bcast(results, source, para_env)
broadcast results type
subroutine, public cp_results_erase(results, description, nval)
erase a part of result_list
logical function, public test_for_result(results, description)
test for a certain result in the result_list
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_result_copy(results_in, results_out)
Copies the cp_result type.
subroutine, public cp_result_release(results)
Releases cp_result type.
subroutine, public cp_result_create(results)
Allocates and intitializes the cp_result.
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_set(subsys, atomic_kinds, particles, local_particles, molecules, molecule_kinds, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, results, cell)
sets various propreties of the subsys
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
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
The environment for the empirical interatomic potential methods.
Empirical interatomic potentials for Silicon.
subroutine, public eip_lenosky(eip_env)
Interface routine of Goedecker's Lenosky force field to CP2K.
subroutine, public eip_bazant(eip_env)
Interface routine of Goedecker's Bazant EDIP to CP2K.
Methods to include the effect of an external potential during an MD or energy calculation.
subroutine, public add_external_potential(force_env)
...
subroutine, public fist_calc_energy_force(fist_env, debug)
Calculates the total potential energy, total force, and the total pressure tensor from the potentials...
Interface for the force calculations.
recursive subroutine, public force_env_calc_energy_force(force_env, calc_force, consistent_energies, skip_external_control, eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor)
Interface routine for force and energy calculations.
subroutine, public force_env_calc_num_pressure(force_env, dx)
Evaluates the stress tensor and pressure numerically.
subroutine, public force_env_create(force_env, root_section, para_env, globenv, fist_env, qs_env, meta_env, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, force_env_section, mixed_env, embed_env, nnp_env, ipi_env)
creates and initializes a force environment
Interface for the force calculations.
integer function, public force_env_get_natom(force_env)
returns the number of atoms
integer, parameter, public use_qmmm
integer, parameter, public use_mixed_force
character(len=10), dimension(501:510), parameter, public use_prog_name
integer, parameter, public use_eip_force
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
integer, parameter, public use_embed
integer, parameter, public use_qmmmx
subroutine, public force_env_set(force_env, meta_env, fp_env, force_env_section, method_name_id, additional_potential)
changes some attributes of the force_env
integer, parameter, public use_qs_force
integer, parameter, public use_pwdft_force
integer, parameter, public use_nnp_force
integer, parameter, public use_ipi
integer, parameter, public use_fist_force
subroutine, public write_forces(particles, iw, label, ndigits, unit_string, total_force, grand_total_force, zero_force_core_shell_atom)
Write forces.
subroutine, public write_atener(iounit, particles, atener, label)
Write the atomic coordinates, types, and energies.
subroutine, public rescale_forces(force_env)
Rescale forces if requested.
subroutine, public get_generic_info(gen_section, func_name, xfunction, parameters, values, var_values, size_variables, i_rep_sec, input_variables)
Reads from the input structure all information for generic functions.
methods used in the flexible partitioning scheme
subroutine, public fp_eval(fp_env, subsys, cell)
computest the forces and the energy due to the flexible potential & bias, and writes the weights file
This public domain function parser module is intended for applications where a set of mathematical ex...
subroutine, public parsef(i, funcstr, var)
Parse ith function string FuncStr and compile it into bytecode.
real(rn) function, public evalf(i, val)
...
integer, public evalerrtype
real(kind=rn) function, public evalfd(id_fun, ipar, vals, h, err)
Evaluates derivatives.
subroutine, public finalizef()
...
subroutine, public initf(n)
...
Define type storing the global information of a run. Keep the amount of stored data small....
subroutine, public globenv_retain(globenv)
Retains the global environment globenv.
subroutine, public write_grrm(iounit, force_env, particles, energy, dipole, hessian, dipder, polar, fixed_atoms)
Write GRRM interface file.
The environment for the empirical interatomic potential methods.
i–PI server mode: Communication with i–PI clients
subroutine, public request_forces(ipi_env)
Send atomic positions to a client and retrieve forces.
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
Collection of simple mathematical functions and subroutines.
logical function, public abnormal_value(a)
determines if a value is not normal (e.g. for Inf and Nan) based on IO to work also under optimizatio...
Interface to the message passing library MPI.
Methods for mixed CDFT calculations.
subroutine, public mixed_cdft_calculate_coupling(force_env)
Driver routine to calculate the electronic coupling(s) between CDFT states.
subroutine, public mixed_cdft_build_weight(force_env, calculate_forces, iforce_eval)
Driver routine to handle the build of CDFT weight/gradient in parallel and serial modes.
subroutine, public mixed_cdft_init(force_env, calculate_forces)
Initialize a mixed CDFT calculation.
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.
subroutine, public get_subsys_map_index(mapping_section, natom, iforce_eval, nforce_eval, map_index, force_eval_embed)
performs mapping of the subsystems of different force_eval
subroutine, public mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, factor, iforce_eval, nforce_eval, map_index, mapping_section, overwrite)
Maps forces between the different force_eval sections/environments.
represent a simple array based list of the given type
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.
Data types for neural network potentials.
Methods dealing with Neural Network potentials.
subroutine, public nnp_calc_energy_force(nnp, calc_forces)
Calculate the energy and force for a given configuration with the NNP.
subroutine, public check_dmfet(opt_dmfet, qs_env)
...
subroutine, public release_dmfet_opt(opt_dmfet)
...
subroutine, public build_full_dm(qs_env, dm, open_shell, open_shell_embed, dm_beta)
Builds density matrices from MO coefficients in full matrix format.
subroutine, public prepare_dmfet_opt(qs_env, opt_dmfet, opt_dmfet_section)
...
logical function, public subsys_spin(qs_env)
...
subroutine, public print_embed_restart(qs_env, dimen_aux, embed_pot_coef, embed_pot, i_iter, embed_pot_spin, open_shell_embed, grid_opt, final_one)
Print embedding potential as a cube and as a binary (for restarting)
subroutine, public make_subsys_embed_pot(qs_env, embed_pot, embed_pot_subsys, spin_embed_pot, spin_embed_pot_subsys, open_shell_embed, change_spin_sign)
Creates a subsystem embedding potential.
subroutine, public print_rho_spin_diff(spin_diff_rho_r, i_iter, qs_env, final_one)
Prints a cube for the (spin_rho_A + spin_rho_B - spin_rho_ref) to be minimized in embedding.
subroutine, public get_max_subsys_diff(opt_embed, force_env, subsys_num)
...
subroutine, public print_emb_opt_info(output_unit, step_num, opt_embed)
...
subroutine, public init_embed_pot(qs_env, embed_pot, add_const_pot, fermi_amaldi, const_pot, open_shell_embed, spin_embed_pot, pot_diff, coulomb_guess, grid_opt)
...
subroutine, public understand_spin_states(force_env, ref_subsys_number, change_spin, open_shell_embed, all_nspins)
Find out whether we need to swap alpha- and beta- spind densities in the second subsystem.
subroutine, public read_embed_pot(qs_env, embed_pot, spin_embed_pot, section, opt_embed)
...
subroutine, public get_prev_density(opt_embed, force_env, subsys_num)
...
subroutine, public coulomb_guess(v_rspace, rhs, mapping_section, qs_env, nforce_eval, iforce_eval, eta)
Calculates subsystem Coulomb potential from the RESP charges of the total system.
subroutine, public print_rho_diff(diff_rho_r, i_iter, qs_env, final_one)
Prints a cube for the (rho_A + rho_B - rho_ref) to be minimized in embedding.
subroutine, public conv_check_embed(opt_embed, diff_rho_r, diff_rho_spin, output_unit)
...
subroutine, public step_control(opt_embed)
Controls the step, changes the trust radius if needed in maximization of the V_emb.
subroutine, public opt_embed_step(diff_rho_r, diff_rho_spin, opt_embed, embed_pot, spin_embed_pot, rho_r_ref, qs_env)
Takes maximization step in embedding potential optimization.
subroutine, public calculate_embed_pot_grad(qs_env, diff_rho_r, diff_rho_spin, opt_embed)
Calculates the derivative of the embedding potential wrt to the expansion coefficients.
subroutine, public print_pot_simple_grid(qs_env, embed_pot, embed_pot_spin, i_iter, open_shell_embed, final_one, qs_env_cluster)
Prints a volumetric file: X Y Z value for interfacing with external programs.
subroutine, public prepare_embed_opt(qs_env, opt_embed, opt_embed_section)
Creates and allocates objects for optimization of embedding potential.
subroutine, public release_opt_embed(opt_embed)
Deallocate stuff for optimizing embedding potential.
represent a simple array based list of the given type
Definition of physical constants:
real(kind=dp), parameter, public debye
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
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
The type definitions for the PWDFT environment.
Methods and functions on the PWDFT environment.
subroutine, public pwdft_calc_energy_force(pwdft_env, calculate_forces, calculate_stress)
Calculate energy and forces within the PWDFT/SIRIUS code.
Calculates QM/MM energy and forces.
subroutine, public qmmm_calc_energy_force(qmmm_env, calc_force, consistent_energies, linres)
calculates the qm/mm energy and forces
Basic container type for QM/MM.
subroutine, public apply_qmmm_translate(qmmm_env)
Apply translation to the full system in order to center the QM system into the QM box.
Calculates QM/MM energy and forces with Force-Mixing.
subroutine, public qmmmx_calc_energy_force(qmmmx_env, calc_force, consistent_energies, linres, require_consistent_energy_force)
calculates the qm/mm energy and forces
Basic container type for QM/MM with force mixing.
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, 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, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
Set the QUICKSTEP environment.
Quickstep force driver routine.
subroutine, public qs_calc_energy_force(qs_env, calc_force, consistent_energies, linres)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Handles all possible kinds of restraints in CP2K.
subroutine, public restraint_control(force_env)
Computes restraints.
subroutine, public write_scine(iounit, force_env, particles, energy, hessian)
Write SCINE interface file.
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
subroutine, public write_stress_tensor(pv_virial, iw, cell, unit_string, numerical)
Print stress tensor to output file.
subroutine, public write_stress_tensor_components(virial, iw, cell, unit_string)
...
subroutine, public zero_virial(virial, reset)
...
subroutine, public symmetrize_virial(virial)
Symmetrize the virial components.
type for the atomic properties
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
contains arbitrary information which need to be stored
represent a pointer to a subsys, to be able to create arrays of pointers
represents a system: atoms, molecules, their pos,vel,...
The empirical interatomic potential environment.
Embedding environment type.
Type containing main data for matrix embedding potential optimization.
Type containing main data for embedding potential optimization.
allows for the creation of an array of force_env
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
represent a list of objects
Main data type collecting all relevant data for neural network potentials.
represents a pointer to a list
represent a list of objects
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
The PWDFT environment type.
keeps the density in various representations, keeping track of which ones are valid.