52#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'motion_utils'
81 SUBROUTINE rot_ana(particles, mat, dof, print_section, keep_rotations, mass_weighted, &
82 natoms, rot_dof, inertia)
84 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: mat
85 INTEGER,
INTENT(OUT) :: dof
87 LOGICAL,
INTENT(IN) :: keep_rotations, mass_weighted
88 INTEGER,
INTENT(IN) :: natoms
89 INTEGER,
INTENT(OUT),
OPTIONAL :: rot_dof
90 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: inertia(3)
92 CHARACTER(len=*),
PARAMETER :: routinen =
'rot_ana'
94 INTEGER :: handle, i, iparticle, iseq, iw, j, k, &
96 LOGICAL :: present_mat
97 REAL(kind=
dp) :: cp(3), ip(3, 3), ip_eigval(3), mass, &
98 masst, norm, rcom(3), rm(3)
99 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rot, tr
102 CALL timeset(routinen, handle)
104 present_mat =
PRESENT(mat)
105 cpassert(
ASSOCIATED(particles))
106 IF (present_mat)
THEN
107 cpassert(.NOT.
ASSOCIATED(mat))
109 IF (.NOT. keep_rotations)
THEN
113 DO iparticle = 1, natoms
115 IF (mass_weighted) mass = particles(iparticle)%atomic_kind%mass
116 cpassert(mass >= 0.0_dp)
118 rcom = particles(iparticle)%r*mass + rcom
120 cpassert(masst > 0.0_dp)
124 DO iparticle = 1, natoms
126 IF (mass_weighted) mass = particles(iparticle)%atomic_kind%mass
127 rm = particles(iparticle)%r - rcom
128 ip(1, 1) = ip(1, 1) + mass*(rm(2)**2 + rm(3)**2)
129 ip(2, 2) = ip(2, 2) + mass*(rm(1)**2 + rm(3)**2)
130 ip(3, 3) = ip(3, 3) + mass*(rm(1)**2 + rm(2)**2)
131 ip(1, 2) = ip(1, 2) - mass*(rm(1)*rm(2))
132 ip(1, 3) = ip(1, 3) - mass*(rm(1)*rm(3))
133 ip(2, 3) = ip(2, 3) - mass*(rm(2)*rm(3))
137 IF (
PRESENT(inertia)) inertia = ip_eigval
140 WRITE (unit=iw, fmt=
'(/,T2,A)') &
141 'ROT| Rotational analysis information'
142 WRITE (unit=iw, fmt=
'(T2,A)') &
143 'ROT| Principal axes and moments of inertia [a.u.]'
144 WRITE (unit=iw, fmt=
'(T2,A,T14,3(1X,I19))') &
146 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,ES19.11))') &
147 'ROT| Eigenvalues', ip_eigval(1:3)
148 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
150 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
152 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
156 iw =
cp_print_key_unit_nr(logger, print_section,
"ROTATIONAL_INFO/COORDINATES", extension=
".vibLog")
158 WRITE (unit=iw, fmt=
'(/,T2,A)')
'ROT| Standard molecule orientation in Angstrom'
159 DO iparticle = 1, natoms
160 WRITE (unit=iw, fmt=
'(T2,"ROT|",T20,A,T27,3(3X,F15.9))') &
161 trim(particles(iparticle)%atomic_kind%name), &
162 matmul(particles(iparticle)%r, ip)*
angstrom
168 ALLOCATE (tr(natoms*3, 3))
172 DO iparticle = 1, natoms
174 IF (mass_weighted) mass = sqrt(particles(iparticle)%atomic_kind%mass)
177 IF (j == k) tr(iseq, k) = mass
183 norm = norm2(tr(:, i))
184 tr(:, i) = tr(:, i)/norm
188 ALLOCATE (rot(natoms*3, 3))
190 IF (.NOT. keep_rotations)
THEN
191 DO iparticle = 1, natoms
193 IF (mass_weighted) mass = sqrt(particles(iparticle)%atomic_kind%mass)
194 rm = particles(iparticle)%r - rcom
195 cp(1) = rm(1)*ip(1, 1) + rm(2)*ip(2, 1) + rm(3)*ip(3, 1)
196 cp(2) = rm(1)*ip(1, 2) + rm(2)*ip(2, 2) + rm(3)*ip(3, 2)
197 cp(3) = rm(1)*ip(1, 3) + rm(2)*ip(2, 3) + rm(3)*ip(3, 3)
199 rot((iparticle - 1)*3 + 1, 1) = (cp(2)*ip(1, 3) - ip(1, 2)*cp(3))*mass
200 rot((iparticle - 1)*3 + 2, 1) = (cp(2)*ip(2, 3) - ip(2, 2)*cp(3))*mass
201 rot((iparticle - 1)*3 + 3, 1) = (cp(2)*ip(3, 3) - ip(3, 2)*cp(3))*mass
203 rot((iparticle - 1)*3 + 1, 2) = (cp(3)*ip(1, 1) - ip(1, 3)*cp(1))*mass
204 rot((iparticle - 1)*3 + 2, 2) = (cp(3)*ip(2, 1) - ip(2, 3)*cp(1))*mass
205 rot((iparticle - 1)*3 + 3, 2) = (cp(3)*ip(3, 1) - ip(3, 3)*cp(1))*mass
207 rot((iparticle - 1)*3 + 1, 3) = (cp(1)*ip(1, 2) - ip(1, 1)*cp(2))*mass
208 rot((iparticle - 1)*3 + 2, 3) = (cp(1)*ip(2, 2) - ip(2, 1)*cp(2))*mass
209 rot((iparticle - 1)*3 + 3, 3) = (cp(1)*ip(3, 2) - ip(3, 1)*cp(2))*mass
215 norm = dot_product(rot(:, i), rot(:, i))
220 rot(:, i) = rot(:, i)/sqrt(norm)
224 rot(:, i + 1) = rot(:, i + 1) - dot_product(rot(:, i + 1), rot(:, j))*rot(:, j)
229 IF (
PRESENT(rot_dof)) rot_dof = count(lrot == 1)
230 dof = dof + count(lrot == 1)
233 WRITE (iw,
'(T2,A,T71,I10)')
'ROT| Number of rotovibrational vectors', dof
235 WRITE (iw,
'(T2,A)') &
236 'ROT| Linear molecule detected'
238 IF ((dof == 3) .AND. (.NOT. keep_rotations))
THEN
239 WRITE (iw,
'(T2,A)') &
240 'ROT| Single atom detected'
244 IF (present_mat)
THEN
246 ALLOCATE (mat(natoms*3, dof))
250 IF (lrot(i) == 1)
THEN
252 mat(:, 3 + iseq) = rot(:, i)
258 CALL timestop(handle)
281 pos, act, middle_name, particles, extended_xmol_title)
284 INTEGER,
INTENT(IN) :: it
285 REAL(kind=
dp),
INTENT(IN) :: time, dtime, etot
286 CHARACTER(LEN=*),
OPTIONAL :: pk_name
287 CHARACTER(LEN=default_string_length),
OPTIONAL :: pos, act
288 CHARACTER(LEN=*),
OPTIONAL :: middle_name
290 LOGICAL,
INTENT(IN),
OPTIONAL :: extended_xmol_title
292 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_trajectory'
294 CHARACTER(LEN=1024) :: cell_str, title
295 CHARACTER(LEN=4) :: id_dcd
296 CHARACTER(LEN=5) :: pbc_str
297 CHARACTER(LEN=80),
DIMENSION(2) :: remark
298 CHARACTER(LEN=default_string_length) :: etot_str, id_extxyz, id_label, id_wpc, my_act, &
299 my_ext, my_form, my_middle, my_pk_name, my_pos, section_ref, step_str, time_str, unit_str
300 CHARACTER(LEN=timestamp_length) :: timestamp
301 INTEGER :: handle, i, ii, iskip, nat, outformat, &
303 INTEGER,
POINTER :: force_mixing_indices(:), &
304 force_mixing_labels(:)
305 LOGICAL :: charge_beta, charge_extended, &
306 charge_occup, explicit, &
307 my_extended_xmol_title, new_file, &
309 REAL(
dp),
ALLOCATABLE :: fml_array(:)
310 REAL(kind=
dp) :: unit_conv
317 force_mixing_restart_section
319 CALL timeset(routinen, handle)
321 NULLIFY (logger, cell, subsys, my_particles, particle_set)
323 id_label = logger%iter_info%level_name(logger%iter_info%n_rlevel)
327 my_pk_name =
"TRAJECTORY"
328 IF (
PRESENT(middle_name)) my_middle = middle_name
329 IF (
PRESENT(pos)) my_pos = pos
330 IF (
PRESENT(act)) my_act = act
331 IF (
PRESENT(pk_name)) my_pk_name = pk_name
333 SELECT CASE (trim(my_pk_name))
334 CASE (
"TRAJECTORY",
"SHELL_TRAJECTORY",
"CORE_TRAJECTORY")
338 CASE (
"VELOCITIES",
"SHELL_VELOCITIES",
"CORE_VELOCITIES")
342 CASE (
"FORCES",
"SHELL_FORCES",
"CORE_FORCES")
346 CASE (
"FORCE_MIXING_LABELS")
348 id_wpc =
"FORCE_MIXING_LABELS"
349 id_extxyz =
"force_mixing_label"
351 CALL cp_abort(__location__, &
352 "<TRAJECTORY>, <VELOCITIES>, <FORCES>, "// &
353 "<FORCE_MIXING_LABELS> are supported as "// &
354 "the <my_pk_name> for write_trajectory, "// &
355 "found unknown option "// &
356 "<"//trim(my_pk_name)//
">")
359 charge_occup = .false.
360 charge_beta = .false.
361 charge_extended = .false.
365 IF (
PRESENT(particles))
THEN
366 cpassert(
ASSOCIATED(particles))
367 my_particles => particles
371 particle_set => my_particles%els
372 nat = my_particles%n_els
374 IF (cell%perd(1) == 1) pbc_str(1:1) =
"T"
375 IF (cell%perd(2) == 1) pbc_str(3:3) =
"T"
376 IF (cell%perd(3) == 1) pbc_str(5:5) =
"T"
379 IF (trim(my_pk_name) /=
"FORCE_MIXING_LABELS")
THEN
386 CALL get_output_format(root_section,
"MOTION%PRINT%"//trim(my_pk_name), my_form, my_ext)
388 extension=my_ext, file_position=my_pos, file_action=my_act, &
389 file_form=my_form, middle_name=trim(my_middle), is_new_file=new_file)
390 IF (traj_unit > 0)
THEN
394 SELECT CASE (outformat)
398 section_ref =
"MOTION%PRINT%"//trim(my_pk_name)//
"%EACH%"//trim(id_label)
403 WRITE (unit=traj_unit) id_dcd, 0, it, iskip, 0, 0, 0, 0, 0, 0, real(dtime, kind=
sp), &
404 1, 0, 0, 0, 0, 0, 0, 0, 0, 24
405 remark(1) =
"REMARK "//id_dcd//
" DCD file created by "//trim(
cp2k_version(:i))// &
408 WRITE (unit=traj_unit)
SIZE(remark), remark(:)
409 WRITE (unit=traj_unit) nat
413 my_extended_xmol_title = .false.
416 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
418 IF (my_extended_xmol_title)
THEN
419 WRITE (unit=title, fmt=
"(A,I8,A,F12.3,A,F20.10)") &
420 " i = ", it,
", time = ", time,
", E = ", etot
422 WRITE (unit=title, fmt=
"(A,I8,A,F20.10)")
" i = ", it,
", E = ", etot
425 CALL section_vals_val_get(root_section,
"MOTION%PRINT%TRAJECTORY%PRINT_ATOM_KIND", l_val=print_kind)
426 WRITE (unit=cell_str, fmt=
"(9(1X,F19.10))") cell%hmat(:, 1)*
angstrom, cell%hmat(:, 2)*
angstrom, cell%hmat(:, 3)*
angstrom
427 WRITE (unit=step_str, fmt=
"(I8)") it
428 WRITE (unit=time_str, fmt=
"(F12.3)") time
429 WRITE (unit=etot_str, fmt=
"(F20.10)") etot
430 WRITE (unit=title, fmt=
"(A)") &
431 'Lattice="'//trim(adjustl(cell_str))//
'"'// &
432 ' Properties=species:S:1:'//trim(id_extxyz)//
':R:3'// &
433 ' pbc="'//pbc_str//
'"'// &
434 ' Step='//trim(adjustl(step_str))// &
435 ' Time='//trim(adjustl(time_str))// &
436 ' Energy='//trim(adjustl(etot_str))
440 IF (id_wpc ==
"POS")
THEN
446 l_val=charge_extended)
447 i = count([charge_occup, charge_beta, charge_extended])
449 cpabort(
"Either only CHARGE_OCCUP, CHARGE_BETA, or CHARGE_EXTENDED can be selected, ")
458 WRITE (unit=traj_unit, fmt=
"(A6,T11,A)") &
462 my_extended_xmol_title = .false.
463 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
464 IF (my_extended_xmol_title)
THEN
465 WRITE (unit=title, fmt=
"(A,I0,A,F0.3,A,F0.10)") &
466 "Step ", it,
", time = ", time,
", E = ", etot
468 WRITE (unit=title, fmt=
"(A,I0,A,F0.10)") &
469 "Step ", it,
", E = ", etot
472 cpabort(
"Unknown output format")
474 IF (trim(my_pk_name) ==
"FORCE_MIXING_LABELS")
THEN
475 ALLOCATE (fml_array(3*
SIZE(particle_set)))
477 CALL force_env_get(force_env, force_env_section=force_env_section)
479 "QMMM%FORCE_MIXING%RESTART_INFO", &
480 can_return_null=.true.)
481 IF (
ASSOCIATED(force_mixing_restart_section))
THEN
486 DO i = 1,
SIZE(force_mixing_indices)
487 ii = force_mixing_indices(i)
488 cpassert(ii <=
SIZE(particle_set))
489 fml_array((ii - 1)*3 + 1:(ii - 1)*3 + 3) = force_mixing_labels(i)
494 array=fml_array, print_kind=print_kind)
495 DEALLOCATE (fml_array)
498 unit_conv=unit_conv, print_kind=print_kind, &
499 charge_occup=charge_occup, &
500 charge_beta=charge_beta, &
501 charge_extended=charge_extended)
507 CALL timestop(handle)
522 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: path
523 CHARACTER(LEN=*),
INTENT(OUT) :: my_form, my_ext
525 INTEGER :: output_format
527 IF (
PRESENT(path))
THEN
533 SELECT CASE (output_format)
535 my_form =
"UNFORMATTED"
538 my_form =
"FORMATTED"
541 my_form =
"FORMATTED"
565 INTEGER,
INTENT(IN) :: itimes
566 REAL(kind=
dp),
INTENT(IN) :: time
567 CHARACTER(LEN=default_string_length),
INTENT(IN), &
570 CHARACTER(LEN=default_string_length) :: my_act, my_pos
571 INTEGER :: output_unit
573 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_total_bar
579 IF (virial%pv_availability)
THEN
582 IF (
PRESENT(pos)) my_pos = pos
583 IF (
PRESENT(act)) my_act = act
585 extension=
".stress", file_position=my_pos, &
586 file_action=my_act, file_form=
"FORMATTED", &
587 is_new_file=new_file)
592 IF (output_unit > 0)
THEN
594 WRITE (unit=output_unit, fmt=
'(A,9(12X,A2," [bar]"),6X,A)') &
595 "# Step Time [fs]",
"xx",
"xy",
"xz",
"yx",
"yy",
"yz",
"zx",
"zy",
"zz"
606 WRITE (unit=output_unit, fmt=
'(I8,F12.3,9(1X,F19.10))') itimes, time, &
607 pv_total_bar(1, 1), pv_total_bar(1, 2), pv_total_bar(1, 3), &
608 pv_total_bar(2, 1), pv_total_bar(2, 2), pv_total_bar(2, 3), &
609 pv_total_bar(3, 1), pv_total_bar(3, 2), pv_total_bar(3, 3)
613 IF (virial%pv_availability)
THEN
636 INTEGER,
INTENT(IN) :: itimes
637 REAL(kind=
dp),
INTENT(IN) :: time
638 CHARACTER(LEN=default_string_length),
INTENT(IN), &
641 CHARACTER(LEN=default_string_length) :: my_act, my_pos
642 INTEGER :: output_unit
651 IF (
PRESENT(pos)) my_pos = pos
652 IF (
PRESENT(act)) my_act = act
655 extension=
".cell", file_position=my_pos, &
656 file_action=my_act, file_form=
"FORMATTED", &
657 is_new_file=new_file)
659 IF (output_unit > 0)
THEN
661 WRITE (unit=output_unit, fmt=
'(A,9(7X,A2," [Angstrom]"),6X,A)') &
662 "# Step Time [fs]",
"Ax",
"Ay",
"Az",
"Bx",
"By",
"Bz",
"Cx",
"Cy",
"Cz", &
663 "Volume [Angstrom^3]"
665 WRITE (unit=output_unit, fmt=
"(I8,F12.3,9(1X,F19.10),1X,F24.10)") itimes, time, &
Handles all functions related to the CELL.
some minimal info about CP2K, including its version and license
character(len=default_string_length), public r_host_name
character(len= *), parameter, public compile_revision
character(len= *), parameter, public cp2k_version
character(len=default_string_length), public r_user_name
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Interface for the force calculations.
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
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public sp
Machine interface based on Fortran 2003 and POSIX.
integer, parameter, public timestamp_length
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
subroutine, public m_timestamp(timestamp)
Returns a human readable timestamp.
Collection of simple mathematical functions and subroutines.
subroutine, public diamat_all(a, eigval, dac)
Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix...
Output Utilities for MOTION_SECTION.
real(kind=dp), parameter, public thrs_motion
subroutine, public get_output_format(section, path, my_form, my_ext)
Info on the unit to be opened to dump MD informations.
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 rot_ana(particles, mat, dof, print_section, keep_rotations, mass_weighted, natoms, rot_dof, inertia)
Performs an analysis of the principal inertia axis Getting back the generators of the translating and...
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_particle_coordinates(particle_set, iunit, output_format, content, title, cell, array, unit_conv, charge_occup, charge_beta, charge_extended, print_kind)
Should be able to write a few formats e.g. xmol, and some binary format (dcd) some format can be used...
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public angstrom
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
wrapper to abstract the force evaluation of the various methods
represent a list of objects