(git:374b731)
Loading...
Searching...
No Matches
cp_symmetry.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 Work with symmetry
10!> \par History
11!> \author jgh
12! **************************************************************************************************
15 USE cell_types, ONLY: cell_type,&
21 USE cryssym, ONLY: crys_sym_gen,&
22 csym_type,&
28 USE kinds, ONLY: dp
29 USE molsym, ONLY: molecular_symmetry,&
34 USE physcon, ONLY: massunit
36#include "./base/base_uses.f90"
37
38 IMPLICIT NONE
39
40 PRIVATE
41
42 ! Global parameters (in this module)
43
44 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_symmetry'
45
46 PUBLIC :: write_symmetry
47
48! **************************************************************************************************
49
50CONTAINS
51
52! **************************************************************************************************
53!> \brief Write symmetry information to output
54!> \param particle_set Atom coordinates and types
55!> \param cell Cell information
56!> \param input_section Input
57!> \par History
58!> \author jgh
59! **************************************************************************************************
60 SUBROUTINE write_symmetry(particle_set, cell, input_section)
61 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
62 TYPE(cell_type), POINTER :: cell
63 TYPE(section_vals_type), POINTER :: input_section
64
65 CHARACTER(LEN=*), PARAMETER :: routinen = 'write_symmetry'
66
67 CHARACTER(LEN=2), ALLOCATABLE, DIMENSION(:) :: element
68 CHARACTER(LEN=8) :: csymm, esymm
69 INTEGER :: handle, i, iw, natom, plevel
70 INTEGER, ALLOCATABLE, DIMENSION(:) :: atype, z
71 LOGICAL :: check, molecular, pall, pcoor, pinertia, &
72 prmat, psymmele
73 REAL(kind=dp) :: eps_geo
74 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: weight
75 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: coord, scoord
76 TYPE(cp_logger_type), POINTER :: logger
77 TYPE(csym_type) :: crys_sym
78 TYPE(molsym_type), POINTER :: mol_sym
79 TYPE(section_vals_type), POINTER :: section
80
81 CALL timeset(routinen, handle)
82
83 NULLIFY (logger)
84 NULLIFY (section)
85
86 logger => cp_get_default_logger()
87 iw = cp_print_key_unit_nr(logger=logger, &
88 basis_section=input_section, &
89 print_key_path="PRINT%SYMMETRY", &
90 extension=".symLog")
91
92 IF (iw > 0) THEN
93 section => section_vals_get_subs_vals(section_vals=input_section, &
94 subsection_name="PRINT%SYMMETRY")
95 CALL section_vals_val_get(section_vals=section, &
96 keyword_name="MOLECULE", l_val=molecular)
97 CALL section_vals_val_get(section_vals=section, &
98 keyword_name="EPS_GEO", r_val=eps_geo)
99 IF (molecular) THEN
100
101 NULLIFY (mol_sym)
102
103 natom = SIZE(particle_set)
104 ALLOCATE (coord(3, natom), z(natom), weight(natom), atype(natom), element(natom))
105
106 DO i = 1, natom
107 CALL get_atomic_kind(particle_set(i)%atomic_kind, z=z(i))
108 CALL get_atomic_kind(atomic_kind=particle_set(i)%atomic_kind, &
109 kind_number=atype(i), element_symbol=element(i), mass=weight(i))
110 coord(1:3, i) = particle_set(i)%r(1:3)
111 END DO
112 weight(:) = weight(:)/massunit
113
114 CALL molecular_symmetry(mol_sym, eps_geo, coord, atype, weight)
115
116 CALL section_vals_val_get(section_vals=section, &
117 keyword_name="STANDARD_ORIENTATION", l_val=pcoor)
118 CALL section_vals_val_get(section_vals=section, &
119 keyword_name="INERTIA", l_val=pinertia)
120 CALL section_vals_val_get(section_vals=section, &
121 keyword_name="SYMMETRY_ELEMENTS", l_val=psymmele)
122 CALL section_vals_val_get(section_vals=section, &
123 keyword_name="ALL", l_val=pall)
124 plevel = 0
125 IF (pcoor) plevel = plevel + 1
126 IF (pinertia) plevel = plevel + 10
127 IF (psymmele) plevel = plevel + 100
128 IF (pall) plevel = 1111111111
129
130 CALL print_symmetry(mol_sym, coord, atype, element, z, weight, iw, plevel)
131
132 CALL section_vals_val_get(section_vals=section, &
133 keyword_name="CHECK_SYMMETRY", c_val=esymm)
134 CALL uppercase(esymm)
135 IF (trim(esymm) /= "NONE") THEN
136 csymm = mol_sym%point_group_symbol
137 CALL uppercase(csymm)
138 check = trim(adjustl(csymm)) == trim(adjustl(esymm))
139 IF (.NOT. check) THEN
140 CALL cp_warn(__location__, "Symmetry check failed: "// &
141 "Expected symmetry:"//trim(adjustl(esymm))// &
142 "Calculated symmetry:"//trim(adjustl(csymm)))
143 END IF
144 cpassert(check)
145 END IF
146
147 DEALLOCATE (coord, z, weight, atype, element)
148
149 CALL release_molsym(mol_sym)
150
151 ELSE
152 ! Crystal symmetry
153
154 natom = SIZE(particle_set)
155 ALLOCATE (scoord(3, natom), atype(natom))
156
157 DO i = 1, natom
158 CALL get_atomic_kind(atomic_kind=particle_set(i)%atomic_kind, kind_number=atype(i))
159 CALL real_to_scaled(scoord(1:3, i), particle_set(i)%r(1:3), cell)
160 END DO
161
162 CALL crys_sym_gen(crys_sym, scoord, atype, cell%hmat, delta=eps_geo, iounit=iw)
163
164 CALL section_vals_val_get(section_vals=section, &
165 keyword_name="ROTATION_MATRICES", l_val=prmat)
166 CALL section_vals_val_get(section_vals=section, &
167 keyword_name="ALL", l_val=pall)
168 plevel = 0
169 IF (prmat) plevel = plevel + 1
170 IF (pall) plevel = 1111111111
171 crys_sym%plevel = plevel
172
173 CALL print_crys_symmetry(crys_sym)
174
175 DEALLOCATE (scoord, atype)
176
177 CALL release_csym_type(crys_sym)
178
179 END IF
180
181 END IF
182 CALL cp_print_key_finished_output(iw, logger, input_section, "PRINT%SYMMETRY")
183
184 CALL timestop(handle)
185
186 END SUBROUTINE write_symmetry
187
188! **************************************************************************************************
189
190END MODULE cp_symmetry
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
Definition cell_types.F:486
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,...
Work with symmetry.
Definition cp_symmetry.F:13
subroutine, public write_symmetry(particle_set, cell, input_section)
Write symmetry information to output.
Definition cp_symmetry.F:61
K-points and crystal symmetry routines.
Definition cryssym.F:12
subroutine, public print_crys_symmetry(csym)
...
Definition cryssym.F:510
subroutine, public crys_sym_gen(csym, scoor, types, hmat, delta, iounit)
...
Definition cryssym.F:114
subroutine, public release_csym_type(csym)
Release the CSYM type.
Definition cryssym.F:72
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Molecular symmetry routines.
Definition molsym.F:14
subroutine, public molecular_symmetry(sym, eps_geo, coord, atype, weight)
Main program for symmetry analysis.
Definition molsym.F:1075
subroutine, public release_molsym(sym)
release an object of molsym type
Definition molsym.F:143
subroutine, public print_symmetry(sym, coord, atype, element, z, weight, iw, plevel)
Print the output of the symmetry analysis.
Definition molsym.F:1386
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public massunit
Definition physcon.F:141
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
type of a logger, at the moment it contains just a print level starting at which level it should be l...
CSM type.
Definition cryssym.F:36
Container for information about molecular symmetry.
Definition molsym.F:94