prop.F90 11.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
!!-------------------------------------------------------
!!---- Relaxed Selected Excitation (RelaxSE)
!!-------------------------------------------------------
!!---- This file is part of RelaxSE
!!---- 
!!---- The RelaxSE project is distributed under LGPL. In agreement with the
!!---- Intergovernmental Convention of the ILL, this software cannot be used
!!---- in military applications.
!!---- 
!!---- Copyright (C) 2016-2021  Institut Laue-Langevin (ILL), Grenoble, FRANCE
!!----                          Institut Neel - CNRS-UPR2940 (CNRS), Grenoble, FRANCE
!!---- 
!!---- Authors: Elisa REBOLINI (ILL)             rebolini@ill.fr
!!----          Marie-Bernadette LEPETIT (CNRS)  Marie-Bernadette.Lepetit@neel.cnrs.fr
!!---- 
!!---- RelaxSE is free software; you can redistribute it and/or
!!---- modify it under the terms of the GNU Lesser General Public
!!---- License as published by the Free Software Foundation; either
!!---- version 3.0 of the License, or (at your option) any later version.
!!---- 
!!---- RelaxSE is distributed in the hope that it will be useful,
!!---- but WITHOUT ANY WARRANTY; without even the implied warranty of
!!---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
!!---- Lesser General Public License for more details.
!!---- 
!!---- You should have received a copy of the GNU Lesser General Public
!!---- License along with this library; if not, see <http://www.gnu.org/licenses/>.
!!---- 


!> @file Main for the properties of SASS program
!> @author Marie-Bernadette Lepetit and Elisa Rebolini

Program proprietes
!!$ -------- Donness globales ---------------------------------
  use info
  use info_prop
  use files
  use typedet
  use spindetact
  use gener_ref0
  use gener_ref1
  use gener_monos
  use utils_char
  use utils_wrt
Elisa Rebolini's avatar
Elisa Rebolini committed
46
#ifdef VAR_DEV
Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
47
  use densite
48
  !  use density_matrix
Elisa Rebolini's avatar
Elisa Rebolini committed
49
#endif
50
  !$ use OMP_LIB
51
52
53
  
!!$ -------- Donnes locales -----------------------------------
  implicit none
54

55
56
57
58
59
60
61
62
  type(prop_infotype)   :: prop_info
  type(prog_infotype)   :: prog_info
  type(g_infotype)      :: g_info
  type(o_infotype)      :: o_info
  type(v_infotype)      :: v_info
  type(det_infotype)    :: det_info
  type(sym_infotype)    :: sym_info

63

64
65
66
67
68
69
70
71
72
73
74
75
76
  ! det
  type(deter), dimension(:), allocatable ::  det, ref0
  Integer (KIND=kd_int) :: ndet, nvec, nblock, nelact, nact
  Integer, dimension(:), allocatable :: shtblkdet, nblkdet, deter_index
  type(rlist) :: r
  type(spinrlist) :: rspin
  integer, parameter :: nb_rlist = 9
  type(spindetact_list), pointer :: r0
  type(deter_dblocklist) :: d

  ! vecteurs
  real(kd_dble), dimension(:,:),  allocatable :: psi
  real(kd_dble), dimension(:),    allocatable :: ener, psi_S
77

78
79
80
81
  ! prop
  Integer(KIND=kd_int) :: nprop
  character*5, dimension(:), allocatable :: whichprop

Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
82
  ! proprietes
83
  !  real(kd_dble), dimension(:,:,:),  allocatable :: rho_tot,rho_spin
84

85
86
87
88
89
90
  ! impressions
  integer, parameter :: pas = 10
  character*1, parameter :: A1=" "

  ! autres
  integer ::  idet, ivec, iprop, nb_thread
91
  integer ::  nr, nq, iwr, i, j, n, nref0lu
92
93
94
95
96
  real(kd_dble) :: tstart, tend, wstart, wend, wstart1, wend1,t1, t2, wt1, wt2

  CHARACTER(LEN=8)     :: date      ! returned values from DATE_AND_TIME()
  CHARACTER(LEN=10)    :: time
  CHARACTER(LEN=5)     :: zone
97
98
99
100
101
102
103
  INTEGER,DIMENSION(8) :: values

#ifdef VAR_DEV
  integer :: iorb1, iorb2, norb
  real(kind=kd_dble), allocatable :: rho(:, :)
  real(kind=kd_dble), allocatable :: WF(:)
#endif
104

105
106
107
108
109
!!$============================================================
!!$ -------- Code ---------------------------------------------
!!$-----
!!$----- Initialisations 
!!$-----
110
  call init_prop(g_info, prog_info, o_info, v_info, det_info, sym_info, prop_info)
111
112
113
114
115

#ifdef VAR_OMP
  !$OMP PARALLEL SHARED(nb_thread)
  nb_thread=OMP_GET_MAX_THREADS()
  !$OMP END PARALLEL
116

