11 integer,
parameter ::
dp = kind(1.0d0)
15 character(20) :: jobname
16 character(50) :: typeofrot
36 integer :: rotate_atoms(2)
49 integer,
parameter :: nkey_char = 2, nkey_int = 6, nkey_re = 15, nkey_log = 1
50 character(20) :: jobname
51 character(len=*) :: filename
55 character(len=50),
parameter :: keyvector_char(nkey_char) = [character(len=100) :: &
56 'Jobname=',
'TypeOfRotation=']
57 character(len=100) :: valvector_char(nkey_char) = [character(len=100) :: &
60 character(len=50),
parameter :: keyvector_int(nkey_int) = [character(len=50) :: &
61 'Atom1=',
'Atom2=',
'CAtom=',
'CAtom2=',
'ListToRot1=',
'ListToRot2=']
62 integer :: valvector_int(nkey_int) = (/ &
65 character(len=50),
parameter :: keyvector_re(nkey_re) = [character(len=50) :: &
66 'PQ1X=',
'PQ1Y=',
'PQ1Z=',
'PQ2X=',
'PQ2Y=',
'PQ2Z=',
'V1X=',
'V1Y=', &
67 &
'V1Z=',
'V2X=',
'V2Y=',
'V2Z=',
'VQX=',
'VQY=',
'VQZ=']
68 real(
dp) :: valvector_re(nkey_re) = (/&
69 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/)
71 character(len=50),
parameter :: keyvector_log(nkey_log) = [character(len=100) :: &
73 logical :: valvector_log(nkey_log) = (/&
77 character(len=50),
parameter :: startstop(2) = [character(len=50) :: &
81 ,keyvector_int,valvector_int,keyvector_re,valvector_re,&
82 keyvector_log,valvector_log,trim(filename),startstop)
84 rot%jobname= valvector_char(1)
85 rot%typeofrot= valvector_char(2)
87 rot%patom1= valvector_int(1)
88 rot%patom2= valvector_int(2)
89 rot%catom= valvector_int(3)
90 rot%catom2= valvector_int(4)
91 rot%rotate_atoms(1)= valvector_int(5)
92 rot%rotate_atoms(2)= valvector_int(6)
94 rot%pq1(1)= valvector_re(1)
95 rot%pq1(2)= valvector_re(2)
96 rot%pq1(3)= valvector_re(3)
98 rot%pq2(1)= valvector_re(4)
99 rot%pq2(2)= valvector_re(5)
100 rot%pq2(3)= valvector_re(6)
102 rot%v1(1)= valvector_re(7)
103 rot%v1(2)= valvector_re(8)
104 rot%v1(3)= valvector_re(9)
106 rot%v2(1)= valvector_re(10)
107 rot%v2(2)= valvector_re(11)
108 rot%v2(3)= valvector_re(12)
110 rot%vQ(1)= valvector_re(13)
111 rot%vQ(2)= valvector_re(14)
112 rot%vQ(3)= valvector_re(15)
139 integer :: natoms, catom, catom2, i
140 integer :: k, l, patom1, patom2
141 integer :: rotate_atoms(2)
142 integer,
intent(in) :: verbose
143 real(
dp) :: mat(3,3), p1minusc1(3), vtr(3)
144 real(
dp) :: alpha, angle, d, deformation
145 real(
dp) :: dotprod, dv1, dv2, hinge(3)
146 real(
dp) :: hinge2, hingedotp1minusc1, pq1(3), pq2(3)
147 real(
dp) :: pi, v1(3), v11(3), v1mod
148 real(
dp) :: v1x, v1y, v1z, v1zversor
149 real(
dp) :: v2(3), v22(3), vn(3), vq(3)
150 real(
dp) :: vad(3), vdirn(3), vp(3), vr11(3)
151 real(
dp) :: vr2(3), vr22(3)
152 real(
dp),
allocatable :: rr(:,:), v(:,:), vr(:,:), vr1(:,:)
153 real(
dp),
intent(inout) :: r(:,:)
156 pi=3.1415926535897993d0
158 alpha= (alpha/180.0_dp)*pi
160 natoms =
size(r, dim=2)
162 allocate(v(3,natoms))
163 allocate(vr(3,natoms))
164 allocate(vr1(3,natoms))
165 allocate(rr(3,natoms))
197 rotate_atoms(1)=rot%rotate_atoms(1)
198 rotate_atoms(2)=rot%rotate_atoms(2)
200 if(rotate_atoms(2).gt.natoms) rotate_atoms(2)=natoms
217 hinge=r(:,catom2)-r(:,catom)
218 hinge2=hinge(1)**2+hinge(2)**2+hinge(3)**2
219 p1minusc1=pq1(:)-r(:,catom)
220 hingedotp1minusc1=hinge(1)*p1minusc1(1) + hinge(2)*p1minusc1(2) + hinge(3)*p1minusc1(3)
221 vq(:)=r(:,catom) + hinge(:)*hingedotp1minusc1/hinge2
224 write(*,*)hingedotp1minusc1/hinge2
227 if(v1(1).eq.0.0_dp.and.v1(2).eq.0.0_dp.and.v1(3).eq.0.0_dp)
then
231 if(v2(1).eq.0.0_dp.and.v2(2).eq.0.0_dp.and.v2(3).eq.0.0_dp)
then
239 dv1=dsqrt(v1(1)**2+v1(2)**2+v1(3)**2)
240 dv2=dsqrt(v2(1)**2+v2(2)**2+v2(3)**2)
241 dotprod=v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
242 alpha=-acos(dotprod/(dv1*dv2))
244 if(alpha.eq.0.0_dp)
write(*,*)
'V1 and V2 are in the same direction'
245 if(abs(alpha-pi).lt.1.0e-10)
write(*,*)
'V1 and V2 are in the same direction'
247 if(verbose >= 1)
write(*,*)
'alpha=',alpha
249 do i=rotate_atoms(1),rotate_atoms(2)
250 r(1,i) = r(1,i)-vq(1)
251 r(2,i) = r(2,i)-vq(2)
252 r(3,i) = r(3,i)-vq(3)
257 vn(1)=v1(2)*v2(3)-v1(3)*v2(2)
258 vn(2)=-v1(1)*v2(3)+v2(1)*v1(3)
259 vn(3)=v1(1)*v2(2)-v2(1)*v1(2)
261 vp(1)=vn(2)*vad(3)-vn(3)*vad(2)
262 vp(2)=-vn(1)*vad(3)+vad(1)*vn(3)
263 vp(3)=vn(1)*vad(2)-vad(1)*vn(2)
265 d=dsqrt(vad(1)**2+vad(2)**2+vad(3)**2)
268 d=dsqrt(vp(1)**2+vp(2)**2+vp(3)**2)
271 d=dsqrt(vn(1)**2+vn(2)**2+vn(3)**2)
276 do i=rotate_atoms(1),rotate_atoms(2)
277 v(1,i)=r(1,i)*vad(1)+r(2,i)*vad(2)+r(3,i)*vad(3)
278 v(2,i)=r(1,i)*vp(1)+r(2,i)*vp(2)+r(3,i)*vp(3)
279 v(3,i)=r(1,i)*vn(1)+r(2,i)*vn(2)+r(3,i)*vn(3)
296 do l=rotate_atoms(1),rotate_atoms(2)
299 vr(i,l)=vr(i,l)+mat(k,i)*v(k,l)
306 do i=rotate_atoms(1),rotate_atoms(2)
307 vr1(1,i)=vr(1,i)*vad(1) + vr(2,i)*vp(1) + vr(3,i)*vn(1)
308 vr1(2,i)=vr(1,i)*vad(2) + vr(2,i)*vp(2) + vr(3,i)*vn(2)
309 vr1(3,i)=vr(1,i)*vad(3) + vr(2,i)*vp(3) + vr(3,i)*vn(3)
312 if(alpha.eq.0.0_dp)vr1=r
313 if(abs(alpha-pi).lt.1.0e-10)vr1=-r
315 do i=rotate_atoms(1),rotate_atoms(2)
316 rr(1,i)=vr1(1,i)+vq(1)+vtr(1)
317 rr(2,i)=vr1(2,i)+vq(2)+vtr(2)
318 rr(3,i)=vr1(3,i)+vq(3)+vtr(3)
321 do i=rotate_atoms(1),rotate_atoms(2)
329 do i=rotate_atoms(1),rotate_atoms(2)
330 d=dsqrt((r(1,1)-r(1,i))**2+(r(2,1)-r(2,i))**2+(r(3,1)-r(3,i))**2)
331 deformation=deformation + d
332 d=dsqrt((rr(1,1)-rr(1,i))**2+(rr(2,1)-rr(2,i))**2+(rr(3,1)-rr(3,i))**2)
333 deformation=deformation - d
336 if(deformation >= 0.001_dp)
then
337 write(*,*)
'Rotation failed ...'
338 write(*,*)
'Deformation=',deformation
Some general parsing functions.
subroutine, public prg_parsing_kernel(keyvector_char, valvector_char, keyvector_int, valvector_int, keyvector_re, valvector_re, keyvector_log, valvector_log, filename, startstop)
The general parsing function. It is used to vectorize a set of "keywords" "value" pairs as included i...
A module to rotate the coordinates of a sybsystem in chemical systems.
subroutine, public prg_rotate(rot, r, verbose)
Rotation routine.
subroutine, public prg_parse_rotation(rot, filename)
The parser for rotation.