1
subroutine debug_update_g_anl_quad1(
7
c Purpose: Debugging input to update_g_anl_quad
9
c Author : Fredy W. Aquino
11
c Note.- Modified from original aoresponse source code
12
c for extension to spin-unrestricted case
13
c original aoresponse source code was written by
14
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
15
c --> Experimental (not published yet)
20
#include "mafdecls.fh"
24
integer g_quadel,g_anl,
25
& g_vecE1(2,2),g_vectors(2)
27
& write(*,*) '---- g_quadel-------- START'
28
call ga_print(g_quadel)
30
& write(*,*) '---- g_quadel-------- END'
32
if (ga_nodeid().eq.0) then
34
17 format('---- g_anl-lquad-bef(',i3,')-------- START')
37
if (ga_nodeid().eq.0) then
39
18 format('---- g_anl-lquad-bef(',i3,')-------- END')
42
if (ga_nodeid().eq.0) then
44
13 format('---- g_vecE1(',i3,')-------- START')
46
call ga_print(g_vecE1(ispin,1))
47
if (ga_nodeid().eq.0) then
49
14 format('---- g_vecE1(',i3,')-------- END')
52
if (ga_nodeid().eq.0) then
54
15 format('---- g_vectors(',i3,')-------- START')
56
call ga_print(g_vectors(ispin))
57
if (ga_nodeid().eq.0) then
59
16 format('---- g_vectors(',i3,')-------- END')
64
subroutine update_g_anl_quad(
66
& g_quadel, ! in : quadrupole AO integral
67
& g_vecE1, ! in : 1st-order elect. pert. MO vector
68
& g_vectors,! in : MO vector
69
& scaling, ! in : scaling factor
70
& g_temp, ! in : scratch GA array
71
& g_work, ! in : scratch GA array
72
& idir, ! in : =1,2,3=x,y,z
73
& nocc, ! in : nr. occupied MOs
74
& nbf, ! in : nr. basis functions
75
& debug, ! in : debugging flag
76
& lstatic) ! in : static flag
78
c Author : Fredy W. Aquino
80
c Note.- Modified from original aoresponse source code
81
c for extension to spin-unrestricted case
82
c original aoresponse source code was written by
83
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
84
c --> Experimental (not published yet)
89
#include "mafdecls.fh"
97
integer g_anl, ! in/out
101
logical lstatic,debug
102
integer nbf,nocc,iresp,idir
103
integer alo(3),ahi(3),
107
data ind_dkl/ 2, 3, ! dkl=123
110
integer ind_p(2,2),p,ind1,ind2,k,l
111
data ind_p/1, 2, ! p12 p=1
116
double precision scl,scaling,one,two,four
117
parameter(one=1.0d0,two=2.0d0,four=4.0d0)
119
c define translation table for quadrupole indices in
121
c XX=1, XY=YX=2, XZ=ZX=3, YY=4, YZ=ZY=5, ZZ=6
134
c Allowing: (dkl)=(123,132,231,213,312,321) d=idir
137
scl=-LCred(p)*scaling
138
iresp = qindex(l,idir)
140
call get_C1MC(g_work, ! out: C(E) M C
141
& g_vecE1, ! in : 1st-order pert vec RE
142
& g_quadel, ! in : dipole electric or magnetic
143
& g_vectors, ! in : MO vectors
144
& k, ! in : = 1,2,3=x,y,z directions
145
& iresp, ! in : = 1,2,3
146
& 1, ! in : indices in (alo,ahi)(3) (blo,bhi)(3)
147
& nbf, ! in : nr. basis functions
148
& nocc, ! in : nr. occupied alpha or beta
149
& debug, ! in : logical var for debugging
150
& g_temp) ! in : scratch GA array -> out
156
call nga_add_patch(scl,g_work,clo,chi,
157
& one,g_anl ,clo,chi,
163
subroutine update_g_anl_elmag(
165
& g_vecE1,! in : C(E) pert MO vect.
166
& g_smatx,! in : 0th/1st overlap deriv.
167
& g_vec, ! in : MO vect or C(B) MO vect
168
& scaling,! in : scaling factor
169
& idir, ! in : direction (x,y or z)
170
& caseAO, ! in : 3 or 4
171
& nbf, ! in : nr. basis functions
172
& nocc, ! in : nr. occupied MOs
173
& lstatic,! in : flag for static calc.
174
& debug, ! in : flag for debugging
175
& g_work, ! in : scratch GA array
176
& g_temp) ! in : scratch GA array
178
c Author : Fredy W. Aquino
180
c Note.- Modified from original aoresponse source code
181
c for extension to spin-unrestricted case
182
c original aoresponse source code was written by
183
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
184
c --> Experimental (not published yet)
187
#include "errquit.fh"
189
#include "mafdecls.fh"
193
integer clo(3),chi(3)
194
integer caseAO,nbf,nocc,idir
195
logical lstatic,debug
196
integer g_smatx,g_vecE1,g_vec,g_anl,
197
& g_temp,g_work ! scratch GA arrays
198
double precision scaling,one,two,four
199
parameter (one=1d0,two=2d0,four=4.0d0)
201
if (caseAO.ne.3 .and. caseAO.ne.4) then
202
call errquit('update_g_anl_elmag: caseAO ne 3 or 4',
207
& g_work, ! out: C(E) M C
208
& g_vecE1, ! in : 1st-order pert vec RE
209
& g_smatx, ! in : dipole electric or magnetic
210
& g_vec, ! in : MO vectors
211
& idir, ! in : = 1,2,3=x,y,z directions
212
& 0, ! in : for caseAO=3,4 is dummy
213
& caseAO, ! in : caseAO:(ind1,ind2)=(idir,1)
214
& nbf, ! in : nr. basis functions
215
& nocc, ! in : nr. occupied alpha or beta
216
& debug, ! in : logical var for debugging
217
& g_temp) ! in : scratch GA array
220
if (ga_nodeid().eq.0) then
222
5 format('---- g_work(',i3,')-------- START')
224
call ga_print(g_work)
225
if (ga_nodeid().eq.0) then
227
6 format('---- g_work(',i3,')-------- END')
234
call nga_add_patch(scaling,g_work,clo,chi,
235
& one,g_anl ,clo,chi,
240
subroutine get_trace_ganl(g_anl, ! in/out:
242
& idir, ! in: 1,2,3=x,y,z
243
& oprint, ! in: logical var
244
& nocc) ! in: nr. occupied MOs
246
c Author : Fredy W. Aquino
248
c Note.- Modified from original aoresponse source code
249
c for extension to spin-unrestricted case
250
c original aoresponse source code was written by
251
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
252
c --> Experimental (not published yet)
255
#include "errquit.fh"
257
#include "mafdecls.fh"
264
& g_tmpanl! scratch GA array
266
character*(256) cstemp
268
double precision ga_trace_diag,trace,ac_trace
269
external ga_trace_diag
270
if (.not. ma_push_get(mt_dbl,nocc,'diag',l_diag,k_diag))
271
& call errquit('error alloc MA diag', 0, MA_ERR)
272
c Note.- This routine is for testing only
273
c ====> it will be better to use the idea of
274
c trace() defined in aor_r1_tensor.F
275
c test: symmetrize the g_anl matrix before the LMO trafo:
277
& write (luout,*) 'Message from beta_anl: Symmetrizing X'
278
call ga_symmetrize(g_anl)
280
write (cstemp,'(a)') 'aor_beta: tmpanl'
281
if(.not.ga_create(MT_DBL,nocc,nocc,trim(cstemp),
283
& call errquit (trim(cstemp),0,GA_ERR)
284
call ga_zero(g_tmpanl)
285
call ga_dgemm('t', 'n',nocc,nocc,nocc,
286
$ 1.0d0,g_tran,g_anl,0.0d0,
287
& g_tmpanl) ! out: g_tmpanl
289
c ========= Added by FA to compute trace ====== START
292
ac_trace=ga_ddot_patch(g_tmpanl,'n',i,i ,1,nocc,
293
& g_tran ,'n',1,nocc,i,i)
296
if (ga_nodeid().eq.0) then
298
2 format('trace(',i3,')=',f15.8)
302
c ========= Added by FA to compute trace ====== END
303
call ga_dgemm('n', 'n',nocc,nocc,nocc,
304
$ 1.0d0,g_tmpanl,g_tran,0.0d0,
305
& g_anl) ! out: g_anl
306
if (.not.ga_destroy(g_tmpanl)) call errquit
307
& ('aor_beta: ga_destroy failed g_tmpanl',0,GA_ERR)
309
if (oprint) write (luout,
310
& '(/t12,a,t26,a/t11,6(''-''),t22,12(''-''))')
313
call ga_get_diagonal(g_anl,dbl_mb(k_diag))
318
sum = sum + dbl_mb(k_diag+i-1)
320
if (ga_nodeid().eq.0) then
322
1 format('sum(',i3,')=',f15.8)
325
if (oprint) write (luout,'(t11,i6,t22,f12.4)')
326
& i,dbl_mb(k_diag+i-1)
329
if (ga_nodeid().eq.0) then
330
write(*,23) 1,sum,ga_trace_diag(g_anl),trace
331
23 format('g_anl-trace-lmo(',i3,')=(',
332
& f15.8,',',f15.8,',',f15.8,')')
336
& write (luout,'(1x,a,2i1,a,f12.4)')
337
& 'Component ',idir,idir,': Sum = ',sum
339
if (oprint) write (luout,'(1x,40(''-''))')
341
sum = ga_trace_diag(g_anl)
342
if (oprint) write (luout,*) 'sum from ga_trace: ',sum
344
if (.not. ma_pop_stack(l_diag))
345
& call errquit('error deloc MA diag',0, MA_ERR)
349
subroutine get_tracelessQtensor(g_quadel, ! in/out: quadrupole tensor
350
& nbf, ! in: nr. basis functions
351
& g_work) ! in: scratch GA array
353
c Author : Fredy W. Aquino
355
c Note.- Modified from original aoresponse source code
356
c for extension to spin-unrestricted case
357
c original aoresponse source code was written by
358
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
359
c --> Experimental (not published yet)
362
#include "errquit.fh"
364
#include "mafdecls.fh"
367
integer g_quadel,g_work
369
integer alo(3),ahi(3),
372
double precision tenm8,one,two,three,
373
& zero,half,third,four
374
parameter (tenm8=1d-8, one=1d0, two=2d0, three=3d0,
375
& zero=0d0, half=one/two,
376
& third=one/three, four=4.0d0)
377
c define translation table for quadrupole indices in
379
c XX=1, XY=YX=2, XZ=ZX=3, YY=4, YZ=ZY=5, ZZ=6
389
c a) from trace -> g_work
390
call ga_zero(g_work) ! use for trace
396
alo(3) = qindex(iresp,iresp)
397
ahi(3) = qindex(iresp,iresp)
402
call nga_add_patch(one,g_quadel,alo,ahi,
403
& one,g_work ,blo,bhi,
405
enddo ! end-loop-iresp
406
c b) scale quadel by 3
407
call ga_scale(g_quadel,three)
408
c c) subtract trace from diagonal
414
alo(3) = qindex(iresp,iresp)
415
ahi(3) = qindex(iresp,iresp)
420
call nga_add_patch(one,g_quadel,alo,ahi,
421
& -one,g_work ,blo,bhi,
423
enddo ! end-loop-iresp
424
c d) divide the result by two, then by three
425
c because of the factor by which the result enters
426
c the Buckingham-Dunn tensor
427
call ga_scale(g_quadel,half*third)
431
subroutine write_vects(
432
& rtdb,geom,basis, ! in: handles
433
& g_vecE1, ! in: C^(1,E)
434
& g_vecB1, ! in: C^(1,B)
436
& g_vectmp, ! in: scratch GA array
437
& npol,nocc, ! in: nr. polariz,occ MOs
438
& nocct,nvirt, ! in: nr. occ,virt MOs
439
& nopen,nmot, ! in: nr. open shells,nmot=nocc*nvirt
441
& nbf, ! in: nr. basis functions
442
& lmo, ! in: logical flag
443
& debug) ! in: logical flag for debugging
445
c Author : Fredy W. Aquino
447
c Note.- Modified from original aoresponse source code
448
c for extension to spin-unrestricted case
449
c original aoresponse source code was written by
450
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
451
c --> Experimental (not published yet)
454
#include "errquit.fh"
456
#include "mafdecls.fh"
463
integer rtdb,geom,basis
464
integer g_vecE1,g_vecB1,g_tran,
466
integer idir,nbf,npol,nocc
468
integer alo(3),ahi(3),
471
character*(256) cstemp
472
integer nocct(npol),nvirt(npol),
473
& nopen(npol),nmot(npol)
474
double precision froct(nbf,2),epst(nbf,2)
475
c ---------------------------------------------------
476
c part of the analysis is storing the perturbed
477
c MOs. As elsewhere, we assume a closed shell system.
478
c We write a lot of data here, e-field and b-field
479
c perturbed canonical MOs and, if applicable, LMOs
480
c ----------------------------------------------------
492
call ga_zero(g_vectmp(1))
493
call nga_copy_patch('n',g_vecE1 ,alo,ahi,
494
& g_vectmp(1),blo,bhi)
496
if (ga_nodeid().eq.0) then
498
24 format('---- g_vectmp-vecE1(',i3,')-------- START')
500
call ga_print(g_vectmp(1))
501
if (ga_nodeid().eq.0) then
503
25 format('---- g_vectmp-vecE1(',i3,')-------- END')
506
write(cstemp,'(a,i1,a)') 'cmo-efield',idir,'.movecs'
507
call hnd_vec_write(rtdb,geom,basis,
508
& nbf,nocct,nopen,nvirt,'scf',
509
& g_vectmp,froct,epst,nmot,cstemp)
510
call ga_zero(g_vectmp(1))
511
call nga_copy_patch('n',g_vecB1 ,alo,ahi,
512
& g_vectmp(1),blo,bhi)
514
if (ga_nodeid().eq.0) then
516
26 format('---- g_vectmp-vecB1(',i3,')-------- START')
518
call ga_print(g_vectmp(1))
519
if (ga_nodeid().eq.0) then
521
27 format('---- g_vectmp-vecB1(',i3,')-------- END')
524
write(cstemp,'(a,i1,a)') 'cmo-bfield',idir,'.movecs'
525
call hnd_vec_write(rtdb,geom,basis,
526
& nbf,nocct,nopen,nvirt,'scf',
527
& g_vectmp,froct,epst,nmot,cstemp)
543
call ga_zero(g_vectmp(1))
544
call nga_matmul_patch('n','n',1d0,0d0,
547
& g_vectmp(1),clo,chi)
549
if (ga_nodeid().eq.0) then
551
28 format('---- g_vectmp-vecE1-lmo(',i3,')---- START')
553
call ga_print(g_vectmp(1))
554
if (ga_nodeid().eq.0) then
556
29 format('---- g_vectmp-vecE1-lmo(',i3,')---- END')
559
write(cstemp,'(a,i1,a)') 'lmo-efield',idir,'.movecs'
560
call hnd_vec_write(rtdb,geom,basis,
561
& nbf,nocct,nopen,nvirt,'scf',
562
& g_vectmp,froct,epst,nmot,cstemp)
563
call ga_zero(g_vectmp(1))
564
call nga_matmul_patch('n','n',1d0,0d0,
567
& g_vectmp(1),clo,chi)
569
if (ga_nodeid().eq.0) then
571
30 format('---- g_vectmp-vecB1-lmo(',i3,')---- START')
573
call ga_print(g_vectmp(1))
574
if (ga_nodeid().eq.0) then
576
31 format('---- g_vectmp-vecB1-lmo(',i3,')---- END')
579
write(cstemp,'(a,i1,a)') 'lmo-bfield',idir,'.movecs'
580
call hnd_vec_write(rtdb,geom,basis,
581
& nbf,nocct,nopen,nvirt,'scf',
582
& g_vectmp,froct,epst,nmot, cstemp)