(git:6344619)
Loading...
Searching...
No Matches
gopt_f_methods.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief contains a functional that calculates the energy and its derivatives
10!> for the geometry optimizer
11!> \par History
12!> none
13! **************************************************************************************************
15
19 USE bibliography, ONLY: henkelman1999,&
20 cite_reference
21 USE cell_methods, ONLY: cell_create,&
22 init_cell,&
25 get_dg_dh,&
27 USE cell_types, ONLY: cell_copy,&
29 cell_type,&
48 use_qmmm,&
50 USE gopt_f_types, ONLY: gopt_f_type
60 USE kinds, ONLY: default_string_length,&
61 dp,&
62 int_8
63 USE machine, ONLY: m_flush
64 USE md_energies, ONLY: sample_memory
82 USE virial_types, ONLY: virial_type
83#include "../base/base_uses.f90"
84
85 IMPLICIT NONE
86 PRIVATE
87
88 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gopt_f_methods'
89 INTEGER(KIND=int_8), PARAMETER, PRIVATE :: bytes_per_mib = 1024*1024
90
91 PUBLIC :: cp_eval_at, &
96
97CONTAINS
98
99! **************************************************************************************************
100!> \brief returns the value of the parameters for the actual configuration
101!> \param gopt_env the geometry optimization environment you want the info about
102!> x0: the parameter vector (is allocated by this routine)
103!> \param x0 ...
104!> \par History
105!> - Cell optimization revised (06.11.2012,MK)
106! **************************************************************************************************
107 SUBROUTINE gopt_f_create_x0(gopt_env, x0)
108
109 TYPE(gopt_f_type), POINTER :: gopt_env
110 REAL(kind=dp), DIMENSION(:), POINTER :: x0
111
112 INTEGER :: i, idg, j, nparticle
113 TYPE(cell_type), POINTER :: cell
114 TYPE(cp_subsys_type), POINTER :: subsys
115
116 NULLIFY (cell)
117 NULLIFY (subsys)
118
119 SELECT CASE (gopt_env%type_id)
121 CALL force_env_get(gopt_env%force_env, subsys=subsys)
122 ! before starting we handle the case of translating coordinates (QM/MM)
123 CALL apply_qmmm_translation(gopt_env)
124 nparticle = force_env_get_nparticle(gopt_env%force_env)
125 ALLOCATE (x0(3*nparticle))
126 CALL pack_subsys_particles(subsys=subsys, r=x0)
128 CALL force_env_get(gopt_env%force_env, subsys=subsys, cell=cell)
129 ! Store reference cell
130 gopt_env%h_ref = cell%hmat
131 ! before starting we handle the case of translating coordinates (QM/MM)
132 CALL apply_qmmm_translation(gopt_env)
133 nparticle = force_env_get_nparticle(gopt_env%force_env)
134 ALLOCATE (x0(3*nparticle + 6))
135 CALL pack_subsys_particles(subsys=subsys, r=x0)
136 idg = 3*nparticle
137 DO i = 1, 3
138 DO j = 1, i
139 idg = idg + 1
140 x0(idg) = gopt_env%cell_env%opt_cell%hmat(j, i)
141 END DO
142 END DO
143 CASE DEFAULT
144 cpabort("Invalid or not yet implemented type of optimization")
145 END SELECT
146
147 END SUBROUTINE gopt_f_create_x0
148
149! **************************************************************************************************
150!> \brief Apply the QM/MM and QM/MM/X coordinate translations before packing x0
151!> \param gopt_env ...
152! **************************************************************************************************
153 SUBROUTINE apply_qmmm_translation(gopt_env)
154 TYPE(gopt_f_type), POINTER :: gopt_env
155
156 IF (gopt_env%force_env%in_use == use_qmmm) THEN
157 CALL apply_qmmm_translate(gopt_env%force_env%qmmm_env)
158 END IF
159 IF (gopt_env%force_env%in_use == use_qmmmx) THEN
160 CALL apply_qmmmx_translate(gopt_env%force_env%qmmmx_env)
161 END IF
162 END SUBROUTINE apply_qmmm_translation
163
164! **************************************************************************************************
165!> \brief evaluete the potential energy and its gradients using an array
166!> with same dimension as the particle_set
167!> \param gopt_env the geometry optimization environment
168!> \param x the position where the function should be evaluated
169!> \param f the function value
170!> \param gradient the value of its gradient
171!> \param master ...
172!> \param para_env ...
173!> \par History
174!> CELL OPTIMIZATION: Teodoro Laino [tlaino] - University of Zurich - 03.2008
175!> 07.2020 Pierre Cazade [pcazade] Space Group Symmetry
176!> \author Teodoro Laino [tlaino] - University of Zurich - 01.2008
177! **************************************************************************************************
178 SUBROUTINE cp_eval_at(gopt_env, x, f, gradient, master, &
179 para_env)
180
181 TYPE(gopt_f_type), POINTER :: gopt_env
182 REAL(kind=dp), DIMENSION(:), POINTER :: x
183 REAL(kind=dp), INTENT(OUT), OPTIONAL :: f
184 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: gradient
185 INTEGER, INTENT(IN) :: master
186 TYPE(mp_para_env_type), POINTER :: para_env
187
188 CHARACTER(len=*), PARAMETER :: routinen = 'cp_eval_at'
189
190 INTEGER :: handle, idg, idir, ip, nparticle, nsize, &
191 shell_index
192 REAL(kind=dp) :: f_ts
193 REAL(kind=dp), DIMENSION(3, 3) :: av_ptens, av_ptens_opt
194 REAL(kind=dp), DIMENSION(:), POINTER :: cell_gradient, gradient_ts
195 TYPE(cell_type), POINTER :: cell
196 TYPE(cp_subsys_type), POINTER :: subsys
197 TYPE(particle_list_type), POINTER :: core_particles, particles, &
198 shell_particles
199 TYPE(spgr_type), POINTER :: spgr
200 TYPE(virial_type), POINTER :: virial
201
202 NULLIFY (cell)
203 NULLIFY (core_particles)
204 NULLIFY (gradient_ts)
205 NULLIFY (particles)
206 NULLIFY (shell_particles)
207 NULLIFY (subsys)
208 NULLIFY (virial)
209 NULLIFY (spgr)
210
211 CALL timeset(routinen, handle)
212
213 CALL force_env_get(gopt_env%force_env, subsys=subsys, cell=cell)
214 CALL cp_subsys_get(subsys, &
215 core_particles=core_particles, &
216 particles=particles, &
217 shell_particles=shell_particles, &
218 virial=virial)
219
220 spgr => gopt_env%spgr
221
222 SELECT CASE (gopt_env%type_id)
224 CALL unpack_subsys_particles(subsys=subsys, r=x)
225 CALL write_structure_data(particles%els, cell, gopt_env%motion_section)
226 SELECT CASE (gopt_env%type_id)
228 ! Geometry Minimization
229 CALL force_env_calc_energy_force(gopt_env%force_env, &
230 calc_force=PRESENT(gradient), &
231 require_consistent_energy_force=gopt_env%require_consistent_energy_force)
232 ! Possibly take the potential energy
233 IF (PRESENT(f)) THEN
234 CALL force_env_get(gopt_env%force_env, potential_energy=f)
235 END IF
236 ! Possibly take the gradients
237 IF (PRESENT(gradient)) THEN
238 IF (master == para_env%mepos) THEN ! we are on the master
239 CALL pack_subsys_particles(subsys=subsys, f=gradient, fscale=-1.0_dp)
240 IF (spgr%keep_space_group) THEN
241 CALL spgr_apply_rotations_force(spgr, gradient)
242 CALL unpack_subsys_particles(subsys=subsys, f=gradient, fscale=-1.0_dp)
243 END IF
244 END IF
245 END IF
247 ! Transition State Optimization
248 ALLOCATE (gradient_ts(particles%n_els*3))
249 ! Real calculation of energy and forces for transition state optimization:
250 ! When doing dimer methods forces have to be always computed since the function
251 ! to minimize is not the energy but the effective force
252 CALL cp_eval_at_ts(gopt_env, x, f_ts, gradient_ts, calc_force=.true.)
253 CALL cite_reference(henkelman1999)
254 ! Possibly take the potential energy
255 IF (PRESENT(f)) f = f_ts
256 ! Possibly take the gradients
257 IF (PRESENT(gradient)) THEN
258 IF (master == para_env%mepos) THEN ! we are on the master
259 cpassert(ASSOCIATED(gradient))
260 gradient = gradient_ts
261 END IF
262 END IF
263 DEALLOCATE (gradient_ts)
264 END SELECT
265 ! This call is necessary for QM/MM if a Translation is applied
266 ! this makes the geometry optimizer consistent
267 CALL unpack_subsys_particles(subsys=subsys, r=x)
269 ! Check for VIRIAL
270 IF (.NOT. virial%pv_availability) THEN
271 CALL cp_abort(__location__, &
272 "For the CELL_OPT task, the FORCE_EVAL/STRESS_TENSOR "// &
273 "keyword MUST be defined in the input file for the "// &
274 "evaluation of the stress tensor, but none is found!")
275 END IF
276 IF (gopt_env%cell_env%keep_volume) THEN
277 nparticle = force_env_get_nparticle(gopt_env%force_env)
278 idg = 3*nparticle
279 CALL rescale_new_cell_volume(cell%deth, x, idg)
280 END IF
281
282 CALL apply_cell_change(gopt_env, cell, x, update_forces=.false.)
283 ! Possibly output the new cell used for the next calculation
284 CALL write_cell(cell, gopt_env%geo_section)
285 ! Compute the pressure tensor
286 block
287 TYPE(virial_type) :: virial_avg
288 CALL force_env_calc_energy_force(gopt_env%force_env, &
289 calc_force=PRESENT(gradient), &
290 require_consistent_energy_force=gopt_env%require_consistent_energy_force)
291 ! Possibly take the potential energy
292 virial_avg = virial
293 CALL virial_update(virial_avg, subsys, para_env)
294 IF (PRESENT(f)) THEN
295 CALL force_env_get(gopt_env%force_env, potential_energy=f)
296 END IF
297 ! Possibly take the gradients
298 IF (PRESENT(gradient)) THEN
299 cpassert(any(virial_avg%pv_total /= 0))
300 ! Convert the average ptens
301 av_ptens(:, :) = virial_avg%pv_total(:, :)/cell%deth
302 IF (master == para_env%mepos) THEN ! we are on the master
303 cpassert(ASSOCIATED(gradient))
304 nparticle = force_env_get_nparticle(gopt_env%force_env)
305 nsize = 3*nparticle
306 cpassert((SIZE(gradient) == nsize + 6))
307 CALL pack_subsys_particles(subsys=subsys, f=gradient(1:nsize), fscale=-1.0_dp)
308 CALL apply_cell_change(gopt_env, cell, gradient, update_forces=.true.)
309 IF (spgr%keep_space_group) THEN
310 CALL spgr_apply_rotations_force(spgr, gradient)
311 CALL spgr_apply_rotations_stress(spgr, cell, av_ptens)
312 CALL spgr_write_stress_tensor(av_ptens, spgr)
313 END IF
314 cell_gradient => gradient(nsize + 1:nsize + 6)
315 cell_gradient = 0.0_dp
316 av_ptens_opt = matmul(gopt_env%cell_env%input_to_opt, &
317 matmul(av_ptens, gopt_env%cell_env%opt_to_input))
318 CALL get_dg_dh(cell_gradient, av_ptens_opt, gopt_env%cell_env%pres_ext, &
319 gopt_env%cell_env%opt_cell, gopt_env%cell_env%mtrx, &
320 keep_angles=gopt_env%cell_env%keep_angles, &
321 keep_symmetry=gopt_env%cell_env%keep_symmetry, &
322 pres_int=gopt_env%cell_env%pres_int, &
323 pres_constr=gopt_env%cell_env%pres_constr, &
324 constraint_id=gopt_env%cell_env%constraint_id)
325 END IF
326 ! some callers expect pres_int to be available on all ranks. Also, here master is not necessarily a single rank.
327 ! Assume at least master==0
328 CALL para_env%bcast(gopt_env%cell_env%pres_int, 0)
329 IF (gopt_env%cell_env%constraint_id /= fix_none) THEN
330 CALL para_env%bcast(gopt_env%cell_env%pres_constr, 0)
331 END IF
332 END IF
333 END block
335 idg = 0
336 DO ip = 1, particles%n_els
337 shell_index = particles%els(ip)%shell_index
338 IF (shell_index /= 0) THEN
339 DO idir = 1, 3
340 idg = 3*(shell_index - 1) + idir
341 shell_particles%els(shell_index)%r(idir) = core_particles%els(ip)%r(idir) - x(idg)
342 END DO
343 END IF
344 END DO
345 CALL write_structure_data(particles%els, cell, gopt_env%motion_section)
346
347 ! Shell-core optimization
348 CALL force_env_calc_energy_force(gopt_env%force_env, &
349 calc_force=PRESENT(gradient), &
350 require_consistent_energy_force=gopt_env%require_consistent_energy_force)
351
352 ! Possibly take the potential energy
353 IF (PRESENT(f)) THEN
354 CALL force_env_get(gopt_env%force_env, potential_energy=f)
355 END IF
356
357 ! Possibly take the gradients
358 IF (PRESENT(gradient)) THEN
359 IF (master == para_env%mepos) THEN ! we are on the master
360 cpassert(ASSOCIATED(gradient))
361 idg = 0
362 DO ip = 1, shell_particles%n_els
363 DO idir = 1, 3
364 idg = idg + 1
365 gradient(idg) = -(core_particles%els(ip)%f(idir) - shell_particles%els(ip)%f(idir))
366 END DO
367 END DO
368 END IF
369 END IF
370 CASE DEFAULT
371 cpabort("Invalid or not yet implemented type of optimization")
372 END SELECT
373
374 CALL timestop(handle)
375
376 END SUBROUTINE cp_eval_at
377
378! **************************************************************************************************
379!> \brief Prints iteration step of the optimization procedure on screen
380!> \param its ...
381!> \param output_unit ...
382!> \author Teodoro Laino [tlaino] - University of Zurich - 03.2008
383! **************************************************************************************************
384 SUBROUTINE gopt_f_ii(its, output_unit)
385
386 INTEGER, INTENT(IN) :: its, output_unit
387
388 IF (output_unit > 0) THEN
389 WRITE (unit=output_unit, fmt="(/,T2,26('-'))")
390 WRITE (unit=output_unit, fmt="(T2,A,I6)") "OPTIMIZATION STEP: ", its
391 WRITE (unit=output_unit, fmt="(T2,26('-'))")
392 CALL m_flush(output_unit)
393 END IF
394
395 END SUBROUTINE gopt_f_ii
396
397! **************************************************************************************************
398!> \brief Retrieves the reporting metadata used during an optimization step.
399!> \param gopt_env Optimization environment supplying print configuration and units
400!> \param force_env Force environment used for memory sampling
401!> \param max_memory Sampled memory, or zero if memory reporting is disabled
402!> \param energy_unit Energy reporting unit
403!> \param stress_unit Stress reporting unit
404! **************************************************************************************************
405 SUBROUTINE get_reporting_metadata(gopt_env, force_env, max_memory, energy_unit, stress_unit)
406
407 TYPE(gopt_f_type), POINTER :: gopt_env
408 TYPE(force_env_type), POINTER :: force_env
409 INTEGER(KIND=int_8), INTENT(OUT) :: max_memory
410 CHARACTER(LEN=default_string_length), INTENT(OUT) :: energy_unit, stress_unit
411
412 LOGICAL :: print_memory
413 TYPE(mp_para_env_type), POINTER :: para_env
414
415 NULLIFY (para_env)
416 CALL section_vals_val_get(gopt_env%motion_section, "PRINT%MEMORY_INFO", l_val=print_memory)
417 max_memory = 0
418 IF (print_memory) THEN
419 CALL force_env_get(force_env, para_env=para_env)
420 max_memory = sample_memory(para_env)
421 END IF
422
423 CALL section_vals_val_get(gopt_env%force_env%force_env_section, &
424 "PRINT%PROGRAM_RUN_INFO%ENERGY_UNIT", &
425 c_val=energy_unit)
426 CALL section_vals_val_get(gopt_env%force_env%force_env_section, &
427 "PRINT%STRESS_TENSOR%STRESS_UNIT", &
428 c_val=stress_unit)
429
430 END SUBROUTINE get_reporting_metadata
431
432! **************************************************************************************************
433!> \brief Handles the Output during an optimization run
434!> \param gopt_env ...
435!> \param output_unit ...
436!> \param opt_energy ...
437!> \param wildcard ...
438!> \param its ...
439!> \param used_time ...
440!> \author Teodoro Laino [tlaino] - University of Zurich - 03.2008
441! **************************************************************************************************
442 SUBROUTINE gopt_f_io_init(gopt_env, output_unit, opt_energy, wildcard, its, used_time)
443
444 TYPE(gopt_f_type), POINTER :: gopt_env
445 INTEGER, INTENT(IN) :: output_unit
446 REAL(kind=dp) :: opt_energy
447 CHARACTER(LEN=5) :: wildcard
448 INTEGER, INTENT(IN) :: its
449 REAL(kind=dp) :: used_time
450
451 CHARACTER(LEN=default_string_length) :: energy_unit, stress_unit
452 INTEGER(KIND=int_8) :: max_memory
453 REAL(kind=dp) :: pres_int
454
455 CALL get_reporting_metadata(gopt_env, gopt_env%force_env, max_memory, energy_unit, stress_unit)
456
457 SELECT CASE (gopt_env%type_id)
458 CASE (default_ts_method_id, default_minimization_method_id)
459 ! Geometry Optimization (Minimization and Transition State Search)
460 IF (.NOT. gopt_env%dimer_rotation) THEN
461 CALL write_cycle_infos(output_unit, &
462 it=its, &
463 etot=opt_energy, &
464 wildcard=wildcard, &
465 used_time=used_time, &
466 max_memory=max_memory, &
467 energy_unit=energy_unit, &
468 stress_unit=stress_unit)
469 ELSE
470 CALL write_rot_cycle_infos(output_unit, &
471 it=its, &
472 etot=opt_energy, &
473 dimer_env=gopt_env%dimer_env, &
474 wildcard=wildcard, &
475 used_time=used_time, &
476 max_memory=max_memory)
477 END IF
478 CASE (default_cell_method_id)
479 ! Cell Optimization
480 pres_int = gopt_env%cell_env%pres_int
481 CALL write_cycle_infos(output_unit, &
482 it=its, &
483 etot=opt_energy, &
484 pres_int=pres_int, &
485 wildcard=wildcard, &
486 used_time=used_time, &
487 max_memory=max_memory, &
488 energy_unit=energy_unit, &
489 stress_unit=stress_unit)
490 CASE (default_shellcore_method_id)
491 CALL write_cycle_infos(output_unit, &
492 it=its, &
493 etot=opt_energy, &
494 wildcard=wildcard, &
495 used_time=used_time, &
496 max_memory=max_memory, &
497 energy_unit=energy_unit, &
498 stress_unit=stress_unit)
499 END SELECT
500
501 END SUBROUTINE gopt_f_io_init
502
503! **************************************************************************************************
504!> \brief Handles the Output during an optimization run
505!> \param gopt_env ...
506!> \param force_env ...
507!> \param root_section ...
508!> \param its ...
509!> \param opt_energy ...
510!> \param output_unit ...
511!> \param eold ...
512!> \param emin ...
513!> \param wildcard ...
514!> \param gopt_param ...
515!> \param ndf ...
516!> \param dx ...
517!> \param xi ...
518!> \param conv ...
519!> \param pred ...
520!> \param rat ...
521!> \param step ...
522!> \param rad ...
523!> \param used_time ...
524!> \author Teodoro Laino [tlaino] - University of Zurich - 03.2008
525! **************************************************************************************************
526 SUBROUTINE gopt_f_io(gopt_env, force_env, root_section, its, opt_energy, &
527 output_unit, eold, emin, wildcard, gopt_param, ndf, dx, xi, conv, pred, rat, &
528 step, rad, used_time)
529
530 TYPE(gopt_f_type), POINTER :: gopt_env
531 TYPE(force_env_type), POINTER :: force_env
532 TYPE(section_vals_type), POINTER :: root_section
533 INTEGER, INTENT(IN) :: its
534 REAL(kind=dp), INTENT(IN) :: opt_energy
535 INTEGER, INTENT(IN) :: output_unit
536 REAL(kind=dp) :: eold, emin
537 CHARACTER(LEN=5) :: wildcard
538 TYPE(gopt_param_type), POINTER :: gopt_param
539 INTEGER, INTENT(IN), OPTIONAL :: ndf
540 REAL(kind=dp), DIMENSION(:), INTENT(IN), OPTIONAL :: dx
541 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: xi
542 LOGICAL, OPTIONAL :: conv
543 REAL(kind=dp), INTENT(IN), OPTIONAL :: pred, rat, step, rad
544 REAL(kind=dp) :: used_time
545
546 CHARACTER(LEN=default_string_length) :: energy_unit, stress_unit
547 INTEGER(KIND=int_8) :: max_memory
548 REAL(kind=dp) :: pres_diff, pres_diff_constr, pres_int, &
549 pres_tol
550
551 CALL get_reporting_metadata(gopt_env, force_env, max_memory, energy_unit, stress_unit)
552
553 SELECT CASE (gopt_env%type_id)
554 CASE (default_ts_method_id, default_minimization_method_id)
555 ! Geometry Optimization (Minimization and Transition State Search)
556 IF (.NOT. gopt_env%dimer_rotation) THEN
557 CALL geo_opt_io(force_env=force_env, root_section=root_section, &
558 motion_section=gopt_env%motion_section, its=its, opt_energy=opt_energy)
559 CALL write_cycle_infos(output_unit, &
560 it=its, &
561 etot=opt_energy, &
562 ediff=(opt_energy - eold), &
563 pred=pred, &
564 rat=rat, &
565 step=step, &
566 rad=rad, &
567 emin=emin, &
568 wildcard=wildcard, &
569 used_time=used_time, &
570 max_memory=max_memory, &
571 energy_unit=energy_unit, &
572 stress_unit=stress_unit)
573 ! Possibly check convergence
574 IF (PRESENT(conv)) THEN
575 cpassert(PRESENT(ndf))
576 cpassert(PRESENT(dx))
577 cpassert(PRESENT(xi))
578 CALL check_and_report_convergence(output_unit, gopt_param, ndf, dx, xi, conv, &
579 max_memory, stress_unit)
580 END IF
581 ELSE
582 CALL update_dimer_vec(gopt_env%dimer_env, gopt_env%motion_section)
583 CALL write_restart(force_env=force_env, root_section=root_section)
584 CALL write_rot_cycle_infos(output_unit, its, opt_energy, opt_energy - eold, emin, gopt_env%dimer_env, &
585 wildcard=wildcard, used_time=used_time, max_memory=max_memory)
586 ! Possibly check convergence
587 IF (PRESENT(conv)) THEN
588 cpassert(ASSOCIATED(gopt_env%dimer_env))
589 CALL check_rot_conv(gopt_env%dimer_env, output_unit, conv)
590 END IF
591 END IF
592 CASE (default_cell_method_id)
593 ! Cell Optimization
594 pres_diff = gopt_env%cell_env%pres_int - gopt_env%cell_env%pres_ext
595 pres_int = gopt_env%cell_env%pres_int
596 pres_tol = gopt_env%cell_env%pres_tol
597 CALL geo_opt_io(force_env=force_env, root_section=root_section, &
598 motion_section=gopt_env%motion_section, its=its, opt_energy=opt_energy)
599 CALL write_cycle_infos(output_unit, &
600 it=its, &
601 etot=opt_energy, &
602 ediff=(opt_energy - eold), &
603 pred=pred, &
604 rat=rat, &
605 step=step, &
606 rad=rad, &
607 emin=emin, &
608 pres_int=pres_int, &
609 wildcard=wildcard, &
610 used_time=used_time, &
611 max_memory=max_memory, &
612 energy_unit=energy_unit, &
613 stress_unit=stress_unit)
614 ! Possibly check convergence
615 IF (PRESENT(conv)) THEN
616 cpassert(PRESENT(ndf))
617 cpassert(PRESENT(dx))
618 cpassert(PRESENT(xi))
619 IF (gopt_env%cell_env%constraint_id == fix_none) THEN
620 CALL check_and_report_convergence(output_unit, gopt_param, ndf, dx, xi, conv, &
621 max_memory, stress_unit, pres_diff, pres_tol)
622 ELSE
623 pres_diff_constr = gopt_env%cell_env%pres_constr - gopt_env%cell_env%pres_ext
624 CALL check_and_report_convergence(output_unit, gopt_param, ndf, dx, xi, conv, &
625 max_memory, stress_unit, pres_diff, pres_tol, &
626 pres_diff_constr)
627 END IF
628 END IF
629 CASE (default_shellcore_method_id)
630 CALL write_cycle_infos(output_unit, &
631 it=its, &
632 etot=opt_energy, &
633 ediff=(opt_energy - eold), &
634 pred=pred, &
635 rat=rat, &
636 step=step, &
637 rad=rad, &
638 emin=emin, &
639 wildcard=wildcard, &
640 used_time=used_time, &
641 max_memory=max_memory, &
642 energy_unit=energy_unit, &
643 stress_unit=stress_unit)
644 ! Possibly check convergence
645 IF (PRESENT(conv)) THEN
646 cpassert(PRESENT(ndf))
647 cpassert(PRESENT(dx))
648 cpassert(PRESENT(xi))
649 CALL check_and_report_convergence(output_unit, gopt_param, ndf, dx, xi, conv, &
650 max_memory, stress_unit)
651 END IF
652 END SELECT
653
654 END SUBROUTINE gopt_f_io
655
656! **************************************************************************************************
657!> \brief Handles the Output at the end of an optimization run
658!> \param gopt_env ...
659!> \param force_env ...
660!> \param x0 ...
661!> \param conv ...
662!> \param its ...
663!> \param root_section ...
664!> \param para_env ...
665!> \param master ...
666!> \param output_unit ...
667!> \author Teodoro Laino [tlaino] - University of Zurich - 03.2008
668! **************************************************************************************************
669 RECURSIVE SUBROUTINE gopt_f_io_finalize(gopt_env, force_env, x0, conv, its, root_section, &
670 para_env, master, output_unit)
671 TYPE(gopt_f_type), POINTER :: gopt_env
672 TYPE(force_env_type), POINTER :: force_env
673 REAL(kind=dp), DIMENSION(:), POINTER :: x0
674 LOGICAL :: conv
675 INTEGER :: its
676 TYPE(section_vals_type), POINTER :: root_section
677 TYPE(mp_para_env_type), POINTER :: para_env
678 INTEGER, INTENT(IN) :: master, output_unit
679
680 IF (gopt_env%eval_opt_geo) THEN
681 IF (.NOT. gopt_env%dimer_rotation) THEN
682 CALL write_final_info(output_unit, conv, its, gopt_env, x0, master, &
683 para_env, force_env, gopt_env%motion_section, root_section)
684 ELSE
685 CALL update_dimer_vec(gopt_env%dimer_env, gopt_env%motion_section)
686 CALL write_restart(force_env=force_env, root_section=root_section)
687 END IF
688 END IF
689
690 END SUBROUTINE gopt_f_io_finalize
691
692! **************************************************************************************************
693!> \brief ...
694!> \param output_unit ...
695!> \param it ...
696!> \param etot ...
697!> \param ediff ...
698!> \param pred ...
699!> \param rat ...
700!> \param step ...
701!> \param rad ...
702!> \param emin ...
703!> \param pres_int ...
704!> \param wildcard ...
705!> \param used_time ...
706!> \param max_memory ...
707!> \param energy_unit ...
708!> \param stress_unit ...
709! **************************************************************************************************
710 SUBROUTINE write_cycle_infos(output_unit, it, etot, ediff, pred, rat, step, rad, emin, &
711 pres_int, wildcard, used_time, max_memory, energy_unit, stress_unit)
712
713 INTEGER, INTENT(IN) :: output_unit, it
714 REAL(kind=dp), INTENT(IN) :: etot
715 REAL(kind=dp), INTENT(IN), OPTIONAL :: ediff, pred, rat, step, rad, emin, &
716 pres_int
717 CHARACTER(LEN=5), INTENT(IN) :: wildcard
718 REAL(kind=dp), INTENT(IN) :: used_time
719 INTEGER(KIND=int_8), INTENT(IN) :: max_memory
720 CHARACTER(LEN=default_string_length), INTENT(IN) :: energy_unit, stress_unit
721
722 CHARACTER(LEN=5) :: tag
723
724 IF (output_unit > 0) THEN
725 tag = "OPT| "
726 WRITE (unit=output_unit, fmt="(/,T2,A)") tag//repeat("*", 74)
727 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,I25)") &
728 tag//"Step number", it
729 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,A25)") &
730 tag//"Optimization method", wildcard
731 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
732 tag//"Total energy ["//trim(adjustl(energy_unit))//"]", &
733 cp_unit_from_cp2k(etot, trim(energy_unit))
734 IF (PRESENT(pres_int)) THEN
735 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
736 tag//"Internal pressure ["//trim(adjustl(stress_unit))//"]", &
737 cp_unit_from_cp2k(pres_int, trim(stress_unit))
738 END IF
739 IF (PRESENT(ediff)) THEN
740 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
741 tag//"Effective energy change ["//trim(adjustl(energy_unit))//"]", &
742 cp_unit_from_cp2k(ediff, trim(energy_unit))
743 END IF
744 IF (PRESENT(pred)) THEN
745 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
746 tag//"Predicted energy change ["//trim(adjustl(energy_unit))//"]", &
747 cp_unit_from_cp2k(pred, trim(energy_unit))
748 END IF
749 IF (PRESENT(rat)) THEN
750 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
751 tag//"Scaling factor", rat
752 END IF
753 IF (PRESENT(step)) THEN
754 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
755 tag//"Step size", step
756 END IF
757 IF (PRESENT(rad)) THEN
758 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
759 tag//"Trust radius", rad
760 END IF
761 IF (PRESENT(emin)) THEN
762 IF (etot < emin) THEN
763 WRITE (unit=output_unit, fmt="(T2,A,T77,A4)") &
764 tag//"Decrease in energy", " YES"
765 ELSE
766 WRITE (unit=output_unit, fmt="(T2,A,T77,A4)") &
767 tag//"Decrease in energy", " NO"
768 END IF
769 END IF
770 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.3)") &
771 tag//"Used time [s]", used_time
772 IF (it == 0) THEN
773 WRITE (unit=output_unit, fmt="(T2,A)") tag//repeat("*", 74)
774 IF (max_memory /= 0) THEN
775 WRITE (unit=output_unit, fmt="(T2,A,T60,1X,I20)") &
776 tag//"Estimated peak process memory [MiB]", &
777 (max_memory + bytes_per_mib - 1)/bytes_per_mib
778 END IF
779 END IF
780 END IF
781
782 END SUBROUTINE write_cycle_infos
783
784! **************************************************************************************************
785!> \brief ...
786!> \param output_unit ...
787!> \param it ...
788!> \param etot ...
789!> \param ediff ...
790!> \param emin ...
791!> \param dimer_env ...
792!> \param used_time ...
793!> \param wildcard ...
794!> \param max_memory ...
795!> \date 01.2008
796!> \author Luca Bellucci and Teodoro Laino - created [tlaino]
797! **************************************************************************************************
798 SUBROUTINE write_rot_cycle_infos(output_unit, it, etot, ediff, emin, dimer_env, used_time, &
799 wildcard, max_memory)
800
801 INTEGER, INTENT(IN) :: output_unit, it
802 REAL(kind=dp), INTENT(IN) :: etot
803 REAL(kind=dp), INTENT(IN), OPTIONAL :: ediff, emin
804 TYPE(dimer_env_type), POINTER :: dimer_env
805 REAL(kind=dp), INTENT(IN) :: used_time
806 CHARACTER(LEN=5), INTENT(IN) :: wildcard
807 INTEGER(KIND=int_8), INTENT(IN) :: max_memory
808
809 CHARACTER(LEN=5) :: tag
810
811 IF (output_unit > 0) THEN
812 tag = "OPT| "
813 WRITE (unit=output_unit, fmt="(/,T2,A)") tag//repeat("*", 74)
814 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,I25)") &
815 tag//"Rotational step number", it
816 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,A25)") &
817 tag//"Optimization method", wildcard
818 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
819 tag//"Local curvature", dimer_env%rot%curvature, &
820 tag//"Total rotational force", etot
821 IF (PRESENT(ediff)) THEN
822 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
823 tag//"Rotational force change", ediff
824 END IF
825 IF (PRESENT(emin)) THEN
826 IF (etot < emin) THEN
827 WRITE (unit=output_unit, fmt="(T2,A,T77,A4)") &
828 tag//"Decrease in rotational force", " YES"
829 ELSE
830 WRITE (unit=output_unit, fmt="(T2,A,T77,A4)") &
831 tag//"Decrease in rotational force", " NO"
832 END IF
833 END IF
834 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.3)") &
835 tag//"Used time [s]", used_time
836 IF (it == 0) THEN
837 WRITE (unit=output_unit, fmt="(T2,A)") tag//repeat("*", 74)
838 IF (max_memory /= 0) THEN
839 WRITE (unit=output_unit, fmt="(T2,A,T60,1X,I20)") &
840 tag//"Estimated peak process memory [MiB]", &
841 (max_memory + bytes_per_mib - 1)/bytes_per_mib
842 END IF
843 END IF
844 END IF
845
846 END SUBROUTINE write_rot_cycle_infos
847
848! **************************************************************************************************
849!> \brief Evaluate the geometry/cell optimization convergence criteria (pure decision, no I/O)
850!> \param ndf ...
851!> \param dr ...
852!> \param g ...
853!> \param gopt_param ...
854!> \param conv ...
855!> \param conv_dx ...
856!> \param conv_rdx ...
857!> \param conv_g ...
858!> \param conv_rg ...
859!> \param conv_p ...
860!> \param max_dr ...
861!> \param rms_dr ...
862!> \param max_grad ...
863!> \param rms_grad ...
864!> \param pres_diff ...
865!> \param pres_tol ...
866!> \param pres_diff_constr ...
867! **************************************************************************************************
868 SUBROUTINE check_converg(ndf, dr, g, gopt_param, conv, conv_dx, conv_rdx, conv_g, conv_rg, conv_p, &
869 max_dr, rms_dr, max_grad, rms_grad, pres_diff, pres_tol, pres_diff_constr)
870
871 INTEGER, INTENT(IN) :: ndf
872 REAL(kind=dp), INTENT(IN) :: dr(ndf), g(ndf)
873 TYPE(gopt_param_type), POINTER :: gopt_param
874 LOGICAL, INTENT(OUT) :: conv, conv_dx, conv_rdx, conv_g, &
875 conv_rg, conv_p
876 REAL(kind=dp), INTENT(OUT) :: max_dr, rms_dr, max_grad, rms_grad
877 REAL(kind=dp), INTENT(IN), OPTIONAL :: pres_diff, pres_tol, pres_diff_constr
878
879 INTEGER :: indf
880 REAL(kind=dp) :: dumm, dxcon, gcon, rmsgcon, rmsxcon
881
882 dxcon = gopt_param%max_dr
883 gcon = gopt_param%max_force
884 rmsgcon = gopt_param%rms_force
885 rmsxcon = gopt_param%rms_dr
886
887 conv = .false.
888 conv_dx = .true.
889 conv_rdx = .true.
890 conv_g = .true.
891 conv_rg = .true.
892 conv_p = .true.
893
894 dumm = 0.0_dp
895 DO indf = 1, ndf
896 IF (indf == 1) max_dr = abs(dr(indf))
897 dumm = dumm + dr(indf)**2
898 IF (abs(dr(indf)) > dxcon) conv_dx = .false.
899 IF (abs(dr(indf)) > max_dr) max_dr = abs(dr(indf))
900 END DO
901 ! SQRT(dumm/ndf) > rmsxcon
902 IF (dumm > (rmsxcon*rmsxcon*ndf)) conv_rdx = .false.
903 rms_dr = sqrt(dumm/ndf)
904
905 dumm = 0.0_dp
906 DO indf = 1, ndf
907 IF (indf == 1) max_grad = abs(g(indf))
908 dumm = dumm + g(indf)**2
909 IF (abs(g(indf)) > gcon) conv_g = .false.
910 IF (abs(g(indf)) > max_grad) max_grad = abs(g(indf))
911 END DO
912 ! SQRT(dumm/ndf) > rmsgcon
913 IF (dumm > (rmsgcon*rmsgcon*ndf)) conv_rg = .false.
914 rms_grad = sqrt(dumm/ndf)
915
916 IF (PRESENT(pres_diff_constr) .AND. PRESENT(pres_tol)) THEN
917 conv_p = abs(pres_diff_constr) < abs(pres_tol)
918 ELSE IF (PRESENT(pres_diff) .AND. PRESENT(pres_tol)) THEN
919 conv_p = abs(pres_diff) < abs(pres_tol)
920 END IF
921
922 IF (conv_dx .AND. conv_rdx .AND. conv_g .AND. conv_rg .AND. conv_p) conv = .true.
923
924 END SUBROUTINE check_converg
925
926! **************************************************************************************************
927!> \brief Print one YES/NO convergence flag line
928!> \param output_unit ...
929!> \param tag ...
930!> \param label ...
931!> \param flag ...
932! **************************************************************************************************
933 SUBROUTINE write_conv_flag(output_unit, tag, label, flag)
934 INTEGER, INTENT(IN) :: output_unit
935 CHARACTER(LEN=*), INTENT(IN) :: tag, label
936 LOGICAL, INTENT(IN) :: flag
937
938 IF (flag) THEN
939 WRITE (unit=output_unit, fmt="(T2,A,T77,A4)") tag//label, " YES"
940 ELSE
941 WRITE (unit=output_unit, fmt="(T2,A,T77,A4)") tag//label, " NO"
942 END IF
943 END SUBROUTINE write_conv_flag
944
945! **************************************************************************************************
946!> \brief Print the per-cycle convergence report (body moved verbatim from check_converg)
947!> \param output_unit ...
948!> \param gopt_param ...
949!> \param conv ...
950!> \param conv_dx ...
951!> \param conv_rdx ...
952!> \param conv_g ...
953!> \param conv_rg ...
954!> \param conv_p ...
955!> \param max_dr ...
956!> \param rms_dr ...
957!> \param max_grad ...
958!> \param rms_grad ...
959!> \param max_memory ...
960!> \param stress_unit ...
961!> \param pres_diff ...
962!> \param pres_tol ...
963!> \param pres_diff_constr ...
964! **************************************************************************************************
965 SUBROUTINE write_convergence_infos(output_unit, gopt_param, conv, conv_dx, conv_rdx, conv_g, &
966 conv_rg, conv_p, max_dr, rms_dr, max_grad, rms_grad, &
967 max_memory, stress_unit, pres_diff, pres_tol, pres_diff_constr)
968
969 INTEGER, INTENT(IN) :: output_unit
970 TYPE(gopt_param_type), POINTER :: gopt_param
971 LOGICAL, INTENT(IN) :: conv, conv_dx, conv_rdx, conv_g, &
972 conv_rg, conv_p
973 REAL(kind=dp), INTENT(IN) :: max_dr, rms_dr, max_grad, rms_grad
974 INTEGER(KIND=int_8), INTENT(IN) :: max_memory
975 CHARACTER(LEN=default_string_length), INTENT(IN) :: stress_unit
976 REAL(kind=dp), INTENT(IN), OPTIONAL :: pres_diff, pres_tol, pres_diff_constr
977
978 CHARACTER(LEN=5) :: tag
979 REAL(kind=dp) :: dxcon, gcon, rmsgcon, rmsxcon
980
981 dxcon = gopt_param%max_dr
982 gcon = gopt_param%max_force
983 rmsgcon = gopt_param%rms_force
984 rmsxcon = gopt_param%rms_dr
985
986 IF (output_unit > 0) THEN
987
988 tag = "OPT| "
989
990 WRITE (unit=output_unit, fmt="(T2,A)") trim(tag)
991 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
992 tag//"Maximum step size", max_dr, &
993 tag//"Convergence limit for maximum step size", dxcon
994 CALL write_conv_flag(output_unit, tag, "Maximum step size is converged", &
995 conv_dx)
996
997 WRITE (unit=output_unit, fmt="(T2,A)") trim(tag)
998 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
999 tag//"RMS step size", rms_dr, &
1000 tag//"Convergence limit for RMS step size", rmsxcon
1001 CALL write_conv_flag(output_unit, tag, "RMS step size is converged", &
1002 conv_rdx)
1003
1004 WRITE (unit=output_unit, fmt="(T2,A)") trim(tag)
1005 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1006 tag//"Maximum gradient", max_grad, &
1007 tag//"Convergence limit for maximum gradient", gcon
1008 CALL write_conv_flag(output_unit, tag, "Maximum gradient is converged", &
1009 conv_g)
1010
1011 WRITE (unit=output_unit, fmt="(T2,A)") trim(tag)
1012 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1013 tag//"RMS gradient", rms_grad, &
1014 tag//"Convergence limit for RMS gradient", rmsgcon
1015 CALL write_conv_flag(output_unit, tag, "RMS gradient is converged", &
1016 conv_rg)
1017
1018 IF (PRESENT(pres_diff) .AND. PRESENT(pres_tol)) THEN
1019 WRITE (unit=output_unit, fmt="(T2,A)") trim(tag)
1020 IF (PRESENT(pres_diff_constr)) THEN
1021 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1022 tag//"Pressure deviation without constraint ["// &
1023 trim(adjustl(stress_unit))//"]", &
1024 cp_unit_from_cp2k(pres_diff, trim(stress_unit))
1025 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1026 tag//"Pressure deviation with constraint ["// &
1027 trim(adjustl(stress_unit))//"]", &
1028 cp_unit_from_cp2k(pres_diff_constr, trim(stress_unit))
1029 ELSE
1030 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1031 tag//"Pressure deviation ["//trim(adjustl(stress_unit))//"]", &
1032 cp_unit_from_cp2k(pres_diff, trim(stress_unit))
1033 END IF
1034 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1035 tag//"Pressure tolerance ["//trim(adjustl(stress_unit))//"]", &
1036 cp_unit_from_cp2k(pres_tol, trim(stress_unit))
1037 CALL write_conv_flag(output_unit, tag, "Pressure is converged", conv_p)
1038 END IF
1039
1040 WRITE (unit=output_unit, fmt="(T2,A)") tag//repeat("*", 74)
1041
1042 IF (max_memory /= 0) THEN
1043 WRITE (unit=output_unit, fmt="(T2,A,T60,1X,I20)") &
1044 tag//"Estimated peak process memory after this step [MiB]", &
1045 (max_memory + bytes_per_mib - 1)/bytes_per_mib
1046 END IF
1047
1048 END IF
1049
1050 IF ((conv) .AND. (output_unit > 0)) THEN
1051 WRITE (unit=output_unit, fmt="(/,T2,A)") repeat("*", 79)
1052 WRITE (unit=output_unit, fmt="(T2,A,T25,A,T78,A)") &
1053 "***", "GEOMETRY OPTIMIZATION COMPLETED", "***"
1054 WRITE (unit=output_unit, fmt="(T2,A)") repeat("*", 79)
1055 END IF
1056
1057 END SUBROUTINE write_convergence_infos
1058
1059! **************************************************************************************************
1060!> \brief Check convergence and print the per-cycle report (gopt_f_io call sites)
1061!> \param output_unit ...
1062!> \param gopt_param ...
1063!> \param ndf ...
1064!> \param dr ...
1065!> \param g ...
1066!> \param conv ...
1067!> \param max_memory ...
1068!> \param stress_unit ...
1069!> \param pres_diff ...
1070!> \param pres_tol ...
1071!> \param pres_diff_constr ...
1072! **************************************************************************************************
1073 SUBROUTINE check_and_report_convergence(output_unit, gopt_param, ndf, dr, g, conv, &
1074 max_memory, stress_unit, pres_diff, pres_tol, pres_diff_constr)
1075
1076 INTEGER, INTENT(IN) :: output_unit
1077 TYPE(gopt_param_type), POINTER :: gopt_param
1078 INTEGER, INTENT(IN) :: ndf
1079 REAL(kind=dp), INTENT(IN) :: dr(ndf), g(ndf)
1080 LOGICAL, INTENT(INOUT) :: conv
1081 INTEGER(KIND=int_8), INTENT(IN) :: max_memory
1082 CHARACTER(LEN=default_string_length), INTENT(IN) :: stress_unit
1083 REAL(kind=dp), INTENT(IN), OPTIONAL :: pres_diff, pres_tol, pres_diff_constr
1084
1085 LOGICAL :: conv_dx, conv_g, conv_p, conv_rdx, &
1086 conv_rg
1087 REAL(kind=dp) :: max_dr, max_grad, rms_dr, rms_grad
1088
1089 CALL check_converg(ndf, dr, g, gopt_param, conv, conv_dx, conv_rdx, conv_g, conv_rg, &
1090 conv_p, max_dr, rms_dr, max_grad, rms_grad, pres_diff, pres_tol, &
1091 pres_diff_constr)
1092 CALL write_convergence_infos(output_unit, gopt_param, conv, conv_dx, conv_rdx, conv_g, &
1093 conv_rg, conv_p, max_dr, rms_dr, max_grad, rms_grad, &
1094 max_memory, stress_unit, pres_diff, pres_tol, pres_diff_constr)
1095 END SUBROUTINE check_and_report_convergence
1096
1097! **************************************************************************************************
1098!> \brief ...
1099!> \param dimer_env ...
1100!> \param output_unit ...
1101!> \param conv ...
1102!> \date 01.2008
1103!> \author Luca Bellucci and Teodoro Laino - created [tlaino]
1104! **************************************************************************************************
1105 SUBROUTINE check_rot_conv(dimer_env, output_unit, conv)
1106
1107 TYPE(dimer_env_type), POINTER :: dimer_env
1108 INTEGER, INTENT(IN) :: output_unit
1109 LOGICAL, INTENT(OUT) :: conv
1110
1111 CHARACTER(LEN=5) :: tag
1112
1113 conv = (abs(dimer_env%rot%angle2) < dimer_env%rot%angle_tol)
1114
1115 IF (output_unit > 0) THEN
1116 tag = "OPT| "
1117 WRITE (unit=output_unit, fmt="(T2,A)") trim(tag)
1118 WRITE (unit=output_unit, fmt="(T2,A,T55,1X,F25.10)") &
1119 tag//"Predicted angle step size", dimer_env%rot%angle1, &
1120 tag//"Effective angle step size", dimer_env%rot%angle2, &
1121 tag//"Convergence limit for angle step size", dimer_env%rot%angle_tol
1122 CALL write_conv_flag(output_unit, tag, "Angle step size is converged", conv)
1123 WRITE (unit=output_unit, fmt="(T2,A)") tag//repeat("*", 74)
1124 END IF
1125
1126 IF ((conv) .AND. (output_unit > 0)) THEN
1127 WRITE (unit=output_unit, fmt="(/,T2,A)") repeat("*", 79)
1128 WRITE (unit=output_unit, fmt="(T2,A,T25,A,T78,A)") &
1129 "***", "ROTATION OPTIMIZATION COMPLETED", "***"
1130 WRITE (unit=output_unit, fmt="(T2,A)") repeat("*", 79)
1131 END IF
1132
1133 END SUBROUTINE check_rot_conv
1134
1135! **************************************************************************************************
1136!> \brief ...
1137!> \param output_unit ...
1138!> \param conv ...
1139!> \param it ...
1140!> \param gopt_env ...
1141!> \param x0 ...
1142!> \param master ...
1143!> \param para_env ...
1144!> \param force_env ...
1145!> \param motion_section ...
1146!> \param root_section ...
1147!> \date 11.2007
1148!> \author Teodoro Laino [tlaino] - University of Zurich
1149! **************************************************************************************************
1150 RECURSIVE SUBROUTINE write_final_info(output_unit, conv, it, gopt_env, x0, master, para_env, force_env, &
1151 motion_section, root_section)
1152 INTEGER, INTENT(IN) :: output_unit
1153 LOGICAL, INTENT(IN) :: conv
1154 INTEGER, INTENT(INOUT) :: it
1155 TYPE(gopt_f_type), POINTER :: gopt_env
1156 REAL(kind=dp), DIMENSION(:), POINTER :: x0
1157 INTEGER, INTENT(IN) :: master
1158 TYPE(mp_para_env_type), POINTER :: para_env
1159 TYPE(force_env_type), POINTER :: force_env
1160 TYPE(section_vals_type), POINTER :: motion_section, root_section
1161
1162 CHARACTER(LEN=default_string_length) :: constraint_label
1163 LOGICAL :: keep_angles, keep_symmetry, keep_volume
1164 REAL(kind=dp) :: etot
1165 TYPE(cell_type), POINTER :: cell
1166 TYPE(cp_subsys_type), POINTER :: subsys
1167 TYPE(particle_list_type), POINTER :: particles
1168 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1169
1170 CALL force_env_get(force_env, cell=cell, subsys=subsys)
1171 CALL cp_subsys_get(subsys=subsys, particles=particles)
1172 particle_set => particles%els
1173
1174 ! Passing gopt_f_type pointer gopt_env to particle_methods where
1175 ! write_final_structure is defined causes a circular dependency, so it
1176 ! is necessary to get some flags by preprocessing...
1177 keep_angles = .true.
1178 keep_symmetry = .true.
1179 keep_volume = .true.
1180 constraint_label = "NONE"
1181 IF (gopt_env%type_id == default_cell_method_id) THEN
1182 keep_angles = gopt_env%cell_env%keep_angles
1183 keep_symmetry = gopt_env%cell_env%keep_symmetry
1184 keep_volume = gopt_env%cell_env%keep_volume
1185 constraint_label = cell_opt_constraint_label(gopt_env%cell_env%constraint_id)
1186 END IF
1187 CALL write_final_structure(particle_set, cell, motion_section, conv, &
1188 keep_angles, keep_symmetry, keep_volume, &
1189 gopt_env%label, constraint_label)
1190
1191 IF (conv) THEN
1192 it = it + 1
1193 CALL write_structure_data(particle_set, cell, motion_section)
1194 CALL write_restart(force_env=force_env, root_section=root_section)
1195
1196 IF (output_unit > 0) THEN
1197 WRITE (unit=output_unit, fmt="(/,T20,' Reevaluating energy at the minimum')")
1198 END IF
1199
1200 CALL cp_eval_at(gopt_env, x0, f=etot, master=master, &
1201 para_env=para_env)
1202 CALL write_geo_traj(force_env, root_section, it, etot)
1203 CALL write_simulation_cell(cell, motion_section, it, 0.0_dp)
1204 END IF
1205
1206 END SUBROUTINE write_final_info
1207
1208! **************************************************************************************************
1209!> \brief Specific driver for dumping trajectory during a GEO_OPT
1210!> \param force_env ...
1211!> \param root_section ...
1212!> \param it ...
1213!> \param etot ...
1214!> \date 11.2007
1215!> \par History
1216!> 09.2010: Output of core and shell positions and forces (MK)
1217!> \author Teodoro Laino [tlaino] - University of Zurich
1218! **************************************************************************************************
1219 SUBROUTINE write_geo_traj(force_env, root_section, it, etot)
1220
1221 TYPE(force_env_type), POINTER :: force_env
1222 TYPE(section_vals_type), POINTER :: root_section
1223 INTEGER, INTENT(IN) :: it
1224 REAL(kind=dp), INTENT(IN) :: etot
1225
1226 LOGICAL :: shell_adiabatic, shell_present
1227 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
1228 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1229 TYPE(cp_subsys_type), POINTER :: subsys
1230 TYPE(particle_list_type), POINTER :: core_particles, shell_particles
1231
1232 NULLIFY (atomic_kinds)
1233 NULLIFY (atomic_kind_set)
1234 NULLIFY (core_particles)
1235 NULLIFY (shell_particles)
1236 NULLIFY (subsys)
1237
1238 CALL write_trajectory(force_env, root_section, it, 0.0_dp, 0.0_dp, etot)
1239 ! Print Force
1240 CALL write_trajectory(force_env, root_section, it, 0.0_dp, 0.0_dp, etot, "FORCES", middle_name="frc")
1241 CALL force_env_get(force_env, subsys=subsys)
1242 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds)
1243 atomic_kind_set => atomic_kinds%els
1244 CALL get_atomic_kind_set(atomic_kind_set, &
1245 shell_present=shell_present, &
1246 shell_adiabatic=shell_adiabatic)
1247 IF (shell_present) THEN
1248 CALL cp_subsys_get(subsys, &
1249 core_particles=core_particles, &
1250 shell_particles=shell_particles)
1251 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
1252 etot=etot, pk_name="SHELL_TRAJECTORY", middle_name="shpos", &
1253 particles=shell_particles)
1254 IF (shell_adiabatic) THEN
1255 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
1256 etot=etot, pk_name="SHELL_FORCES", middle_name="shfrc", &
1257 particles=shell_particles)
1258 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
1259 etot=etot, pk_name="CORE_TRAJECTORY", middle_name="copos", &
1260 particles=core_particles)
1261 CALL write_trajectory(force_env, root_section, it=it, time=0.0_dp, dtime=0.0_dp, &
1262 etot=etot, pk_name="CORE_FORCES", middle_name="cofrc", &
1263 particles=core_particles)
1264 END IF
1265 END IF
1266
1267 END SUBROUTINE write_geo_traj
1268
1269! **************************************************************************************************
1270!> \brief ...
1271!> \param gopt_env ...
1272!> \param output_unit ...
1273!> \param label ...
1274!> \date 01.2008
1275!> \author Teodoro Laino [tlaino] - University of Zurich
1276! **************************************************************************************************
1277 SUBROUTINE print_geo_opt_header(gopt_env, output_unit, label)
1278
1279 TYPE(gopt_f_type), POINTER :: gopt_env
1280 INTEGER, INTENT(IN) :: output_unit
1281 CHARACTER(LEN=*), INTENT(IN) :: label
1282
1283 CHARACTER(LEN=default_string_length) :: my_format, my_label
1284 INTEGER :: ix
1285
1286 IF (output_unit > 0) THEN
1287 WRITE (unit=output_unit, fmt="(/,T2,A)") repeat("*", 79)
1288 IF (gopt_env%dimer_rotation) THEN
1289 my_label = "OPTIMIZING DIMER ROTATION"
1290 ELSE
1291 my_label = "STARTING "//gopt_env%tag(1:8)//" OPTIMIZATION"
1292 END IF
1293
1294 ix = (80 - 7 - len_trim(my_label))/2
1295 ix = ix + 5
1296 my_format = "(T2,A,T"//cp_to_string(ix)//",A,T78,A)"
1297 WRITE (unit=output_unit, fmt=trim(my_format)) "***", trim(my_label), "***"
1298
1299 ix = (80 - 7 - len_trim(label))/2
1300 ix = ix + 5
1301 my_format = "(T2,A,T"//cp_to_string(ix)//",A,T78,A)"
1302 WRITE (unit=output_unit, fmt=trim(my_format)) "***", trim(label), "***"
1303
1304 WRITE (unit=output_unit, fmt="(T2,A)") repeat("*", 79)
1305 CALL m_flush(output_unit)
1306 END IF
1307 END SUBROUTINE print_geo_opt_header
1308
1309! **************************************************************************************************
1310!> \brief ...
1311!> \param gopt_env ...
1312!> \param output_unit ...
1313!> \date 01.2008
1314!> \author Teodoro Laino [tlaino] - University of Zurich
1315! **************************************************************************************************
1316 SUBROUTINE print_geo_opt_nc(gopt_env, output_unit)
1317
1318 TYPE(gopt_f_type), POINTER :: gopt_env
1319 INTEGER, INTENT(IN) :: output_unit
1320
1321 IF (output_unit > 0) THEN
1322 WRITE (unit=output_unit, fmt="(/,T2,A)") &
1323 "*** MAXIMUM NUMBER OF OPTIMIZATION STEPS REACHED ***"
1324 IF (.NOT. gopt_env%dimer_rotation) THEN
1325 WRITE (unit=output_unit, fmt="(T2,A)") &
1326 "*** EXITING GEOMETRY OPTIMIZATION ***"
1327 ELSE
1328 WRITE (unit=output_unit, fmt="(T2,A)") &
1329 "*** EXITING ROTATION OPTIMIZATION ***"
1330 END IF
1331 CALL m_flush(output_unit)
1332 END IF
1333
1334 END SUBROUTINE print_geo_opt_nc
1335
1336! **************************************************************************************************
1337!> \brief Prints information during GEO_OPT common to all optimizers
1338!> \param force_env ...
1339!> \param root_section ...
1340!> \param motion_section ...
1341!> \param its ...
1342!> \param opt_energy ...
1343!> \date 02.2008
1344!> \author Teodoro Laino [tlaino] - University of Zurich
1345!> \version 1.0
1346! **************************************************************************************************
1347 SUBROUTINE geo_opt_io(force_env, root_section, motion_section, its, opt_energy)
1348
1349 TYPE(force_env_type), POINTER :: force_env
1350 TYPE(section_vals_type), POINTER :: root_section, motion_section
1351 INTEGER, INTENT(IN) :: its
1352 REAL(kind=dp), INTENT(IN) :: opt_energy
1353
1354 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
1355 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1356 TYPE(cell_type), POINTER :: cell
1357 TYPE(cp_subsys_type), POINTER :: subsys
1358 TYPE(distribution_1d_type), POINTER :: local_particles
1359 TYPE(mp_para_env_type), POINTER :: para_env
1360 TYPE(particle_list_type), POINTER :: particles
1361 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1362 TYPE(virial_type), POINTER :: virial
1363
1364 NULLIFY (para_env, atomic_kind_set, subsys, particle_set, &
1365 local_particles, atomic_kinds, particles)
1366
1367 ! Write Restart File
1368 CALL write_restart(force_env=force_env, root_section=root_section)
1369
1370 ! Write Trajectory
1371 CALL write_geo_traj(force_env, root_section, its, opt_energy)
1372
1373 ! Write the stress Tensor
1374 CALL force_env_get(force_env, cell=cell, para_env=para_env, &
1375 subsys=subsys)
1376 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1377 particles=particles, virial=virial)
1378 atomic_kind_set => atomic_kinds%els
1379 particle_set => particles%els
1380 CALL virial_evaluate(atomic_kind_set, particle_set, local_particles, &
1381 virial, para_env)
1382 CALL write_stress_tensor_to_file(virial, cell, motion_section, its, 0.0_dp)
1383
1384 ! Write the cell
1385 CALL write_simulation_cell(cell, motion_section, its, 0.0_dp)
1386
1387 END SUBROUTINE geo_opt_io
1388
1389! **************************************************************************************************
1390!> \brief Apply coordinate transformations after cell (shape) change
1391!> \param gopt_env ...
1392!> \param cell ...
1393!> \param x ...
1394!> \param update_forces ...
1395!> \date 05.11.2012 (revised version of unbiase_coordinates moved here, MK)
1396!> \author Matthias Krack
1397!> \version 1.0
1398! **************************************************************************************************
1399 SUBROUTINE apply_cell_change(gopt_env, cell, x, update_forces)
1400
1401 TYPE(gopt_f_type), POINTER :: gopt_env
1402 TYPE(cell_type), POINTER :: cell
1403 REAL(kind=dp), DIMENSION(:), POINTER :: x
1404 LOGICAL, INTENT(IN) :: update_forces
1405
1406 INTEGER :: i, iatom, idg, j, natom, nparticle, &
1407 shell_index
1408 REAL(kind=dp) :: fc, fs, mass
1409 REAL(kind=dp), DIMENSION(3) :: s
1410 TYPE(cell_type), POINTER :: cell_ref
1411 TYPE(cp_subsys_type), POINTER :: subsys
1412 TYPE(particle_list_type), POINTER :: core_particles, particles, &
1413 shell_particles
1414
1415 NULLIFY (cell_ref)
1416 NULLIFY (core_particles)
1417 NULLIFY (particles)
1418 NULLIFY (shell_particles)
1419 NULLIFY (subsys)
1420
1421 natom = force_env_get_natom(gopt_env%force_env)
1422 nparticle = force_env_get_nparticle(gopt_env%force_env)
1423 CALL force_env_get(gopt_env%force_env, &
1424 subsys=subsys)
1425 CALL cp_subsys_get(subsys=subsys, &
1426 core_particles=core_particles, &
1427 particles=particles, &
1428 shell_particles=shell_particles)
1429
1430 ! Retrieve the reference cell
1431 CALL cell_create(cell_ref)
1432 CALL cell_copy(cell, cell_ref, tag="CELL_OPT_REF")
1433
1434 ! Load the updated cell information
1435 idg = 3*nparticle
1436 CALL init_cell(cell_ref, hmat=gopt_env%h_ref)
1437 cpassert((SIZE(x) == idg + 6))
1438
1439 IF (update_forces) THEN
1440
1441 ! Transform particle forces back to reference cell
1442 idg = 1
1443 DO iatom = 1, natom
1444 CALL real_to_scaled(s, x(idg:idg + 2), cell)
1445 CALL scaled_to_real(x(idg:idg + 2), s, cell_ref)
1446 idg = idg + 3
1447 END DO
1448
1449 ELSE
1450
1451 ! Update the six independent components in the canonical optimization frame.
1452 gopt_env%cell_env%opt_cell%hmat = 0.0_dp
1453 DO i = 1, 3
1454 DO j = 1, i
1455 idg = idg + 1
1456 gopt_env%cell_env%opt_cell%hmat(j, i) = x(idg)
1457 END DO
1458 END DO
1459 CALL init_cell(gopt_env%cell_env%opt_cell)
1460 IF (gopt_env%spgr%keep_space_group) THEN
1461 CALL spgr_project_cell_metric(gopt_env%spgr, gopt_env%cell_env%opt_cell)
1462 ! Keep the optimizer variables synchronized with the projected cell.
1463 idg = 3*nparticle
1464 DO i = 1, 3
1465 DO j = 1, i
1466 idg = idg + 1
1467 x(idg) = gopt_env%cell_env%opt_cell%hmat(j, i)
1468 END DO
1469 END DO
1470 END IF
1471
1472 ! Reconstruct the physical cell in the fixed orientation of the input cell.
1473 cell%hmat = matmul(gopt_env%cell_env%opt_to_input, &
1474 gopt_env%cell_env%opt_cell%hmat)
1475 CALL init_cell(cell)
1476 CALL cp_subsys_set(subsys, cell=cell)
1477
1478 ! Retrieve particle coordinates for the current cell
1479 idg = 1
1480 DO iatom = 1, natom
1481 CALL real_to_scaled(s, x(idg:idg + 2), cell_ref)
1482 shell_index = particles%els(iatom)%shell_index
1483 IF (shell_index == 0) THEN
1484 CALL scaled_to_real(particles%els(iatom)%r, s, cell)
1485 ELSE
1486 CALL scaled_to_real(core_particles%els(shell_index)%r, s, cell)
1487 i = 3*(natom + shell_index - 1) + 1
1488 CALL real_to_scaled(s, x(i:i + 2), cell_ref)
1489 CALL scaled_to_real(shell_particles%els(shell_index)%r, s, cell)
1490 ! Update atomic position due to core and shell motion
1491 mass = particles%els(iatom)%atomic_kind%mass
1492 fc = core_particles%els(shell_index)%atomic_kind%shell%mass_core/mass
1493 fs = shell_particles%els(shell_index)%atomic_kind%shell%mass_shell/mass
1494 particles%els(iatom)%r(1:3) = fc*core_particles%els(shell_index)%r(1:3) + &
1495 fs*shell_particles%els(shell_index)%r(1:3)
1496 END IF
1497 idg = idg + 3
1498 END DO
1499 END IF
1500
1501 CALL cell_release(cell_ref)
1502
1503 END SUBROUTINE apply_cell_change
1504
1505END MODULE gopt_f_methods
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.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public henkelman1999
Handles all functions related to the CELL.
subroutine, public write_cell(cell, subsys_section, tag)
Write the cell parameters to the output unit.
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
contains a functional that calculates the energy and its derivatives for the geometry optimizer
subroutine, public rescale_new_cell_volume(vol, x, idg)
Rescale x(idg+1:idg+6) according to vol.
subroutine, public get_dg_dh(gradient, av_ptens, pres_ext, cell, mtrx, keep_angles, keep_symmetry, pres_int, pres_constr, constraint_id)
Computes the derivatives for the cell.
pure character(len=default_string_length) function, public cell_opt_constraint_label(mask)
Returns the label of the consolidated cell constraint mask.
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
Definition cell_types.F:661
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
Definition cell_types.F:631
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:704
subroutine, public cell_copy(cell_in, cell_out, tag)
Copy cell variable.
Definition cell_types.F:161
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 unpack_subsys_particles(subsys, f, r, s, v, fscale, cell)
Unpack components of a subsystem particle sets into a single vector.
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.
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition cp_units.F:1311
Contains types used for a Dimer Method calculations.
recursive subroutine, public cp_eval_at_ts(gopt_env, x, f, gradient, calc_force)
Computes the dimer energy/gradients (including the rotation of the dimer).
Contains types used for a Dimer Method calculations.
Definition dimer_types.F:14
Contains utilities for a Dimer Method calculations.
Definition dimer_utils.F:14
subroutine, public update_dimer_vec(dimer_env, motion_section)
Updates the orientation of the dimer vector in the input file.
Definition dimer_utils.F:74
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
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.
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 cp_eval_at(gopt_env, x, f, gradient, master, para_env)
evaluete the potential energy and its gradients using an array with same dimension as the particle_se...
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
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public default_shellcore_method_id
integer, parameter, public default_cell_method_id
integer, parameter, public default_minimization_method_id
integer, parameter, public default_ts_method_id
integer, parameter, public fix_none
Set of routines to dump the restart file of CP2K.
subroutine, public write_restart(md_env, force_env, root_section, coords, vels, pint_env, helium_env)
checks if a restart needs to be written and does so, updating all necessary fields in the input file....
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:127
prints all energy info per timestep to the screen or to user defined output files
Definition md_energies.F:16
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.
Definition qmmm_util.F:375
Routines used for force-mixing QM/MM calculations.
Definition qmmmx_util.F:14
subroutine, public apply_qmmmx_translate(qmmmx_env)
Apply translation to the full system in order to center the QM system into the QM box.
Definition qmmmx_util.F:75
Space Group Symmetry Type Module (version 1.0, Ferbruary 12, 2021).
Space Group Symmetry Module (version 1.0, January 16, 2020).
subroutine, public spgr_apply_rotations_stress(spgr, cell, stress)
routine applies the rotation matrices to the stress tensor.
subroutine, public spgr_project_cell_metric(spgr, cell)
Project a cell onto the metric preserved by the selected space-group rotations.
subroutine, public spgr_apply_rotations_force(spgr, force)
routine applies the rotation matrices to the forces.
subroutine, public spgr_write_stress_tensor(stress, spgr)
Variable precision output of the symmetrized stress tensor.
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).
subroutine, public virial_update(virial, subsys, para_env)
Updates the virial given the virial and subsys.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
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