Merge lp:~albertog/siesta/4.0-images into lp:siesta/4.0

Proposed by Alberto Garcia
Status: Superseded
Proposed branch: lp:~albertog/siesta/4.0-images
Merge into: lp:siesta/4.0
Diff against target: 839 lines (+478/-94) (has conflicts)
9 files modified
Src/Makefile (+7/-3)
Src/diagk0.F (+295/-0)
Src/diagon.F (+18/-2)
Src/hsparse.F (+53/-76)
Src/new_dm.F (+20/-1)
Src/pdos.F (+9/-1)
Src/state_init.F (+53/-8)
Src/writewave.F (+14/-3)
version.info (+9/-0)
Text conflict in version.info
To merge this branch: bzr merge lp:~albertog/siesta/4.0-images
Reviewer Review Type Date Requested Status
Nick Papior Approve
Review via email: mp+344377@code.launchpad.net

This proposal has been superseded by a proposal from 2018-05-08.

Commit message

(See individual commit messages)

Description of the change

Two independent changes:

1. The fix for the "severe folding" leading to wrong norm of the DM initialized by atomic data.
2. A saner hsparse.

I am not sure it is worth detecting the "severe folding" in hsparse (by checking for sameness of io and jo) for informative purposes.

To post a comment you must log in.
Revision history for this message
Alberto Garcia (albertog) wrote :

For Harris-functional calculations, severe folding is just plain crazy, as there is no time to smooth out the initial differences. We should remove the Harris option from the force_2 test.

In general, we should remove tests with non-physically small cells with gamma point (or at least flag them as showcases for the problems).

Revision history for this message
Nick Papior (nickpapior) wrote :

Could we force the auxiliary cell for Harris functional?

1) I think very few people are using it,
2) The overhead is negligeble in this case.

Revision history for this message
Nick Papior (nickpapior) :
review: Approve
lp:~albertog/siesta/4.0-images updated
576. By Alberto Garcia

Check for diagonal folding. Stop Harris runs if found

577. By Alberto Garcia

Add diagonalizer for gamma point with auxiliary supercell

The new routine 'diagk0' is a minor modification of 'diagg' that
can work with an auxiliary supercell while still using real
arithmetic. It is meant to be used when 'force-aux-cell T' is
specified in the input file, for gamma point calculations. (This
option can be set to carry out COOP/COHP analyses, or to avoid
severe folding in test cases.)

The rest of the program logic is kept as it was. It might be worth
rethinking the use of the 'gamma' variable.

578. By Alberto Garcia

Use 'diagk0' when appropriate in pdos and writewave

This might save time when computing the COOP-related wavefunctions,
and when carrying out a pDOS calculation with the 'gamma' sampling.

Unmerged revisions

578. By Alberto Garcia

Use 'diagk0' when appropriate in pdos and writewave

This might save time when computing the COOP-related wavefunctions,
and when carrying out a pDOS calculation with the 'gamma' sampling.

577. By Alberto Garcia

Add diagonalizer for gamma point with auxiliary supercell

The new routine 'diagk0' is a minor modification of 'diagg' that
can work with an auxiliary supercell while still using real
arithmetic. It is meant to be used when 'force-aux-cell T' is
specified in the input file, for gamma point calculations. (This
option can be set to carry out COOP/COHP analyses, or to avoid
severe folding in test cases.)