117
118
119
120
121
122
123
  prog_info%nb_thread = nb_thread
#endif

  ! Definition des fichiers
  call def_files_prop(prog_info, ndet)
  flush(f_output)

124

125
  call gettime(tstart, wstart)
126
127


128
129
130
131
132
133
134
135
  ! lecture des x_info
  read(f_info) prog_info
  read(f_info) g_info
  read(f_info) o_info
  read(f_info) v_info
  read(f_info) det_info
  read(f_info) nblock
  allocate(shtblkdet(nblock), nblkdet(nblock), deter_index(nblock))
136
137
138
  shtblkdet(:)    = 0
  nblkdet(:)      = 0
  deter_index(:)  = 99
139
140
141
142
143
144
145
146
147
148
  read(f_info) shtblkdet(1:nblock), nblkdet(1:nblock), deter_index(1:nblock)
  read(f_info) sym_info

  call read_propinp(prop_info, nref0lu, f_input)
  prog_info%restart = .true.
  ndet   = det_info%ndet
  nvec   = v_info%nvec
  nelact = g_info%nelact
  nact   = o_info%nact
  det_info%nref0 = nref0lu
149

150
151
152
!!$-----
!!$ --- Generation des det
!!$-----
153
154
  if (prog_info%methodAct.eq.'cas') then
     det_info%nref0 = comb(o_info%nact,g_info%na) * comb(o_info%nact,g_info%nb)
155
     call deter_init(ref0, det_info%nref0)
156
157
     call gener_cas(ref0, prog_info, det_info, g_info, o_info)
  else
158
     call deter_init(ref0, det_info%nref0)
159
160
161
162
     call lect_ref0(ref0, prog_info, det_info, g_info, o_info, v_info)
  end if
  if (prog_info%id_cpu.eq.0)  flush(f_output)

163

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  call detact_all_init(r, nb_rlist)  
  if (prog_info%id_cpu.eq.0) then
     write(f_output,*)
     write(f_output,*)">>> Generation of all determinants"
     flush(f_output)
  endif
  call gettime(t1,wstart1)
  ! Calcul des conf de spin des ref0
  call generspin_ref0(ref0, vecref0, r, o_info, det_info, v_info, prog_info)
  ! Calcul des conf de spin des ref1
  call generspin_ref1(ref0, r, o_info, det_info, g_info%nelact, prog_info)
  call deter_free(ref0)

  ! Generation of all active determinants
  call compute_all_spindetact(rspin, r, o_info, v_info%sz)
  ! Generation of all determinants   
  call deter_blocklist_init(d)
  call generspin_det(det_info, rspin, d, o_info, v_info, prog_info, .false.)
  call gettime(t2,wend1)
  if (prog_info%id_cpu.eq.0) then
     write(f_output,*) '>>>Determinants generated in',t2-t1,'second(s)'
     flush(f_output)
  endif

!!$-----
!!$ --- Lecture des det 
!!$-----
  write(f_output,*)
  write(f_output,*) '>>> Reading determinants in file bdet'
  allocate (det(ndet))
  call read_bdet(det,ndet,f_bdet)

!!$-----
!!$ --- Lecture des vecteurs
!!$-----
  write(f_output,*)
  write(f_output,'(" >>> Reading vectors from file restart")')
  allocate(psi(ndet,nvec), ener(nvec))
  psi(:,:) = 0.d0
  ener(:)  = 0.d0
  call lect_vect(psi, ener, ndet, nvec)
205

206
207
208
!!$-----
!!$ --- Projection sur le cas
!!$-----
209
210
211
212
213
214
  write(f_output,*)
  write(f_output,*)"================================================================================"
  write(f_output,*)
  write(f_output,*)"                            Properties section                                  "
  write(f_output,*)
  write(f_output,*)"================================================================================"
215
216
  call gettime(t1,wt1)
  write(f_output,*)
217
218
  n=len("Vectors projection on active space")
  call wrt_mess(f_output,n,"Vectors projection on active space")
219
220
221
222
223
224
225
  call cass_proj(psi, ener, ndet, nvec, nelact,det, det_info, o_info, &
       nblock, shtblkdet,nblkdet,deter_index,f_output)
  call gettime(t2,wt2)
  write(f_output,*)
  write(f_output,'(X,A,A,F17.2,A,F17.2,A)') '>>> Active space projection in ',&
       'CPU time ',t2-t1,'s, Wall time ',wt2-wt1,' s'
  flush(f_output)
226

227
!!$-----------------------------------------------------------------------------
228
!!$ --- Autres proprits
229
!!$-----------------------------------------------------------------------------
230
  nprop = prop_info%nprop
231
232
233
234
235
236
237
238
239
  if (nprop.ne.0) then

     allocate(whichprop(nprop))
     whichprop(1:nprop) = prop_info%whichprop(1:nprop)


     do iprop = 1, nprop
        call lowercase(whichprop(iprop))
        select case (whichprop(iprop))
