(git:374b731)
Loading...
Searching...
No Matches
scine_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 SCINE interface
10!> \author JGH - 01.2020
11! **************************************************************************************************
13
14 USE cell_types, ONLY: cell_type
17 USE kinds, ONLY: dp
19 USE physcon, ONLY: angstrom
22#include "./base/base_uses.f90"
23
24 IMPLICIT NONE
25
26 PRIVATE
27
28 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'scine_utils'
29
30 PUBLIC :: write_scine
31
32! **************************************************************************************************
33
34CONTAINS
35
36! **************************************************************************************************
37!> \brief Write SCINE interface file
38!>
39!> \param iounit ...
40!> \param force_env ...
41!> \param particles ...
42!> \param energy ...
43!> \param hessian ...
44! **************************************************************************************************
45 SUBROUTINE write_scine(iounit, force_env, particles, energy, hessian)
46
47 INTEGER, INTENT(IN) :: iounit
48 TYPE(force_env_type), POINTER :: force_env
49 TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particles
50 REAL(kind=dp), INTENT(IN) :: energy
51 REAL(kind=dp), DIMENSION(:, :), INTENT(IN), &
52 OPTIONAL :: hessian
53
54 REAL(kind=dp), PARAMETER :: zero = 0.0_dp
55
56 CHARACTER(LEN=20) :: sunit
57 INTEGER :: i, j, natom, nc
58 LOGICAL :: nddo
59 REAL(kind=dp) :: eout
60 REAL(kind=dp), DIMENSION(5) :: fz
61 TYPE(cell_type), POINTER :: cell
62 TYPE(dft_control_type), POINTER :: dft_control
63 TYPE(qs_energy_type), POINTER :: qs_energy
64
65 IF (iounit > 0) THEN
66 ! the units depend on the qs method!
67 cpassert(ASSOCIATED(force_env%qs_env))
68 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
69 nddo = dft_control%qs_control%semi_empirical
70 IF (nddo) THEN
71 CALL get_qs_env(force_env%qs_env, energy=qs_energy)
72 eout = energy + qs_energy%core_self
73 ELSE
74 eout = energy
75 END IF
76 !
77 CALL get_qs_env(force_env%qs_env, cell=cell)
78 natom = SIZE(particles)
79 WRITE (iounit, "(A,A)") "title: ", "'SCINE Interface File'"
80 sunit = "'hartree'"
81 WRITE (iounit, "(A,F18.12,A,A)") "energy: [", eout, ", "//trim(sunit), " ]"
82 sunit = "'angstrom'"
83 WRITE (iounit, "(A)") "system:"
84 WRITE (iounit, "(T2,A,A)") "unit: ", trim(sunit)
85 WRITE (iounit, "(T2,A)") "cell: "
86 WRITE (iounit, "(T4,A,F24.12,',',F24.12,',',F24.12,A)") &
87 "- A: [", cell%hmat(1:3, 1)*angstrom, " ]"
88 WRITE (iounit, "(T4,A,F24.12,',',F24.12,',',F24.12,A)") &
89 "- B: [", cell%hmat(1:3, 2)*angstrom, " ]"
90 WRITE (iounit, "(T4,A,F24.12,',',F24.12,',',F24.12,A)") &
91 "- C: [", cell%hmat(1:3, 3)*angstrom, " ]"
92 WRITE (iounit, "(T2,A,L1,', ',L1,', ',L1,' ]')") "periodicity: [ ", (cell%perd == 1)
93 WRITE (iounit, "(T2,A)") "coordinates: "
94 DO i = 1, natom
95 WRITE (iounit, "(T4,A,A2,A,F24.12,',',F24.12,',',F24.12,A)") &
96 "- ", trim(adjustl(particles(i)%atomic_kind%element_symbol))//":", &
97 " [", particles(i)%r(1:3)*angstrom, " ]"
98 END DO
99 WRITE (iounit, "(A)") "gradient:"
100 sunit = "'hartree/bohr'"
101 WRITE (iounit, "(T2,A,A)") "unit: ", trim(sunit)
102 WRITE (iounit, "(T2,A)") "values: "
103 DO i = 1, natom
104 WRITE (iounit, "(T4,A,A2,A,F24.12,',',F24.12,',',F24.12,A)") &
105 "- ", trim(adjustl(particles(i)%atomic_kind%element_symbol))//":", &
106 " [", particles(i)%f(1:3), " ]"
107 END DO
108 fz = zero
109 IF (PRESENT(hessian)) THEN
110 WRITE (iounit, "(A)") "hessian:"
111 sunit = "'hartree/bohr^2'"
112 WRITE (iounit, "(T2,A,A)") "unit: ", trim(sunit)
113 DO i = 1, natom
114 WRITE (iounit, "(T4,A)") trim(adjustl(particles(i)%atomic_kind%element_symbol))//":"
115 nc = 3*(i - 1) + 1
116 WRITE (iounit, "(T6,'X: [')")
117 DO j = 1, nc, 5
118 IF (nc > j + 4) THEN
119 WRITE (iounit, "(T12,5(F20.12,','))") hessian(nc, j:j + 4)
120 ELSEIF (nc == j + 4) THEN
121 WRITE (iounit, "(T12,4(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
122 ELSEIF (nc == j + 3) THEN
123 WRITE (iounit, "(T12,3(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
124 ELSEIF (nc == j + 2) THEN
125 WRITE (iounit, "(T12,2(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
126 ELSEIF (nc == j + 1) THEN
127 WRITE (iounit, "(T12,1(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
128 ELSEIF (nc == j) THEN
129 WRITE (iounit, "(T12,F20.12,' ]')") hessian(nc, j:nc)
130 END IF
131 END DO
132 nc = 3*(i - 1) + 2
133 WRITE (iounit, "(T6,'Y: [')")
134 DO j = 1, nc, 5
135 IF (nc > j + 4) THEN
136 WRITE (iounit, "(T12,5(F20.12,','))") hessian(nc, j:j + 4)
137 ELSEIF (nc == j + 4) THEN
138 WRITE (iounit, "(T12,4(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
139 ELSEIF (nc == j + 3) THEN
140 WRITE (iounit, "(T12,3(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
141 ELSEIF (nc == j + 2) THEN
142 WRITE (iounit, "(T12,2(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
143 ELSEIF (nc == j + 1) THEN
144 WRITE (iounit, "(T12,1(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
145 ELSEIF (nc == j) THEN
146 WRITE (iounit, "(T12,F20.12,' ]')") hessian(nc, j:nc)
147 END IF
148 END DO
149 nc = 3*(i - 1) + 3
150 WRITE (iounit, "(T6,'Z: [')")
151 DO j = 1, nc, 5
152 IF (nc > j + 4) THEN
153 WRITE (iounit, "(T12,5(F20.12,','))") hessian(nc, j:j + 4)
154 ELSEIF (nc == j + 4) THEN
155 WRITE (iounit, "(T12,4(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
156 ELSEIF (nc == j + 3) THEN
157 WRITE (iounit, "(T12,3(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
158 ELSEIF (nc == j + 2) THEN
159 WRITE (iounit, "(T12,2(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
160 ELSEIF (nc == j + 1) THEN
161 WRITE (iounit, "(T12,1(F20.12,','),F20.12,' ]')") hessian(nc, j:nc)
162 ELSEIF (nc == j) THEN
163 WRITE (iounit, "(T12,F20.12,' ]')") hessian(nc, j:nc)
164 END IF
165 END DO
166 END DO
167 END IF
168 END IF
169
170 END SUBROUTINE write_scine
171
172END MODULE scine_utils
Handles all functions related to the CELL.
Definition cell_types.F:15
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Interface for the force calculations.
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.
SCINE interface.
Definition scine_utils.F:12
subroutine, public write_scine(iounit, force_env, particles, energy, hessian)
Write SCINE interface file.
Definition scine_utils.F:46
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
wrapper to abstract the force evaluation of the various methods