51#include "./base/base_uses.f90"
60 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'motion_utils'
80 SUBROUTINE rot_ana(particles, mat, dof, print_section, keep_rotations, mass_weighted, &
81 natoms, rot_dof, inertia)
83 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: mat
84 INTEGER,
INTENT(OUT) :: dof
86 LOGICAL,
INTENT(IN) :: keep_rotations, mass_weighted
87 INTEGER,
INTENT(IN) :: natoms
88 INTEGER,
INTENT(OUT),
OPTIONAL :: rot_dof
89 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: inertia(3)
91 CHARACTER(len=*),
PARAMETER :: routinen =
'rot_ana'
93 INTEGER :: handle, i, iparticle, iseq, iw, j, k, &
95 LOGICAL :: present_mat
96 REAL(kind=
dp) :: cp(3), ip(3, 3), ip_eigval(3), mass, &
97 masst, norm, rcom(3), rm(3)
98 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rot, tr
101 CALL timeset(routinen, handle)
103 present_mat =
PRESENT(mat)
104 cpassert(
ASSOCIATED(particles))
105 IF (present_mat)
THEN
106 cpassert(.NOT.
ASSOCIATED(mat))
108 IF (.NOT. keep_rotations)
THEN
112 DO iparticle = 1, natoms
114 IF (mass_weighted) mass = particles(iparticle)%atomic_kind%mass
115 cpassert(mass >= 0.0_dp)
117 rcom = particles(iparticle)%r*mass + rcom
119 cpassert(masst > 0.0_dp)
123 DO iparticle = 1, natoms
125 IF (mass_weighted) mass = particles(iparticle)%atomic_kind%mass
126 rm = particles(iparticle)%r - rcom
127 ip(1, 1) = ip(1, 1) + mass*(rm(2)**2 + rm(3)**2)
128 ip(2, 2) = ip(2, 2) + mass*(rm(1)**2 + rm(3)**2)
129 ip(3, 3) = ip(3, 3) + mass*(rm(1)**2 + rm(2)**2)
130 ip(1, 2) = ip(1, 2) - mass*(rm(1)*rm(2))
131 ip(1, 3) = ip(1, 3) - mass*(rm(1)*rm(3))
132 ip(2, 3) = ip(2, 3) - mass*(rm(2)*rm(3))
136 IF (
PRESENT(inertia)) inertia = ip_eigval
139 WRITE (unit=iw, fmt=
'(/,T2,A)') &
140 'ROT| Rotational analysis information'
141 WRITE (unit=iw, fmt=
'(T2,A)') &
142 'ROT| Principal axes and moments of inertia [a.u.]'
143 WRITE (unit=iw, fmt=
'(T2,A,T14,3(1X,I19))') &
145 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,ES19.11))') &
146 'ROT| Eigenvalues', ip_eigval(1:3)
147 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
149 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
151 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
155 iw =
cp_print_key_unit_nr(logger, print_section,
"ROTATIONAL_INFO/COORDINATES", extension=
".vibLog")
157 WRITE (unit=iw, fmt=
'(/,T2,A)')
'ROT| Standard molecule orientation in Angstrom'
158 DO iparticle = 1, natoms
159 WRITE (unit=iw, fmt=
'(T2,"ROT|",T20,A,T27,3(3X,F15.9))') &
160 trim(particles(iparticle)%atomic_kind%name), &
161 matmul(particles(iparticle)%r, ip)*
angstrom
167 ALLOCATE (tr(natoms*3, 3))
171 DO iparticle = 1, natoms
173 IF (mass_weighted) mass = sqrt(particles(iparticle)%atomic_kind%mass)
176 IF (j == k) tr(iseq, k) = mass
182 norm = sqrt(dot_product(tr(:, i), tr(:, i)))
183 tr(:, i) = tr(:, i)/norm
187 ALLOCATE (rot(natoms*3, 3))
189 IF (.NOT. keep_rotations)
THEN
190 DO iparticle = 1, natoms
192 IF (mass_weighted) mass = sqrt(particles(iparticle)%atomic_kind%mass)
193 rm = particles(iparticle)%r - rcom
194 cp(1) = rm(1)*ip(1, 1) + rm(2)*ip(2, 1) + rm(3)*ip(3, 1)
195 cp(2) = rm(1)*ip(1, 2) + rm(2)*ip(2, 2) + rm(3)*ip(3, 2)
196 cp(3) = rm(1)*ip(1, 3) + rm(2)*ip(2, 3) + rm(3)*ip(3, 3)
198 rot((iparticle - 1)*3 + 1, 1) = (cp(2)*ip(1, 3) - ip(1, 2)*cp(3))*mass
199 rot((iparticle - 1)*3 + 2, 1) = (cp(2)*ip(2, 3) - ip(2, 2)*cp(3))*mass
200 rot((iparticle - 1)*3 + 3, 1) = (cp(2)*ip(3, 3) - ip(3, 2)*cp(3))*mass
202 rot((iparticle - 1)*3 + 1, 2) = (cp(3)*ip(1, 1) - ip(1, 3)*cp(1))*mass
203 rot((iparticle - 1)*3 + 2, 2) = (cp(3)*ip(2, 1) - ip(2, 3)*cp(1))*mass
204 rot((iparticle - 1)*3 + 3, 2) = (cp(3)*ip(3, 1) - ip(3, 3)*cp(1))*mass
206 rot((iparticle - 1)*3 + 1, 3) = (cp(1)*ip(1, 2) - ip(1, 1)*cp(2))*mass
207 rot((iparticle - 1)*3 + 2, 3) = (cp(1)*ip(2, 2) - ip(2, 1)*cp(2))*mass
208 rot((iparticle - 1)*3 + 3, 3) = (cp(1)*ip(3, 2) - ip(3, 1)*cp(2))*mass
214 norm = dot_product(rot(:, i), rot(:, i))
219 rot(:, i) = rot(:, i)/sqrt(norm)
223 rot(:, i + 1) = rot(:, i + 1) - dot_product(rot(:, i + 1), rot(:, j))*rot(:, j)
228 IF (
PRESENT(rot_dof)) rot_dof = count(lrot == 1)
229 dof = dof + count(lrot == 1)
232 WRITE (iw,
'(T2,A,T71,I10)')
'ROT| Number of rotovibrational vectors', dof
234 WRITE (iw,
'(T2,A)') &
235 'ROT| Linear molecule detected'
237 IF ((dof == 3) .AND. (.NOT. keep_rotations))
THEN
238 WRITE (iw,
'(T2,A)') &
239 'ROT| Single atom detected'
243 IF (present_mat)
THEN
245 ALLOCATE (mat(natoms*3, dof))
249 IF (lrot(i) == 1)
THEN
251 mat(:, 3 + iseq) = rot(:, i)
257 CALL timestop(handle)
280 pos, act, middle_name, particles, extended_xmol_title)
283 INTEGER,
INTENT(IN) :: it
284 REAL(kind=
dp),
INTENT(IN) :: time, dtime, etot
285 CHARACTER(LEN=*),
OPTIONAL :: pk_name
286 CHARACTER(LEN=default_string_length),
OPTIONAL :: pos, act
287 CHARACTER(LEN=*),
OPTIONAL :: middle_name
289 LOGICAL,
INTENT(IN),
OPTIONAL :: extended_xmol_title
291 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_trajectory'
293 CHARACTER(LEN=4) :: id_dcd
294 CHARACTER(LEN=80),
DIMENSION(2) :: remark
295 CHARACTER(LEN=default_string_length) :: id_label, id_wpc, my_act, my_ext, &
296 my_form, my_middle, my_pk_name, &
297 my_pos, section_ref, title, unit_str
298 CHARACTER(LEN=timestamp_length) :: timestamp
299 INTEGER :: handle, i, ii, iskip, nat, outformat, &
301 INTEGER,
POINTER :: force_mixing_indices(:), &
302 force_mixing_labels(:)
303 LOGICAL :: charge_beta, charge_extended, &
304 charge_occup, explicit, &
305 my_extended_xmol_title, new_file, &
307 REAL(
dp),
ALLOCATABLE :: fml_array(:)
308 REAL(kind=
dp) :: unit_conv
315 force_mixing_restart_section
317 CALL timeset(routinen, handle)
319 NULLIFY (logger, cell, subsys, my_particles, particle_set)
321 id_label = logger%iter_info%level_name(logger%iter_info%n_rlevel)
325 my_pk_name =
"TRAJECTORY"
326 IF (
PRESENT(middle_name)) my_middle = middle_name
327 IF (
PRESENT(pos)) my_pos = pos
328 IF (
PRESENT(act)) my_act = act
329 IF (
PRESENT(pk_name)) my_pk_name = pk_name
331 SELECT CASE (trim(my_pk_name))
332 CASE (
"TRAJECTORY",
"SHELL_TRAJECTORY",
"CORE_TRAJECTORY")
335 CASE (
"VELOCITIES",
"SHELL_VELOCITIES",
"CORE_VELOCITIES")
338 CASE (
"FORCES",
"SHELL_FORCES",
"CORE_FORCES")
341 CASE (
"FORCE_MIXING_LABELS")
343 id_wpc =
"FORCE_MIXING_LABELS"
348 charge_occup = .false.
349 charge_beta = .false.
350 charge_extended = .false.
354 IF (
PRESENT(particles))
THEN
355 cpassert(
ASSOCIATED(particles))
356 my_particles => particles
360 particle_set => my_particles%els
361 nat = my_particles%n_els
364 IF (trim(my_pk_name) /=
"FORCE_MIXING_LABELS")
THEN
371 CALL get_output_format(root_section,
"MOTION%PRINT%"//trim(my_pk_name), my_form, my_ext)
373 extension=my_ext, file_position=my_pos, file_action=my_act, &
374 file_form=my_form, middle_name=trim(my_middle), is_new_file=new_file)
375 IF (traj_unit > 0)
THEN
379 SELECT CASE (outformat)
383 section_ref =
"MOTION%PRINT%"//trim(my_pk_name)//
"%EACH%"//trim(id_label)
388 WRITE (unit=traj_unit) id_dcd, 0, it, iskip, 0, 0, 0, 0, 0, 0, real(dtime, kind=
sp), &
389 1, 0, 0, 0, 0, 0, 0, 0, 0, 24
390 remark(1) =
"REMARK "//id_dcd//
" DCD file created by "//trim(
cp2k_version(:i))// &
393 WRITE (unit=traj_unit)
SIZE(remark), remark(:)
394 WRITE (unit=traj_unit) nat
398 my_extended_xmol_title = .false.
401 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
403 IF (my_extended_xmol_title)
THEN
404 WRITE (unit=title, fmt=
"(A,I8,A,F12.3,A,F20.10)") &
405 " i = ", it,
", time = ", time,
", E = ", etot
407 WRITE (unit=title, fmt=
"(A,I8,A,F20.10)")
" i = ", it,
", E = ", etot
412 IF (id_wpc ==
"POS")
THEN
418 l_val=charge_extended)
419 i = count((/charge_occup, charge_beta, charge_extended/))
421 cpabort(
"Either only CHARGE_OCCUP, CHARGE_BETA, or CHARGE_EXTENDED can be selected, ")
429 WRITE (unit=traj_unit, fmt=
"(A6,T11,A)") &
433 my_extended_xmol_title = .false.
434 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
435 IF (my_extended_xmol_title)
THEN
436 WRITE (unit=title, fmt=
"(A,I0,A,F0.3,A,F0.10)") &
437 "Step ", it,
", time = ", time,
", E = ", etot
439 WRITE (unit=title, fmt=
"(A,I0,A,F0.10)") &
440 "Step ", it,
", E = ", etot
445 IF (trim(my_pk_name) ==
"FORCE_MIXING_LABELS")
THEN
446 ALLOCATE (fml_array(3*
SIZE(particle_set)))
448 CALL force_env_get(force_env, force_env_section=force_env_section)
450 "QMMM%FORCE_MIXING%RESTART_INFO", &
451 can_return_null=.true.)
452 IF (
ASSOCIATED(force_mixing_restart_section))
THEN
457 DO i = 1,
SIZE(force_mixing_indices)
458 ii = force_mixing_indices(i)
459 cpassert(ii <=
SIZE(particle_set))
460 fml_array((ii - 1)*3 + 1:(ii - 1)*3 + 3) = force_mixing_labels(i)
465 array=fml_array, print_kind=print_kind)
466 DEALLOCATE (fml_array)
469 unit_conv=unit_conv, print_kind=print_kind, &
470 charge_occup=charge_occup, &
471 charge_beta=charge_beta, &
472 charge_extended=charge_extended)
478 CALL timestop(handle)
493 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: path
494 CHARACTER(LEN=*),
INTENT(OUT) :: my_form, my_ext
496 INTEGER :: output_format
498 IF (
PRESENT(path))
THEN
504 SELECT CASE (output_format)
506 my_form =
"UNFORMATTED"
509 my_form =
"FORMATTED"
512 my_form =
"FORMATTED"
536 INTEGER,
INTENT(IN) :: itimes
537 REAL(kind=
dp),
INTENT(IN) :: time
538 CHARACTER(LEN=default_string_length),
INTENT(IN), &
541 CHARACTER(LEN=default_string_length) :: my_act, my_pos
542 INTEGER :: output_unit
544 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_total_bar
550 IF (virial%pv_availability)
THEN
553 IF (
PRESENT(pos)) my_pos = pos
554 IF (
PRESENT(act)) my_act = act
556 extension=
".stress", file_position=my_pos, &
557 file_action=my_act, file_form=
"FORMATTED", &
558 is_new_file=new_file)
563 IF (output_unit > 0)
THEN
565 WRITE (unit=output_unit, fmt=
'(A,9(12X,A2," [bar]"),6X,A)') &
566 "# Step Time [fs]",
"xx",
"xy",
"xz",
"yx",
"yy",
"yz",
"zx",
"zy",
"zz"
577 WRITE (unit=output_unit, fmt=
'(I8,F12.3,9(1X,F19.10))') itimes, time, &
578 pv_total_bar(1, 1), pv_total_bar(1, 2), pv_total_bar(1, 3), &
579 pv_total_bar(2, 1), pv_total_bar(2, 2), pv_total_bar(2, 3), &
580 pv_total_bar(3, 1), pv_total_bar(3, 2), pv_total_bar(3, 3)
584 IF (virial%pv_availability)
THEN
607 INTEGER,
INTENT(IN) :: itimes
608 REAL(kind=
dp),
INTENT(IN) :: time
609 CHARACTER(LEN=default_string_length),
INTENT(IN), &
612 CHARACTER(LEN=default_string_length) :: my_act, my_pos
613 INTEGER :: output_unit
622 IF (
PRESENT(pos)) my_pos = pos
623 IF (
PRESENT(act)) my_act = act
626 extension=
".cell", file_position=my_pos, &
627 file_action=my_act, file_form=
"FORMATTED", &
628 is_new_file=new_file)
630 IF (output_unit > 0)
THEN
632 WRITE (unit=output_unit, fmt=
'(A,9(7X,A2," [Angstrom]"),6X,A)') &
633 "# Step Time [fs]",
"Ax",
"Ay",
"Az",
"Bx",
"By",
"Bz",
"Cx",
"Cy",
"Cz", &
634 "Volume [Angstrom^3]"
636 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