74#include "../base/base_uses.f90"
93 SUBROUTINE cp_eval_at(gopt_env, x, f, gradient, master, &
94 final_evaluation, para_env)
100 TYPE(gopt_f_type),
POINTER :: gopt_env
101 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: x
102 REAL(KIND=
dp),
INTENT(out),
OPTIONAL :: f
103 REAL(KIND=
dp),
DIMENSION(:),
OPTIONAL, &
105 INTEGER,
INTENT(IN) :: master
106 LOGICAL,
INTENT(IN),
OPTIONAL :: final_evaluation
107 TYPE(mp_para_env_type),
POINTER :: para_env
113 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
114 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"gopt_f_methods"
133 TYPE(gopt_f_type),
POINTER :: gopt_env
134 REAL(kind=dp),
DIMENSION(:),
POINTER :: x0
136 INTEGER :: i, idg, j, nparticle
143 SELECT CASE (gopt_env%type_id)
147 IF (gopt_env%force_env%in_use ==
use_qmmm)
THEN
150 IF (gopt_env%force_env%in_use ==
use_qmmmx)
THEN
154 ALLOCATE (x0(3*nparticle))
157 CALL force_env_get(gopt_env%force_env, subsys=subsys, cell=cell)
159 gopt_env%h_ref = cell%hmat
161 IF (gopt_env%force_env%in_use ==
use_qmmm)
THEN
164 IF (gopt_env%force_env%in_use ==
use_qmmmx)
THEN
168 ALLOCATE (x0(3*nparticle + 6))
174 x0(idg) = cell%hmat(j, i)
178 cpabort(
"Invalid or not yet implemented type of optimization")
191 INTEGER,
INTENT(IN) :: its, output_unit
193 IF (output_unit > 0)
THEN
194 WRITE (unit=output_unit, fmt=
"(/,T2,26('-'))")
195 WRITE (unit=output_unit, fmt=
"(T2,A,I6)")
"OPTIMIZATION STEP: ", its
196 WRITE (unit=output_unit, fmt=
"(T2,26('-'))")
212 SUBROUTINE gopt_f_io_init(gopt_env, output_unit, opt_energy, wildcard, its, used_time)
214 TYPE(gopt_f_type),
POINTER :: gopt_env
215 INTEGER,
INTENT(IN) :: output_unit
216 REAL(kind=dp) :: opt_energy
217 CHARACTER(LEN=5) :: wildcard
218 INTEGER,
INTENT(IN) :: its
219 REAL(kind=dp) :: used_time
221 TYPE(mp_para_env_type),
POINTER :: para_env
222 CHARACTER(LEN=default_string_length) :: energy_unit, stress_unit
223 REAL(kind=dp) :: pres_int
224 INTEGER(KIND=int_8) :: max_memory
225 LOGICAL :: print_memory
230 IF (print_memory)
THEN
236 "PRINT%PROGRAM_RUN_INFO%ENERGY_UNIT", &
239 "PRINT%STRESS_TENSOR%STRESS_UNIT", &
242 SELECT CASE (gopt_env%type_id)
245 IF (.NOT. gopt_env%dimer_rotation)
THEN
246 CALL write_cycle_infos(output_unit, &
250 used_time=used_time, &
251 max_memory=max_memory, &
252 energy_unit=energy_unit, &
253 stress_unit=stress_unit)
255 CALL write_rot_cycle_infos(output_unit, &
258 dimer_env=gopt_env%dimer_env, &
260 used_time=used_time, &
261 max_memory=max_memory)
265 pres_int = gopt_env%cell_env%pres_int
266 CALL write_cycle_infos(output_unit, &
271 used_time=used_time, &
272 max_memory=max_memory, &
273 energy_unit=energy_unit, &
274 stress_unit=stress_unit)
276 CALL write_cycle_infos(output_unit, &
280 used_time=used_time, &
281 max_memory=max_memory, &
282 energy_unit=energy_unit, &
283 stress_unit=stress_unit)
311 SUBROUTINE gopt_f_io(gopt_env, force_env, root_section, its, opt_energy, &
312 output_unit, eold, emin, wildcard, gopt_param, ndf, dx, xi, conv, pred, rat, &
313 step, rad, used_time)
315 TYPE(gopt_f_type),
POINTER :: gopt_env
318 INTEGER,
INTENT(IN) :: its
319 REAL(kind=dp),
INTENT(IN) :: opt_energy
320 INTEGER,
INTENT(IN) :: output_unit
321 REAL(kind=dp) :: eold, emin
322 CHARACTER(LEN=5) :: wildcard
324 INTEGER,
INTENT(IN),
OPTIONAL :: ndf
325 REAL(kind=dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: dx
326 REAL(kind=dp),
DIMENSION(:),
OPTIONAL,
POINTER :: xi
327 LOGICAL,
OPTIONAL :: conv
328 REAL(kind=dp),
INTENT(IN),
OPTIONAL :: pred, rat, step, rad
329 REAL(kind=dp) :: used_time
331 CHARACTER(LEN=default_string_length) :: energy_unit, stress_unit
332 INTEGER(KIND=int_8) :: max_memory
333 LOGICAL :: print_memory
334 REAL(kind=dp) :: pres_diff, pres_diff_constr, pres_int, &
336 TYPE(mp_para_env_type),
POINTER :: para_env
341 IF (print_memory)
THEN
347 "PRINT%PROGRAM_RUN_INFO%ENERGY_UNIT", &
350 "PRINT%STRESS_TENSOR%STRESS_UNIT", &
353 SELECT CASE (gopt_env%type_id)
356 IF (.NOT. gopt_env%dimer_rotation)
THEN
357 CALL geo_opt_io(force_env=force_env, root_section=root_section, &
358 motion_section=gopt_env%motion_section, its=its, opt_energy=opt_energy)
359 CALL write_cycle_infos(output_unit, &
362 ediff=(opt_energy - eold), &
369 used_time=used_time, &
370 max_memory=max_memory, &
371 energy_unit=energy_unit, &
372 stress_unit=stress_unit)
374 IF (
PRESENT(conv))
THEN
375 cpassert(
PRESENT(ndf))
376 cpassert(
PRESENT(dx))
377 cpassert(
PRESENT(xi))
378 CALL check_converg(ndf, dx, xi, output_unit, conv, gopt_param, max_memory, stress_unit)
382 CALL write_restart(force_env=force_env, root_section=root_section)
383 CALL write_rot_cycle_infos(output_unit, its, opt_energy, opt_energy - eold, emin, gopt_env%dimer_env, &
384 wildcard=wildcard, used_time=used_time, max_memory=max_memory)
386 IF (
PRESENT(conv))
THEN
387 cpassert(
ASSOCIATED(gopt_env%dimer_env))
388 CALL check_rot_conv(gopt_env%dimer_env, output_unit, conv)
393 pres_diff = gopt_env%cell_env%pres_int - gopt_env%cell_env%pres_ext
394 pres_int = gopt_env%cell_env%pres_int
395 pres_tol = gopt_env%cell_env%pres_tol
396 CALL geo_opt_io(force_env=force_env, root_section=root_section, &
397 motion_section=gopt_env%motion_section, its=its, opt_energy=opt_energy)
398 CALL write_cycle_infos(output_unit, &
401 ediff=(opt_energy - eold), &
409 used_time=used_time, &
410 max_memory=max_memory, &
411 energy_unit=energy_unit, &
412 stress_unit=stress_unit)
414 IF (
PRESENT(conv))
THEN
415 cpassert(
PRESENT(ndf))
416 cpassert(
PRESENT(dx))
417 cpassert(
PRESENT(xi))
418 IF (gopt_env%cell_env%constraint_id ==
fix_none)
THEN
419 CALL check_converg(ndf, dx, xi, output_unit, conv, gopt_param, max_memory, stress_unit, &
422 pres_diff_constr = gopt_env%cell_env%pres_constr - gopt_env%cell_env%pres_ext
423 CALL check_converg(ndf, dx, xi, output_unit, conv, gopt_param, max_memory, stress_unit, &
424 pres_diff, pres_tol, pres_diff_constr)
428 CALL write_cycle_infos(output_unit, &
431 ediff=(opt_energy - eold), &
438 used_time=used_time, &
439 max_memory=max_memory, &
440 energy_unit=energy_unit, &
441 stress_unit=stress_unit)
443 IF (
PRESENT(conv))
THEN
444 cpassert(
PRESENT(ndf))
445 cpassert(
PRESENT(dx))
446 cpassert(
PRESENT(xi))
447 CALL check_converg(ndf, dx, xi, output_unit, conv, gopt_param, max_memory, stress_unit)
467 para_env, master, output_unit)
468 TYPE(gopt_f_type),
POINTER :: gopt_env
470 REAL(kind=dp),
DIMENSION(:),
POINTER :: x0
474 TYPE(mp_para_env_type),
POINTER :: para_env
475 INTEGER,
INTENT(IN) :: master, output_unit
477 IF (gopt_env%eval_opt_geo)
THEN
478 IF (.NOT. gopt_env%dimer_rotation)
THEN
479 CALL write_final_info(output_unit, conv, its, gopt_env, x0, master, &
480 para_env, force_env, gopt_env%motion_section, root_section)
483 CALL write_restart(force_env=force_env, root_section=root_section)
504 SUBROUTINE write_cycle_infos(output_unit, it, etot, ediff, pred, rat, step, rad, emin, &
505 pres_int, wildcard, used_time, max_memory, energy_unit, stress_unit)
507 INTEGER,
INTENT(IN) :: output_unit, it
508 REAL(kind=dp),
INTENT(IN) :: etot
509 REAL(kind=dp),
INTENT(IN),
OPTIONAL :: ediff, pred, rat, step, rad, emin, &
511 CHARACTER(LEN=5),
INTENT(IN) :: wildcard
512 REAL(kind=dp),
INTENT(IN) :: used_time
513 INTEGER(KIND=int_8),
INTENT(IN) :: max_memory
514 CHARACTER(LEN=default_string_length),
INTENT(IN) :: energy_unit, stress_unit
516 CHARACTER(LEN=5) :: tag
518 IF (output_unit > 0)
THEN
520 WRITE (unit=output_unit, fmt=
"(/,T2,A)") tag//repeat(
"*", 74)
521 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,I25)") &
522 tag//
"Step number", it
523 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,A25)") &
524 tag//
"Optimization method", wildcard
525 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
526 tag//
"Total energy ["//trim(adjustl(energy_unit))//
"]", &
528 IF (
PRESENT(pres_int))
THEN
529 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
530 tag//
"Internal pressure ["//trim(adjustl(stress_unit))//
"]", &
533 IF (
PRESENT(ediff))
THEN
534 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
535 tag//
"Effective energy change ["//trim(adjustl(energy_unit))//
"]", &
538 IF (
PRESENT(pred))
THEN
539 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
540 tag//
"Predicted energy change ["//trim(adjustl(energy_unit))//
"]", &
543 IF (
PRESENT(rat))
THEN
544 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
545 tag//
"Scaling factor", rat
547 IF (
PRESENT(step))
THEN
548 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
549 tag//
"Step size", step
551 IF (
PRESENT(rad))
THEN
552 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
553 tag//
"Trust radius", rad
555 IF (
PRESENT(emin))
THEN
556 IF (etot < emin)
THEN
557 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
558 tag//
"Decrease in energy",
" YES"
560 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
561 tag//
"Decrease in energy",
" NO"
564 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.3)") &
565 tag//
"Used time [s]", used_time
567 WRITE (unit=output_unit, fmt=
"(T2,A)") tag//repeat(
"*", 74)
568 IF (max_memory /= 0)
THEN
569 WRITE (unit=output_unit, fmt=
"(T2,A,T60,1X,I20)") &
570 tag//
"Estimated peak process memory [MiB]", &
571 (max_memory + (1024*1024) - 1)/(1024*1024)
576 END SUBROUTINE write_cycle_infos
591 SUBROUTINE write_rot_cycle_infos(output_unit, it, etot, ediff, emin, dimer_env, used_time, &
592 wildcard, max_memory)
594 INTEGER,
INTENT(IN) :: output_unit, it
595 REAL(kind=dp),
INTENT(IN) :: etot
596 REAL(kind=dp),
INTENT(IN),
OPTIONAL :: ediff, emin
598 REAL(kind=dp),
INTENT(IN) :: used_time
599 CHARACTER(LEN=5),
INTENT(IN) :: wildcard
600 INTEGER(KIND=int_8),
INTENT(IN) :: max_memory
602 CHARACTER(LEN=5) :: tag
604 IF (output_unit > 0)
THEN
606 WRITE (unit=output_unit, fmt=
"(/,T2,A)") tag//repeat(
"*", 74)
607 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,I25)") &
608 tag//
"Rotational step number", it
609 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,A25)") &
610 tag//
"Optimization method", wildcard
611 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
612 tag//
"Local curvature", dimer_env%rot%curvature, &
613 tag//
"Total rotational force", etot
614 IF (
PRESENT(ediff))
THEN
615 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
616 tag//
"Rotational force change", ediff
618 IF (
PRESENT(emin))
THEN
619 IF (etot < emin)
THEN
620 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
621 tag//
"Decrease in rotational force",
" YES"
623 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
624 tag//
"Decrease in rotational force",
" NO"
627 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.3)") &
628 tag//
"Used time [s]", used_time
630 WRITE (unit=output_unit, fmt=
"(T2,A)") tag//repeat(
"*", 74)
631 IF (max_memory /= 0)
THEN
632 WRITE (unit=output_unit, fmt=
"(T2,A,T60,1X,I20)") &
633 tag//
"Estimated peak process memory [MiB]", &
634 (max_memory + (1024*1024) - 1)/(1024*1024)
639 END SUBROUTINE write_rot_cycle_infos
654 SUBROUTINE check_converg(ndf, dr, g, output_unit, conv, gopt_param, max_memory, stress_unit, &
655 pres_diff, pres_tol, pres_diff_constr)
657 INTEGER,
INTENT(IN) :: ndf
658 REAL(kind=dp),
INTENT(IN) :: dr(ndf), g(ndf)
659 INTEGER,
INTENT(IN) :: output_unit
660 LOGICAL,
INTENT(OUT) :: conv
662 INTEGER(KIND=int_8),
INTENT(IN) :: max_memory
663 CHARACTER(LEN=default_string_length),
INTENT(IN) :: stress_unit
664 REAL(kind=dp),
INTENT(IN),
OPTIONAL :: pres_diff, pres_tol, pres_diff_constr
666 CHARACTER(LEN=5) :: tag
668 LOGICAL :: conv_dx, conv_g, conv_p, conv_rdx, &
670 REAL(kind=dp) :: dumm, dxcon, gcon, maxdum(4), rmsgcon, &
673 dxcon = gopt_param%max_dr
674 gcon = gopt_param%max_force
675 rmsgcon = gopt_param%rms_force
676 rmsxcon = gopt_param%rms_dr
687 IF (indf == 1) maxdum(1) = abs(dr(indf))
688 dumm = dumm + dr(indf)**2
689 IF (abs(dr(indf)) > dxcon) conv_dx = .false.
690 IF (abs(dr(indf)) > maxdum(1)) maxdum(1) = abs(dr(indf))
693 IF (dumm > (rmsxcon*rmsxcon*ndf)) conv_rdx = .false.
694 maxdum(2) = sqrt(dumm/ndf)
698 IF (indf == 1) maxdum(3) = abs(g(indf))
699 dumm = dumm + g(indf)**2
700 IF (abs(g(indf)) > gcon) conv_g = .false.
701 IF (abs(g(indf)) > maxdum(3)) maxdum(3) = abs(g(indf))
704 IF (dumm > (rmsgcon*rmsgcon*ndf)) conv_rg = .false.
705 maxdum(4) = sqrt(dumm/ndf)
707 IF (
PRESENT(pres_diff_constr) .AND.
PRESENT(pres_tol))
THEN
708 conv_p = abs(pres_diff_constr) < abs(pres_tol)
709 ELSE IF (
PRESENT(pres_diff) .AND.
PRESENT(pres_tol))
THEN
710 conv_p = abs(pres_diff) < abs(pres_tol)
713 IF (output_unit > 0)
THEN
717 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(tag)
718 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
719 tag//
"Maximum step size", maxdum(1), &
720 tag//
"Convergence limit for maximum step size", dxcon
722 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
723 tag//
"Maximum step size is converged",
" YES"
725 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
726 tag//
"Maximum step size is converged",
" NO"
729 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(tag)
730 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
731 tag//
"RMS step size", maxdum(2), &
732 tag//
"Convergence limit for RMS step size", rmsxcon
734 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
735 tag//
"RMS step size is converged",
" YES"
737 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
738 tag//
"RMS step size is converged",
" NO"
741 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(tag)
742 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
743 tag//
"Maximum gradient", maxdum(3), &
744 tag//
"Convergence limit for maximum gradient", gcon
746 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
747 tag//
"Maximum gradient is converged",
" YES"
749 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
750 tag//
"Maximum gradient is converged",
" NO"
753 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(tag)
754 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
755 tag//
"RMS gradient", maxdum(4), &
756 tag//
"Convergence limit for RMS gradient", rmsgcon
758 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
759 tag//
"RMS gradient is converged",
" YES"
761 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
762 tag//
"RMS gradient is converged",
" NO"
765 IF (
PRESENT(pres_diff) .AND.
PRESENT(pres_tol))
THEN
766 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(tag)
767 IF (
PRESENT(pres_diff_constr))
THEN
768 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
769 tag//
"Pressure deviation without constraint ["// &
770 trim(adjustl(stress_unit))//
"]", &
772 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
773 tag//
"Pressure deviation with constraint ["// &
774 trim(adjustl(stress_unit))//
"]", &
777 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
778 tag//
"Pressure deviation ["//trim(adjustl(stress_unit))//
"]", &
781 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
782 tag//
"Pressure tolerance ["//trim(adjustl(stress_unit))//
"]", &
785 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
786 tag//
"Pressure is converged",
" YES"
788 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
789 tag//
"Pressure is converged",
" NO"
793 WRITE (unit=output_unit, fmt=
"(T2,A)") tag//repeat(
"*", 74)
795 IF (max_memory /= 0)
THEN
796 WRITE (unit=output_unit, fmt=
"(T2,A,T60,1X,I20)") &
797 tag//
"Estimated peak process memory after this step [MiB]", &
798 (max_memory + (1024*1024) - 1)/(1024*1024)
803 IF (conv_dx .AND. conv_rdx .AND. conv_g .AND. conv_rg .AND. conv_p) conv = .true.
805 IF ((conv) .AND. (output_unit > 0))
THEN
806 WRITE (unit=output_unit, fmt=
"(/,T2,A)") repeat(
"*", 79)
807 WRITE (unit=output_unit, fmt=
"(T2,A,T25,A,T78,A)") &
808 "***",
"GEOMETRY OPTIMIZATION COMPLETED",
"***"
809 WRITE (unit=output_unit, fmt=
"(T2,A)") repeat(
"*", 79)
812 END SUBROUTINE check_converg
822 SUBROUTINE check_rot_conv(dimer_env, output_unit, conv)
825 INTEGER,
INTENT(IN) :: output_unit
826 LOGICAL,
INTENT(OUT) :: conv
828 CHARACTER(LEN=5) :: tag
830 conv = (abs(dimer_env%rot%angle2) < dimer_env%rot%angle_tol)
832 IF (output_unit > 0)
THEN
834 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(tag)
835 WRITE (unit=output_unit, fmt=
"(T2,A,T55,1X,F25.10)") &
836 tag//
"Predicted angle step size", dimer_env%rot%angle1, &
837 tag//
"Effective angle step size", dimer_env%rot%angle2, &
838 tag//
"Convergence limit for angle step size", dimer_env%rot%angle_tol
840 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
841 tag//
"Angle step size is converged",
" YES"
843 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
844 tag//
"Angle step size is converged",
" NO"
846 WRITE (unit=output_unit, fmt=
"(T2,A)") tag//repeat(
"*", 74)
849 IF ((conv) .AND. (output_unit > 0))
THEN
850 WRITE (unit=output_unit, fmt=
"(/,T2,A)") repeat(
"*", 79)
851 WRITE (unit=output_unit, fmt=
"(T2,A,T25,A,T78,A)") &
852 "***",
"ROTATION OPTIMIZATION COMPLETED",
"***"
853 WRITE (unit=output_unit, fmt=
"(T2,A)") repeat(
"*", 79)
856 END SUBROUTINE check_rot_conv
873 RECURSIVE SUBROUTINE write_final_info(output_unit, conv, it, gopt_env, x0, master, para_env, force_env, &
874 motion_section, root_section)
875 INTEGER,
INTENT(IN) :: output_unit
876 LOGICAL,
INTENT(IN) :: conv
877 INTEGER,
INTENT(INOUT) :: it
878 TYPE(gopt_f_type),
POINTER :: gopt_env
879 REAL(kind=dp),
DIMENSION(:),
POINTER :: x0
880 INTEGER,
INTENT(IN) :: master
881 TYPE(mp_para_env_type),
POINTER :: para_env
885 CHARACTER(LEN=4) :: constraint_label
886 LOGICAL :: keep_angles, keep_symmetry, &
888 REAL(kind=dp) :: etot
896 particle_set => particles%els
902 keep_symmetry = .true.
904 constraint_label =
"NONE"
906 keep_angles = gopt_env%cell_env%keep_angles
907 keep_symmetry = gopt_env%cell_env%keep_symmetry
908 keep_volume = gopt_env%cell_env%keep_volume
909 SELECT CASE (gopt_env%cell_env%constraint_id)
911 constraint_label =
" X"
913 constraint_label =
" Y"
915 constraint_label =
" Z"
917 constraint_label =
" XY"
919 constraint_label =
" XZ"
921 constraint_label =
" YZ"
923 constraint_label =
"NONE"
927 keep_angles, keep_symmetry, keep_volume, &
928 gopt_env%label, constraint_label)
933 CALL write_restart(force_env=force_env, root_section=root_section)
935 IF (output_unit > 0)
THEN
936 WRITE (unit=output_unit, fmt=
"(/,T20,' Reevaluating energy at the minimum')")
939 CALL cp_eval_at(gopt_env, x0, f=etot, master=master, final_evaluation=.true., &
941 CALL write_geo_traj(force_env, root_section, it, etot)
944 END SUBROUTINE write_final_info
957 SUBROUTINE write_geo_traj(force_env, root_section, it, etot)
961 INTEGER,
INTENT(IN) :: it
962 REAL(kind=dp),
INTENT(IN) :: etot
964 LOGICAL :: shell_adiabatic, shell_present
970 NULLIFY (atomic_kinds)
971 NULLIFY (atomic_kind_set)
972 NULLIFY (core_particles)
973 NULLIFY (shell_particles)
978 CALL write_trajectory(force_env, root_section, it, 0.0_dp, 0.0_dp, etot,
"FORCES", middle_name=
"frc")
981 atomic_kind_set => atomic_kinds%els
983 shell_present=shell_present, &
984 shell_adiabatic=shell_adiabatic)
985 IF (shell_present)
THEN
987 core_particles=core_particles, &
988 shell_particles=shell_particles)
989 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
990 etot=etot, pk_name=
"SHELL_TRAJECTORY", middle_name=
"shpos", &
991 particles=shell_particles)
992 IF (shell_adiabatic)
THEN
993 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
994 etot=etot, pk_name=
"SHELL_FORCES", middle_name=
"shfrc", &
995 particles=shell_particles)
996 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
997 etot=etot, pk_name=
"CORE_TRAJECTORY", middle_name=
"copos", &
998 particles=core_particles)
999 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
1000 etot=etot, pk_name=
"CORE_FORCES", middle_name=
"cofrc", &
1001 particles=core_particles)
1005 END SUBROUTINE write_geo_traj
1017 TYPE(gopt_f_type),
POINTER :: gopt_env
1018 INTEGER,
INTENT(IN) :: output_unit
1019 CHARACTER(LEN=*),
INTENT(IN) :: label
1021 CHARACTER(LEN=default_string_length) :: my_format, my_label
1024 IF (output_unit > 0)
THEN
1025 WRITE (unit=output_unit, fmt=
"(/,T2,A)") repeat(
"*", 79)
1026 IF (gopt_env%dimer_rotation)
THEN
1027 my_label =
"OPTIMIZING DIMER ROTATION"
1029 my_label =
"STARTING "//gopt_env%tag(1:8)//
" OPTIMIZATION"
1032 ix = (80 - 7 - len_trim(my_label))/2
1035 WRITE (unit=output_unit, fmt=trim(my_format))
"***", trim(my_label),
"***"
1037 ix = (80 - 7 - len_trim(label))/2
1040 WRITE (unit=output_unit, fmt=trim(my_format))
"***", trim(label),
"***"
1042 WRITE (unit=output_unit, fmt=
"(T2,A)") repeat(
"*", 79)
1056 TYPE(gopt_f_type),
POINTER :: gopt_env
1057 INTEGER,
INTENT(IN) :: output_unit
1059 IF (output_unit > 0)
THEN
1060 WRITE (unit=output_unit, fmt=
"(/,T2,A)") &
1061 "*** MAXIMUM NUMBER OF OPTIMIZATION STEPS REACHED ***"
1062 IF (.NOT. gopt_env%dimer_rotation)
THEN
1063 WRITE (unit=output_unit, fmt=
"(T2,A)") &
1064 "*** EXITING GEOMETRY OPTIMIZATION ***"
1066 WRITE (unit=output_unit, fmt=
"(T2,A)") &
1067 "*** EXITING ROTATION OPTIMIZATION ***"
1085 SUBROUTINE geo_opt_io(force_env, root_section, motion_section, its, opt_energy)
1089 INTEGER,
INTENT(IN) :: its
1090 REAL(kind=dp),
INTENT(IN) :: opt_energy
1097 TYPE(mp_para_env_type),
POINTER :: para_env
1102 NULLIFY (para_env, atomic_kind_set, subsys, particle_set, &
1103 local_particles, atomic_kinds, particles)
1106 CALL write_restart(force_env=force_env, root_section=root_section)
1109 CALL write_geo_traj(force_env, root_section, its, opt_energy)
1112 CALL force_env_get(force_env, cell=cell, para_env=para_env, &
1114 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1115 particles=particles, virial=virial)
1116 atomic_kind_set => atomic_kinds%els
1117 particle_set => particles%els
1118 CALL virial_evaluate(atomic_kind_set, particle_set, local_particles, &
1125 END SUBROUTINE geo_opt_io
1139 TYPE(gopt_f_type),
POINTER :: gopt_env
1141 REAL(kind=dp),
DIMENSION(:),
POINTER :: x
1142 LOGICAL,
INTENT(IN) :: update_forces
1144 INTEGER :: i, iatom, idg, j, natom, nparticle, &
1146 REAL(kind=dp) :: fc, fs, mass
1147 REAL(kind=dp),
DIMENSION(3) :: s
1154 NULLIFY (core_particles)
1156 NULLIFY (shell_particles)
1164 core_particles=core_particles, &
1165 particles=particles, &
1166 shell_particles=shell_particles)
1170 CALL cell_copy(cell, cell_ref, tag=
"CELL_OPT_REF")
1174 CALL init_cell(cell_ref, hmat=gopt_env%h_ref)
1175 cpassert((
SIZE(x) == idg + 6))
1177 IF (update_forces)
THEN
1193 cell%hmat(j, i) = x(idg)
1203 shell_index = particles%els(iatom)%shell_index
1204 IF (shell_index == 0)
THEN
1208 i = 3*(natom + shell_index - 1) + 1
1212 mass = particles%els(iatom)%atomic_kind%mass
1213 fc = core_particles%els(shell_index)%atomic_kind%shell%mass_core/mass
1214 fs = shell_particles%els(shell_index)%atomic_kind%shell%mass_shell/mass
1215 particles%els(iatom)%r(1:3) = fc*core_particles%els(shell_index)%r(1:3) + &
1216 fs*shell_particles%els(shell_index)%r(1:3)
subroutine cp_eval_at(gopt_env, x, f, gradient, master, final_evaluation, para_env)
evaluete the potential energy and its gradients using an array with same dimension as the particle_se...
represent a simple array based list of the given type
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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.
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_copy(cell_in, cell_out, tag)
Copy cell variable.
various routines to log and control the output. The idea is that decisions about where to log should ...
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, cell_ref, use_ref_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, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
subroutine, public pack_subsys_particles(subsys, f, r, s, v, fscale, cell)
Pack components of a subsystem particle sets into a single vector.
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Contains types used for a Dimer Method calculations.
Contains utilities for a Dimer Method calculations.
subroutine, public update_dimer_vec(dimer_env, motion_section)
Updates the orientation of the dimer vector in the input file.
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Interface for the force calculations.
integer function, public force_env_get_natom(force_env)
returns the number of atoms
integer, parameter, public use_qmmm
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_qmmmx
integer function, public force_env_get_nparticle(force_env)
returns the number of particles in a force environment
contains a functional that calculates the energy and its derivatives for the geometry optimizer
subroutine, public print_geo_opt_header(gopt_env, output_unit, label)
...
subroutine, public gopt_f_io_init(gopt_env, output_unit, opt_energy, wildcard, its, used_time)
Handles the Output during an optimization run.
subroutine, public gopt_f_create_x0(gopt_env, x0)
returns the value of the parameters for the actual configuration
recursive subroutine, public gopt_f_io_finalize(gopt_env, force_env, x0, conv, its, root_section, para_env, master, output_unit)
Handles the Output at the end of an optimization run.
subroutine, public apply_cell_change(gopt_env, cell, x, update_forces)
Apply coordinate transformations after cell (shape) change.
subroutine, public gopt_f_io(gopt_env, force_env, root_section, its, opt_energy, output_unit, eold, emin, wildcard, gopt_param, ndf, dx, xi, conv, pred, rat, step, rad, used_time)
Handles the Output during an optimization run.
subroutine, public print_geo_opt_nc(gopt_env, output_unit)
...
subroutine, public gopt_f_ii(its, output_unit)
Prints iteration step of the optimization procedure on screen.
contains a functional that calculates the energy and its derivatives for the geometry optimizer
contains typo and related routines to handle parameters controlling the GEO_OPT module
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
prints all energy info per timestep to the screen or to user defined output files
integer(kind=int_8) function, public sample_memory(para_env)
Samples memory usage.
Interface to the message passing library MPI.
Output Utilities for MOTION_SECTION.
subroutine, public write_simulation_cell(cell, motion_section, itimes, time, pos, act)
Prints the Simulation Cell.
subroutine, public write_trajectory(force_env, root_section, it, time, dtime, etot, pk_name, pos, act, middle_name, particles, extended_xmol_title)
Prints the information controlled by the TRAJECTORY section.
subroutine, public write_stress_tensor_to_file(virial, cell, motion_section, itimes, time, pos, act)
Prints the Stress Tensor.
represent a simple array based list of the given type
Define methods related to particle_type.
subroutine, public write_final_structure(particle_set, cell, input_section, conv, keep_angles, keep_symmetry, keep_volume, gopt_env_label, constraint_label)
Write the final geometry and cell information to files.
subroutine, public write_structure_data(particle_set, cell, input_section)
Write structure data requested by a separate structure data input section to the output unit....
Define the data structure for the particle information.
subroutine, public apply_qmmm_translate(qmmm_env)
Apply translation to the full system in order to center the QM system into the QM box.
Routines used for force-mixing QM/MM calculations.
subroutine, public apply_qmmmx_translate(qmmmx_env)
Apply translation to the full system in order to center the QM system into the QM box.
subroutine, public virial_evaluate(atomic_kind_set, particle_set, local_particles, virial, igroup)
Computes the kinetic part of the pressure tensor and updates the full VIRIAL (PV)
represent a list of objects
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represents a system: atoms, molecules, their pos,vel,...
Defines the environment for a Dimer Method calculation.
structure to store local (to a processor) ordered lists of integers.
wrapper to abstract the force evaluation of the various methods
calculates the potential energy of a system, and its derivatives
stores all the informations relevant to an mpi environment
represent a list of objects