240
241
242
243
244
245
           
        case("s-s2") !------- Compute total S -------------------------------------
           write(f_output,*)
           write(f_output,*)
           n=len("Total S")
           call wrt_mess(f_output,n,"Total S")
246
247
248
249
250
251
252
253
254
255
256
257
           allocate(psi_S(nvec))
           psi_S(:) = 0.d0
           call s2(psi,psi_S,ndet,nvec,nelact, det, det_info, d, o_info, f_output)
           nq=nvec/10
           nr=nvec - nq*pas
           do i =1,nq
              write(f_output,'(" S    ")',advance='no')
              do iwr = 1, max(2*nact +1-6,0)
                 write(f_output,'(a1)',advance='no') A1
              end do
              write(f_output,9012) psi_S((i-1)*pas+1:i*pas)
           end do
258
259
260
261
           write(f_output,'(" S    ")',advance='no')
           do iwr = 1, max(2*nact +1-6,0)
              write(f_output,'(a1)',advance='no') A1
           end do
262
263
264
265
           write(f_output,9012) psi_S(nq*pas+1:nvec)
           write(f_output,*)
           deallocate(psi_S)
9012       format(10(F18.8,2x))
266
           
267
        case("wf") !------- Print WFs ---------------------------------------------
268
269
270
271
           write(f_output,*)
           write(f_output,*)
           n=len("Total WFs")
           call wrt_mess(f_output,n,"Total WFs")
272
           call wrt_WF(ndet,nvec,1,nvec,det,psi,o_info,f_output)
273
           
274
        case("pref1") !---- Project WF on Ref1 ------------------------------------
275
276
277
278
           write(f_output,*)
           write(f_output,*)
           n=len("Projection on Ref1")
           call wrt_mess(f_output,n,"Projection on Ref1")
279
           write(f_output,*) "      Not yet implemented"
280
           
281
        case("lcoef") !---- Print largest determinants ----------------------------
282
283
284
285
286
287
288
           write(f_output,*)
           write(f_output,*)
           n=len("Projection on determinants with coefficients largest than a threshold")
           call wrt_mess(f_output,n,"Projection on determinants with coefficients largest than a threshold")
           write(f_output,'("  Threshold = ",f8.5)')  prop_info%seuilcoef
           call largecoef(prop_info%seuilcoef,ndet,nvec,det,psi,o_info,f_output)
           
289
        case("dens") !----- 1e-density matrix --------------------------------------
290
291
292
           write(f_output,*)
           n=len("One particule density matrices")
           call wrt_mess(f_output,n,"One particule density matrices")
Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
293
#ifdef VAR_DEV
294
           call  dens(ndet,nvec, psi,det, d,rspin, o_info,g_info,prog_info)
295
           !           call  verif_dens(ndet,nvec, psi,det, d,rspin, o_info,g_info,prog_info)
296
297
298
           write(f_output,*)
           write(f_output,*)
           
Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
299
#endif
300
301
        end select
     end do
302

303
     deallocate(whichprop)
304

305
  end if
306

307
  write(f_output,*)
308
309
310
311
312
  write(f_output,*)"================================================================================"
  write(f_output,*)
  write(f_output,*)"                        End of properties section                               "
  write(f_output,*)
  write(f_output,*)"================================================================================"
313
  write(f_output,*)
314

315
316
317
  deallocate(shtblkdet, nblkdet, deter_index)
  deallocate(det)
  deallocate(psi, ener)
Elisa Rebolini's avatar
Elisa Rebolini committed
318

319
320
321
322
323
324
  call gettime(tend,wend)

  call date_and_time(date, time, zone, values)
  write(f_output,'(X,A,F17.2,A,F17.2,A)') 'Calculation finished in CPUtime',&
       tend-tstart,'s Walltime:', &
       wend-wstart,'s'
325

326
327
  write(f_output,*) 'Calculation finished on ', date(7:8),'-',date(5:6),&
       '-',date(1:4), ' at ', time(1:2),':',time(3:4)
328
  flush(f_output)
329
330
331
332
333
334

!!$ Clean
  call detact_all_free(r)
  call spindetact_all_free(rspin)
  call deter_blocklist_free(d)

335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
contains
  subroutine wrt_mess(iunit,n,mess)
    implicit none
    character(len=*), intent(in) :: mess
    Integer(KIND=kd_int), intent(in) :: iunit,n 
    Integer :: i,d
    
    d= (80-n-2)/2
    do i=1,d
       write(iunit,9001,advance="no") ">"
    end do
    write(iunit,9001,advance="no") " "
    do i=1,n
       write(iunit,9001,advance="no") mess(i:i)
    end do
    write(iunit,9001,advance="no") " "
    do i=1, 80-n-2-d
       write(iunit,9001,advance="no") "<"
    end do
    write(iunit,*)
9001 format(a1)
    
  end subroutine wrt_mess
358
end Program proprietes