50#include "./base/base_uses.f90"
59 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'motion_utils'
79 SUBROUTINE rot_ana(particles, mat, dof, print_section, keep_rotations, mass_weighted, &
80 natoms, rot_dof, inertia)
82 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: mat
83 INTEGER,
INTENT(OUT) :: dof
85 LOGICAL,
INTENT(IN) :: keep_rotations, mass_weighted
86 INTEGER,
INTENT(IN) :: natoms
87 INTEGER,
INTENT(OUT),
OPTIONAL :: rot_dof
88 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: inertia(3)
90 CHARACTER(len=*),
PARAMETER :: routinen =
'rot_ana'
92 INTEGER :: handle, i, iparticle, iseq, iw, j, k, &
94 LOGICAL :: present_mat
95 REAL(kind=
dp) :: cp(3), ip(3, 3), ip_eigval(3), mass, &
96 masst, norm, rcom(3), rm(3)
97 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: rot, tr
100 CALL timeset(routinen, handle)
102 present_mat =
PRESENT(mat)
103 cpassert(
ASSOCIATED(particles))
104 IF (present_mat)
THEN
105 cpassert(.NOT.
ASSOCIATED(mat))
107 IF (.NOT. keep_rotations)
THEN
111 DO iparticle = 1, natoms
113 IF (mass_weighted) mass = particles(iparticle)%atomic_kind%mass
114 cpassert(mass >= 0.0_dp)
116 rcom = particles(iparticle)%r*mass + rcom
118 cpassert(masst > 0.0_dp)
122 DO iparticle = 1, natoms
124 IF (mass_weighted) mass = particles(iparticle)%atomic_kind%mass
125 rm = particles(iparticle)%r - rcom
126 ip(1, 1) = ip(1, 1) + mass*(rm(2)**2 + rm(3)**2)
127 ip(2, 2) = ip(2, 2) + mass*(rm(1)**2 + rm(3)**2)
128 ip(3, 3) = ip(3, 3) + mass*(rm(1)**2 + rm(2)**2)
129 ip(1, 2) = ip(1, 2) - mass*(rm(1)*rm(2))
130 ip(1, 3) = ip(1, 3) - mass*(rm(1)*rm(3))
131 ip(2, 3) = ip(2, 3) - mass*(rm(2)*rm(3))
135 IF (
PRESENT(inertia)) inertia = ip_eigval
138 WRITE (unit=iw, fmt=
'(/,T2,A)') &
139 'ROT| Rotational analysis information'
140 WRITE (unit=iw, fmt=
'(T2,A)') &
141 'ROT| Principal axes and moments of inertia [a.u.]'
142 WRITE (unit=iw, fmt=
'(T2,A,T14,3(1X,I19))') &
144 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,ES19.11))') &
145 'ROT| Eigenvalues', ip_eigval(1:3)
146 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
148 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
150 WRITE (unit=iw, fmt=
'(T2,A,T21,3(1X,F19.12))') &
154 iw =
cp_print_key_unit_nr(logger, print_section,
"ROTATIONAL_INFO/COORDINATES", extension=
".vibLog")
156 WRITE (unit=iw, fmt=
'(/,T2,A)')
'ROT| Standard molecule orientation in Angstrom'
157 DO iparticle = 1, natoms
158 WRITE (unit=iw, fmt=
'(T2,"ROT|",T20,A,T27,3(3X,F15.9))') &
159 trim(particles(iparticle)%atomic_kind%name), &
160 matmul(particles(iparticle)%r, ip)*
angstrom
166 ALLOCATE (tr(natoms*3, 3))
170 DO iparticle = 1, natoms
172 IF (mass_weighted) mass = sqrt(particles(iparticle)%atomic_kind%mass)
175 IF (j == k) tr(iseq, k) = mass
181 norm = sqrt(dot_product(tr(:, i), tr(:, i)))
182 tr(:, i) = tr(:, i)/norm
186 ALLOCATE (rot(natoms*3, 3))
188 IF (.NOT. keep_rotations)
THEN
189 DO iparticle = 1, natoms
191 IF (mass_weighted) mass = sqrt(particles(iparticle)%atomic_kind%mass)
192 rm = particles(iparticle)%r - rcom
193 cp(1) = rm(1)*ip(1, 1) + rm(2)*ip(2, 1) + rm(3)*ip(3, 1)
194 cp(2) = rm(1)*ip(1, 2) + rm(2)*ip(2, 2) + rm(3)*ip(3, 2)
195 cp(3) = rm(1)*ip(1, 3) + rm(2)*ip(2, 3) + rm(3)*ip(3, 3)
197 rot((iparticle - 1)*3 + 1, 1) = (cp(2)*ip(1, 3) - ip(1, 2)*cp(3))*mass
198 rot((iparticle - 1)*3 + 2, 1) = (cp(2)*ip(2, 3) - ip(2, 2)*cp(3))*mass
199 rot((iparticle - 1)*3 + 3, 1) = (cp(2)*ip(3, 3) - ip(3, 2)*cp(3))*mass
201 rot((iparticle - 1)*3 + 1, 2) = (cp(3)*ip(1, 1) - ip(1, 3)*cp(1))*mass
202 rot((iparticle - 1)*3 + 2, 2) = (cp(3)*ip(2, 1) - ip(2, 3)*cp(1))*mass
203 rot((iparticle - 1)*3 + 3, 2) = (cp(3)*ip(3, 1) - ip(3, 3)*cp(1))*mass
205 rot((iparticle - 1)*3 + 1, 3) = (cp(1)*ip(1, 2) - ip(1, 1)*cp(2))*mass
206 rot((iparticle - 1)*3 + 2, 3) = (cp(1)*ip(2, 2) - ip(2, 1)*cp(2))*mass
207 rot((iparticle - 1)*3 + 3, 3) = (cp(1)*ip(3, 2) - ip(3, 1)*cp(2))*mass
213 norm = sqrt(dot_product(rot(:, i), rot(:, i)))
218 rot(:, i) = rot(:, i)/norm
222 rot(:, i + 1) = rot(:, i + 1) - dot_product(rot(:, i + 1), rot(:, j))*rot(:, j)
227 IF (
PRESENT(rot_dof)) rot_dof = count(lrot == 1)
228 dof = dof + count(lrot == 1)
231 WRITE (iw,
'(T2,A,T71,I10)')
'ROT| Number of rotovibrational vectors', dof
233 WRITE (iw,
'(T2,A)') &
234 'ROT| Linear molecule detected'
236 IF ((dof == 3) .AND. (.NOT. keep_rotations))
THEN
237 WRITE (iw,
'(T2,A)') &
238 'ROT| Single atom detected'
242 IF (present_mat)
THEN
244 ALLOCATE (mat(natoms*3, dof))
248 IF (lrot(i) == 1)
THEN
250 mat(:, 3 + iseq) = rot(:, i)
256 CALL timestop(handle)
279 pos, act, middle_name, particles, extended_xmol_title)
282 INTEGER,
INTENT(IN) :: it
283 REAL(kind=
dp),
INTENT(IN) :: time, dtime, etot
284 CHARACTER(LEN=*),
OPTIONAL :: pk_name
285 CHARACTER(LEN=default_string_length),
OPTIONAL :: pos, act
286 CHARACTER(LEN=*),
OPTIONAL :: middle_name
288 LOGICAL,
INTENT(IN),
OPTIONAL :: extended_xmol_title
290 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_trajectory'
292 CHARACTER(LEN=4) :: id_dcd
293 CHARACTER(LEN=default_string_length) :: id_label, id_wpc, my_act, my_ext, &
294 my_form, my_middle, my_pk_name, &
295 my_pos, remark1, remark2, section_ref, &
297 INTEGER :: handle, i, ii, iskip, nat, outformat, &
299 INTEGER,
POINTER :: force_mixing_indices(:), &
300 force_mixing_labels(:)
301 LOGICAL :: charge_beta, charge_extended, &
302 charge_occup, explicit, &
303 my_extended_xmol_title, new_file, &
305 REAL(
dp),
ALLOCATABLE :: fml_array(:)
306 REAL(kind=
dp) :: unit_conv
313 force_mixing_restart_section
315 CALL timeset(routinen, handle)
317 NULLIFY (logger, cell, subsys, my_particles, particle_set)
319 id_label = logger%iter_info%level_name(logger%iter_info%n_rlevel)
323 my_pk_name =
"TRAJECTORY"
324 IF (
PRESENT(middle_name)) my_middle = middle_name
325 IF (
PRESENT(pos)) my_pos = pos
326 IF (
PRESENT(act)) my_act = act
327 IF (
PRESENT(pk_name)) my_pk_name = pk_name
329 SELECT CASE (trim(my_pk_name))
330 CASE (
"TRAJECTORY",
"SHELL_TRAJECTORY",
"CORE_TRAJECTORY")
333 CASE (
"VELOCITIES",
"SHELL_VELOCITIES",
"CORE_VELOCITIES")
336 CASE (
"FORCES",
"SHELL_FORCES",
"CORE_FORCES")
339 CASE (
"FORCE_MIXING_LABELS")
341 id_wpc =
"FORCE_MIXING_LABELS"
346 charge_occup = .false.
347 charge_beta = .false.
348 charge_extended = .false.
352 IF (
PRESENT(particles))
THEN
353 cpassert(
ASSOCIATED(particles))
354 my_particles => particles
358 particle_set => my_particles%els
359 nat = my_particles%n_els
362 IF (trim(my_pk_name) /=
"FORCE_MIXING_LABELS")
THEN
369 CALL get_output_format(root_section,
"MOTION%PRINT%"//trim(my_pk_name), my_form, my_ext)
371 extension=my_ext, file_position=my_pos, file_action=my_act, &
372 file_form=my_form, middle_name=trim(my_middle), is_new_file=new_file)
373 IF (traj_unit > 0)
THEN
377 SELECT CASE (outformat)
381 section_ref =
"MOTION%PRINT%"//trim(my_pk_name)//
"%EACH%"//trim(id_label)
383 WRITE (unit=traj_unit) id_dcd, 0, it, iskip, 0, 0, 0, 0, 0, 0, real(dtime, kind=
sp), &
384 1, 0, 0, 0, 0, 0, 0, 0, 0, 24
385 remark1 =
"REMARK "//id_dcd//
" DCD file created by "//trim(
cp2k_version)// &
388 WRITE (unit=traj_unit) 2, remark1, remark2
389 WRITE (unit=traj_unit) nat
393 my_extended_xmol_title = .false.
396 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
398 IF (my_extended_xmol_title)
THEN
399 WRITE (unit=title, fmt=
"(A,I8,A,F12.3,A,F20.10)") &
400 " i = ", it,
", time = ", time,
", E = ", etot
402 WRITE (unit=title, fmt=
"(A,I8,A,F20.10)")
" i = ", it,
", E = ", etot
407 IF (id_wpc ==
"POS")
THEN
413 l_val=charge_extended)
414 i = count((/charge_occup, charge_beta, charge_extended/))
416 cpabort(
"Either only CHARGE_OCCUP, CHARGE_BETA, or CHARGE_EXTENDED can be selected, ")
423 WRITE (unit=traj_unit, fmt=
"(A6,T11,A)") &
427 my_extended_xmol_title = .false.
428 IF (
PRESENT(extended_xmol_title)) my_extended_xmol_title = extended_xmol_title
429 IF (my_extended_xmol_title)
THEN
430 WRITE (unit=title, fmt=
"(A,I0,A,F0.3,A,F0.10)") &
431 "Step ", it,
", time = ", time,
", E = ", etot
433 WRITE (unit=title, fmt=
"(A,I0,A,F0.10)") &
434 "Step ", it,
", E = ", etot
439 IF (trim(my_pk_name) ==
"FORCE_MIXING_LABELS")
THEN
440 ALLOCATE (fml_array(3*
SIZE(particle_set)))
442 CALL force_env_get(force_env, force_env_section=force_env_section)
444 "QMMM%FORCE_MIXING%RESTART_INFO", &
445 can_return_null=.true.)
446 IF (
ASSOCIATED(force_mixing_restart_section))
THEN
451 DO i = 1,
SIZE(force_mixing_indices)
452 ii = force_mixing_indices(i)
453 cpassert(ii <=
SIZE(particle_set))
454 fml_array((ii - 1)*3 + 1:(ii - 1)*3 + 3) = force_mixing_labels(i)
459 array=fml_array, print_kind=print_kind)
460 DEALLOCATE (fml_array)
463 unit_conv=unit_conv, print_kind=print_kind, &
464 charge_occup=charge_occup, &
465 charge_beta=charge_beta, &
466 charge_extended=charge_extended)
472 CALL timestop(handle)
487 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: path
488 CHARACTER(LEN=*),
INTENT(OUT) :: my_form, my_ext
490 INTEGER :: output_format
492 IF (
PRESENT(path))
THEN
498 SELECT CASE (output_format)
500 my_form =
"UNFORMATTED"
503 my_form =
"FORMATTED"
506 my_form =
"FORMATTED"
530 INTEGER,
INTENT(IN) :: itimes
531 REAL(kind=
dp),
INTENT(IN) :: time
532 CHARACTER(LEN=default_string_length),
INTENT(IN), &
535 CHARACTER(LEN=default_string_length) :: my_act, my_pos
536 INTEGER :: output_unit
538 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_total_bar
544 IF (virial%pv_availability)
THEN
547 IF (
PRESENT(pos)) my_pos = pos
548 IF (
PRESENT(act)) my_act = act
550 extension=
".stress", file_position=my_pos, &
551 file_action=my_act, file_form=
"FORMATTED", &
552 is_new_file=new_file)
557 IF (output_unit > 0)
THEN
559 WRITE (unit=output_unit, fmt=
'(A,9(12X,A2," [bar]"),6X,A)') &
560 "# Step Time [fs]",
"xx",
"xy",
"xz",
"yx",
"yy",
"yz",
"zx",
"zy",
"zz"
571 WRITE (unit=output_unit, fmt=
'(I8,F12.3,9(1X,F19.10))') itimes, time, &
572 pv_total_bar(1, 1), pv_total_bar(1, 2), pv_total_bar(1, 3), &
573 pv_total_bar(2, 1), pv_total_bar(2, 2), pv_total_bar(2, 3), &
574 pv_total_bar(3, 1), pv_total_bar(3, 2), pv_total_bar(3, 3)
578 IF (virial%pv_availability)
THEN
601 INTEGER,
INTENT(IN) :: itimes
602 REAL(kind=
dp),
INTENT(IN) :: time
603 CHARACTER(LEN=default_string_length),
INTENT(IN), &
606 CHARACTER(LEN=default_string_length) :: my_act, my_pos
607 INTEGER :: output_unit
616 IF (
PRESENT(pos)) my_pos = pos
617 IF (
PRESENT(act)) my_act = act
620 extension=
".cell", file_position=my_pos, &
621 file_action=my_act, file_form=
"FORMATTED", &
622 is_new_file=new_file)
624 IF (output_unit > 0)
THEN
626 WRITE (unit=output_unit, fmt=
'(A,9(7X,A2," [Angstrom]"),6X,A)') &
627 "# Step Time [fs]",
"Ax",
"Ay",
"Az",
"Bx",
"By",
"Bz",
"Cx",
"Cy",
"Cz", &
628 "Volume [Angstrom^3]"
630 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
character(len=26), public r_datx
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.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
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