The rest of the program logic is kept as it was. It might be worth
rethinking the use of the 'gamma' variable.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Src/Makefile'
--- Src/Makefile 2018-04-11 11:00:02 +0000
+++ Src/Makefile 2018-05-08 09:38:49 +0000
@@ -84,7 +84,7 @@
84 chempot.o coceri.o coxmol.o cross.o compute_norm.o\84 chempot.o coceri.o coxmol.o cross.o compute_norm.o\
85 denmat.o denmatlomem.o detover.o dfscf.o m_diagon.o diagon.o digcel.o \85 denmat.o denmatlomem.o detover.o dfscf.o m_diagon.o diagon.o digcel.o \
86 fft.o dhscf.o constr.o diagk_file.o \86 fft.o dhscf.o constr.o diagk_file.o \
87 diagg.o diagk.o diagkp.o diag2g.o diag2k.o diagpol.o \87 diagg.o diagk0.o diagk.o diagkp.o diag2g.o diag2k.o diagpol.o \
88 diagsprl.o dipole.o dismin.o dnaefs.o doping_uniform.o dot.o \88 diagsprl.o dipole.o dismin.o dnaefs.o doping_uniform.o dot.o \
89 m_efield.o egandd.o ener3.o ener3lomem.o errorf.o extrapolon.o \89 m_efield.o egandd.o ener3.o ener3lomem.o errorf.o extrapolon.o \
90 fixed.o interpolation.o gradient.o gradientlomem.o grdsam.o \90 fixed.o interpolation.o gradient.o gradientlomem.o grdsam.o \
@@ -474,6 +474,8 @@
474diagg.o: writewave.o474diagg.o: writewave.o
475diagk.o: compute_norm.o fermid.o parallel.o parallelsubs.o precision.o sys.o475diagk.o: compute_norm.o fermid.o parallel.o parallelsubs.o precision.o sys.o
476diagk.o: writewave.o476diagk.o: writewave.o
477diagk0.o: alloc.o fermid.o parallel.o parallelsubs.o precision.o sys.o
478diagk0.o: writewave.o
477diagk_file.o: fermid.o iowfs_netcdf.o parallel.o parallelsubs.o precision.o479diagk_file.o: fermid.o iowfs_netcdf.o parallel.o parallelsubs.o precision.o
478diagk_file.o: sys.o writewave.o480diagk_file.o: sys.o writewave.o
479diagkp.o: alloc.o fermid.o parallel.o parallelsubs.o precision.o sys.o481diagkp.o: alloc.o fermid.o parallel.o parallelsubs.o precision.o sys.o
@@ -528,8 +530,8 @@
528grdsam.o: alloc.o dhscf.o files.o m_mpi_utils.o m_partial_charges.o parallel.o530grdsam.o: alloc.o dhscf.o files.o m_mpi_utils.o m_partial_charges.o parallel.o
529grdsam.o: precision.o siesta_geom.o siesta_options.o sys.o units.o531grdsam.o: precision.o siesta_geom.o siesta_options.o sys.o units.o
530hsparse.o: alloc.o atm_types.o atmfuncs.o atomlist.o listsc.o mneighb.o532hsparse.o: alloc.o atm_types.o atmfuncs.o atomlist.o listsc.o mneighb.o
531hsparse.o: parallel.o parallelsubs.o precision.o siesta_options.o sorting.o533hsparse.o: parallel.o parallelsubs.o precision.o sorting.o sparse_matrices.o
532hsparse.o: sparse_matrices.o sys.o534hsparse.o: sys.o
533idiag.o: parallel.o sys.o535idiag.o: parallel.o sys.o
534initatom.o: atmparams.o atom.o atom_options.o basis_io.o basis_specs.o536initatom.o: atmparams.o atom.o atom_options.o basis_io.o basis_specs.o
535initatom.o: basis_types.o electrostatic.o old_atmfuncs.o precision.o537initatom.o: basis_types.o electrostatic.o old_atmfuncs.o precision.o
@@ -703,6 +705,8 @@
703ofc.o: alloc.o files.o precision.o units.o705ofc.o: alloc.o files.o precision.o units.o
704old_atmfuncs.o: alloc.o atmparams.o precision.o sys.o706old_atmfuncs.o: alloc.o atmparams.o precision.o sys.o
705on_subs.o: alloc.o onmod.o onmod.o707on_subs.o: alloc.o onmod.o onmod.o
708one.diagk0.o: compute_norm.o fermid.o parallel.o parallelsubs.o precision.o
709one.diagk0.o: sys.o writewave.o
706onmod.o: precision.o710onmod.o: precision.o
707optical.o: alloc.o atomlist.o densematrix.o fermid.o files.o parallel.o711optical.o: alloc.o atomlist.o densematrix.o fermid.o files.o parallel.o
708optical.o: parallelsubs.o precision.o sys.o units.o712optical.o: parallelsubs.o precision.o sys.o units.o
709713
=== added file 'Src/diagk0.F'
--- Src/diagk0.F 1970-01-01 00:00:00 +0000
+++ Src/diagk0.F 2018-05-08 09:38:49 +0000
@@ -0,0 +1,295 @@
1!
2! Copyright (C) 1996-2016 The SIESTA group
3! This file is distributed under the terms of the
4! GNU General Public License: see COPYING in the top directory
5! or http://www.gnu.org/copyleft/gpl.txt.
6! See Docs/Contributors.txt for a list of contributors.
7!
8 subroutine diagk0( nspin, nuo, maxuo, maxnh, maxnd,
9 & maxo, numh, listhptr, listh, numd,
10 & listdptr, listd, H, S,
11 & getD, getPSI, fixspin, qtot, qs, temp, e1, e2,
12 & no_s, indxuo,
13 & eo, qo, Dnew, Enew, ef, efs, Entropy,
14 & Haux, Saux, psi, nuotot, occtol,
15 & iscf, neigwanted )
16C *********************************************************************
17C Subroutine to calculate the eigenvalues and eigenvectors, density
18C and energy-density matrices, and occupation weights of each
19C eigenvector, for given Hamiltonian and Overlap matrices (including
20C spin polarization). Gamma-point version.
21C Writen by J.Soler, August 1998.
22C **************************** INPUT **********************************
23C integer nspin : Number of spin components (1 or 2)
24C integer nuo : Number of basis orbitals local to node
25C integer maxuo : Last dimension of xij
26C Must be at least max(indxuo)
27C integer maxnh : Maximum number of orbitals interacting
28C integer maxnd : Maximum number of nonzero elements of
29C each row of density matrix
30C integer maxo : First dimension of eo and qo
31C integer numh(nuo) : Number of nonzero elements of each row
32C of hamiltonian matrix
33C integer listhptr(nuo) : Pointer to each row (-1) of the
34C hamiltonian matrix
35C integer listh(maxnh) : Nonzero hamiltonian-matrix element
36C column indexes for each matrix row
37C integer numd(nuo) : Number of nonzero elements of each row
38C ofdensity matrix
39C integer listdptr(nuo) : Pointer to each row (-1) of the
40C density matrix
41C integer listd(maxnd) : Nonzero density-matrix element column
42C indexes for each matrix row
43C real*8 H(maxnh,nspin) : Hamiltonian in sparse form
44C real*8 S(maxnh) : Overlap in sparse form
45C logical getD : Find occupations and density matrices?
46C logical getPSI : Find and print wavefunctions?
47C logical fixspin : Fix the spin of the system?
48C real*8 qtot : Number of electrons in unit cell
49C real*8 qs(nspin) : Number of electrons in unit cell for each
50C spin component (if fixed spin option is used)
51C real*8 temp : Electronic temperature
52C real*8 e1, e2 : Energy range for density-matrix states
53C (to find local density of states)
54C Not used if e1 > e2
55C integer no_s : Number of orbitals in auxiliary supercell
56C integer indxuo(no_s) : Map from aux supercell to unit cell
57C integer nuotot : total number of orbitals per unit cell
58C over all processors
59C integer iscf : SCF cycle number
60C real*8 occtol : Occupancy threshold for DM build
61C integer neigwanted : Number of eigenvalues wanted
62C *************************** OUTPUT **********************************
63C real*8 eo(maxo,nspn) : Eigenvalues
64C ******************** OUTPUT (only if getD=.true.) *******************
65C real*8 qo(maxo,nspn) : Occupations of eigenstates
66C real*8 Dnew(maxnd,nspin) : Output Density Matrix
67C real*8 Enew(maxnd,nspin) : Output Energy-Density Matrix
68C real*8 ef : Fermi energy
69C real*8 efs(nspin) : Fermi energy for each spin
70C (for fixed spin calculations)
71C real*8 Entropy : Electronic entropy
72C *************************** AUXILIARY *******************************
73C real*8 Haux(nuotot,nuo) : Auxiliary space for the hamiltonian matrix
74C real*8 Saux(nuotot,nuo) : Auxiliary space for the overlap matrix
75C real*8 psi(nuotot,maxuo,nspin) : Auxiliary space for the eigenvectors
76C real*8 aux(nuotot) : Extra auxiliary space
77C *************************** UNITS ***********************************
78C eo, Enew and ef returned in the units of H.
79C *************************** PARALLEL ********************************
80C The auxiliary arrays are now no longer symmetry and so the order
81C of referencing has been changed in several places to reflect this.
82C *********************************************************************
83C
84C Modules
85C
86 use precision
87 use sys
88 use parallel, only : Node, Nodes, BlockSize
89 use parallelsubs, only : LocalToGlobalOrb
90 use writewave, only : writew
91 use m_fermid, only : fermid, fermispin, stepf
92 use alloc
93
94#ifdef MPI
95 use mpi_siesta
96#endif
97
98 implicit none
99
100#ifdef MPI
101 integer
102 & MPIerror
103#endif
104
105 integer
106 & iscf, maxnd, maxnh, maxuo, maxo, nuo, nspin, nuotot,
107 & neigwanted
108
109 integer
110 & listh(maxnh), numh(nuo), listhptr(nuo),
111 & listd(maxnd), numd(nuo), listdptr(nuo)
112
113 real(dp)
114 & Dnew(maxnd,nspin), e1, e2, ef, Enew(maxnd,nspin),
115 & Entropy, eo(maxo,nspin), H(maxnh,nspin), qo(maxo,nspin),
116 & qtot, qs(nspin), S(maxnh), temp, efs(nspin), occtol
117
118 real(dp)
119 & Haux(nuotot,nuo), Saux(nuotot,nuo), psi(nuotot,maxuo,nspin)
120
121 real(dp), dimension(1), parameter :: wk = (/ 1.0_dp /)
122 integer, parameter :: nk = 1
123
124 integer no_s, indxuo(no_s)
125
126 logical
127 & getD, getPSI, fixspin
128
129 external rdiag
130
131C Internal variables .............................................
132 integer ie, io, iio, ispin, ix, j, jo, BNode, iie, ind,
133 & ierror, nd
134 integer jo_s
135 real(dp) ee, eei, qe, qei, rt, t, k(3)
136
137 integer :: maxnuo, mm
138 integer, pointer :: nuo_LOC(:)
139 real(dp), pointer :: psi_tmp(:), paux(:)
140
141C Solve eigenvalue problem
142 do ispin = 1,nspin
143 call timer( 'r-eigvec', 1 )
144 call timer( 'r-buildHS', 1 )
145 do io = 1,nuo
146 do jo = 1,nuotot
147 Saux(jo,io) = 0.0d0
148 Haux(jo,io) = 0.0d0
149 enddo
150 enddo
151 do io = 1,nuo
152 do j = 1,numh(io)
153 ind = listhptr(io) + j
154 jo_s = listh(ind)
155 jo = indxuo(jo_s) ! In unit cell
156 Saux(jo,io) = Saux(jo,io) + S(ind)
157 Haux(jo,io) = Haux(jo,io) + H(ind,ispin)
158 enddo
159 enddo
160 call timer( 'r-buildHS', 2 )
161 call rdiag( Haux, Saux, nuotot, nuo, nuotot, eo(1,ispin),
162 & psi(1,1,ispin), neigwanted, iscf, ierror )
163 call timer( 'r-eigvec', 2 )
164
165
166C Check error flag and take appropriate action
167 if (ierror.gt.0) then
168 call die('Terminating due to failed diagonalisation')
169 elseif (ierror.lt.0) then
170C Repeat diagonalisation with increased memory to handle clustering
171 do io = 1,nuo
172 do jo = 1,nuotot
173 Saux(jo,io) = 0.0d0
174 Haux(jo,io) = 0.0d0
175 enddo
176 enddo
177 do io = 1,nuo
178 do j = 1,numh(io)
179 ind = listhptr(io) + j
180 jo_s = listh(ind)
181 jo = indxuo(jo_s) ! In unit cell
182 Saux(jo,io) = Saux(jo,io) + S(ind)
183 Haux(jo,io) = Haux(jo,io) + H(ind,ispin)
184 enddo
185 enddo
186 call rdiag( Haux, Saux, nuotot, nuo, nuotot, eo(1,ispin),
187 & psi(1,1,ispin), nuotot, iscf, ierror )
188 endif
189
190 if (getPSI) then
191 do ix = 1,3
192 k(ix) = 0.0d0
193 enddo
194 call writew(nuotot,nuo,1,k,ispin,
195 & eo(1,ispin),psi(1,1,ispin),.true.)
196 endif
197
198 enddo
199C Check if we are done ................................................
200 if (.not.getD) return
201
202C Find new Fermi energy and occupation weights ........................
203 if (fixspin) then
204 call fermispin( nspin, nspin, nk, wk, maxo, neigwanted,
205 & eo, temp, qs, qo, efs, Entropy )
206 else
207 call fermid( nspin, nspin, nk, wk, maxo, neigwanted, eo,
208 & temp, qtot, qo, ef, Entropy )
209 endif
210
211C Find weights for local density of states ............................
212 if (e1 .lt. e2) then
213* e1 = e1 - ef
214* e2 = e2 - ef
215 t = max( temp, 1.d-6 )
216 rt = 1.0d0/t
217 do ispin = 1,nspin
218 do io = 1,nuotot
219 qo(io,ispin) = ( stepf((eo(io,ispin)-e2)*rt) -
220 & stepf((eo(io,ispin)-e1)*rt)) *
221 & 2.0d0/dble(nspin)
222 enddo
223 enddo
224 endif
225
226 if (nuo.gt.0) then
227C New density and energy-density matrices of unit-cell orbitals .......
228 nd = listdptr(nuo) + numd(nuo)
229 Dnew(1:nd,1:nspin) = 0.0d0
230 Enew(1:nd,1:nspin) = 0.0d0
231 endif
232
233 call timer( 'r-buildD', 1 )
234C Global operation to form new density matrix
235 nullify( nuo_LOC )
236 call re_alloc( nuo_LOC, 0, Nodes-1, 'nuo_LOC', 'diagk0' )
237#ifdef MPI
238 call MPI_Allgather( nuo, 1, MPI_INTEGER, nuo_LOC, 1,
239 & MPI_INTEGER, MPI_Comm_World, MPIerror )
240#else
241 nuo_LOC(0) = nuo
242#endif
243 maxnuo = 0
244 do BNode=0, Nodes-1
245 maxnuo = max(nuo_LOC(BNode),maxnuo)
246 enddo
247 nullify( PSI_TMP )
248 call re_alloc( PSI_TMP, 1, nuotot*maxnuo*nspin, 'PSI_TMP',
249 & 'diagk0' )
250
251 do Bnode=0, Nodes-1
252 if (BNode.eq.Node) then
253 mm = 0
254 do ispin= 1, nspin
255 do io= 1, nuo
256 PSI_TMP(mm+1:mm+nuotot) = PSI(1:nuotot,io, ispin)
257 mm = mm + nuotot
258 enddo
259 enddo
260 endif
261#ifdef MPI
262 call MPI_Bcast( PSI_TMP, nuotot*nuo_LOC(Bnode)*nspin,
263 & MPI_double_precision, BNode, MPI_Comm_World,
264 & MPIerror )
265#endif
266 do ispin = 1,nspin
267 do io = 1,nuo
268 call LocalToGlobalOrb(io,Node,Nodes,iio)
269 mm = (ispin-1)*nuo_LOC(Bnode)*nuotot
270 do iie = 1,nuo_LOC(Bnode)
271 call LocalToGlobalOrb(iie,BNode,Nodes,ie)
272 qe = qo(ie,ispin)
273 if (abs(qe).gt.occtol) then
274 paux => PSI_TMP(mm+1:mm+nuotot)
275 ee = qe*eo(ie,ispin)
276 qei = qe*paux(iio)
277 eei = ee*paux(iio)
278 do j = 1,numd(io)
279 ind = listdptr(io) + j
280 jo_s = listd(ind)
281 jo = indxuo(jo_s) ! In unit cell
282 Dnew(ind,ispin) = Dnew(ind,ispin) + qei*paux(jo)
283 Enew(ind,ispin) = Enew(ind,ispin) + eei*paux(jo)
284 enddo
285 endif
286 mm = mm + nuotot
287 enddo
288 enddo
289 enddo
290 enddo
291
292 call timer( 'r-buildD', 2 )
293 call de_alloc( nuo_LOC, 'nuo_LOC', 'diagk0' )
294 call de_alloc( PSI_TMP, 'PSI_TMP', 'diagk0' )
295 end
0296
=== modified file 'Src/diagon.F'
--- Src/diagon.F 2017-02-21 07:36:32 +0000
+++ Src/diagon.F 2018-05-08 09:38:49 +0000
@@ -126,7 +126,7 @@
126 . fixspin, gamma, getD, getPSI126 . fixspin, gamma, getD, getPSI
127127
128 external128 external
129 . diagg, diagk, diag2g, diag2k, readsp, diagsprl129 . diagg, diagk0, diagk, diag2g, diag2k, readsp, diagsprl
130#ifdef CDF130#ifdef CDF
131 external diagk_file131 external diagk_file
132#endif132#endif
@@ -255,6 +255,7 @@
255 . eo, qo, Dnew, Enew, ef, efs, Entropy,255 . eo, qo, Dnew, Enew, ef, efs, Entropy,
256 . Haux, Saux, psi, Haux, Saux, aux, 256 . Haux, Saux, psi, Haux, Saux, aux,
257 . nuotot, occtol, iscf )257 . nuotot, occtol, iscf )
258 call output_kpoint_occupation()
258 else259 else
259#endif260#endif
260#ifndef CDF261#ifndef CDF
@@ -279,8 +280,22 @@
279 . eo, qo, Dnew, Enew, ef, efs, Entropy,280 . eo, qo, Dnew, Enew, ef, efs, Entropy,
280 . Haux, Saux, psi, Haux, Saux, aux, 281 . Haux, Saux, psi, Haux, Saux, aux,
281 . nuotot, occtol, iscf, neigwanted )282 . nuotot, occtol, iscf, neigwanted )
283 call output_kpoint_occupation()
282#endif284#endif
283 else285 else
286 if ( (nk==1) .and.
287 $ sum(kpoint(:,1)) == 0.0_dp) then
288!
289! Use special version (This is still gamma)
290!
291 call diagk0( nspin, nuo, maxuo, maxnh, maxnd, maxo,
292 . numh, listhptr, listh, numd, listdptr, listd,
293 . H, S, getD, getPSI, fixspin, qtot, qs, temp, e1, e2,
294 . no, indxuo,
295 . eo, qo, Dnew, Enew, ef, efs, Entropy,
296 . Haux, Saux, psi, nuotot, occtol, iscf,
297 . neigwanted )
298 else
284 call diagk( nspin, nuo, no, maxspn, maxnh, maxnd, 299 call diagk( nspin, nuo, no, maxspn, maxnh, maxnd,
285 . maxo, numh, listhptr, listh, numd, listdptr,300 . maxo, numh, listhptr, listh, numd, listdptr,
286 . listd, H, S, getD, getPSI, fixspin, qtot, qs, temp, 301 . listd, H, S, getD, getPSI, fixspin, qtot, qs, temp,
@@ -288,8 +303,9 @@
288 . eo, qo, Dnew, Enew, ef, efs, Entropy,303 . eo, qo, Dnew, Enew, ef, efs, Entropy,
289 . Haux, Saux, psi, Haux, Saux, aux, 304 . Haux, Saux, psi, Haux, Saux, aux,
290 . nuotot, occtol, iscf )305 . nuotot, occtol, iscf )
306 call output_kpoint_occupation()
307 endif
291 endif308 endif
292 call output_kpoint_occupation()
293#ifdef MPI309#ifdef MPI
294 endif310 endif
295#endif311#endif
296312
=== modified file 'Src/hsparse.F'
--- Src/hsparse.F 2016-01-25 16:00:16 +0000
+++ Src/hsparse.F 2018-05-08 09:38:49 +0000
@@ -48,7 +48,8 @@
48 subroutine hsparse( negl, cell, nsc, na, isa, xa,48 subroutine hsparse( negl, cell, nsc, na, isa, xa,
49 & lasto, lastkb, iphorb, iphkb, 49 & lasto, lastkb, iphorb, iphkb,
50 & nlhmax, gamma,50 & nlhmax, gamma,
51 $ set_xijo, folding)51 $ set_xijo, folding,
52 $ diagonal_folding, debug_folding)
5253
53 use precision54 use precision
54 use parallel, only : Node, Nodes55 use parallel, only : Node, Nodes
@@ -61,7 +62,7 @@
61 use neighbour, only : mneighb, reset_neighbour_arrays62 use neighbour, only : mneighb, reset_neighbour_arrays
62 use sys, only : die63 use sys, only : die
63 use alloc, only : re_alloc, de_alloc64 use alloc, only : re_alloc, de_alloc
64 use atomlist, only : no_l65 use atomlist, only : no_l, indxuo
65 use sparse_matrices, only : listhptr, numh, listh, xijo66 use sparse_matrices, only : listhptr, numh, listh, xijo
66 implicit none67 implicit none
6768
@@ -76,6 +77,8 @@
76 logical, intent(in) :: gamma77 logical, intent(in) :: gamma
77 logical, intent(in) :: set_xijo78 logical, intent(in) :: set_xijo
78 logical, intent(out) :: folding79 logical, intent(out) :: folding
80 logical, intent(out) :: diagonal_folding
81 logical, intent(in), optional :: debug_folding
7982
80 external timer83 external timer
8184
@@ -99,8 +102,6 @@
99 & rci, rcj, rck, rij, rik, rjk,102 & rci, rcj, rck, rij, rik, rjk,
100 & rmax, rmaxkb, rmaxo103 & rmax, rmaxkb, rmaxo
101104
102 logical, save :: warn1 = .false.
103
104 real(dp), dimension(:), pointer :: rckb105 real(dp), dimension(:), pointer :: rckb
105 logical, dimension(:), pointer :: conect106 logical, dimension(:), pointer :: conect
106 integer, dimension(:), pointer :: index107 integer, dimension(:), pointer :: index
@@ -108,14 +109,18 @@
108 integer, dimension(:), pointer :: listhtmp109 integer, dimension(:), pointer :: listhtmp
109110
110 logical :: connected111 logical :: connected
111112 logical :: debug
113 integer :: nprints ! for debugging
112C -------------------------------------114C -------------------------------------
113#ifdef DEBUG115
114 call write_debug( ' PRE hsparse' )
115#endif
116C Start time counter116C Start time counter
117 call timer( 'hsparse', 1 )117 call timer( 'hsparse', 1 )
118118
119 debug = .false.
120 if (present(debug_folding)) then
121 debug = debug_folding
122 endif
123
119C Check size of internal arrays124C Check size of internal arrays
120 ncells = nsc(1) * nsc(2) * nsc(3)125 ncells = nsc(1) * nsc(2) * nsc(3)
121 nua = na / ncells126 nua = na / ncells
@@ -192,6 +197,7 @@
192 enddo197 enddo
193198
194 folding = .false.199 folding = .false.
200 diagonal_folding = .false.
195201
196C------------------------------------C202C------------------------------------C
197C Find number of non-zeros in H C203C Find number of non-zeros in H C
@@ -324,6 +330,7 @@
324C------------------------------------C330C------------------------------------C
325C Find full H sparsity pattern C331C Find full H sparsity pattern C
326C------------------------------------C332C------------------------------------C
333 nprints = 0
327C Loop on atoms in unit cell334C Loop on atoms in unit cell
328 do ia = 1,nua335 do ia = 1,nua
329C Find neighbour atoms within maximum range336C Find neighbour atoms within maximum range
@@ -396,62 +403,53 @@
396 endif403 endif
397404
398 if (connected) then405 if (connected) then
399 if (conect(jo)) then406 if (conect(jo)) then
400 folding = .true.407 folding = .true.
401408 if (io == indxuo(jo)) then
402 ! This test is now deferred to be able409 diagonal_folding = .true.
403 ! to catch multiple images while avoiding410 endif
404 ! false positives (i.e., we test first411
405 ! whether there is indeed a connection).412 ! If already connected and using supercell, the
406413 ! latter might not be big enough... We defer
407 if (.true.) then414 ! the decision on whether to kill the program
408 ! If already connected and using supercell, 415 ! to the caller. Here keep the first instance
409 ! the latter might not be big enough...
410 ! We warn the user and keep the first instance
411 ! of xij (same behavior as the old xijorb, as416 ! of xij (same behavior as the old xijorb, as
412 ! earlier jnats are closer)417 ! earlier jnats are closer)
413 ! Warn also if Gamma-point calculation, just418 if (debug) then
414 ! in case419 ! This might not be pretty in
415 if (.not.warn1) then420 ! parallel. Better to build a list of a few
416 if (Node.eq.0) then421 ! cases, and pass it to the caller.
417 if (gamma) then422 if (nprints <= 20) then
418 call check_cohp(io,jo)423 print "(a,2i6,a)",
419 else424 . 'WARNING: orbital pair ',io,indxuo(jo),
420 write(6,'(/,a,2i6,a,/,a)')
421 . 'WARNING: orbital pair ',io,jo,
422 . ' is multiply connected'425 . ' is multiply connected'
423 endif426 nprints = nprints + 1
424 endif427 endif
425 warn1 = .true.428 endif
426 endif429
427 endif430 else
428431
429 else432 conect(jo) = .true.
430433 numh(iio) = numh(iio) + 1
431 conect(jo) = .true.434 ind = listhptr(iio)+numh(iio)
432 numh(iio) = numh(iio) + 1435 listh(ind) = jo
433 ind = listhptr(iio)+numh(iio)436 if (set_xijo) then
434 listh(ind) = jo437 xijo(1:3,ind) = xij(1:3,jnat)
435 if (set_xijo) then438 endif
436 xijo(1:3,ind) = xij(1:3,jnat)
437 endif439 endif
438 endif440 endif
439 endif441 enddo
440 enddo442 enddo
441 enddo
442443
443C Restore conect array for next orbital io444C Restore conect array for next orbital io
444 do j = 1,numh(iio)445 do j = 1,numh(iio)
445 jo = listh(listhptr(iio)+j)446 jo = listh(listhptr(iio)+j)
446 conect(jo) = .false.447 conect(jo) = .false.
447 enddo448 enddo
448 endif ! iio > 0449 endif ! iio > 0
449 enddo ! io450 enddo ! io
450 enddo ! ia451 enddo ! ia
451452
452!! print "(a5,i3,a40,3i8)",
453!! $ "Node: ", Node, "in hsparse nuo, nuotot, nlhmax: ",
454!! $ nuo, nuotot, nlhmax
455453
456C Initialize listsc454C Initialize listsc
457 call LISTSC_INIT( nsc, nuotot )455 call LISTSC_INIT( nsc, nuotot )
@@ -466,28 +464,7 @@
466 call de_alloc( rckb, 'rckb', 'hsparse' )464 call de_alloc( rckb, 'rckb', 'hsparse' )
467465
468 call timer( 'hsparse', 2 )466 call timer( 'hsparse', 2 )
469#ifdef DEBUG467
470 call write_debug( ' POS hsparse' )
471#endif
472 end subroutine hsparse468 end subroutine hsparse
473
474 subroutine check_cohp(io,jo)
475 use siesta_options, only: write_coop
476
477 integer, intent(in) :: io, jo
478
479 if (write_coop) then
480 write(6,'(/,a,2i6,a,/,a)')
481 . 'NOTE: orbital pair ',io,jo,
482 . ' (at least) is multiply connected.',
483 . 'NOTE: Your COOP/COHP analysis might ' //
484 $ 'be affected by folding.'
485 write(0,'(/,a,2i6,a,/,a)')
486 . 'NOTE: orbital pair ',io,jo,
487 . ' (at least) is multiply connected.',
488 . 'NOTE: Your COOP/COHP analysis might ' //
489 $ 'be affected by folding.'
490 endif
491 end subroutine check_cohp
492469
493 end module m_hsparse470 end module m_hsparse
494471
=== modified file 'Src/new_dm.F'
--- Src/new_dm.F 2018-04-06 12:32:04 +0000
+++ Src/new_dm.F 2018-05-08 09:38:49 +0000
@@ -485,6 +485,7 @@
485 use mpi_siesta485 use mpi_siesta
486#endif486#endif
487 use units, only : pi487 use units, only : pi
488 use sparse_matrices, only: S
488489
489 implicit none490 implicit none
490491
@@ -655,7 +656,7 @@
655 endif656 endif
656657
657658
658 else659 else ! Initialize with neutral atoms
659660
660C See whether specific initial spins are given in a DM.InitSpin block661C See whether specific initial spins are given in a DM.InitSpin block
661C and read them in a loop on atoms where lines are read and parsed662C and read them in a loop on atoms where lines are read and parsed
@@ -903,6 +904,24 @@
903904
904 endif905 endif
905906
907 ! We have initialized with atomic information. Correct in case we
908 ! are using such a small cell that there are direct interactions
909 ! of orbitals with their own images, and we insist on using the
910 ! Gamma-point only. Otherwise S(diagonal) is always 1.0 and the
911 ! simple atomic-orbital superposition works as intended.
912
913
914 do io = 1, no_l
915 call LocalToGlobalOrb(io,Node,Nodes,iio)
916 do in = 1,numh(io)
917 ind = listhptr(io)+in
918 jo = listh(ind)
919 if (iio .eq. jo) then ! diagonal element
920 Dscf(ind,:) = Dscf(ind,:) / S(ind)
921 endif
922 enddo
923 enddo
924
906 endif925 endif
907926
908 end subroutine initdm927 end subroutine initdm
909928
=== modified file 'Src/pdos.F'
--- Src/pdos.F 2018-05-07 07:36:34 +0000
+++ Src/pdos.F 2018-05-08 09:38:49 +0000
@@ -180,11 +180,19 @@
180 . XIJ, INDXUO, NK, KPOINT, WK, EO,180 . XIJ, INDXUO, NK, KPOINT, WK, EO,
181 . HAUX, SAUX, PSI, DTOT, DPR, NO_U )181 . HAUX, SAUX, PSI, DTOT, DPR, NO_U )
182 else182 else
183 call pdosk( NSPIN, NUO, NO, MAXSPN, MAXNH,183 if ((nk==1) .and. (sum(kpoint(:,1)) == 0.0d0)) then
184 ! pdosg already setup for auxiliary supercell!!
185 call pdosg( NSPIN, NUO, NO, MAXSPN, MAXNH,
186 . MAXO, NUMH, LISTHPTR, LISTH, H, S,
187 . E1, E2, NHIST, SIGMA, INDXUO, EO,
188 . HAUX, SAUX, PSI, DTOT, DPR, NO_U )
189 else
190 call pdosk( NSPIN, NUO, NO, MAXSPN, MAXNH,
184 . MAXO, NUMH, LISTHPTR, LISTH, H, S,191 . MAXO, NUMH, LISTHPTR, LISTH, H, S,
185 . E1, E2, NHIST, SIGMA, 192 . E1, E2, NHIST, SIGMA,
186 . XIJ, INDXUO, NK, KPOINT, WK, EO,193 . XIJ, INDXUO, NK, KPOINT, WK, EO,
187 . HAUX, SAUX, PSI, DTOT, DPR, NO_U )194 . HAUX, SAUX, PSI, DTOT, DPR, NO_U )
195 endif
188 endif196 endif
189 endif197 endif
190198
191199
=== modified file 'Src/state_init.F'
--- Src/state_init.F 2018-04-11 09:23:27 +0000
+++ Src/state_init.F 2018-05-08 09:38:49 +0000
@@ -48,7 +48,7 @@
48 use m_mpi_utils, only: globalize_or48 use m_mpi_utils, only: globalize_or
49 use m_mpi_utils, only: globalize_sum49 use m_mpi_utils, only: globalize_sum
50 use domain_decom, only: domainDecom, use_dd, use_dd_perm50 use domain_decom, only: domainDecom, use_dd, use_dd_perm
5151 use fdf, only: fdf_get
52#ifdef TRANSIESTA52#ifdef TRANSIESTA
53 use m_ts_options, only : onlyS53 use m_ts_options, only : onlyS
54 use sys, only : bye54 use sys, only : bye
@@ -69,6 +69,7 @@
69 integer :: i, ix, iadispl, ixdispl69 integer :: i, ix, iadispl, ixdispl
70 logical :: auxchanged ! Auxiliary supercell changed?70 logical :: auxchanged ! Auxiliary supercell changed?
71 logical :: folding, folding171 logical :: folding, folding1
72 logical :: diag_folding, diag_folding1
72 logical :: foundxv ! dummy for call to ioxv73 logical :: foundxv ! dummy for call to ioxv
73 real(dp) :: dummy_qspin(8)74 real(dp) :: dummy_qspin(8)
74 external :: madelung, timer75 external :: madelung, timer
@@ -255,7 +256,39 @@
255! analyses.256! analyses.
256 call hsparse( negl, scell, nsc, na_s, isa, xa, lasto,257 call hsparse( negl, scell, nsc, na_s, isa, xa, lasto,
257 & lastkb, iphorb, iphKB, maxnh, gamma,258 & lastkb, iphorb, iphKB, maxnh, gamma,
258 $ set_xijo=.true., folding=folding1)259 $ set_xijo=.true., folding=folding1,
260 $ diagonal_folding=diag_folding1,
261 $ debug_folding=fdf_get('debug-folding',.false.))
262!
263 call globalize_or(diag_folding1,diag_folding)
264 if (diag_folding .and. gamma) then
265 if (IOnode) then
266 write(6,"(a)") "Gamma-point calculation " //
267 $ "with interaction between periodic images!"
268 write(6,"(a)") "Some features might not work optimally"
269 endif
270 if (harrisfun) call die("Harris functional run needs " //
271 $ "'force-aux-cell T'")
272 endif
273 !
274 call globalize_or(folding1,folding)
275 if (folding) then
276 if (gamma) then
277 if (IOnode) then
278 write(6,"(a)") "Gamma-point calculation " //
279 $ "with multiply-connected orbital pairs"
280 write(6,"(a)") "Folding of H and S implicitly performed"
281 call check_cohp()
282 endif
283 else
284 write(6,"(a,/,a)") "Non Gamma-point calculation " //
285 $ "with multiply-connected orbital pairs " //
286 $ "in auxiliary supercell.",
287 $ "Possible internal error. " //
288 $ "Use 'debug-folding T' to debug."
289 call die("Inadequate auxiliary supercell")
290 endif
291 endif
259!292!
260 call globalize_sum(maxnh,nnz)293 call globalize_sum(maxnh,nnz)
261 if (cml_p) then294 if (cml_p) then
@@ -269,12 +302,6 @@
269 call cmlEndPropertyList(mainXML)302 call cmlEndPropertyList(mainXML)
270 endif303 endif
271 !304 !
272 call globalize_or(folding1,folding)
273 if (folding) then
274 if (IOnode) then
275 print *, "Folding of H and S is implicitly performed"
276 endif
277 endif
278 !305 !
279 ! If using domain decomposition, redistribute orbitals306 ! If using domain decomposition, redistribute orbitals
280 ! for this geometry, based on the hsparse info. 307 ! for this geometry, based on the hsparse info.
@@ -387,4 +414,22 @@
387414
388!--------------------------------------------------------------------------- END415!--------------------------------------------------------------------------- END
389 END subroutine state_init416 END subroutine state_init
417
418 subroutine check_cohp()
419 use siesta_options, only: write_coop
420
421 if (write_coop) then
422 write(6,'(/,a,a,/,a)')
423 . 'NOTE: There are multiply-connected orbitals.',
424 . 'NOTE: Your COOP/COHP analysis might ' //
425 $ 'be affected by folding.',
426 . 'NOTE: Use "force-aux-cell T" or k-point sampling'
427 write(0,'(/,a,a,/,a)')
428 . 'NOTE: There are multiply-connected orbitals.',
429 . 'NOTE: Your COOP/COHP analysis might ' //
430 $ 'be affected by folding.',
431 . 'NOTE: Use "force-aux-cell T" or k-point sampling'
432 endif
433 end subroutine check_cohp
434
390 END module m_state_init435 END module m_state_init
391436
=== modified file 'Src/writewave.F'
--- Src/writewave.F 2017-10-04 09:48:27 +0000
+++ Src/writewave.F 2018-05-08 09:38:49 +0000
@@ -471,6 +471,7 @@
471 data Dnew, Enew, e1, e2, qk, qtot, temp, wk /8*0.d0/471 data Dnew, Enew, e1, e2, qk, qtot, temp, wk /8*0.d0/
472472
473 logical SaveParallelOverK473 logical SaveParallelOverK
474 external :: diagg, diagk0, diagk
474475
475C Get local number of orbitals476C Get local number of orbitals
476#ifdef MPI477#ifdef MPI
@@ -600,8 +601,17 @@
600 ParallelOverK = .false.601 ParallelOverK = .false.
601 ResetFirstCall = .true.602 ResetFirstCall = .true.
602603
603 604 if ( (nk==1) .and. (sum(kpoint(:,1)) == 0.0d0)) then
604 call diagk( nspin, nuo, no, maxspn, maxnh, maxnh, 605 call diagk0( nspin, nuo, maxuo, maxnh, maxnh,
606 . maxo, numh, listhptr, listh, numh, listhptr,
607 . listh, H, S, getD, getPSI,
608 . fixspin, qtot, qs, temp,
609 . e1, e2,
610 $ no, indxuo,
611 $ ek, qk, Dnew, Enew, ef, efs, Entropy,
612 . Haux, Saux, psi, nuotot, occtol, 1, nuotot )
613 else
614 call diagk( nspin, nuo, no, maxspn, maxnh, maxnh,
605 . maxo, numh, listhptr, listh, numh, listhptr, 615 . maxo, numh, listhptr, listh, numh, listhptr,
606 . listh, H, S, getD, getPSI,616 . listh, H, S, getD, getPSI,
607 . fixspin, qtot, qs, temp,617 . fixspin, qtot, qs, temp,
@@ -609,6 +619,7 @@
609 . ek, qk, Dnew, Enew, ef, efs, Entropy,619 . ek, qk, Dnew, Enew, ef, efs, Entropy,
610 . Haux, Saux, psi, Haux, Saux, aux, nuotot,620 . Haux, Saux, psi, Haux, Saux, aux, nuotot,
611 . occtol, 1 )621 . occtol, 1 )
622 endif
612 ParallelOverK = SaveParallelOverK623 ParallelOverK = SaveParallelOverK
613 ResetFirstCall = .false.624 ResetFirstCall = .false.
614625
@@ -663,7 +674,7 @@
663 real(SP), dimension(:,:), allocatable :: aux !! NOTE SP674 real(SP), dimension(:,:), allocatable :: aux !! NOTE SP
664675
665 external io_assign, io_close676 external io_assign, io_close
666677
667C ...................678C ...................
668679
669C Allocate auxiliary arrays680C Allocate auxiliary arrays
670681
=== modified file 'version.info'
--- version.info 2018-05-07 12:07:29 +0000
+++ version.info 2018-05-08 09:38:49 +0000
@@ -1,1 +1,10 @@
1<<<<<<< TREE
1siesta-4.0--5752siesta-4.0--575
3=======
4siesta-4.0--573--folding-578
5
6
7
8
9
10>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches