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 = sqrt(dot_product(tr(:, i), 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=80),
DIMENSION(2) :: remark
297 CHARACTER(LEN=default_string_length) :: etot_str, id_extxyz, id_label, id_wpc, my_act, &
298 my_ext, my_form, my_middle, my_pk_name, my_pos, section_ref, step_str, time_str, unit_str
299 CHARACTER(LEN=timestamp_length) :: timestamp
300 INTEGER :: handle, i, ii, iskip, nat, outformat, &
302 INTEGER,
POINTER :: force_mixing_indices(:), &
303 force_mixing_labels(:)
304 LOGICAL :: charge_beta, charge_extended, &
305 charge_occup, explicit, &
306 my_extended_xmol_title, new_file, &
308 REAL(
dp),
ALLOCATABLE :: fml_array(:)
309 REAL(kind=
dp) :: unit_conv
316 force_mixing_restart_section
318 CALL timeset(routinen, handle)
320 NULLIFY (logger, cell, subsys, my_particles, particle_set)
322 id_label = logger%iter_info%level_name(logger%iter_info%n_rlevel)
326 my_pk_name =
"TRAJECTORY"
327 IF (
PRESENT(middle_name)) my_middle = middle_name
328 IF (
PRESENT(pos)) my_pos = pos
329 IF (
PRESENT(act)) my_act = act
330 IF (
PRESENT(pk_name)) my_pk_name = pk_name
332 SELECT CASE (trim(my_pk_name))
333 CASE (
"TRAJECTORY",
"SHELL_TRAJECTORY",
"CORE_TRAJECTORY")
337 CASE (
"VELOCITIES",
"SHELL_VELOCITIES",
"CORE_VELOCITIES")
341 CASE (
"FORCES",
"SHELL_FORCES",
"CORE_FORCES")
345 CASE (
"FORCE_MIXING_LABELS")
347 id_wpc =
"FORCE_MIXING_LABELS"
348 id_extxyz =
"force_mixing_label"
353 charge_occup = .false.
354 charge_beta = .false.
355 charge_extended = .false.
359 IF (
PRESENT(particles))
THEN
360 cpassert(
ASSOCIATED(particles))
361 my_particles => particles
365 particle_set => my_particles%els
366 nat = my_particles%n_els
369 IF (trim(my_pk_name) /=
"FORCE_MIXING_LABELS")
THEN
376 CALL get_output_format(root_section,
"MOTION%PRINT%"//trim(my_pk_name), my_form, my_ext)
378 extension=my_ext, file_position=my_pos, file_action=my_act, &
379 file_form=my_form, middle_name=trim(my_middle), is_new_file=new_file)
380 IF (traj_unit > 0)
THEN
384 SELECT CASE (outformat)
388 section_ref =
"MOTION%PRINT%"//trim(my_pk_name)//
"%EACH%"//trim(id_label)
393 WRITE (unit=traj_unit) id_dcd, 0, it, iskip, 0, 0, 0, 0, 0, 0, real(dtime, kind=
sp), &
394 1, 0, 0, 0, 0, 0, 0, 0, 0, 24
395 remark(1) =
"REMARK "//id_dcd//
" DCD file created by "//trim(
cp2k_version(:i))// &
398 WRITE (unit=traj_unit)
SIZE(remark), remark(:)
399 WRITE (unit=traj_unit) nat
403 my_extended_xmol_title = .false.
406 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
408 IF (my_extended_xmol_title)
THEN
409 WRITE (unit=title, fmt=
"(A,I8,A,F12.3,A,F20.10)") &
410 " i = ", it,
", time = ", time,
", E = ", etot
412 WRITE (unit=title, fmt=
"(A,I8,A,F20.10)")
" i = ", it,
", E = ", etot
415 CALL section_vals_val_get(root_section,
"MOTION%PRINT%TRAJECTORY%PRINT_ATOM_KIND", l_val=print_kind)
416 WRITE (unit=cell_str, fmt=
"(9(1X,F10.3))") cell%hmat(:, 1)*
angstrom, cell%hmat(:, 2)*
angstrom, cell%hmat(:, 3)*
angstrom
417 WRITE (unit=step_str, fmt=
"(I8)") it
418 WRITE (unit=time_str, fmt=
"(F12.3)") time
419 WRITE (unit=etot_str, fmt=
"(F20.10)") etot
420 WRITE (unit=title, fmt=
"(A)") &
421 'Lattice="'//trim(adjustl(cell_str))//
'"'// &
422 ' Properties="species:S:1:'//trim(id_extxyz)//
':R:3"'// &
423 ' Step='//trim(adjustl(step_str))// &
424 ' Time='//trim(adjustl(time_str))// &
425 ' Energy='//trim(adjustl(etot_str))
429 IF (id_wpc ==
"POS")
THEN
435 l_val=charge_extended)
436 i = count([charge_occup, charge_beta, charge_extended])
438 cpabort(
"Either only CHARGE_OCCUP, CHARGE_BETA, or CHARGE_EXTENDED can be selected, ")
446 WRITE (unit=traj_unit, fmt=
"(A6,T11,A)") &
450 my_extended_xmol_title = .false.
451 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
452 IF (my_extended_xmol_title)
THEN
453 WRITE (unit=title, fmt=
"(A,I0,A,F0.3,A,F0.10)") &
454 "Step ", it,
", time = ", time,
", E = ", etot
456 WRITE (unit=title, fmt=
"(A,I0,A,F0.10)") &
457 "Step ", it,
", E = ", etot
462 IF (trim(my_pk_name) ==
"FORCE_MIXING_LABELS")
THEN
463 ALLOCATE (fml_array(3*
SIZE(particle_set)))
465 CALL force_env_get(force_env, force_env_section=force_env_section)
467 "QMMM%FORCE_MIXING%RESTART_INFO", &
468 can_return_null=.true.)
469 IF (
ASSOCIATED(force_mixing_restart_section))
THEN
474 DO i = 1,
SIZE(force_mixing_indices)
475 ii = force_mixing_indices(i)
476 cpassert(ii <=
SIZE(particle_set))
477 fml_array((ii - 1)*3 + 1:(ii - 1)*3 + 3) = force_mixing_labels(i)
482 array=fml_array, print_kind=print_kind)
483 DEALLOCATE (fml_array)
486 unit_conv=unit_conv, print_kind=print_kind, &
487 charge_occup=charge_occup, &
488 charge_beta=charge_beta, &
489 charge_extended=charge_extended)
495 CALL timestop(handle)
510 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: path
511 CHARACTER(LEN=*),
INTENT(OUT) :: my_form, my_ext
513 INTEGER :: output_format
515 IF (
PRESENT(path))
THEN
521 SELECT CASE (output_format)
523 my_form =
"UNFORMATTED"
526 my_form =
"FORMATTED"
529 my_form =
"FORMATTED"
553 INTEGER,
INTENT(IN) :: itimes
554 REAL(kind=
dp),
INTENT(IN) :: time
555 CHARACTER(LEN=default_string_length),
INTENT(IN), &
558 CHARACTER(LEN=default_string_length) :: my_act, my_pos
559 INTEGER :: output_unit
561 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_total_bar
567 IF (virial%pv_availability)
THEN
570 IF (
PRESENT(pos)) my_pos = pos
571 IF (
PRESENT(act)) my_act = act
573 extension=
".stress", file_position=my_pos, &
574 file_action=my_act, file_form=
"FORMATTED", &
575 is_new_file=new_file)
580 IF (output_unit > 0)
THEN
582 WRITE (unit=output_unit, fmt=
'(A,9(12X,A2," [bar]"),6X,A)') &
583 "# Step Time [fs]",
"xx",
"xy",
"xz",
"yx",
"yy",
"yz",
"zx",
"zy",
"zz"
594 WRITE (unit=output_unit, fmt=
'(I8,F12.3,9(1X,F19.10))') itimes, time, &
595 pv_total_bar(1, 1), pv_total_bar(1, 2), pv_total_bar(1, 3), &
596 pv_total_bar(2, 1), pv_total_bar(2, 2), pv_total_bar(2, 3), &
597 pv_total_bar(3, 1), pv_total_bar(3, 2), pv_total_bar(3, 3)
601 IF (virial%pv_availability)
THEN
624 INTEGER,
INTENT(IN) :: itimes
625 REAL(kind=
dp),
INTENT(IN) :: time
626 CHARACTER(LEN=default_string_length),
INTENT(IN), &
629 CHARACTER(LEN=default_string_length) :: my_act, my_pos
630 INTEGER :: output_unit
639 IF (
PRESENT(pos)) my_pos = pos
640 IF (
PRESENT(act)) my_act = act
643 extension=
".cell", file_position=my_pos, &
644 file_action=my_act, file_form=
"FORMATTED", &
645 is_new_file=new_file)
647 IF (output_unit > 0)
THEN
649 WRITE (unit=output_unit, fmt=
'(A,9(7X,A2," [Angstrom]"),6X,A)') &
650 "# Step Time [fs]",
"Ax",
"Ay",
"Az",
"Bx",
"By",
"Bz",
"Cx",
"Cy",
"Cz", &
651 "Volume [Angstrom^3]"
653 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)
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