Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Molecular symmetry routines
10 : !> \par History
11 : !> 2008 adapted from older routines by Matthias Krack
12 : !> \author jgh
13 : ! **************************************************************************************************
14 : MODULE molsym
15 :
16 : USE kinds, ONLY: dp
17 : USE mathconstants, ONLY: pi
18 : USE mathlib, ONLY: angle,&
19 : build_rotmat,&
20 : jacobi,&
21 : reflect_vector,&
22 : rotate_vector,&
23 : unit_matrix,&
24 : vector_product
25 : USE physcon, ONLY: angstrom
26 : USE util, ONLY: sort
27 : #include "./base/base_uses.f90"
28 :
29 : IMPLICIT NONE
30 : PRIVATE
31 :
32 : LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
33 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'molsym'
34 :
35 : INTEGER, PARAMETER :: maxcn = 20, &
36 : maxsec = maxcn + 1, &
37 : maxses = 2*maxcn + 1, &
38 : maxsig = maxcn + 1, &
39 : maxsn = 2*maxcn
40 :
41 : PUBLIC :: molsym_type
42 : PUBLIC :: release_molsym, molecular_symmetry, print_symmetry, get_symmetry_number
43 :
44 : ! **************************************************************************************************
45 : !> \brief Container for information about molecular symmetry
46 : !> \param ain : Atomic identification numbers (symmetry code).
47 : !> \param aw : Atomic weights for the symmetry analysis.
48 : !> \param eps_geo : Accuracy requested for analysis
49 : !> \param inptostd : Transformation matrix for input to standard orientation.
50 : !> \param point_group_symbol: Point group symbol.
51 : !> \param rotmat : Rotation matrix.
52 : !> \param sec : List of C axes
53 : !> (sec(:,i,j) => x,y,z of the ith j-fold C axis).
54 : !> \param ses : List of S axes
55 : !> (ses(:,i,j) => x,y,z of the ith j-fold S axis).
56 : !> \param sig : List of mirror planes
57 : !> (sig(:,i) => x,y,z of the ith mirror plane).
58 : !> \param center_of_mass : Shift vector for the center of mass.
59 : !> \param tenmat : Molecular tensor of inertia.
60 : !> \param tenval : Eigenvalues of the molecular tensor of inertia.
61 : !> \param tenvec : Eigenvectors of the molecular tensor of inertia.
62 : !> \param group_of : Group of equivalent atom.
63 : !> \param llequatom : Lower limit of a group in symequ_list.
64 : !> \param ncn : Degree of the C axis with highest degree.
65 : !> \param ndod : Number of substituted dodecahedral angles.
66 : !> \param nequatom : Number of equivalent atoms.
67 : !> \param ngroup : Number of groups of equivalent atoms.
68 : !> \param nico : Number of substituted icosahedral angles.
69 : !> \param nlin : Number of substituted angles of 180 degrees.
70 : !> \param nsec : Number of C axes.
71 : !> \param nses : Number of S axes.
72 : !> \param nsig : Number of mirror planes.
73 : !> \param nsn : Degree of the S axis with highest degree.
74 : !> \param ntet : Number of substituted tetrahedral angles.
75 : !> \param point_group_order : Group order.
76 : !> \param symequ_list : List of all atoms ordered in groups of equivalent atoms.
77 : !> \param ulequatom : Upper limit of a group in symequ_list.
78 : !> \param cubic : .TRUE., if a cubic point group was found (T,Th,Td,O,Oh,I,Ih).
79 : !> \param dgroup: .TRUE., if a point group of D symmetry was found (Dn,Dnh,Dnd)
80 : !> \param igroup: .TRUE., if a point group of icosahedral symmetry was found (I,Ih).
81 : !> \param invers: .TRUE., if the molecule has a center of inversion.
82 : !> \param linear: .TRUE., if the molecule is linear.
83 : !> \param maxis : .TRUE., if the molecule has a main axis.
84 : !> \param ogroup: .TRUE., if a point group of octahedral symmetry was found (O,Oh)
85 : !> \param sgroup: .TRUE., if a point group of S symmetry was found.
86 : !> \param sigmad: .TRUE., if there is a sigma_d mirror plane.
87 : !> \param sigmah: .TRUE., if there is a sigma_h mirror plane.
88 : !> \param sigmav: .TRUE., if there is a sigma_v mirror plane.
89 : !> \param tgroup: .TRUE., if a point group of tetrahedral symmetry was found (T,Th,Td).
90 : !> \par History
91 : !> 05.2008 created
92 : !> \author jgh
93 : ! **************************************************************************************************
94 : TYPE molsym_type
95 : CHARACTER(LEN=4) :: point_group_symbol = ""
96 : INTEGER :: point_group_order = -1
97 : INTEGER :: ncn = -1, ndod = -1, ngroup = -1, nico = -1, &
98 : nlin = -1, nsig = -1, nsn = -1, ntet = -1
99 : LOGICAL :: cubic = .FALSE., dgroup = .FALSE., igroup = .FALSE., &
100 : invers = .FALSE., linear = .FALSE., maxis = .FALSE., &
101 : ogroup = .FALSE., sgroup = .FALSE., sigmad = .FALSE., &
102 : sigmah = .FALSE., sigmav = .FALSE., tgroup = .FALSE.
103 : REAL(KIND=dp) :: eps_geo = 0.0_dp
104 : REAL(KIND=dp), DIMENSION(3) :: center_of_mass = 0.0_dp, tenval = 0.0_dp
105 : REAL(KIND=dp), DIMENSION(3) :: x_axis = 0.0_dp, y_axis = 0.0_dp, z_axis = 0.0_dp
106 : REAL(KIND=dp), DIMENSION(:), POINTER :: ain => NULL(), aw => NULL()
107 : REAL(KIND=dp), DIMENSION(3, 3) :: inptostd = 0.0_dp, rotmat = 0.0_dp, tenmat = 0.0_dp, tenvec = 0.0_dp
108 : REAL(KIND=dp), DIMENSION(3, maxsig) :: sig = 0.0_dp
109 : REAL(KIND=dp), DIMENSION(3, maxsec, 2:maxcn) :: sec = 0.0_dp
110 : REAL(KIND=dp), DIMENSION(3, maxses, 2:maxsn) :: ses = 0.0_dp
111 : INTEGER, DIMENSION(maxcn) :: nsec = -1
112 : INTEGER, DIMENSION(maxsn) :: nses = -1
113 : INTEGER, DIMENSION(:), POINTER :: group_of => NULL(), llequatom => NULL(), nequatom => NULL(), &
114 : symequ_list => NULL(), ulequatom => NULL()
115 : END TYPE molsym_type
116 :
117 : ! **************************************************************************************************
118 :
119 : CONTAINS
120 :
121 : ! **************************************************************************************************
122 : !> \brief Create an object of molsym type
123 : !> \param sym ...
124 : !> \param natoms ...
125 : !> \author jgh
126 : ! **************************************************************************************************
127 60 : SUBROUTINE create_molsym(sym, natoms)
128 : TYPE(molsym_type), POINTER :: sym
129 : INTEGER, INTENT(IN) :: natoms
130 :
131 60 : IF (ASSOCIATED(sym)) CALL release_molsym(sym)
132 :
133 496260 : ALLOCATE (sym)
134 :
135 : ALLOCATE (sym%ain(natoms), sym%aw(natoms), sym%group_of(natoms), sym%llequatom(natoms), &
136 600 : sym%nequatom(natoms), sym%symequ_list(natoms), sym%ulequatom(natoms))
137 :
138 60 : END SUBROUTINE create_molsym
139 :
140 : ! **************************************************************************************************
141 : !> \brief release an object of molsym type
142 : !> \param sym ...
143 : !> \author jgh
144 : ! **************************************************************************************************
145 60 : SUBROUTINE release_molsym(sym)
146 : TYPE(molsym_type), POINTER :: sym
147 :
148 60 : CPASSERT(ASSOCIATED(sym))
149 :
150 60 : IF (ASSOCIATED(sym%aw)) THEN
151 60 : DEALLOCATE (sym%aw)
152 : END IF
153 60 : IF (ASSOCIATED(sym%ain)) THEN
154 60 : DEALLOCATE (sym%ain)
155 : END IF
156 60 : IF (ASSOCIATED(sym%group_of)) THEN
157 60 : DEALLOCATE (sym%group_of)
158 : END IF
159 60 : IF (ASSOCIATED(sym%llequatom)) THEN
160 60 : DEALLOCATE (sym%llequatom)
161 : END IF
162 60 : IF (ASSOCIATED(sym%nequatom)) THEN
163 60 : DEALLOCATE (sym%nequatom)
164 : END IF
165 60 : IF (ASSOCIATED(sym%symequ_list)) THEN
166 60 : DEALLOCATE (sym%symequ_list)
167 : END IF
168 60 : IF (ASSOCIATED(sym%ulequatom)) THEN
169 60 : DEALLOCATE (sym%ulequatom)
170 : END IF
171 :
172 60 : DEALLOCATE (sym)
173 :
174 60 : END SUBROUTINE release_molsym
175 :
176 : ! **************************************************************************************************
177 :
178 : ! **************************************************************************************************
179 : !> \brief Add a new C_n axis to the list sec, but first check, if the
180 : !> Cn axis is already in the list.
181 : !> \param n ...
182 : !> \param a ...
183 : !> \param sym ...
184 : !> \par History
185 : !> Creation (19.10.98, Matthias Krack)
186 : !> \author jgh
187 : ! **************************************************************************************************
188 1419 : SUBROUTINE addsec(n, a, sym)
189 : INTEGER, INTENT(IN) :: n
190 : REAL(dp), DIMENSION(3), INTENT(IN) :: a
191 : TYPE(molsym_type), INTENT(inout) :: sym
192 :
193 : INTEGER :: isec
194 : REAL(dp) :: length_of_a, scapro
195 : REAL(dp), DIMENSION(3) :: d
196 :
197 1419 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
198 5676 : d(:) = a(:)/length_of_a
199 :
200 : ! Check, if the current Cn axis is already in the list
201 6384 : DO isec = 1, sym%nsec(n)
202 6088 : scapro = sym%sec(1, isec, n)*d(1) + sym%sec(2, isec, n)*d(2) + sym%sec(3, isec, n)*d(3)
203 6384 : IF (ABS(ABS(scapro) - 1.0_dp) < sym%eps_geo) RETURN
204 : END DO
205 296 : sym%ncn = MAX(sym%ncn, n)
206 :
207 : ! Add the new Cn axis to the list sec
208 296 : CPASSERT(sym%nsec(n) < maxsec)
209 296 : sym%nsec(1) = sym%nsec(1) + 1
210 296 : sym%nsec(n) = sym%nsec(n) + 1
211 1184 : sym%sec(:, sym%nsec(n), n) = d(:)
212 :
213 : END SUBROUTINE addsec
214 :
215 : ! **************************************************************************************************
216 : !> \brief Add a new Sn axis to the list ses, but first check, if the
217 : !> Sn axis is already in the list.
218 : !> \param n ...
219 : !> \param a ...
220 : !> \param sym ...
221 : !> \par History
222 : !> Creation (19.10.98, Matthias Krack)
223 : !> \author jgh
224 : ! **************************************************************************************************
225 284 : SUBROUTINE addses(n, a, sym)
226 : INTEGER, INTENT(IN) :: n
227 : REAL(dp), DIMENSION(3), INTENT(IN) :: a
228 : TYPE(molsym_type), INTENT(inout) :: sym
229 :
230 : INTEGER :: ises
231 : REAL(dp) :: length_of_a, scapro
232 : REAL(dp), DIMENSION(3) :: d
233 :
234 284 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
235 1136 : d(:) = a(:)/length_of_a
236 :
237 : ! Check, if the current Sn axis is already in the list
238 1051 : DO ises = 1, sym%nses(n)
239 888 : scapro = sym%ses(1, ises, n)*d(1) + sym%ses(2, ises, n)*d(2) + sym%ses(3, ises, n)*d(3)
240 1051 : IF (ABS(ABS(scapro) - 1.0_dp) < sym%eps_geo) RETURN
241 : END DO
242 163 : sym%nsn = MAX(sym%nsn, n)
243 :
244 : ! Add the new Sn axis to the list ses
245 163 : CPASSERT(sym%nses(n) < maxses)
246 163 : sym%nses(1) = sym%nses(1) + 1
247 163 : sym%nses(n) = sym%nses(n) + 1
248 652 : sym%ses(:, sym%nses(n), n) = d(:)
249 :
250 : END SUBROUTINE addses
251 :
252 : ! **************************************************************************************************
253 : !> \brief Add a new mirror plane to the list sig, but first check, if the
254 : !> normal vector of the mirror plane is already in the list.
255 : !> \param a ...
256 : !> \param sym ...
257 : !> \par History
258 : !> Creation (19.10.98, Matthias Krack)
259 : !> \author jgh
260 : ! **************************************************************************************************
261 597 : SUBROUTINE addsig(a, sym)
262 : REAL(dp), DIMENSION(3), INTENT(IN) :: a
263 : TYPE(molsym_type), INTENT(inout) :: sym
264 :
265 : INTEGER :: isig
266 : REAL(dp) :: length_of_a, scapro
267 : REAL(dp), DIMENSION(3) :: d
268 :
269 597 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
270 2388 : d(:) = a(:)/length_of_a
271 :
272 : ! Check, if the normal vector of the current mirror plane is already in the list
273 2426 : DO isig = 1, sym%nsig
274 2273 : scapro = sym%sig(1, isig)*d(1) + sym%sig(2, isig)*d(2) + sym%sig(3, isig)*d(3)
275 2426 : IF (ABS(ABS(scapro) - 1.0_dp) < sym%eps_geo) RETURN
276 : END DO
277 :
278 : ! Add the normal vector of the new mirror plane to the list sig
279 153 : CPASSERT(sym%nsig < maxsig)
280 153 : sym%nsig = sym%nsig + 1
281 612 : sym%sig(:, sym%nsig) = d(:)
282 :
283 : END SUBROUTINE addsig
284 :
285 : ! **************************************************************************************************
286 : !> \brief Symmetry handling for only one atom.
287 : !> \param sym ...
288 : !> \par History
289 : !> Creation (19.10.98, Matthias Krack)
290 : !> \author jgh
291 : ! **************************************************************************************************
292 1 : SUBROUTINE atomsym(sym)
293 : TYPE(molsym_type), INTENT(inout) :: sym
294 :
295 : ! Set point group symbol
296 :
297 1 : sym%point_group_symbol = "R(3)"
298 :
299 : ! Set variables like D*h
300 1 : sym%linear = .TRUE.
301 1 : sym%invers = .TRUE.
302 1 : sym%dgroup = .TRUE.
303 1 : sym%sigmah = .TRUE.
304 :
305 1 : END SUBROUTINE atomsym
306 :
307 : ! **************************************************************************************************
308 : !> \brief Search for point groups with AXial SYMmetry (Cn,Cnh,Cnv,Dn,Dnh,Dnd,S2n).
309 : !> \param coord ...
310 : !> \param sym ...
311 : !> \par History
312 : !> Creation (19.10.98, Matthias Krack)
313 : !> \author jgh
314 : ! **************************************************************************************************
315 45 : SUBROUTINE axsym(coord, sym)
316 : REAL(Kind=dp), DIMENSION(:, :), INTENT(inout) :: coord
317 : TYPE(molsym_type), INTENT(inout) :: sym
318 :
319 : INTEGER :: iatom, isig, jatom, m, n, natoms, nx, &
320 : ny, nz
321 : REAL(dp) :: phi
322 : REAL(dp), DIMENSION(3) :: a, b, d
323 :
324 : ! Find the correct main axis and rotate main axis to z axis
325 :
326 45 : IF ((sym%ncn == 2) .AND. (sym%nses(2) == 3)) THEN
327 2 : IF (sym%nsn == 4) THEN
328 : ! Special case: D2d
329 0 : phi = angle(sym%ses(:, 1, sym%nsn), sym%z_axis(:))
330 0 : d(:) = vector_product(sym%ses(:, 1, sym%nsn), sym%z_axis(:))
331 0 : CALL rotate_molecule(phi, d(:), sym, coord)
332 : ELSE
333 : ! Special cases: D2 and D2h
334 2 : phi = 0.5_dp*pi
335 2 : nx = naxis(sym%x_axis(:), coord, sym)
336 2 : ny = naxis(sym%y_axis(:), coord, sym)
337 2 : nz = naxis(sym%z_axis(:), coord, sym)
338 2 : IF ((nx > ny) .AND. (nx > nz)) THEN
339 0 : CALL rotate_molecule(-phi, sym%y_axis(:), sym, coord)
340 2 : ELSE IF ((ny > nz) .AND. (ny > nx)) THEN
341 0 : CALL rotate_molecule(phi, sym%x_axis(:), sym, coord)
342 : END IF
343 : END IF
344 : ELSE
345 43 : phi = angle(sym%sec(:, 1, sym%ncn), sym%z_axis(:))
346 43 : d(:) = vector_product(sym%sec(:, 1, sym%ncn), sym%z_axis(:))
347 43 : CALL rotate_molecule(phi, d(:), sym, coord)
348 : END IF
349 :
350 : ! Search for C2 axes perpendicular to the main axis
351 : ! Loop over all pairs of atoms (except on the z axis)
352 45 : natoms = SIZE(coord, 2)
353 459 : DO iatom = 1, natoms
354 1656 : a(:) = coord(:, iatom)
355 459 : IF ((ABS(a(1)) > sym%eps_geo) .OR. (ABS(a(2)) > sym%eps_geo)) THEN
356 388 : a(3) = 0.0_dp
357 388 : IF (caxis(2, a(:), sym, coord)) CALL addsec(2, a(:), sym)
358 388 : d(:) = vector_product(a(:), sym%z_axis(:))
359 388 : IF (sigma(d(:), sym, coord)) CALL addsig(d(:), sym)
360 2283 : DO jatom = iatom + 1, natoms
361 7580 : b(:) = coord(:, jatom)
362 2309 : IF ((ABS(b(1)) > sym%eps_geo) .OR. (ABS(b(2)) > sym%eps_geo)) THEN
363 1871 : b(3) = 0.0_dp
364 1871 : phi = 0.5_dp*angle(a(:), b(:))
365 1871 : d(:) = vector_product(a(:), b(:))
366 1871 : b(:) = rotate_vector(a(:), phi, d(:))
367 1871 : IF (caxis(2, b(:), sym, coord)) CALL addsec(2, b(:), sym)
368 1871 : d(:) = vector_product(b(:), sym%z_axis)
369 1895 : IF (sigma(d(:), sym, coord)) CALL addsig(d(:), sym)
370 : END IF
371 : END DO
372 : END IF
373 : END DO
374 :
375 : ! Check the xy plane for mirror plane
376 45 : IF (sigma(sym%z_axis(:), sym, coord)) THEN
377 14 : CALL addsig(sym%z_axis(:), sym)
378 14 : sym%sigmah = .TRUE.
379 : END IF
380 :
381 : ! Set logical variables for point group determination ***
382 45 : IF (sym%nsec(2) > 1) THEN
383 21 : sym%dgroup = .TRUE.
384 21 : IF ((.NOT. sym%sigmah) .AND. (sym%nsig > 0)) sym%sigmad = .TRUE.
385 : ELSE
386 24 : IF ((.NOT. sym%sigmah) .AND. (sym%nsig > 0)) sym%sigmav = .TRUE.
387 : ! Cnh groups with n>3 were wrong
388 : ! IF (sym%nsn > 3) sym%sgroup = .TRUE.
389 24 : IF ((.NOT. sym%sigmah) .AND. (sym%nsn > 3)) sym%sgroup = .TRUE.
390 : END IF
391 :
392 : ! Rotate to standard orientation
393 45 : n = 0
394 45 : m = 0
395 45 : IF ((sym%dgroup .AND. sym%sigmah) .OR. (sym%dgroup .AND. sym%sigmad) .OR. sym%sigmav) THEN
396 : ! Dnh, Dnd or Cnv
397 133 : DO isig = 1, sym%nsig
398 133 : IF (ABS(sym%sig(3, isig)) < sym%eps_geo) THEN
399 105 : n = nsigma(sym%sig(:, isig), sym, coord)
400 105 : IF (n > m) THEN
401 21 : m = n
402 84 : a(:) = sym%sig(:, isig)
403 : END IF
404 : END IF
405 : END DO
406 21 : IF (m > 0) THEN
407 : ! Check for special case: C2v with all atoms in a plane
408 21 : IF (sym%sigmav .AND. (m == natoms)) THEN
409 1 : phi = angle(a(:), sym%x_axis(:))
410 1 : d(:) = vector_product(a(:), sym%x_axis(:))
411 : ELSE
412 20 : phi = angle(a(:), sym%y_axis(:))
413 20 : d(:) = vector_product(a(:), sym%y_axis(:))
414 : END IF
415 21 : CALL rotate_molecule(phi, d(:), sym, coord)
416 : END IF
417 24 : ELSE IF (sym%sigmah) THEN
418 : ! Cnh
419 81 : DO iatom = 1, natoms
420 81 : IF (ABS(coord(3, iatom)) < sym%eps_geo) THEN
421 70 : n = naxis(coord(:, iatom), coord, sym)
422 70 : IF (n > m) THEN
423 28 : m = n
424 28 : a(:) = coord(:, iatom)
425 : END IF
426 : END IF
427 : END DO
428 7 : IF (m > 0) THEN
429 7 : phi = angle(a(:), sym%x_axis(:))
430 7 : d(:) = vector_product(a(:), sym%x_axis(:))
431 7 : CALL rotate_molecule(phi, d(:), sym, coord)
432 : END IF
433 : ! No action for Dn, Cn or S2n ***
434 : END IF
435 :
436 45 : END SUBROUTINE axsym
437 :
438 : ! **************************************************************************************************
439 : !> \brief Generate a symmetry list to identify equivalent atoms.
440 : !> \param sym ...
441 : !> \param coord ...
442 : !> \par History
443 : !> Creation (19.10.98, Matthias Krack)
444 : !> \author jgh
445 : ! **************************************************************************************************
446 60 : SUBROUTINE build_symequ_list(sym, coord)
447 : TYPE(molsym_type), INTENT(inout) :: sym
448 : REAL(Kind=dp), DIMENSION(:, :), INTENT(inout) :: coord
449 :
450 : INTEGER :: i, iatom, icn, iequatom, incr, isec, &
451 : ises, isig, isn, jatom, jcn, jsn, &
452 : natoms
453 : REAL(KIND=dp) :: phi
454 : REAL(KIND=dp), DIMENSION(3) :: a
455 :
456 60 : natoms = SIZE(coord, 2)
457 :
458 60 : IF (sym%sigmah) THEN
459 : incr = 1
460 : ELSE
461 41 : incr = 2
462 : END IF
463 :
464 : ! Initialize the atom and the group counter
465 60 : iatom = 1
466 60 : sym%ngroup = 1
467 :
468 : loop: DO
469 :
470 : ! Loop over all mirror planes
471 336 : DO isig = 1, sym%nsig
472 226 : a(:) = reflect_vector(coord(:, iatom), sym%sig(:, isig))
473 226 : iequatom = equatom(iatom, a(:), sym, coord)
474 336 : IF ((iequatom > 0) .AND. (.NOT. in_symequ_list(iequatom, sym))) THEN
475 111 : sym%ulequatom(sym%ngroup) = sym%ulequatom(sym%ngroup) + 1
476 111 : sym%symequ_list(sym%ulequatom(sym%ngroup)) = iequatom
477 111 : sym%nequatom(sym%ngroup) = sym%nequatom(sym%ngroup) + 1
478 : END IF
479 : END DO
480 :
481 : ! Loop over all Cn axes
482 449 : DO icn = 2, sym%ncn
483 833 : DO isec = 1, sym%nsec(icn)
484 1465 : DO jcn = 1, icn - 1
485 1126 : IF (newse(jcn, icn)) THEN
486 644 : phi = 2.0_dp*pi*REAL(jcn, KIND=dp)/REAL(icn, KIND=dp)
487 644 : a(:) = rotate_vector(coord(:, iatom), phi, sym%sec(:, isec, icn))
488 644 : iequatom = equatom(iatom, a(:), sym, coord)
489 644 : IF ((iequatom > 0) .AND. (.NOT. in_symequ_list(iequatom, sym))) THEN
490 328 : sym%ulequatom(sym%ngroup) = sym%ulequatom(sym%ngroup) + 1
491 328 : sym%symequ_list(sym%ulequatom(sym%ngroup)) = iequatom
492 328 : sym%nequatom(sym%ngroup) = sym%nequatom(sym%ngroup) + 1
493 : END IF
494 : END IF
495 : END DO
496 : END DO
497 : END DO
498 :
499 : ! Loop over all Sn axes
500 343 : DO isn = 2, sym%nsn
501 446 : DO ises = 1, sym%nses(isn)
502 643 : DO jsn = 1, isn - 1, incr
503 410 : IF (newse(jsn, isn)) THEN
504 243 : phi = 2.0_dp*pi*REAL(jsn, KIND=dp)/REAL(isn, KIND=dp)
505 243 : a(:) = rotate_vector(coord(:, iatom), phi, sym%ses(:, ises, isn))
506 972 : a(:) = reflect_vector(a(:), sym%ses(:, ises, isn))
507 243 : iequatom = equatom(iatom, a(:), sym, coord)
508 243 : IF ((iequatom > 0) .AND. (.NOT. in_symequ_list(iequatom, sym))) THEN
509 30 : sym%ulequatom(sym%ngroup) = sym%ulequatom(sym%ngroup) + 1
510 30 : sym%symequ_list(sym%ulequatom(sym%ngroup)) = iequatom
511 30 : sym%nequatom(sym%ngroup) = sym%nequatom(sym%ngroup) + 1
512 : END IF
513 : END IF
514 : END DO
515 : END DO
516 : END DO
517 :
518 : ! Exit loop, if all atoms are in the list
519 110 : IF (sym%ulequatom(sym%ngroup) == natoms) EXIT loop
520 :
521 : ! Search for the next atom which is not in the list yet
522 160 : DO jatom = 2, natoms
523 100 : IF (.NOT. in_symequ_list(jatom, sym)) THEN
524 50 : iatom = jatom
525 50 : sym%ngroup = sym%ngroup + 1
526 50 : sym%llequatom(sym%ngroup) = sym%ulequatom(sym%ngroup - 1) + 1
527 50 : sym%ulequatom(sym%ngroup) = sym%llequatom(sym%ngroup)
528 50 : sym%symequ_list(sym%llequatom(sym%ngroup)) = iatom
529 50 : CYCLE loop
530 : END IF
531 : END DO
532 :
533 : END DO loop
534 :
535 : ! Generate list vector group_of
536 170 : DO i = 1, sym%ngroup
537 749 : DO iequatom = sym%llequatom(i), sym%ulequatom(i)
538 689 : sym%group_of(sym%symequ_list(iequatom)) = i
539 : END DO
540 : END DO
541 :
542 60 : END SUBROUTINE build_symequ_list
543 :
544 : ! **************************************************************************************************
545 : !> \brief Rotate the molecule about a n-fold axis defined by the vector a
546 : !> using a rotation angle of 2*pi/n. Check, if the axis is a Cn axis.
547 : !> \param n ...
548 : !> \param a ...
549 : !> \param sym ...
550 : !> \param coord ...
551 : !> \return ...
552 : !> \par History
553 : !> Creation (19.10.98, Matthias Krack)
554 : !> \author jgh
555 : ! **************************************************************************************************
556 5543 : FUNCTION caxis(n, a, sym, coord)
557 : INTEGER, INTENT(IN) :: n
558 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
559 : TYPE(molsym_type), INTENT(inout) :: sym
560 : REAL(Kind=dp), DIMENSION(:, :), INTENT(inout) :: coord
561 : LOGICAL :: caxis
562 :
563 : INTEGER :: iatom, natoms
564 : REAL(KIND=dp) :: length_of_a, phi
565 : REAL(KIND=dp), DIMENSION(3) :: b
566 :
567 5543 : caxis = .FALSE.
568 5543 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
569 :
570 : ! Check the length of the axis vector a
571 5543 : natoms = SIZE(coord, 2)
572 5543 : IF (length_of_a > sym%eps_geo) THEN
573 : ! Calculate the rotation angle phi and build up the rotation matrix rotmat
574 5409 : phi = 2.0_dp*pi/REAL(n, dp)
575 5409 : CALL build_rotmat(phi, a(:), sym%rotmat(:, :))
576 : ! Check all atoms
577 18830 : DO iatom = 1, natoms
578 : ! Rotate the actual atom by 2*pi/n about a
579 234507 : b(:) = MATMUL(sym%rotmat(:, :), coord(:, iatom))
580 : ! Check if the coordinates of the rotated atom
581 : ! are in the coordinate set of the molecule
582 18830 : IF (equatom(iatom, b(:), sym, coord) == 0) RETURN
583 : END DO
584 : ! The axis defined by vector a is a Cn axis, thus return with caxis = .TRUE.
585 : caxis = .TRUE.
586 : END IF
587 :
588 : END FUNCTION caxis
589 :
590 : ! **************************************************************************************************
591 : !> \brief Check for a point group of cubic symmetry (I,Ih,O,Oh,T,Th,Td).
592 : !> \param sym ...
593 : !> \param coord ...
594 : !> \param failed ...
595 : !> \par History
596 : !> Creation (19.10.98, Matthias Krack)
597 : !> \author jgh
598 : ! **************************************************************************************************
599 7 : SUBROUTINE cubsym(sym, coord, failed)
600 : TYPE(molsym_type), INTENT(inout) :: sym
601 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
602 : LOGICAL, INTENT(INOUT) :: failed
603 :
604 : INTEGER :: i, iatom, iax, ic3, isec, jatom, jc3, &
605 : jsec, katom, natoms, nc3
606 : REAL(KIND=dp) :: phi1, phi2, phidd, phidi, phiii
607 : REAL(KIND=dp), DIMENSION(3) :: a, b, c, d
608 :
609 : ! Angle between two adjacent atoms of the dodecahedron => <(C3,C3)
610 7 : phidd = ATAN(0.4_dp*SQRT(5.0_dp))
611 : ! Angle between two adjacent atoms of the icosahedron and the dodecahedron => <(C5,C3)
612 7 : phidi = ATAN(3.0_dp - SQRT(5.0_dp))
613 : ! Angle between two adjacent atoms of the icosahedron <(C5,C5)
614 7 : phiii = ATAN(2.0_dp)
615 :
616 : ! Find a pair of C3 axes
617 7 : natoms = SIZE(coord, 2)
618 146 : DO iatom = 1, natoms
619 : ! Check all atomic vectors for C3 axis
620 146 : IF (caxis(3, coord(:, iatom), sym, coord)) THEN
621 2 : CALL addsec(3, coord(:, iatom), sym)
622 2 : IF (sym%nsec(3) > 1) EXIT
623 : END IF
624 : END DO
625 :
626 : ! Check the center of mass vector of a triangle
627 : ! defined by three atomic vectors for C3 axis
628 7 : IF (sym%nsec(3) < 2) THEN
629 :
630 6 : loop: DO iatom = 1, natoms
631 24 : a(:) = coord(:, iatom)
632 24 : DO jatom = iatom + 1, natoms
633 734 : DO katom = jatom + 1, natoms
634 : IF ((ABS(dist(coord(:, iatom), coord(:, jatom)) &
635 716 : - dist(coord(:, iatom), coord(:, katom))) < sym%eps_geo) .AND. &
636 : (ABS(dist(coord(:, iatom), coord(:, jatom)) &
637 18 : - dist(coord(:, jatom), coord(:, katom))) < sym%eps_geo)) THEN
638 48 : b(:) = a(:) + coord(:, jatom) + coord(:, katom)
639 12 : IF (caxis(3, b(:), sym, coord)) THEN
640 12 : CALL addsec(3, b(:), sym)
641 12 : IF (sym%nsec(3) > 1) EXIT loop
642 : END IF
643 : END IF
644 : END DO
645 : END DO
646 : END DO loop
647 :
648 : END IF
649 :
650 : ! Return after unsuccessful search for a pair of C3 axes
651 7 : IF (sym%nsec(3) < 2) THEN
652 0 : failed = .TRUE.
653 0 : RETURN
654 : END IF
655 :
656 : ! Generate the remaining C3 axes
657 16 : nc3 = 0
658 : DO
659 16 : nc3 = sym%nsec(3)
660 82 : DO ic3 = 1, nc3
661 264 : a(:) = sym%sec(:, ic3, 3)
662 462 : DO jc3 = 1, nc3
663 446 : IF (ic3 /= jc3) THEN
664 1256 : d(:) = sym%sec(:, jc3, 3)
665 942 : DO i = 1, 2
666 628 : phi1 = 2.0_dp*REAL(i, KIND=dp)*pi/3.0_dp
667 628 : b(:) = rotate_vector(a(:), phi1, d(:))
668 942 : CALL addsec(3, b(:), sym)
669 : END DO
670 : END IF
671 : END DO
672 : END DO
673 :
674 16 : IF (sym%nsec(3) > nc3) THEN
675 : ! New C3 axes were found
676 : CYCLE
677 : ELSE
678 : ! In the case of I or Ih there have to be more C3 axes
679 7 : IF (sym%nsec(3) == 4) THEN
680 20 : a(:) = sym%sec(:, 1, 3)
681 20 : b(:) = sym%sec(:, 2, 3)
682 5 : phi1 = 0.5_dp*angle(a(:), b(:))
683 5 : IF (phi1 < 0.5_dp*pi) phi1 = phi1 - 0.5_dp*pi
684 5 : d(:) = vector_product(a(:), b(:))
685 5 : b(:) = rotate_vector(a(:), phi1, d(:))
686 20 : c(:) = sym%sec(:, 3, 3)
687 5 : phi1 = 0.5_dp*angle(a(:), c(:))
688 5 : IF (phi1 < 0.5_dp*pi) phi1 = phi1 - 0.5_dp*pi
689 5 : d(:) = vector_product(a(:), c(:))
690 5 : c(:) = rotate_vector(a(:), phi1, d(:))
691 5 : d(:) = vector_product(b(:), c(:))
692 5 : phi1 = 0.5_dp*phidd
693 5 : a(:) = rotate_vector(b(:), phi1, d(:))
694 5 : IF (caxis(3, a(:), sym, coord)) THEN
695 0 : CALL addsec(3, a(:), sym)
696 : ELSE
697 5 : phi2 = 0.5_dp*pi - phi1
698 5 : a(:) = rotate_vector(b(:), phi2, d(:))
699 5 : IF (caxis(3, a(:), sym, coord)) CALL addsec(3, a(:), sym)
700 : END IF
701 :
702 5 : IF (sym%nsec(3) > 4) CYCLE
703 :
704 2 : ELSE IF (sym%nsec(3) /= 10) THEN
705 :
706 : ! C3 axes found, but only 4 or 10 are possible
707 0 : failed = .TRUE.
708 0 : RETURN
709 :
710 : END IF
711 :
712 : ! Exit loop, if 4 or 10 C3 axes were found
713 9 : EXIT
714 :
715 : END IF
716 :
717 : END DO
718 :
719 : ! Loop over all pairs of C3 axes to find all C5, C4 and C2 axes
720 47 : DO isec = 1, sym%nsec(3)
721 :
722 160 : a(:) = sym%sec(:, isec, 3)
723 167 : DO jsec = isec + 1, sym%nsec(3)
724 120 : phi1 = 0.5_dp*angle(a(:), sym%sec(:, jsec, 3))
725 120 : d(:) = vector_product(a(:), sym%sec(:, jsec, 3))
726 :
727 : ! Check for C5 axis (I,Ih)
728 120 : IF (sym%nsec(3) == 10) THEN
729 90 : b(:) = rotate_vector(a(:), phidi, d(:))
730 90 : IF (caxis(5, b(:), sym, coord)) THEN
731 14 : CALL addsec(5, b(:), sym)
732 14 : phi1 = phidi + phiii
733 14 : b(:) = rotate_vector(a(:), phi1, d(:))
734 14 : IF (caxis(5, b(:), sym, coord)) CALL addsec(5, b(:), sym)
735 : END IF
736 : END IF
737 :
738 : ! Check for C4 (O,Oh), C2 and S2 (center of inversion) axis
739 360 : DO i = 0, 1
740 240 : phi2 = phi1 - 0.5_dp*REAL(i, KIND=dp)*pi
741 240 : b(:) = rotate_vector(a(:), phi2, d(:))
742 240 : IF (caxis(2, b(:), sym, coord)) THEN
743 134 : CALL addsec(2, b(:), sym)
744 134 : IF (sym%nsec(3) == 4) THEN
745 42 : IF (caxis(4, b(:), sym, coord)) CALL addsec(4, b(:), sym)
746 : END IF
747 134 : IF (saxis(2, b(:), sym, coord)) THEN
748 64 : CALL addses(2, b(:), sym)
749 64 : sym%invers = .TRUE.
750 : END IF
751 : END IF
752 360 : IF (sigma(b(:), sym, coord)) CALL addsig(b(:), sym)
753 : END DO
754 :
755 : ! Check for mirror plane
756 160 : IF (sigma(d(:), sym, coord)) CALL addsig(d(:), sym)
757 :
758 : END DO
759 :
760 : END DO
761 :
762 : ! Set the logical variables for point group determination
763 7 : iax = sym%ncn
764 :
765 7 : IF ((sym%ncn == 5) .AND. (sym%nsec(5) > 1)) THEN
766 2 : sym%igroup = .TRUE.
767 5 : ELSE IF ((sym%ncn == 4) .AND. (sym%nsec(4) > 1)) THEN
768 2 : sym%ogroup = .TRUE.
769 3 : ELSE IF ((sym%ncn == 3) .AND. (sym%nsec(3) > 1)) THEN
770 3 : sym%tgroup = .TRUE.
771 3 : IF ((.NOT. sym%invers) .AND. (sym%nsig > 0)) sym%sigmad = .TRUE.
772 : iax = 2
773 : ELSE
774 : ! No main axis found
775 0 : failed = .TRUE.
776 0 : RETURN
777 : END IF
778 :
779 : ! Rotate molecule to standard orientation
780 7 : phi1 = angle(sym%sec(:, 1, iax), sym%z_axis(:))
781 7 : d(:) = vector_product(sym%sec(:, 1, iax), sym%z_axis(:))
782 7 : CALL rotate_molecule(phi1, d(:), sym, coord)
783 :
784 28 : a(:) = sym%sec(:, 2, iax)
785 7 : a(3) = 0.0_dp
786 7 : phi2 = angle(a(:), sym%x_axis(:))
787 7 : d(:) = vector_product(a(:), sym%x_axis(:))
788 7 : CALL rotate_molecule(phi2, d(:), sym, coord)
789 :
790 : END SUBROUTINE cubsym
791 :
792 : ! **************************************************************************************************
793 : !> \brief The number of a equivalent atom to atoma is returned. If there
794 : !> is no equivalent atom, then zero is returned. The cartesian
795 : !> coordinates of the equivalent atom are defined by the vector a.
796 : !> \param atoma ...
797 : !> \param a ...
798 : !> \param sym ...
799 : !> \param coord ...
800 : !> \return ...
801 : !> \par History
802 : !> Creation (19.10.98, Matthias Krack)
803 : !> \author jgh
804 : ! **************************************************************************************************
805 38174 : FUNCTION equatom(atoma, a, sym, coord)
806 : INTEGER, INTENT(IN) :: atoma
807 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
808 : TYPE(molsym_type), INTENT(inout) :: sym
809 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
810 : INTEGER :: equatom
811 :
812 : INTEGER :: iatom, natoms
813 :
814 38174 : equatom = 0
815 38174 : natoms = SIZE(coord, 2)
816 413414 : DO iatom = 1, natoms
817 : IF ((ABS(sym%ain(iatom) - sym%ain(atoma)) < TINY(0.0_dp)) .AND. &
818 : (ABS(a(1) - coord(1, iatom)) < sym%eps_geo) .AND. &
819 400644 : (ABS(a(2) - coord(2, iatom)) < sym%eps_geo) .AND. &
820 12770 : (ABS(a(3) - coord(3, iatom)) < sym%eps_geo)) THEN
821 38174 : equatom = iatom
822 : RETURN
823 : END IF
824 : END DO
825 :
826 : END FUNCTION equatom
827 :
828 : ! **************************************************************************************************
829 : !> \brief Calculate the order of the point group.
830 : !> \param sym ...
831 : !> \par History
832 : !> Creation (19.10.98, Matthias Krack)
833 : !> \author jgh
834 : ! **************************************************************************************************
835 55 : SUBROUTINE get_point_group_order(sym)
836 : TYPE(molsym_type), INTENT(inout) :: sym
837 :
838 : INTEGER :: icn, incr, isec, ises, isn, jcn, jsn
839 :
840 : ! Count all symmetry elements of the symmetry group
841 : ! First E and all mirror planes
842 55 : sym%point_group_order = 1 + sym%nsig
843 :
844 : ! Loop over all C axes
845 249 : DO icn = 2, sym%ncn
846 545 : DO isec = 1, sym%nsec(icn)
847 1021 : DO jcn = 1, icn - 1
848 827 : IF (newse(jcn, icn)) sym%point_group_order = sym%point_group_order + 1
849 : END DO
850 : END DO
851 : END DO
852 :
853 : ! Loop over all S axes
854 55 : IF (sym%sigmah) THEN
855 : incr = 1
856 : ELSE
857 40 : incr = 2
858 : END IF
859 :
860 212 : DO isn = 2, sym%nsn
861 285 : DO ises = 1, sym%nses(isn)
862 452 : DO jsn = 1, isn - 1, incr
863 295 : IF (newse(jsn, isn)) sym%point_group_order = sym%point_group_order + 1
864 : END DO
865 : END DO
866 : END DO
867 :
868 55 : END SUBROUTINE get_point_group_order
869 :
870 : ! **************************************************************************************************
871 : !> \brief Get the point group symbol.
872 : !> \param sym ...
873 : !> \par History
874 : !> Creation (19.10.98, Matthias Krack)
875 : !> \author jgh
876 : ! **************************************************************************************************
877 59 : SUBROUTINE get_point_group_symbol(sym)
878 : TYPE(molsym_type), INTENT(inout) :: sym
879 :
880 : CHARACTER(LEN=4) :: degree
881 :
882 59 : IF (sym%linear) THEN
883 4 : IF (sym%invers) THEN
884 3 : sym%point_group_symbol = "D*h"
885 : ELSE
886 1 : sym%point_group_symbol = "C*v"
887 : END IF
888 55 : ELSE IF (sym%cubic) THEN
889 7 : IF (sym%igroup) THEN
890 2 : sym%point_group_symbol = "I"
891 5 : ELSE IF (sym%ogroup) THEN
892 2 : sym%point_group_symbol = "O"
893 3 : ELSE IF (sym%tgroup) THEN
894 3 : sym%point_group_symbol = "T"
895 : END IF
896 7 : IF (sym%invers) THEN
897 3 : sym%point_group_symbol = TRIM(sym%point_group_symbol)//"h"
898 4 : ELSE IF (sym%sigmad) THEN
899 1 : sym%point_group_symbol = TRIM(sym%point_group_symbol)//"d"
900 : END IF
901 48 : ELSE IF (sym%maxis) THEN
902 45 : IF (sym%dgroup) THEN
903 21 : WRITE (degree, "(I3)") sym%ncn
904 21 : sym%point_group_symbol = "D"//TRIM(ADJUSTL(degree))
905 21 : IF (sym%sigmah) THEN
906 7 : sym%point_group_symbol = TRIM(sym%point_group_symbol)//"h"
907 14 : ELSE IF (sym%sigmad) THEN
908 7 : sym%point_group_symbol = TRIM(sym%point_group_symbol)//"d"
909 : END IF
910 24 : ELSE IF (sym%sgroup) THEN
911 3 : WRITE (degree, "(I3)") sym%nsn
912 3 : sym%point_group_symbol = "S"//TRIM(ADJUSTL(degree))
913 : ELSE
914 21 : WRITE (degree, "(I3)") sym%ncn
915 21 : sym%point_group_symbol = "C"//TRIM(ADJUSTL(degree))
916 21 : IF (sym%sigmah) THEN
917 7 : sym%point_group_symbol = TRIM(sym%point_group_symbol)//"h"
918 14 : ELSE IF (sym%sigmav) THEN
919 7 : sym%point_group_symbol = TRIM(sym%point_group_symbol)//"v"
920 : END IF
921 : END IF
922 : ELSE
923 3 : IF (sym%invers) THEN
924 1 : sym%point_group_symbol = "Ci"
925 2 : ELSE IF (sym%sigmah) THEN
926 1 : sym%point_group_symbol = "Cs"
927 : ELSE
928 1 : sym%point_group_symbol = "C1"
929 : END IF
930 : END IF
931 :
932 59 : END SUBROUTINE get_point_group_symbol
933 :
934 : ! **************************************************************************************************
935 : !> \brief Rotational symmetry number, i.e. the order of the pure rotation subgroup (including E).
936 : !> \param sym ...
937 : !> \return ...
938 : ! **************************************************************************************************
939 2 : FUNCTION get_symmetry_number(sym) RESULT(sym_num)
940 : TYPE(molsym_type), INTENT(in) :: sym
941 : INTEGER :: sym_num
942 :
943 2 : IF (sym%linear) THEN
944 2 : IF (sym%invers) THEN
945 : sym_num = 2
946 : ELSE
947 0 : sym_num = 1
948 : END IF
949 0 : ELSE IF (sym%cubic) THEN
950 0 : IF (sym%igroup) THEN
951 : sym_num = 60
952 0 : ELSE IF (sym%ogroup) THEN
953 : sym_num = 24
954 : ELSE
955 0 : sym_num = 12
956 : END IF
957 0 : ELSE IF (sym%maxis) THEN
958 0 : IF (sym%dgroup) THEN
959 0 : sym_num = 2*sym%ncn
960 0 : ELSE IF (sym%sgroup) THEN
961 0 : sym_num = MAX(1, sym%nsn/2)
962 : ELSE
963 0 : sym_num = sym%ncn
964 : END IF
965 : ELSE
966 : sym_num = 1
967 : END IF
968 :
969 2 : END FUNCTION get_symmetry_number
970 :
971 : ! **************************************************************************************************
972 : !> \brief Initialization of the global variables of module symmetry.
973 : !> \param sym ...
974 : !> \param atype ...
975 : !> \param weight ...
976 : !> \par History
977 : !> Creation (19.10.98, Matthias Krack)
978 : !> \author jgh
979 : ! **************************************************************************************************
980 60 : SUBROUTINE init_symmetry(sym, atype, weight)
981 : TYPE(molsym_type), INTENT(inout) :: sym
982 : INTEGER, DIMENSION(:), INTENT(IN) :: atype
983 : REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: weight
984 :
985 : INTEGER :: i, iatom, natoms
986 :
987 : ! Define the Cartesian axis vectors
988 240 : sym%x_axis = [1.0_dp, 0.0_dp, 0.0_dp]
989 240 : sym%y_axis = [0.0_dp, 1.0_dp, 0.0_dp]
990 240 : sym%z_axis = [0.0_dp, 0.0_dp, 1.0_dp]
991 :
992 : ! Initialize lists for symmetry elements
993 96960 : sym%sec(:, :, :) = 0.0_dp
994 386160 : sym%ses(:, :, :) = 0.0_dp
995 5100 : sym%sig(:, :) = 0.0_dp
996 :
997 240 : sym%center_of_mass(:) = 0.0_dp
998 :
999 : ! Initialize symmetry element counters
1000 60 : sym%ncn = 1
1001 60 : sym%nsn = 1
1002 1260 : sym%nsec(:) = 0
1003 2460 : sym%nses(:) = 0
1004 60 : sym%nsig = 0
1005 :
1006 : ! Initialize logical variables
1007 60 : sym%cubic = .FALSE.
1008 60 : sym%dgroup = .FALSE.
1009 60 : sym%igroup = .FALSE.
1010 60 : sym%invers = .FALSE.
1011 60 : sym%linear = .FALSE.
1012 60 : sym%maxis = .FALSE.
1013 60 : sym%ogroup = .FALSE.
1014 60 : sym%sgroup = .FALSE.
1015 60 : sym%sigmad = .FALSE.
1016 60 : sym%sigmah = .FALSE.
1017 60 : sym%sigmav = .FALSE.
1018 60 : sym%tgroup = .FALSE.
1019 :
1020 : ! Initialize list of equivalent atoms (C1 symmetry)
1021 60 : natoms = SIZE(sym%nequatom)
1022 60 : sym%ngroup = natoms
1023 639 : sym%nequatom(:) = 1
1024 639 : DO i = 1, sym%ngroup
1025 579 : sym%group_of(i) = i
1026 579 : sym%llequatom(i) = i
1027 579 : sym%symequ_list(i) = i
1028 639 : sym%ulequatom(i) = i
1029 : END DO
1030 :
1031 60 : sym%point_group_order = -1
1032 :
1033 639 : DO iatom = 1, natoms
1034 639 : sym%aw(iatom) = weight(iatom)
1035 : END DO
1036 :
1037 : ! Generate atomic identification numbers (symmetry code) ***
1038 639 : sym%ain(:) = REAL(atype(:), KIND=dp) + sym%aw(:)
1039 :
1040 : ! Initialize the transformation matrix for input orientation -> standard orientation
1041 60 : CALL unit_matrix(sym%inptostd(:, :))
1042 :
1043 60 : END SUBROUTINE init_symmetry
1044 :
1045 : ! **************************************************************************************************
1046 : !> \brief Return .TRUE., if the atom atoma is in the list symequ_list.
1047 : !> \param atoma ...
1048 : !> \param sym ...
1049 : !> \return ...
1050 : !> \par History
1051 : !> Creation (21.04.95, Matthias Krack)
1052 : !> \author jgh
1053 : ! **************************************************************************************************
1054 1213 : FUNCTION in_symequ_list(atoma, sym)
1055 : INTEGER, INTENT(IN) :: atoma
1056 : TYPE(molsym_type), INTENT(inout) :: sym
1057 : LOGICAL :: in_symequ_list
1058 :
1059 : INTEGER :: iatom
1060 :
1061 1213 : in_symequ_list = .FALSE.
1062 :
1063 7973 : DO iatom = 1, sym%ulequatom(sym%ngroup)
1064 7973 : IF (sym%symequ_list(iatom) == atoma) THEN
1065 1213 : in_symequ_list = .TRUE.
1066 : RETURN
1067 : END IF
1068 : END DO
1069 :
1070 : END FUNCTION in_symequ_list
1071 :
1072 : ! **************************************************************************************************
1073 : !> \brief Search for point groups of LOW SYMmetry (Ci,Cs).
1074 : !> \param sym ...
1075 : !> \param coord ...
1076 : !> \par History
1077 : !> Creation (21.04.95, Matthias Krack)
1078 : !> \author jgh
1079 : ! **************************************************************************************************
1080 3 : SUBROUTINE lowsym(sym, coord)
1081 : TYPE(molsym_type), INTENT(inout) :: sym
1082 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1083 :
1084 : REAL(KIND=dp) :: phi
1085 : REAL(KIND=dp), DIMENSION(3) :: d
1086 :
1087 3 : IF (sym%nsn == 2) THEN
1088 : ! Ci
1089 1 : sym%invers = .TRUE.
1090 1 : phi = angle(sym%ses(:, 1, 2), sym%z_axis(:))
1091 1 : d(:) = vector_product(sym%ses(:, 1, 2), sym%z_axis(:))
1092 1 : CALL rotate_molecule(phi, d(:), sym, coord)
1093 2 : ELSE IF (sym%nsig == 1) THEN
1094 : ! Cs
1095 1 : sym%sigmah = .TRUE.
1096 1 : phi = angle(sym%sig(:, 1), sym%z_axis(:))
1097 1 : d(:) = vector_product(sym%sig(:, 1), sym%z_axis(:))
1098 1 : CALL rotate_molecule(phi, d(:), sym, coord)
1099 : END IF
1100 :
1101 3 : END SUBROUTINE lowsym
1102 :
1103 : ! **************************************************************************************************
1104 : !> \brief Main program for symmetry analysis.
1105 : !> \param sym ...
1106 : !> \param eps_geo ...
1107 : !> \param coord ...
1108 : !> \param atype ...
1109 : !> \param weight ...
1110 : !> \par History
1111 : !> Creation (14.11.98, Matthias Krack)
1112 : !> \author jgh
1113 : ! **************************************************************************************************
1114 60 : SUBROUTINE molecular_symmetry(sym, eps_geo, coord, atype, weight)
1115 : TYPE(molsym_type), POINTER :: sym
1116 : REAL(KIND=dp), INTENT(IN) :: eps_geo
1117 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1118 : INTEGER, DIMENSION(:), INTENT(IN) :: atype
1119 : REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: weight
1120 :
1121 : CHARACTER(LEN=*), PARAMETER :: routineN = 'molecular_symmetry'
1122 :
1123 : INTEGER :: handle, natoms
1124 :
1125 60 : CALL timeset(routineN, handle)
1126 :
1127 : ! Perform memory allocation for the symmetry analysis
1128 60 : natoms = SIZE(coord, 2)
1129 60 : CALL create_molsym(sym, natoms)
1130 60 : sym%eps_geo = eps_geo
1131 :
1132 : ! Initialization of symmetry analysis
1133 60 : CALL init_symmetry(sym, atype, weight)
1134 :
1135 60 : IF (natoms == 1) THEN
1136 : ! Special case: only one atom
1137 1 : CALL atomsym(sym)
1138 : ELSE
1139 : ! Find molecular symmetry
1140 59 : CALL moleculesym(sym, coord)
1141 : ! Get point group and load point group table
1142 59 : CALL get_point_group_symbol(sym)
1143 : END IF
1144 :
1145 : ! Calculate group order
1146 60 : IF (.NOT. sym%linear) CALL get_point_group_order(sym)
1147 :
1148 : ! Generate a list of equivalent atoms
1149 60 : CALL build_symequ_list(sym, coord)
1150 :
1151 60 : CALL timestop(handle)
1152 :
1153 60 : END SUBROUTINE molecular_symmetry
1154 :
1155 : ! **************************************************************************************************
1156 : !> \brief Find the molecular symmetry.
1157 : !> \param sym ...
1158 : !> \param coord ...
1159 : !> \par History
1160 : !> Creation (14.11.98, Matthias Krack)
1161 : !> \author jgh
1162 : ! **************************************************************************************************
1163 59 : SUBROUTINE moleculesym(sym, coord)
1164 : TYPE(molsym_type), INTENT(inout) :: sym
1165 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1166 :
1167 : INTEGER :: icn, isec, isn
1168 : LOGICAL :: failed
1169 : REAL(KIND=dp) :: eps_tenval
1170 :
1171 : ! Tolerance of degenerate eigenvalues for the molecular tensor of inertia
1172 :
1173 59 : eps_tenval = 0.01_dp*sym%eps_geo
1174 :
1175 : ! Calculate the molecular tensor of inertia
1176 59 : CALL tensor(sym, coord)
1177 : ! Use symmetry information from the eigenvalues of the molecular tensor of inertia
1178 59 : IF ((sym%tenval(3) - sym%tenval(1)) < eps_tenval) THEN
1179 : ! 0 < tenval(1) = tenval(2) = tenval(3)
1180 7 : sym%cubic = .TRUE.
1181 52 : ELSE IF ((sym%tenval(3) - sym%tenval(2)) < eps_tenval) THEN
1182 : ! 0 < tenval(1) < tenval(2) = tenval(3)
1183 : ! special case: 0 = tenval(1) < tenval(2) = tenval(3)
1184 16 : IF (sym%tenval(1) < eps_tenval) sym%linear = .TRUE.
1185 16 : CALL tracar(sym, coord, [3, 1, 2])
1186 : ELSE
1187 : ! 0 < tenval(1) = tenval(2) < tenval(3) or 0 < tenval(1) < tenval(2) < tenval(3)
1188 36 : CALL tracar(sym, coord, [1, 2, 3])
1189 : END IF
1190 :
1191 : ! Continue with the new coordinate axes
1192 : DO
1193 59 : failed = .FALSE.
1194 59 : IF (sym%cubic) THEN
1195 7 : CALL cubsym(sym, coord, failed)
1196 7 : IF (failed) THEN
1197 0 : sym%cubic = .FALSE.
1198 0 : CYCLE
1199 : END IF
1200 :
1201 52 : ELSE IF (sym%linear) THEN
1202 :
1203 : ! Linear molecule
1204 4 : IF (saxis(2, sym%z_axis(:), sym, coord)) THEN
1205 3 : sym%invers = .TRUE.
1206 3 : sym%dgroup = .TRUE.
1207 3 : sym%sigmah = .TRUE.
1208 : END IF
1209 :
1210 : ELSE
1211 :
1212 : ! Check the new coordinate axes for Cn axes
1213 960 : DO icn = 2, maxcn
1214 912 : IF (caxis(icn, sym%z_axis(:), sym, coord)) CALL addsec(icn, sym%z_axis(:), sym)
1215 912 : IF (caxis(icn, sym%x_axis(:), sym, coord)) CALL addsec(icn, sym%x_axis(:), sym)
1216 960 : IF (caxis(icn, sym%y_axis(:), sym, coord)) CALL addsec(icn, sym%y_axis(:), sym)
1217 : END DO
1218 :
1219 : ! Check the new coordinate axes for Sn axes
1220 1920 : DO isn = 2, maxsn
1221 1872 : IF (saxis(isn, sym%z_axis(:), sym, coord)) CALL addses(isn, sym%z_axis(:), sym)
1222 1872 : IF (saxis(isn, sym%x_axis(:), sym, coord)) CALL addses(isn, sym%x_axis(:), sym)
1223 1920 : IF (saxis(isn, sym%y_axis(:), sym, coord)) CALL addses(isn, sym%y_axis(:), sym)
1224 : END DO
1225 :
1226 : ! Check the new coordinate planes for mirror planes
1227 48 : IF (sigma(sym%z_axis(:), sym, coord)) CALL addsig(sym%z_axis(:), sym)
1228 48 : IF (sigma(sym%x_axis(:), sym, coord)) CALL addsig(sym%x_axis(:), sym)
1229 48 : IF (sigma(sym%y_axis(:), sym, coord)) CALL addsig(sym%y_axis(:), sym)
1230 :
1231 : ! There is a main axis (MAXIS = .TRUE.)
1232 48 : IF ((sym%ncn > 1) .OR. (sym%nsn > 3)) THEN
1233 45 : sym%maxis = .TRUE.
1234 45 : CALL axsym(coord, sym)
1235 : ELSE
1236 : ! Only low or no symmetry (Ci, Cs or C1)
1237 3 : CALL lowsym(sym, coord)
1238 : END IF
1239 :
1240 : END IF
1241 :
1242 59 : IF (.NOT. failed) EXIT
1243 :
1244 : END DO
1245 :
1246 : ! Find the remaining S axes
1247 59 : IF (.NOT. sym%linear) THEN
1248 249 : DO icn = 2, sym%ncn
1249 545 : DO isec = 1, sym%nsec(icn)
1250 296 : IF (saxis(icn, sym%sec(:, isec, icn), sym, coord)) THEN
1251 89 : CALL addses(icn, sym%sec(:, isec, icn), sym)
1252 : END IF
1253 490 : IF (saxis(2*icn, sym%sec(:, isec, icn), sym, coord)) THEN
1254 49 : CALL addses(2*icn, sym%sec(:, isec, icn), sym)
1255 : END IF
1256 : END DO
1257 : END DO
1258 : END IF
1259 :
1260 : ! Remove redundant S2 axes
1261 59 : IF (sym%nses(2) > 0) THEN
1262 16 : sym%nses(1) = sym%nses(1) - sym%nses(2)
1263 16 : sym%nses(2) = 0
1264 16 : CALL addses(2, sym%z_axis(:), sym)
1265 : END IF
1266 :
1267 59 : END SUBROUTINE moleculesym
1268 :
1269 : ! **************************************************************************************************
1270 : !> \brief The number of atoms which are placed on an axis defined by the vector a is returned.
1271 : !> \param a ...
1272 : !> \param coord ...
1273 : !> \param sym ...
1274 : !> \return ...
1275 : !> \par History
1276 : !> Creation (16.11.98, Matthias Krack)
1277 : !> \author jgh
1278 : ! **************************************************************************************************
1279 76 : FUNCTION naxis(a, coord, sym)
1280 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
1281 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1282 : TYPE(molsym_type), INTENT(inout) :: sym
1283 : INTEGER :: naxis
1284 :
1285 : INTEGER :: iatom, natoms
1286 : REAL(KIND=dp) :: length_of_a, length_of_b, scapro
1287 : REAL(KIND=dp), DIMENSION(3) :: a_norm, b, b_norm
1288 :
1289 76 : naxis = 0
1290 76 : natoms = SIZE(coord, 2)
1291 :
1292 76 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
1293 :
1294 : ! Check the length of vector a
1295 76 : IF (length_of_a > sym%eps_geo) THEN
1296 :
1297 956 : DO iatom = 1, natoms
1298 3520 : b(:) = coord(:, iatom)
1299 880 : length_of_b = SQRT(b(1)*b(1) + b(2)*b(2) + b(3)*b(3))
1300 : ! An atom in the origin counts for each axis
1301 956 : IF (length_of_b < sym%eps_geo) THEN
1302 0 : naxis = naxis + 1
1303 : ELSE
1304 3520 : a_norm = a(:)/length_of_a
1305 3520 : b_norm = b(:)/length_of_b
1306 880 : scapro = a_norm(1)*b_norm(1) + a_norm(2)*b_norm(2) + a_norm(3)*b_norm(3)
1307 880 : IF (ABS(ABS(scapro) - 1.0_dp) < sym%eps_geo) naxis = naxis + 1
1308 : END IF
1309 : END DO
1310 :
1311 : END IF
1312 :
1313 76 : END FUNCTION naxis
1314 :
1315 : ! **************************************************************************************************
1316 : !> \brief Return .FALSE., if the symmetry elements se1 and se2 are a pair of
1317 : !> redundant symmetry elements.
1318 : !> \param se1 ...
1319 : !> \param se2 ...
1320 : !> \return ...
1321 : !> \par History
1322 : !> Creation (16.11.98, Matthias Krack)
1323 : !> \author jgh
1324 : ! **************************************************************************************************
1325 1802 : FUNCTION newse(se1, se2)
1326 : INTEGER, INTENT(IN) :: se1, se2
1327 : LOGICAL :: newse
1328 :
1329 : INTEGER :: ise
1330 :
1331 1802 : newse = .TRUE.
1332 :
1333 3878 : DO ise = 2, MIN(se1, se2)
1334 3878 : IF ((MODULO(se1, ise) == 0) .AND. (MODULO(se2, ise) == 0)) THEN
1335 1802 : newse = .FALSE.
1336 : RETURN
1337 : END IF
1338 : END DO
1339 :
1340 : END FUNCTION newse
1341 :
1342 : ! **************************************************************************************************
1343 : !> \brief The number of atoms which are placed in a plane defined by the
1344 : !> the normal vector a is returned.
1345 : !> \param a ...
1346 : !> \param sym ...
1347 : !> \param coord ...
1348 : !> \return ...
1349 : !> \par History
1350 : !> Creation (16.11.98, Matthias Krack)
1351 : !> \author jgh
1352 : ! **************************************************************************************************
1353 105 : FUNCTION nsigma(a, sym, coord)
1354 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
1355 : TYPE(molsym_type), INTENT(inout) :: sym
1356 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1357 : INTEGER :: nsigma
1358 :
1359 : INTEGER :: iatom, natoms
1360 : REAL(KIND=dp) :: length_of_a, length_of_b, scapro
1361 : REAL(KIND=dp), DIMENSION(3) :: a_norm, b, b_norm
1362 :
1363 105 : nsigma = 0
1364 :
1365 105 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
1366 :
1367 : ! Check the length of vector a
1368 105 : IF (length_of_a > sym%eps_geo) THEN
1369 105 : natoms = SIZE(coord, 2)
1370 998 : DO iatom = 1, natoms
1371 3572 : b(:) = coord(:, iatom)
1372 893 : length_of_b = SQRT(b(1)*b(1) + b(2)*b(2) + b(3)*b(3))
1373 : ! An atom in the origin counts for each mirror plane
1374 998 : IF (length_of_b < sym%eps_geo) THEN
1375 0 : nsigma = nsigma + 1
1376 : ELSE
1377 3572 : a_norm = a(:)/length_of_a
1378 3572 : b_norm = b(:)/length_of_b
1379 893 : scapro = a_norm(1)*b_norm(1) + a_norm(2)*b_norm(2) + a_norm(3)*b_norm(3)
1380 893 : IF (ABS(scapro) < sym%eps_geo) nsigma = nsigma + 1
1381 : END IF
1382 : END DO
1383 : END IF
1384 :
1385 105 : END FUNCTION nsigma
1386 :
1387 : ! **************************************************************************************************
1388 : !> \brief Style the output of the symmetry elements.
1389 : !> \param se ...
1390 : !> \param eps ...
1391 : !> \par History
1392 : !> Creation (16.11.98, Matthias Krack)
1393 : !> \author jgh
1394 : ! **************************************************************************************************
1395 522 : SUBROUTINE outse(se, eps)
1396 : REAL(KIND=dp), DIMENSION(3), INTENT(INOUT) :: se
1397 : REAL(KIND=dp), INTENT(IN) :: eps
1398 :
1399 : ! Positive z component for all vectors
1400 :
1401 522 : IF (ABS(se(3)) < eps) THEN
1402 255 : IF (ABS(se(1)) < eps) THEN
1403 47 : se(2) = -se(2)
1404 : ELSE
1405 448 : IF (se(1) < 0.0_dp) se(1:2) = -se(1:2)
1406 : END IF
1407 : ELSE
1408 471 : IF (se(3) < 0.0_dp) se(:) = -se(:)
1409 : END IF
1410 :
1411 522 : END SUBROUTINE outse
1412 :
1413 : ! **************************************************************************************************
1414 : !> \brief Print the output of the symmetry analysis.
1415 : !> \param sym ...
1416 : !> \param coord ...
1417 : !> \param atype ...
1418 : !> \param element ...
1419 : !> \param z ...
1420 : !> \param weight ...
1421 : !> \param iw ...
1422 : !> \param plevel ...
1423 : !> \par History
1424 : !> Creation (16.11.98, Matthias Krack)
1425 : !> \author jgh
1426 : ! **************************************************************************************************
1427 58 : SUBROUTINE print_symmetry(sym, coord, atype, element, z, weight, iw, plevel)
1428 : TYPE(molsym_type), INTENT(inout) :: sym
1429 : REAL(KIND=dp), DIMENSION(:, :), INTENT(in) :: coord
1430 : INTEGER, DIMENSION(:), INTENT(in) :: atype
1431 : CHARACTER(LEN=*), DIMENSION(:), INTENT(in) :: element
1432 : INTEGER, DIMENSION(:), INTENT(in) :: z
1433 : REAL(KIND=dp), DIMENSION(:), INTENT(in) :: weight
1434 : INTEGER, INTENT(IN) :: iw, plevel
1435 :
1436 : REAL(KIND=dp), PARAMETER :: formatmaxval = 1.0E5_dp
1437 :
1438 : CHARACTER(LEN=3) :: string
1439 : INTEGER :: i, icn, iequatom, isec, ises, isig, isn, &
1440 : j, nequatom, secount
1441 58 : INTEGER, ALLOCATABLE, DIMENSION(:) :: equatomlist, idxlist
1442 :
1443 : ! Print point group symbol and point group order
1444 : WRITE (iw, "(/,(T2,A))") &
1445 58 : "MOLSYM| Molecular symmetry information", &
1446 116 : "MOLSYM|"
1447 : WRITE (iw, "(T2,A,T77,A4)") &
1448 58 : "MOLSYM| Point group", ADJUSTR(sym%point_group_symbol)
1449 58 : IF (sym%point_group_order > -1) THEN
1450 : WRITE (iw, "(T2,A,T77,I4)") &
1451 55 : "MOLSYM| Group order ", sym%point_group_order
1452 : END IF
1453 :
1454 58 : IF (MOD(plevel, 10) == 1) THEN
1455 : WRITE (iw, "(T2,A)") &
1456 58 : "MOLSYM|", &
1457 116 : "MOLSYM| Groups of atoms equivalent by symmetry"
1458 : WRITE (iw, "(T2,A,T31,A)") &
1459 58 : "MOLSYM| Group number", "Group members (atomic indices)"
1460 164 : DO i = 1, sym%ngroup
1461 106 : nequatom = sym%ulequatom(i) - sym%llequatom(i) + 1
1462 106 : CPASSERT(nequatom > 0)
1463 424 : ALLOCATE (equatomlist(nequatom), idxlist(nequatom))
1464 681 : equatomlist(1:nequatom) = sym%symequ_list(sym%llequatom(i):sym%ulequatom(i))
1465 106 : idxlist = 0
1466 106 : CALL sort(equatomlist, nequatom, idxlist)
1467 : WRITE (iw, "(T2,A,T10,I5,T16,I6,T31,10(1X,I4),/,(T2,'MOLSYM|',T31,10(1X,I4)))") &
1468 106 : "MOLSYM|", i, nequatom, (equatomlist(iequatom), iequatom=1, nequatom)
1469 164 : DEALLOCATE (equatomlist, idxlist)
1470 : END DO
1471 : END IF
1472 :
1473 58 : IF (MOD(plevel/100, 10) == 1) THEN
1474 : ! Print all symmetry elements
1475 : WRITE (iw, "(T2,A,/,T2,A,/,T2,A,T31,A,T45,A,T60,A,T75,A)") &
1476 58 : "MOLSYM|", &
1477 58 : "MOLSYM| Symmetry elements", &
1478 116 : "MOLSYM| Element number", "Type", "X", "Y", "Z"
1479 58 : secount = 1
1480 : WRITE (iw, "(T2,A,T12,I5,T19,I5,T32,A1,T36,3(1X,F14.8))") &
1481 58 : "MOLSYM|", secount, secount, "E", 0.0_dp, 0.0_dp, 0.0_dp
1482 : ! Mirror planes
1483 58 : string = "@ "
1484 211 : DO isig = 1, sym%nsig
1485 153 : secount = secount + 1
1486 153 : CALL outse(sym%sig(:, isig), sym%eps_geo)
1487 : WRITE (iw, "(T2,A,T12,I5,T19,I5,T32,A3,T36,3(1X,F14.8))") &
1488 670 : "MOLSYM|", secount, isig, string, (sym%sig(i, isig), i=1, 3)
1489 : END DO
1490 : ! C axes
1491 252 : DO icn = 2, sym%ncn
1492 194 : IF (icn < 10) THEN
1493 194 : WRITE (string, "(A1,I1)") "C", icn
1494 : ELSE
1495 0 : WRITE (string, "(A1,I2)") "C", icn
1496 : END IF
1497 548 : DO isec = 1, sym%nsec(icn)
1498 296 : secount = secount + 1
1499 296 : CALL outse(sym%sec(:, isec, icn), sym%eps_geo)
1500 : WRITE (iw, "(T2,A,T12,I5,T19,I5,T32,A3,T36,3(1X,F14.8))") &
1501 1378 : "MOLSYM|", secount, isec, string, (sym%sec(i, isec, icn), i=1, 3)
1502 : END DO
1503 : END DO
1504 : ! S axes
1505 215 : DO isn = 2, sym%nsn
1506 157 : IF (isn == 2) THEN
1507 29 : WRITE (string, "(A3)") "i "
1508 128 : ELSE IF (isn < 10) THEN
1509 111 : WRITE (string, "(A1,I1)") "S", isn
1510 : ELSE
1511 17 : WRITE (string, "(A1,I2)") "S", isn
1512 : END IF
1513 288 : DO ises = 1, sym%nses(isn)
1514 73 : secount = secount + 1
1515 73 : CALL outse(sym%ses(:, ises, isn), sym%eps_geo)
1516 : WRITE (iw, "(T2,A,T12,I5,T19,I5,T32,A3,T36,3(1X,F14.8))") &
1517 449 : "MOLSYM|", secount, ises, string, (sym%ses(i, ises, icn), i=1, 3)
1518 : END DO
1519 : END DO
1520 : END IF
1521 :
1522 58 : IF (MOD(plevel/10, 10) == 1 .AND. SIZE(coord, 2) > 1) THEN
1523 : ! Print the moments of the molecular inertia tensor
1524 : WRITE (iw, "(T2,A,/,T2,A,/,T2,A,T43,A,T58,A,T73,A)") &
1525 57 : "MOLSYM|", &
1526 57 : "MOLSYM| Moments of the molecular inertia tensor [a.u.]", &
1527 114 : "MOLSYM|", "I(x)", "I(y)", "I(z)"
1528 57 : string = "xyz"
1529 741 : IF (MAXVAL(sym%tenmat) >= formatmaxval) THEN
1530 0 : DO i = 1, 3
1531 : WRITE (iw, "(T2,A,T32,A,T36,3(1X,ES14.4))") &
1532 0 : "MOLSYM|", "I("//string(i:i)//")", (sym%tenmat(i, j), j=1, 3)
1533 : END DO
1534 : ELSE
1535 228 : DO i = 1, 3
1536 : WRITE (iw, "(T2,A,T32,A,T36,3(1X,F14.8))") &
1537 741 : "MOLSYM|", "I("//string(i:i)//")", (sym%tenmat(i, j), j=1, 3)
1538 : END DO
1539 : END IF
1540 : WRITE (iw, "(T2,A)") &
1541 57 : "MOLSYM|", &
1542 114 : "MOLSYM| Principal moments and axes of inertia [a.u.]"
1543 741 : IF (MAXVAL(sym%tenmat) >= formatmaxval) THEN
1544 : WRITE (iw, "(T2,A,T36,3(1X,ES14.4))") &
1545 0 : "MOLSYM|", (sym%tenval(i), i=1, 3)
1546 : ELSE
1547 : WRITE (iw, "(T2,A,T36,3(1X,F14.8))") &
1548 228 : "MOLSYM|", (sym%tenval(i), i=1, 3)
1549 : END IF
1550 228 : DO i = 1, 3
1551 : WRITE (iw, "(T2,A,T32,A,T36,3(1X,F14.8))") &
1552 741 : "MOLSYM|", string(i:i), (sym%tenvec(i, j), j=1, 3)
1553 : END DO
1554 : END IF
1555 :
1556 58 : IF (MOD(plevel, 10) == 1) THEN
1557 : ! Print the Cartesian coordinates of the standard orientation
1558 58 : CALL write_coordinates(coord, atype, element, z, weight, iw)
1559 : END IF
1560 :
1561 58 : END SUBROUTINE print_symmetry
1562 :
1563 : ! **************************************************************************************************
1564 : !> \brief Rotate the molecule about an axis defined by the vector a. The
1565 : !> rotation angle is phi (radians).
1566 : !> \param phi ...
1567 : !> \param a ...
1568 : !> \param sym ...
1569 : !> \param coord ...
1570 : !> \par History
1571 : !> Creation (16.11.98, Matthias Krack)
1572 : !> \author jgh
1573 : ! **************************************************************************************************
1574 87 : SUBROUTINE rotate_molecule(phi, a, sym, coord)
1575 : REAL(KIND=dp), INTENT(IN) :: phi
1576 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
1577 : TYPE(molsym_type), INTENT(inout) :: sym
1578 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1579 :
1580 : INTEGER :: i
1581 : REAL(KIND=dp) :: length_of_a
1582 :
1583 : ! Check the length of vector a
1584 87 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
1585 87 : IF (length_of_a > sym%eps_geo) THEN
1586 :
1587 : ! Build up the rotation matrix
1588 42 : CALL build_rotmat(phi, a(:), sym%rotmat(:, :))
1589 :
1590 : ! Rotate the molecule by phi around a
1591 10689 : coord(:, :) = MATMUL(sym%rotmat(:, :), coord(:, :))
1592 :
1593 : ! Rotate the normal vectors of the mirror planes which are already found
1594 3339 : sym%sig(:, 1:sym%nsig) = MATMUL(sym%rotmat(:, :), sym%sig(:, 1:sym%nsig))
1595 :
1596 : ! Rotate the Cn axes which are already found
1597 186 : DO i = 2, sym%ncn
1598 6843 : sym%sec(:, 1:sym%nsec(i), i) = MATMUL(sym%rotmat(:, :), sym%sec(:, 1:sym%nsec(i), i))
1599 : END DO
1600 :
1601 : ! Rotate the Sn axes which are already found
1602 134 : DO i = 2, sym%nsn
1603 2150 : sym%ses(:, 1:sym%nses(i), i) = MATMUL(sym%rotmat(:, :), sym%ses(:, 1:sym%nses(i), i))
1604 : END DO
1605 :
1606 : ! Store current rotation
1607 2688 : sym%inptostd(:, :) = MATMUL(sym%rotmat(:, :), sym%inptostd(:, :))
1608 :
1609 : END IF
1610 :
1611 87 : END SUBROUTINE rotate_molecule
1612 :
1613 : ! **************************************************************************************************
1614 : !> \brief Rotate the molecule about a n-fold axis defined by the vector a
1615 : !> using a rotation angle of 2*pi/n. Check, if the axis is a Cn axis.
1616 : !> \param n ...
1617 : !> \param a ...
1618 : !> \param sym ...
1619 : !> \param coord ...
1620 : !> \return ...
1621 : !> \par History
1622 : !> Creation (16.11.98, Matthias Krack)
1623 : !> \author jgh
1624 : ! **************************************************************************************************
1625 6346 : FUNCTION saxis(n, a, sym, coord)
1626 : INTEGER, INTENT(IN) :: n
1627 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
1628 : TYPE(molsym_type), INTENT(inout) :: sym
1629 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1630 : LOGICAL :: saxis
1631 :
1632 : INTEGER :: iatom, natoms
1633 : REAL(KIND=dp) :: length_of_a, phi
1634 : REAL(KIND=dp), DIMENSION(3) :: b
1635 :
1636 6346 : saxis = .FALSE.
1637 :
1638 6346 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
1639 :
1640 6346 : natoms = SIZE(coord, 2)
1641 :
1642 : ! Check the length of the axis vector a
1643 6346 : IF (length_of_a > sym%eps_geo) THEN
1644 : ! Calculate the rotation angle phi and build up the rotation matrix rotmat
1645 6346 : phi = 2.0_dp*pi/REAL(n, KIND=dp)
1646 6346 : CALL build_rotmat(phi, a(:), sym%rotmat(:, :))
1647 : ! Check all atoms
1648 9822 : DO iatom = 1, natoms
1649 : ! Rotate the actual atom by 2*pi/n about a
1650 124163 : b(:) = MATMUL(sym%rotmat(:, :), coord(:, iatom))
1651 : ! Reflect the coordinates of the rotated atom
1652 38204 : b(:) = reflect_vector(b(:), a(:))
1653 : ! Check if the coordinates of the rotated atom are in the coordinate set of the molecule
1654 9822 : IF (equatom(iatom, b(:), sym, coord) == 0) RETURN
1655 : END DO
1656 : ! The axis defined by a is a Sn axis, thus return with saxis = .TRUE.
1657 : saxis = .TRUE.
1658 : END IF
1659 :
1660 : END FUNCTION saxis
1661 :
1662 : ! **************************************************************************************************
1663 : !> \brief Reflect all atoms of the molecule through a mirror plane defined
1664 : !> by the normal vector a.
1665 : !> \param a ...
1666 : !> \param sym ...
1667 : !> \param coord ...
1668 : !> \return ...
1669 : !> \par History
1670 : !> Creation (16.11.98, Matthias Krack)
1671 : !> \author jgh
1672 : ! **************************************************************************************************
1673 2808 : FUNCTION sigma(a, sym, coord)
1674 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a
1675 : TYPE(molsym_type), INTENT(inout) :: sym
1676 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1677 : LOGICAL :: sigma
1678 :
1679 : INTEGER :: iatom, natoms
1680 : REAL(KIND=dp) :: length_of_a
1681 : REAL(KIND=dp), DIMENSION(3) :: b
1682 :
1683 2808 : sigma = .FALSE.
1684 :
1685 2808 : length_of_a = SQRT(a(1)*a(1) + a(2)*a(2) + a(3)*a(3))
1686 :
1687 : ! Check the length of vector a
1688 2808 : IF (length_of_a > sym%eps_geo) THEN
1689 2674 : natoms = SIZE(coord, 2)
1690 10068 : DO iatom = 1, natoms
1691 : ! Reflect the actual atom
1692 9471 : b(:) = reflect_vector(coord(:, iatom), a(:))
1693 : ! Check if the coordinates of the reflected atom are in the coordinate set of the molecule
1694 10068 : IF (equatom(iatom, b(:), sym, coord) == 0) RETURN
1695 : END DO
1696 : ! The plane defined by a is a mirror plane, thus return with sigma = .TRUE.
1697 : sigma = .TRUE.
1698 : END IF
1699 :
1700 : END FUNCTION sigma
1701 :
1702 : ! **************************************************************************************************
1703 : !> \brief Calculate the molecular tensor of inertia and the vector to the
1704 : !> center of mass of the molecule.
1705 : !> \param sym ...
1706 : !> \param coord ...
1707 : !> \par History
1708 : !> Creation (16.11.98, Matthias Krack)
1709 : !> \author jgh
1710 : ! **************************************************************************************************
1711 59 : SUBROUTINE tensor(sym, coord)
1712 : TYPE(molsym_type), INTENT(inout) :: sym
1713 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1714 :
1715 : INTEGER :: natoms
1716 : REAL(KIND=dp) :: tt
1717 :
1718 : ! Find the vector center_of_mass to molecular center of mass
1719 59 : natoms = SIZE(coord, 2)
1720 3303 : sym%center_of_mass(:) = MATMUL(coord(:, 1:natoms), sym%aw(1:natoms))/SUM(sym%aw(1:natoms))
1721 :
1722 : ! Translate the center of mass of the molecule to the origin
1723 2371 : coord(:, 1:natoms) = coord(:, 1:natoms) - SPREAD(sym%center_of_mass(:), 2, natoms)
1724 :
1725 : ! Build up the molecular tensor of inertia
1726 :
1727 637 : sym%tenmat(1, 1) = DOT_PRODUCT(sym%aw(1:natoms), (coord(2, 1:natoms)**2 + coord(3, 1:natoms)**2))
1728 637 : sym%tenmat(2, 2) = DOT_PRODUCT(sym%aw(1:natoms), (coord(3, 1:natoms)**2 + coord(1, 1:natoms)**2))
1729 637 : sym%tenmat(3, 3) = DOT_PRODUCT(sym%aw(1:natoms), (coord(1, 1:natoms)**2 + coord(2, 1:natoms)**2))
1730 :
1731 637 : sym%tenmat(1, 2) = -DOT_PRODUCT(sym%aw(1:natoms), (coord(1, 1:natoms)*coord(2, 1:natoms)))
1732 637 : sym%tenmat(1, 3) = -DOT_PRODUCT(sym%aw(1:natoms), (coord(1, 1:natoms)*coord(3, 1:natoms)))
1733 637 : sym%tenmat(2, 3) = -DOT_PRODUCT(sym%aw(1:natoms), (coord(2, 1:natoms)*coord(3, 1:natoms)))
1734 :
1735 : ! Symmetrize tensor matrix
1736 59 : sym%tenmat(2, 1) = sym%tenmat(1, 2)
1737 59 : sym%tenmat(3, 1) = sym%tenmat(1, 3)
1738 59 : sym%tenmat(3, 2) = sym%tenmat(2, 3)
1739 :
1740 : ! Diagonalize the molecular tensor of inertia
1741 59 : CALL jacobi(sym%tenmat(:, :), sym%tenval(:), sym%tenvec(:, :))
1742 :
1743 : ! Secure that the principal axes are right-handed
1744 236 : sym%tenvec(:, 3) = vector_product(sym%tenvec(:, 1), sym%tenvec(:, 2))
1745 :
1746 59 : tt = SQRT(sym%tenval(1)**2 + sym%tenval(2)**2 + sym%tenval(3)**2)
1747 59 : CPASSERT(tt /= 0)
1748 :
1749 59 : END SUBROUTINE tensor
1750 :
1751 : ! **************************************************************************************************
1752 : !> \brief Transformation the Cartesian coodinates with the matrix tenvec.
1753 : !> The coordinate axes can be switched according to the index
1754 : !> vector idx. If idx(1) is equal to 3 instead to 1, then the first
1755 : !> eigenvector (smallest eigenvalue) of the molecular tensor of
1756 : !> inertia is connected to the z axis instead of the x axis. In
1757 : !> addition the local atomic coordinate systems are initialized,
1758 : !> if the symmetry is turned off.
1759 : !> \param sym ...
1760 : !> \param coord ...
1761 : !> \param idx ...
1762 : !> \par History
1763 : !> Creation (16.11.98, Matthias Krack)
1764 : !> \author jgh
1765 : ! **************************************************************************************************
1766 52 : SUBROUTINE tracar(sym, coord, idx)
1767 : TYPE(molsym_type), INTENT(inout) :: sym
1768 : REAL(KIND=dp), DIMENSION(:, :), INTENT(inout) :: coord
1769 : INTEGER, DIMENSION(3), INTENT(IN) :: idx
1770 :
1771 : INTEGER :: iatom, natom
1772 : REAL(KIND=dp), DIMENSION(3, 3) :: tenvec
1773 :
1774 : ! Transformation of the atomic coordinates ***
1775 52 : natom = SIZE(coord, 2)
1776 676 : tenvec = TRANSPOSE(sym%tenvec)
1777 488 : DO iatom = 1, natom
1778 3104 : coord(idx, iatom) = MATMUL(tenvec, coord(:, iatom))
1779 : END DO
1780 :
1781 : ! Modify the transformation matrix for input orientation -> standard orientation
1782 676 : sym%inptostd(idx, :) = tenvec
1783 :
1784 52 : END SUBROUTINE tracar
1785 :
1786 : ! **************************************************************************************************
1787 : !> \brief Distance between two points
1788 : !> \param a ...
1789 : !> \param b ...
1790 : !> \return ...
1791 : !> \author jgh
1792 : ! **************************************************************************************************
1793 2864 : FUNCTION dist(a, b) RESULT(d)
1794 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: a, b
1795 : REAL(KIND=dp) :: d
1796 :
1797 11456 : d = SQRT(SUM((a - b)**2))
1798 :
1799 2864 : END FUNCTION dist
1800 : ! **************************************************************************************************
1801 : !> \brief Write atomic coordinates to output unit iw.
1802 : !> \param coord ...
1803 : !> \param atype ...
1804 : !> \param element ...
1805 : !> \param z ...
1806 : !> \param weight ...
1807 : !> \param iw ...
1808 : !> \date 08.05.2008
1809 : !> \author JGH
1810 : ! **************************************************************************************************
1811 58 : SUBROUTINE write_coordinates(coord, atype, element, z, weight, iw)
1812 : REAL(KIND=dp), DIMENSION(:, :), INTENT(in) :: coord
1813 : INTEGER, DIMENSION(:), INTENT(in) :: atype
1814 : CHARACTER(LEN=*), DIMENSION(:), INTENT(in) :: element
1815 : INTEGER, DIMENSION(:), INTENT(in) :: z
1816 : REAL(KIND=dp), DIMENSION(:), INTENT(in) :: weight
1817 : INTEGER, INTENT(IN) :: iw
1818 :
1819 : INTEGER :: iatom, natom
1820 :
1821 58 : IF (iw > 0) THEN
1822 58 : natom = SIZE(coord, 2)
1823 : WRITE (UNIT=iw, FMT="(T2,A)") &
1824 58 : "MOLSYM|", &
1825 116 : "MOLSYM| Atomic coordinates of the standard orientation in BOHR"
1826 : WRITE (UNIT=iw, FMT="(T2,A,T37,A,T51,A,T65,A,T77,A)") &
1827 58 : "MOLSYM| Atom Kind Element", "X", "Y", "Z", "Mass"
1828 633 : DO iatom = 1, natom
1829 : WRITE (UNIT=iw, FMT="(T2,A,I7,1X,I4,1X,A2,1X,I4,3(1X,F13.8),1X,F9.4)") &
1830 575 : "MOLSYM|", iatom, atype(iatom), ADJUSTL(element(iatom)), z(iatom), &
1831 1208 : coord(1:3, iatom), weight(iatom)
1832 : END DO
1833 : WRITE (UNIT=iw, FMT="(T2,A)") &
1834 58 : "MOLSYM|", &
1835 116 : "MOLSYM| Atomic coordinates of the standard orientation in ANGSTROM"
1836 : WRITE (UNIT=iw, FMT="(T2,A,T37,A,T51,A,T65,A,T77,A)") &
1837 58 : "MOLSYM| Atom Kind Element", "X", "Y", "Z", "Mass"
1838 633 : DO iatom = 1, natom
1839 : WRITE (UNIT=iw, FMT="(T2,A,I7,1X,I4,1X,A2,1X,I4,3(1X,F13.8),1X,F9.4)") &
1840 575 : "MOLSYM|", iatom, atype(iatom), ADJUSTL(element(iatom)), z(iatom), &
1841 2933 : coord(1:3, iatom)*angstrom, weight(iatom)
1842 : END DO
1843 : END IF
1844 :
1845 58 : END SUBROUTINE write_coordinates
1846 :
1847 0 : END MODULE molsym
|