(git:374b731)
Loading...
Searching...
No Matches
grrm_utils.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief GRRM interface
10!> \author JGH - 08.2019
11! **************************************************************************************************
13
16 USE kinds, ONLY: dp
18 USE physcon, ONLY: angstrom
21#include "./base/base_uses.f90"
22
23 IMPLICIT NONE
24
25 PRIVATE
26
27 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'grrm_utils'
28
29 PUBLIC :: write_grrm
30
31! **************************************************************************************************
32
33CONTAINS
34
35! **************************************************************************************************
36!> \brief Write GRRM interface file
37!>
38!> \param iounit ...
39!> \param force_env ...
40!> \param particles ...
41!> \param energy ...
42!> \param dipole ...
43!> \param hessian ...
44!> \param dipder ...
45!> \param polar ...
46!> \param fixed_atoms ...
47! **************************************************************************************************
48 SUBROUTINE write_grrm(iounit, force_env, particles, energy, dipole, hessian, dipder, polar, &
49 fixed_atoms)
50
51 INTEGER, INTENT(IN) :: iounit
52 TYPE(force_env_type), POINTER :: force_env
53 TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particles
54 REAL(kind=dp), INTENT(IN) :: energy
55 REAL(kind=dp), DIMENSION(3), INTENT(IN), OPTIONAL :: dipole
56 REAL(kind=dp), DIMENSION(:, :), INTENT(IN), &
57 OPTIONAL :: hessian, dipder
58 REAL(kind=dp), DIMENSION(3, 3), INTENT(IN), &
59 OPTIONAL :: polar
60 INTEGER, INTENT(IN), OPTIONAL :: fixed_atoms
61
62 REAL(kind=dp), PARAMETER :: zero = 0.0_dp
63
64 INTEGER :: i, j, natom, nc
65 LOGICAL :: nddo
66 REAL(kind=dp) :: eout
67 REAL(kind=dp), DIMENSION(5) :: fz
68 TYPE(dft_control_type), POINTER :: dft_control
69 TYPE(qs_energy_type), POINTER :: qs_energy
70
71 IF (iounit > 0) THEN
72 ! the units depend on the qs method!
73 cpassert(ASSOCIATED(force_env%qs_env))
74 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
75 nddo = dft_control%qs_control%semi_empirical
76 IF (nddo) THEN
77 CALL get_qs_env(force_env%qs_env, energy=qs_energy)
78 eout = energy + qs_energy%core_self
79 ELSE
80 eout = energy
81 END IF
82 !
83 natom = SIZE(particles)
84 IF (PRESENT(fixed_atoms)) natom = natom - fixed_atoms
85 WRITE (iounit, "(A7)") "RESULTS"
86 WRITE (iounit, "(A18)") "CURRENT COORDINATE"
87 DO i = 1, natom
88 WRITE (iounit, "(A,3F24.12)") trim(adjustl(particles(i)%atomic_kind%element_symbol)), &
89 particles(i)%r(1:3)*angstrom
90 END DO
91 WRITE (iounit, "(A8,3F18.12)") "ENERGY =", eout, zero, zero
92 WRITE (iounit, "(A8,3F18.12)") " =", zero, zero, zero
93 WRITE (iounit, "(A8,F18.12)") "S**2 =", zero
94 WRITE (iounit, "(A8)") "GRADIENT"
95 DO i = 1, natom
96 WRITE (iounit, "(F17.12)") - particles(i)%f(1:3)
97 END DO
98 IF (PRESENT(dipole)) THEN
99 WRITE (iounit, "(A8,3F18.12)") "DIPOLE =", dipole(1:3)
100 ELSE
101 WRITE (iounit, "(A8,3F18.12)") "DIPOLE =", zero, zero, zero
102 END IF
103 fz = zero
104 WRITE (iounit, "(A7)") "HESSIAN"
105 IF (PRESENT(hessian)) THEN
106 nc = 3*natom
107 DO i = 1, nc, 5
108 DO j = i, nc
109 WRITE (iounit, "(5(F13.9,1X))") hessian(j, i:min(j, i + 4))
110 END DO
111 END DO
112 ELSE
113 nc = 3*natom
114 DO i = 1, nc, 5
115 DO j = i, nc
116 WRITE (iounit, "(5(F13.9,1X))") fz(1:min(j - i + 1, 5))
117 END DO
118 END DO
119 END IF
120 WRITE (iounit, "(A18)") "DIPOLE DERIVATIVES"
121 IF (PRESENT(dipder)) THEN
122 DO i = 1, 3*natom
123 WRITE (iounit, "(3(F17.12,7X))") dipder(1:3, i)
124 END DO
125 ELSE
126 DO i = 1, 3*natom
127 WRITE (iounit, "(3(F17.12,7X))") zero, zero, zero
128 END DO
129 END IF
130 WRITE (iounit, "(A14)") "POLARIZABILITY"
131 IF (PRESENT(polar)) THEN
132 WRITE (iounit, "(1(F17.12,7X))") polar(1, 1)
133 WRITE (iounit, "(2(F17.12,7X))") polar(2, 1), polar(2, 2)
134 WRITE (iounit, "(3(F17.12,7X))") polar(3, 1), polar(3, 2), polar(3, 3)
135 ELSE
136 WRITE (iounit, "(1(F17.12,7X))") zero
137 WRITE (iounit, "(2(F17.12,7X))") zero, zero
138 WRITE (iounit, "(3(F17.12,7X))") zero, zero, zero
139 END IF
140 END IF
141
142 END SUBROUTINE write_grrm
143
144END MODULE grrm_utils
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Interface for the force calculations.
GRRM interface.
Definition grrm_utils.F:12
subroutine, public write_grrm(iounit, force_env, particles, energy, dipole, hessian, dipder, polar, fixed_atoms)
Write GRRM interface file.
Definition grrm_utils.F:50
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public angstrom
Definition physcon.F:144
Perform a QUICKSTEP wavefunction optimization (single point)
Definition qs_energy.F:14
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
wrapper to abstract the force evaluation of the various methods