Merge lp:~albertog/siesta/4.0-spin into lp:siesta/4.0
- 4.0-spin
- Merge into rel-4.0
Status: | Merged |
---|---|
Approved by: | Nick Papior |
Approved revision: | 560 |
Merged at revision: | 562 |
Proposed branch: | lp:~albertog/siesta/4.0-spin |
Merge into: | lp:siesta/4.0 |
Diff against target: |
502 lines (+195/-88) 15 files modified
Docs/compatibility.tex (+5/-0) Src/Makefile (+7/-7) Src/compute_dm.F (+1/-9) Src/mixer.F (+1/-1) Src/mulliken.F (+29/-17) Src/new_dm.F (+1/-43) Src/print_spin.F90 (+9/-7) Src/read_options.F90 (+1/-0) Src/scfconvergence_test.F (+19/-0) Src/siesta_options.F90 (+2/-1) Src/state_init.F (+2/-0) Util/DensityMatrix/README (+4/-0) Util/DensityMatrix/dm_noncol_sign_flip4.f90 (+108/-0) Util/DensityMatrix/makefile (+5/-2) version.info (+1/-1) |
To merge this branch: | bzr merge lp:~albertog/siesta/4.0-spin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nick Papior | Approve | ||
Review via email: mp+342997@code.launchpad.net |
Commit message
Spin monitoring in scf cycle. Clarification of sign convention for DM
* Spin monitoring during scf cycle
If the fdf variable 'Spin.In.Scf' is set to 'true', the size and
components of the (total) spin polarization will be printed at every
scf step. This is analogous to the 'Mulliken.In.Scf' feature.
The default for the Spin.In.SCF fdf flag is 'true' for calculations
involving spin.
A single line of spin information is printed, prefixed by ' spin-moment:'.
Note that now, for each scf step, the spin and/or mulliken analyses are
printed *after* the line showing the energies.
The initial spin polarization for every geometry iteration is also
printed in 'state_init', replacing the similar calls in 'new_dm'.
* Use explicitly the same DM_12 sign-convention as in SOC versions
In the non-collinear case, the code is actually using internally the
same sign convention for the "up-down" components of H and the DM as
the spin-orbit-capable (SOC) versions (>= 4.1): The building of the
dense Hamiltonian has the same form and the off-diagonal components
of Vxc are identical. Routines diag2g and diag2k are actually using
the same convention, but with DM* as an intermediate step.
By changing the interface to the outside world, namely the
correspondence between spin angles and the DM in new_dm, and the
calculation of the spin (actually moment) components in spnvec, the
code can now interoperate (i.e., reuse DMs) with the SOC versions.
In order to reuse DM information produced by previous versions of
the program in the non-collinear case, the sign of D(4) of the old
DM has to be changed. This can be achieved with the
dm_noncol_
Description of the change
Alberto Garcia (albertog) wrote : | # |
I agree to remove the old sections.
> On 11 Apr 2018, at 11:41, Nick Papior <email address hidden> wrote:
>
> LGTM
Nick Papior (nickpapior) wrote : | # |
Super! Great!
Preview Diff
1 | === modified file 'Docs/compatibility.tex' | |||
2 | --- Docs/compatibility.tex 2018-04-09 13:45:49 +0000 | |||
3 | +++ Docs/compatibility.tex 2018-04-11 09:36:55 +0000 | |||
4 | @@ -27,6 +27,11 @@ | |||
5 | 27 | internal tables used to compute two-center integrals. Please see | 27 | internal tables used to compute two-center integrals. Please see |
6 | 28 | \opt{Compat.Matel.NRTAB} for details. | 28 | \opt{Compat.Matel.NRTAB} for details. |
7 | 29 | 29 | ||
8 | 30 | In non-collinear-spin calculations, the sign of the fourth spin | ||
9 | 31 | component of the density matrix is reversed. To re-use old \code{DM} files, | ||
10 | 32 | they can be converted using the | ||
11 | 33 | \code{Util/DensityMatrix/dm_noncol_sign_flip4} program. | ||
12 | 34 | |||
13 | 30 | \item[\emph{any} --- 4.0-b2] The following compatibility issues should be remarked when | 35 | \item[\emph{any} --- 4.0-b2] The following compatibility issues should be remarked when |
14 | 31 | comparing with any later version of \siesta. | 36 | comparing with any later version of \siesta. |
15 | 32 | 37 | ||
16 | 33 | 38 | ||
17 | === modified file 'Src/Makefile' | |||
18 | --- Src/Makefile 2018-04-09 14:08:42 +0000 | |||
19 | +++ Src/Makefile 2018-04-11 09:36:55 +0000 | |||
20 | @@ -689,11 +689,10 @@ | |||
21 | 689 | mulliken.o: alloc.o atmfuncs.o parallel.o parallelsubs.o precision.o | 689 | mulliken.o: alloc.o atmfuncs.o parallel.o parallelsubs.o precision.o |
22 | 690 | mulliken.o: siesta_cml.o | 690 | mulliken.o: siesta_cml.o |
23 | 691 | naefs.o: atmfuncs.o mneighb.o new_matel.o precision.o | 691 | naefs.o: atmfuncs.o mneighb.o new_matel.o precision.o |
29 | 692 | new_dm.o: alloc.o atomlist.o m_energies.o m_fdf_global.o m_iodm.o m_mpi_utils.o | 692 | new_dm.o: alloc.o atomlist.o m_energies.o m_fdf_global.o m_iodm.o m_sparse.o |
30 | 693 | new_dm.o: m_sparse.o m_spin.o m_steps.o m_ts_global_vars.o m_ts_iodm.o | 693 | new_dm.o: m_spin.o m_steps.o m_ts_global_vars.o m_ts_iodm.o m_ts_options.o |
31 | 694 | new_dm.o: m_ts_options.o normalize_dm.o parallel.o parallelsubs.o parsing.o | 694 | new_dm.o: normalize_dm.o parallel.o parallelsubs.o parsing.o precision.o |
32 | 695 | new_dm.o: precision.o siesta_geom.o siesta_options.o sparse_matrices.o sys.o | 695 | new_dm.o: siesta_geom.o siesta_options.o sparse_matrices.o sys.o units.o |
28 | 696 | new_dm.o: units.o | ||
33 | 697 | new_matel.o: alloc.o errorf.o interpolation.o matel_registry.o parallel.o | 696 | new_matel.o: alloc.o errorf.o interpolation.o matel_registry.o parallel.o |
34 | 698 | new_matel.o: precision.o radfft.o siesta_options.o spher_harm.o sys.o | 697 | new_matel.o: precision.o radfft.o siesta_options.o spher_harm.o sys.o |
35 | 699 | nlefsm.o: alloc.o atmfuncs.o mneighb.o new_matel.o parallel.o parallelsubs.o | 698 | nlefsm.o: alloc.o atmfuncs.o mneighb.o new_matel.o parallel.o parallelsubs.o |
36 | @@ -768,8 +767,9 @@ | |||
37 | 768 | save_density_matrix.o: m_steps.o m_ts_global_vars.o m_ts_iodm.o precision.o | 767 | save_density_matrix.o: m_steps.o m_ts_global_vars.o m_ts_iodm.o precision.o |
38 | 769 | save_density_matrix.o: siesta_options.o sparse_matrices.o | 768 | save_density_matrix.o: siesta_options.o sparse_matrices.o |
39 | 770 | savepsi.o: alloc.o parallel.o parallelsubs.o precision.o | 769 | savepsi.o: alloc.o parallel.o parallelsubs.o precision.o |
42 | 771 | scfconvergence_test.o: m_convergence.o m_energies.o m_wallclock.o parallel.o | 770 | scfconvergence_test.o: atomlist.o m_convergence.o m_energies.o m_spin.o |
43 | 772 | scfconvergence_test.o: siesta_cml.o siesta_options.o units.o write_subs.o | 771 | scfconvergence_test.o: m_wallclock.o parallel.o siesta_cml.o siesta_geom.o |
44 | 772 | scfconvergence_test.o: siesta_options.o sparse_matrices.o units.o write_subs.o | ||
45 | 773 | schecomm.o: alloc.o | 773 | schecomm.o: alloc.o |
46 | 774 | setatomnodes.o: alloc.o parallel.o precision.o spatial.o sys.o | 774 | setatomnodes.o: alloc.o parallel.o precision.o spatial.o sys.o |
47 | 775 | setspatial.o: alloc.o parallel.o precision.o spatial.o | 775 | setspatial.o: alloc.o parallel.o precision.o spatial.o |
48 | 776 | 776 | ||
49 | === modified file 'Src/compute_dm.F' | |||
50 | --- Src/compute_dm.F 2016-01-25 16:00:16 +0000 | |||
51 | +++ Src/compute_dm.F 2018-04-11 09:36:55 +0000 | |||
52 | @@ -51,6 +51,7 @@ | |||
53 | 51 | 51 | ||
54 | 52 | ! e1>e2 to signal that we do not want DOS weights | 52 | ! e1>e2 to signal that we do not want DOS weights |
55 | 53 | real(dp), parameter :: e1 = 1.0_dp, e2 = -1.0_dp | 53 | real(dp), parameter :: e1 = 1.0_dp, e2 = -1.0_dp |
56 | 54 | real(dp) :: dummy_qspin(8) | ||
57 | 54 | 55 | ||
58 | 55 | !-------------------------------------------------------------- BEGIN | 56 | !-------------------------------------------------------------- BEGIN |
59 | 56 | call timer( 'compute_dm', 1 ) | 57 | call timer( 'compute_dm', 1 ) |
60 | @@ -147,15 +148,6 @@ | |||
61 | 147 | endif | 148 | endif |
62 | 148 | #endif | 149 | #endif |
63 | 149 | 150 | ||
64 | 150 | ! Print populations at each SCF step if requested before mixing ...... | ||
65 | 151 | if (muldeb) then | ||
66 | 152 | if (ionode) write (6,"(/a)") | ||
67 | 153 | & 'siesta: Mulliken populations (DM_out)' | ||
68 | 154 | call mulliken( mullipop, nspin, na_u, no_u, maxnh, | ||
69 | 155 | & numh, listhptr, listh, S, Dscf, isa, | ||
70 | 156 | & lasto, iaorb, iphorb ) | ||
71 | 157 | endif | ||
72 | 158 | |||
73 | 159 | ! Write orbital indexes. JMS Dec.2009 | 151 | ! Write orbital indexes. JMS Dec.2009 |
74 | 160 | 152 | ||
75 | 161 | if (IOnode .and. iscf==1) then | 153 | if (IOnode .and. iscf==1) then |
76 | 162 | 154 | ||
77 | === modified file 'Src/mixer.F' | |||
78 | --- Src/mixer.F 2016-01-25 16:00:16 +0000 | |||
79 | +++ Src/mixer.F 2018-04-11 09:36:55 +0000 | |||
80 | @@ -94,7 +94,7 @@ | |||
81 | 94 | ! entirely correct. It should be moved to the top, | 94 | ! entirely correct. It should be moved to the top, |
82 | 95 | ! or done somewhere else. | 95 | ! or done somewhere else. |
83 | 96 | 96 | ||
85 | 97 | if (muldeb) then | 97 | if (muldeb .and. (.not. mixH)) then |
86 | 98 | if (IONode) | 98 | if (IONode) |
87 | 99 | & write (6,"(/a)") | 99 | & write (6,"(/a)") |
88 | 100 | & 'siesta: Mulliken populations after mixing' | 100 | & 'siesta: Mulliken populations after mixing' |
89 | 101 | 101 | ||
90 | === modified file 'Src/mulliken.F' | |||
91 | --- Src/mulliken.F 2016-01-25 16:00:16 +0000 | |||
92 | +++ Src/mulliken.F 2018-04-11 09:36:55 +0000 | |||
93 | @@ -533,20 +533,26 @@ | |||
94 | 533 | c integer ns : Number of components in spin density matrix | 533 | c integer ns : Number of components in spin density matrix |
95 | 534 | c real*8 qs(ns) : Spin density matrix elements with the convention | 534 | c real*8 qs(ns) : Spin density matrix elements with the convention |
96 | 535 | c is=1 => Q11; is=2 => Q22; is=3 => Real(Q12); | 535 | c is=1 => Q11; is=2 => Q22; is=3 => Real(Q12); |
98 | 536 | c is=4 => Imag(Q12) | 536 | c is=4 => -Imag(Q12) (*Note |
99 | 537 | c ******* Output ***************************************************** | 537 | c ******* Output ***************************************************** |
100 | 538 | c real*8 qt : Total charge | 538 | c real*8 qt : Total charge |
103 | 539 | c real*8 st : Total spin | 539 | c real*8 st : Total spin moment |
104 | 540 | c real*8 sv(3) : Spin vector | 540 | c real*8 sv(3) : Spin moment vector |
105 | 541 | c ******************************************************************** | 541 | c ******************************************************************** |
107 | 542 | 542 | ! | |
108 | 543 | ! Spin magnetic **moments** in bohr magnetons: | ||
109 | 544 | ! m_x = 2 Re{Q12} = 2*qs(3) | ||
110 | 545 | ! m_y = -2 Im{Q12} = 2*qs(4) | ||
111 | 546 | ! m_z = Q11-Q22 = qs(1)-qs(2) | ||
112 | 547 | ! | ||
113 | 548 | ! The spin moment for a spin angular momentum of 1/2 (hbar) is (very close to) 1 bohr magneton. | ||
114 | 549 | ! | ||
115 | 543 | use precision | 550 | use precision |
116 | 544 | 551 | ||
117 | 545 | implicit none | 552 | implicit none |
122 | 546 | integer ns | 553 | integer, intent(in) :: ns |
123 | 547 | real(dp) qs(ns), qt, st, sv(3) | 554 | real(dp), intent(in) :: qs(ns) |
124 | 548 | real(dp) cosph, costh, sinph, sinth, tiny | 555 | real(dp), intent(out) :: qt, st, sv(3) |
121 | 549 | parameter ( tiny = 1.e-12_dp ) | ||
125 | 550 | 556 | ||
126 | 551 | if (ns .eq. 1) then | 557 | if (ns .eq. 1) then |
127 | 552 | qt = qs(1) | 558 | qt = qs(1) |
128 | @@ -561,15 +567,21 @@ | |||
129 | 561 | sv(2) = 0.0_dp | 567 | sv(2) = 0.0_dp |
130 | 562 | sv(3) = st | 568 | sv(3) = st |
131 | 563 | elseif (ns .eq. 4) then | 569 | elseif (ns .eq. 4) then |
141 | 564 | qt = qs(1) + qs(2) | 570 | qt = qs(1) + qs(2) |
142 | 565 | st = sqrt( (qs(1)-qs(2))**2 + 4._dp*(qs(3)**2+qs(4)**2) ) | 571 | sv(1) = 2.0_dp * qs(3) |
143 | 566 | costh = ( qs(1) - qs(2) ) / ( st + tiny ) | 572 | sv(2) = 2.0_dp * qs(4) |
144 | 567 | sinth = sqrt( 1.0_dp - costh**2 ) | 573 | sv(3) = qs(1) - qs(2) |
145 | 568 | cosph = qs(3) / ( sqrt( qs(3)**2 + qs(4)**2 ) + tiny ) | 574 | st = sqrt(sv(1)**2+sv(2)**2+sv(3)**2) |
146 | 569 | sinph = -qs(4) / ( sqrt( qs(3)**2 + qs(4)**2 ) + tiny ) | 575 | ! |
147 | 570 | sv(1) = st * sinth * cosph | 576 | ! ... roundabout way ... |
148 | 571 | sv(2) = st * sinth * sinph | 577 | ! st = sqrt( (qs(1)-qs(2))**2 + 4._dp*(qs(3)**2+qs(4)**2) ) |
149 | 572 | sv(3) = st * costh | 578 | ! costh = ( qs(1) - qs(2) ) / ( st + tiny ) |
150 | 579 | ! sinth = sqrt( 1.0_dp - costh**2 ) | ||
151 | 580 | ! cosph = qs(3) / ( sqrt( qs(3)**2 + qs(4)**2 ) + tiny ) | ||
152 | 581 | ! sinph = qs(4) / ( sqrt( qs(3)**2 + qs(4)**2 ) + tiny ) | ||
153 | 582 | ! sv(1) = st * sinth * cosph | ||
154 | 583 | ! sv(2) = st * sinth * sinph | ||
155 | 584 | ! sv(3) = st * costh | ||
156 | 573 | else | 585 | else |
157 | 574 | write(6,*) 'spnvec: ERROR: invalid argument ns =', ns | 586 | write(6,*) 'spnvec: ERROR: invalid argument ns =', ns |
158 | 575 | return | 587 | return |
159 | 576 | 588 | ||
160 | === modified file 'Src/new_dm.F' | |||
161 | --- Src/new_dm.F 2016-01-25 16:00:16 +0000 | |||
162 | +++ Src/new_dm.F 2018-04-11 09:36:55 +0000 | |||
163 | @@ -842,7 +842,7 @@ | |||
164 | 842 | Dscf(ind,1) = (qio + spio * costh) / 2 | 842 | Dscf(ind,1) = (qio + spio * costh) / 2 |
165 | 843 | Dscf(ind,2) = (qio - spio * costh) / 2 | 843 | Dscf(ind,2) = (qio - spio * costh) / 2 |
166 | 844 | Dscf(ind,3) = spio * sinth * cosph / 2 | 844 | Dscf(ind,3) = spio * sinth * cosph / 2 |
168 | 845 | Dscf(ind,4) = - spio * sinth * sinph / 2 | 845 | Dscf(ind,4) = spio * sinth * sinph / 2 |
169 | 846 | else | 846 | else |
170 | 847 | Dscf(ind,1) = (qio + spio) / 2 | 847 | Dscf(ind,1) = (qio + spio) / 2 |
171 | 848 | Dscf(ind,2) = (qio - spio) / 2 | 848 | Dscf(ind,2) = (qio - spio) / 2 |
172 | @@ -905,48 +905,6 @@ | |||
173 | 905 | 905 | ||
174 | 906 | endif | 906 | endif |
175 | 907 | 907 | ||
176 | 908 | call print_initial_spin() | ||
177 | 909 | |||
178 | 910 | |||
179 | 911 | CONTAINS | ||
180 | 912 | |||
181 | 913 | subroutine print_initial_spin() | ||
182 | 914 | use m_mpi_utils, only: Globalize_sum | ||
183 | 915 | use sparse_matrices, only: S | ||
184 | 916 | |||
185 | 917 | real(dp) :: qspin(nspin) | ||
186 | 918 | integer :: io, j, ispin, ind | ||
187 | 919 | #ifdef MPI | ||
188 | 920 | real(dp) :: qtmp(nspin) | ||
189 | 921 | #endif | ||
190 | 922 | |||
191 | 923 | ! Print spin polarization | ||
192 | 924 | if (nspin .ge. 2) then | ||
193 | 925 | do ispin = 1,nspin | ||
194 | 926 | qspin(ispin) = 0.0_dp | ||
195 | 927 | do io = 1,no_l | ||
196 | 928 | do j = 1,numh(io) | ||
197 | 929 | ind = listhptr(io)+j | ||
198 | 930 | qspin(ispin) = qspin(ispin) + Dscf(ind,ispin) * S(ind) | ||
199 | 931 | enddo | ||
200 | 932 | enddo | ||
201 | 933 | enddo | ||
202 | 934 | |||
203 | 935 | #ifdef MPI | ||
204 | 936 | ! Global reduction of spin components | ||
205 | 937 | call globalize_sum(qspin(1:nspin),qtmp(1:nspin)) | ||
206 | 938 | qspin(1:nspin) = qtmp(1:nspin) | ||
207 | 939 | #endif | ||
208 | 940 | if (nspin .eq. 2) then | ||
209 | 941 | if (IOnode) then | ||
210 | 942 | write(6,'(/,a,f12.6)') | ||
211 | 943 | . 'initdm: Initial spin polarization (Qup-Qdown) =', | ||
212 | 944 | . qspin(1) - qspin(2) | ||
213 | 945 | endif | ||
214 | 946 | endif | ||
215 | 947 | endif | ||
216 | 948 | end subroutine print_initial_spin | ||
217 | 949 | |||
218 | 950 | end subroutine initdm | 908 | end subroutine initdm |
219 | 951 | 909 | ||
220 | 952 | end module m_new_dm | 910 | end module m_new_dm |
221 | 953 | 911 | ||
222 | === modified file 'Src/print_spin.F90' | |||
223 | --- Src/print_spin.F90 2017-03-05 16:38:31 +0000 | |||
224 | +++ Src/print_spin.F90 2018-04-11 09:36:55 +0000 | |||
225 | @@ -45,9 +45,11 @@ | |||
226 | 45 | if (nspin .eq. 2) then | 45 | if (nspin .eq. 2) then |
227 | 46 | 46 | ||
228 | 47 | if (IOnode) then | 47 | if (IOnode) then |
232 | 48 | write(6,'(/,a,f12.6)') & | 48 | Svec(1) = 0.0_dp |
233 | 49 | 'siesta: Total spin polarization (Qup-Qdown) =', & | 49 | Svec(2) = 0.0_dp |
234 | 50 | qspin(1) - qspin(2) | 50 | Svec(3) = qspin(1) - qspin(2) |
235 | 51 | Stot = Svec(3) | ||
236 | 52 | write(6,'(5x,a,f10.5,2f10.1,f10.5)') 'spin moment: S , {S} = ', Stot, Svec | ||
237 | 51 | endif | 53 | endif |
238 | 52 | if (cml_p) call cmlAddProperty(xf=mainXML, & | 54 | if (cml_p) call cmlAddProperty(xf=mainXML, & |
239 | 53 | value=qspin(1)-qspin(2), dictref='siesta:stot', & | 55 | value=qspin(1)-qspin(2), dictref='siesta:stot', & |
240 | @@ -57,10 +59,10 @@ | |||
241 | 57 | 59 | ||
242 | 58 | call spnvec( nspin, qspin, qaux, Stot, Svec ) | 60 | call spnvec( nspin, qspin, qaux, Stot, Svec ) |
243 | 59 | if (IONode) then | 61 | if (IONode) then |
248 | 60 | write(6,'(a,3f12.6)') & | 62 | ! write(6,'(a,3f12.6)') & |
249 | 61 | 'siesta: Total spin polarization (x,y,z) = ', & | 63 | ! 'siesta: Total spin polarization (x,y,z) = ', & |
250 | 62 | qspin(3)*2, qspin(4)*2, qspin(1)-qspin(2) | 64 | ! qspin(3)*2, -qspin(4)*2, qspin(1)-qspin(2) |
251 | 63 | write(6,'(a,4f12.6)') 'siesta: S , {S} = ', Stot, Svec | 65 | write(6,'(5x,a,4f10.5)') 'spin moment: S , {S} = ', Stot, Svec |
252 | 64 | if (cml_p) then | 66 | if (cml_p) then |
253 | 65 | call cmlAddProperty(xf=mainXML, value=Stot, & | 67 | call cmlAddProperty(xf=mainXML, value=Stot, & |
254 | 66 | dictref='siesta:stot', units='siestaUnits:spin') | 68 | dictref='siesta:stot', units='siestaUnits:spin') |
255 | 67 | 69 | ||
256 | === modified file 'Src/read_options.F90' | |||
257 | --- Src/read_options.F90 2018-04-05 07:11:04 +0000 | |||
258 | +++ Src/read_options.F90 2018-04-11 09:36:55 +0000 | |||
259 | @@ -1467,6 +1467,7 @@ | |||
260 | 1467 | dm_normalization_tol = fdf_get( 'DM.NormalizationTolerance',1.0d-5) | 1467 | dm_normalization_tol = fdf_get( 'DM.NormalizationTolerance',1.0d-5) |
261 | 1468 | normalize_dm_during_scf= fdf_get( 'DM.NormalizeDuringSCF',.true.) | 1468 | normalize_dm_during_scf= fdf_get( 'DM.NormalizeDuringSCF',.true.) |
262 | 1469 | muldeb = fdf_get( 'MullikenInSCF' , .false.) | 1469 | muldeb = fdf_get( 'MullikenInSCF' , .false.) |
263 | 1470 | spndeb = fdf_get( 'SpinInSCF' , (nspin>1) ) | ||
264 | 1470 | rijmin = fdf_get( 'WarningMinimumAtomicDistance', & | 1471 | rijmin = fdf_get( 'WarningMinimumAtomicDistance', & |
265 | 1471 | 1.0_dp, 'Bohr' ) | 1472 | 1.0_dp, 'Bohr' ) |
266 | 1472 | bornz = fdf_get( 'BornCharge' , .false. ) | 1473 | bornz = fdf_get( 'BornCharge' , .false. ) |
267 | 1473 | 1474 | ||
268 | === modified file 'Src/scfconvergence_test.F' | |||
269 | --- Src/scfconvergence_test.F 2016-01-25 16:00:16 +0000 | |||
270 | +++ Src/scfconvergence_test.F 2018-04-11 09:36:55 +0000 | |||
271 | @@ -23,6 +23,11 @@ | |||
272 | 23 | use m_convergence, only: converger_t, tolerance | 23 | use m_convergence, only: converger_t, tolerance |
273 | 24 | use m_convergence, only: add_value, is_converged | 24 | use m_convergence, only: add_value, is_converged |
274 | 25 | 25 | ||
275 | 26 | use m_spin, only: nspin | ||
276 | 27 | use sparse_matrices, only: Dscf, S, numh, listhptr, listh, maxnh | ||
277 | 28 | use siesta_geom, only: na_u, isa | ||
278 | 29 | use atomlist, only: no_u, lasto, iaorb, iphorb | ||
279 | 30 | |||
280 | 26 | implicit none | 31 | implicit none |
281 | 27 | 32 | ||
282 | 28 | integer :: iscf | 33 | integer :: iscf |
283 | @@ -32,6 +37,7 @@ | |||
284 | 32 | type(converger_t), intent(inout) :: conv_harris, conv_freeE | 37 | type(converger_t), intent(inout) :: conv_harris, conv_freeE |
285 | 33 | logical, intent(out) :: converged | 38 | logical, intent(out) :: converged |
286 | 34 | 39 | ||
287 | 40 | real(dp) :: dummy_qspin(8) | ||
288 | 35 | !------------------------------------------------------------------- BEGIN | 41 | !------------------------------------------------------------------- BEGIN |
289 | 36 | 42 | ||
290 | 37 | ! convergence test | 43 | ! convergence test |
291 | @@ -59,6 +65,19 @@ | |||
292 | 59 | call wallclock("-------------- end of scf step") | 65 | call wallclock("-------------- end of scf step") |
293 | 60 | endif | 66 | endif |
294 | 61 | 67 | ||
295 | 68 | ! Print spin polarization at each SCF step if requested before mixing | ||
296 | 69 | if (spndeb) then | ||
297 | 70 | call print_spin(dummy_qspin) | ||
298 | 71 | endif | ||
299 | 72 | ! Print populations at each SCF step if requested before mixing ...... | ||
300 | 73 | if (muldeb) then | ||
301 | 74 | if (ionode) write (6,"(/a)") | ||
302 | 75 | & 'siesta: Mulliken populations (DM_out)' | ||
303 | 76 | call mulliken( mullipop, nspin, na_u, no_u, maxnh, | ||
304 | 77 | & numh, listhptr, listh, S, Dscf, isa, | ||
305 | 78 | & lasto, iaorb, iphorb ) | ||
306 | 79 | endif | ||
307 | 80 | |||
308 | 62 | converged = .false. | 81 | converged = .false. |
309 | 63 | 82 | ||
310 | 64 | if (require_energy_convergence) then | 83 | if (require_energy_convergence) then |
311 | 65 | 84 | ||
312 | === modified file 'Src/siesta_options.F90' | |||
313 | --- Src/siesta_options.F90 2018-04-05 07:11:04 +0000 | |||
314 | +++ Src/siesta_options.F90 2018-04-11 09:36:55 +0000 | |||
315 | @@ -97,7 +97,8 @@ | |||
316 | 97 | 97 | ||
317 | 98 | logical :: atmonly ! Set up pseudoatom information only? | 98 | logical :: atmonly ! Set up pseudoatom information only? |
318 | 99 | logical :: harrisfun ! Use Harris functional? | 99 | logical :: harrisfun ! Use Harris functional? |
320 | 100 | logical :: muldeb ! Write Mulliken polpulations at every SCF step? | 100 | logical :: muldeb ! Write Mulliken populations at every SCF step? |
321 | 101 | logical :: spndeb ! Write spin-polarization information at every SCF step? | ||
322 | 101 | logical :: require_energy_convergence ! free Energy conv. to finish SCF iteration? | 102 | logical :: require_energy_convergence ! free Energy conv. to finish SCF iteration? |
323 | 102 | logical :: require_harris_convergence ! to finish SCF iteration? | 103 | logical :: require_harris_convergence ! to finish SCF iteration? |
324 | 103 | logical :: broyden_optim ! Use Broyden method to optimize geometry? | 104 | logical :: broyden_optim ! Use Broyden method to optimize geometry? |
325 | 104 | 105 | ||
326 | === modified file 'Src/state_init.F' | |||
327 | --- Src/state_init.F 2018-02-26 15:23:37 +0000 | |||
328 | +++ Src/state_init.F 2018-04-11 09:36:55 +0000 | |||
329 | @@ -70,6 +70,7 @@ | |||
330 | 70 | logical :: auxchanged ! Auxiliary supercell changed? | 70 | logical :: auxchanged ! Auxiliary supercell changed? |
331 | 71 | logical :: folding, folding1 | 71 | logical :: folding, folding1 |
332 | 72 | logical :: foundxv ! dummy for call to ioxv | 72 | logical :: foundxv ! dummy for call to ioxv |
333 | 73 | real(dp) :: dummy_qspin(8) | ||
334 | 73 | external :: madelung, timer | 74 | external :: madelung, timer |
335 | 74 | real(dp), external :: volcel | 75 | real(dp), external :: volcel |
336 | 75 | 76 | ||
337 | @@ -332,6 +333,7 @@ | |||
338 | 332 | ! Initialize density matrix | 333 | ! Initialize density matrix |
339 | 333 | ! The resizing of Dscf is done inside new_dm | 334 | ! The resizing of Dscf is done inside new_dm |
340 | 334 | call new_dm( auxchanged, numh, listhptr, listh, Dscf) | 335 | call new_dm( auxchanged, numh, listhptr, listh, Dscf) |
341 | 336 | if (nspin > 1) call print_spin(dummy_qspin) | ||
342 | 335 | 337 | ||
343 | 336 | ! Check for size of Pulay auxiliary matrices | 338 | ! Check for size of Pulay auxiliary matrices |
344 | 337 | call init_pulay_arrays() | 339 | call init_pulay_arrays() |
345 | 338 | 340 | ||
346 | === modified file 'Util/DensityMatrix/README' | |||
347 | --- Util/DensityMatrix/README 2009-08-20 09:25:37 +0000 | |||
348 | +++ Util/DensityMatrix/README 2018-04-11 09:36:55 +0000 | |||
349 | @@ -2,3 +2,7 @@ | |||
350 | 2 | filter the contribution of certain orbitals to the DM. | 2 | filter the contribution of certain orbitals to the DM. |
351 | 3 | 3 | ||
352 | 4 | Also, experimental octave scripts to read DM.nc and DMHS.nc files. | 4 | Also, experimental octave scripts to read DM.nc and DMHS.nc files. |
353 | 5 | |||
354 | 6 | To allow reuse of non-collinear DM files produced with versions < | ||
355 | 7 | 4.0.2, use the program dm_noncol_sign_flip4. | ||
356 | 8 | |||
357 | 5 | 9 | ||
358 | === added file 'Util/DensityMatrix/dm_noncol_sign_flip4.f90' | |||
359 | --- Util/DensityMatrix/dm_noncol_sign_flip4.f90 1970-01-01 00:00:00 +0000 | |||
360 | +++ Util/DensityMatrix/dm_noncol_sign_flip4.f90 2018-04-11 09:36:55 +0000 | |||
361 | @@ -0,0 +1,108 @@ | |||
362 | 1 | ! | ||
363 | 2 | ! Copyright (C) 1996-2018 The SIESTA group | ||
364 | 3 | ! This file is distributed under the terms of the | ||
365 | 4 | ! GNU General Public License: see COPYING in the top directory | ||
366 | 5 | ! or http://www.gnu.org/copyleft/gpl.txt. | ||
367 | 6 | ! See Docs/Contributors.txt for a list of contributors. | ||
368 | 7 | ! | ||
369 | 8 | program dm_noncol_sign_flip4 | ||
370 | 9 | |||
371 | 10 | ! | ||
372 | 11 | ! Changes the sign of the "4" component of a DM (useful to re-use DM files created | ||
373 | 12 | ! with versions prior to 4.0.2 in the non-collinear case). | ||
374 | 13 | ! | ||
375 | 14 | ! Usage: dm_noncol_sign_flip4 | ||
376 | 15 | ! | ||
377 | 16 | ! The input file must be named "DM" (a symbolic link would do) | ||
378 | 17 | ! The output file is called "DMSIGNFLIP4" | ||
379 | 18 | ! | ||
380 | 19 | implicit none | ||
381 | 20 | |||
382 | 21 | integer, parameter :: dp = selected_real_kind(14,100) | ||
383 | 22 | |||
384 | 23 | integer :: norbs ! Number of atomic orbitals | ||
385 | 24 | integer :: nnzs ! Total number of orbital interactions | ||
386 | 25 | integer :: nspin ! Number of spins | ||
387 | 26 | |||
388 | 27 | integer :: iog, ispin, iostat, j | ||
389 | 28 | |||
390 | 29 | integer, dimension(:), allocatable :: numd | ||
391 | 30 | integer, dimension(:), allocatable :: row_pointer | ||
392 | 31 | integer, dimension(:), allocatable :: column | ||
393 | 32 | real(dp), dimension(:,:), allocatable :: dm | ||
394 | 33 | |||
395 | 34 | !----------------------------------------------------- | ||
396 | 35 | |||
397 | 36 | open(unit=1,file="DM",form="unformatted",status="old",action="read", & | ||
398 | 37 | position="rewind",iostat=iostat) | ||
399 | 38 | if (iostat /= 0) then | ||
400 | 39 | print *, "File DM cannot be opened" | ||
401 | 40 | STOP | ||
402 | 41 | endif | ||
403 | 42 | |||
404 | 43 | read(1) norbs, nspin | ||
405 | 44 | print *, "Norbs, nspin: ", norbs, nspin | ||
406 | 45 | |||
407 | 46 | if (nspin /= 4) then | ||
408 | 47 | print *, "The DM is not from a non-collinear spin calculation" | ||
409 | 48 | STOP | ||
410 | 49 | endif | ||
411 | 50 | |||
412 | 51 | allocate(numd(1:norbs),row_pointer(1:norbs)) | ||
413 | 52 | |||
414 | 53 | read(1) (numd(iog),iog=1,norbs) | ||
415 | 54 | nnzs = sum(numd(1:norbs)) | ||
416 | 55 | ! | ||
417 | 56 | allocate(column(1:nnzs),dm(1:nnzs,1:nspin)) | ||
418 | 57 | |||
419 | 58 | ! Compute global row pointer | ||
420 | 59 | row_pointer(1) = 0 | ||
421 | 60 | do iog=2,norbs | ||
422 | 61 | row_pointer(iog) = row_pointer(iog-1) + numd(iog-1) | ||
423 | 62 | enddo | ||
424 | 63 | |||
425 | 64 | ! | ||
426 | 65 | ! Column information | ||
427 | 66 | ! | ||
428 | 67 | do iog = 1, norbs | ||
429 | 68 | read(1) (column(row_pointer(iog)+j),j=1,numd(iog)) | ||
430 | 69 | enddo | ||
431 | 70 | |||
432 | 71 | ! | ||
433 | 72 | ! DM | ||
434 | 73 | ! | ||
435 | 74 | do ispin = 1, nspin | ||
436 | 75 | do iog = 1, norbs | ||
437 | 76 | read(1) (dm(row_pointer(iog)+j,ispin),j=1,numd(iog)) | ||
438 | 77 | enddo | ||
439 | 78 | enddo | ||
440 | 79 | |||
441 | 80 | close(1) | ||
442 | 81 | ! | ||
443 | 82 | ! Change sign | ||
444 | 83 | ! | ||
445 | 84 | dm(:,4) = -dm(:,4) | ||
446 | 85 | ! | ||
447 | 86 | |||
448 | 87 | open(unit=1,file="DMSIGNFLIP4",form="unformatted",status="new",action="write", & | ||
449 | 88 | position="rewind",iostat=iostat) | ||
450 | 89 | if (iostat /= 0) then | ||
451 | 90 | print *, "A file DMSIGNFLIP4 exists. Please remove or change its name" | ||
452 | 91 | STOP | ||
453 | 92 | endif | ||
454 | 93 | |||
455 | 94 | write(1) norbs, nspin | ||
456 | 95 | write(1) (numd(iog),iog=1,norbs) | ||
457 | 96 | do iog = 1, norbs | ||
458 | 97 | write(1) (column(row_pointer(iog)+j),j=1,numd(iog)) | ||
459 | 98 | enddo | ||
460 | 99 | do ispin = 1, nspin | ||
461 | 100 | do iog = 1, norbs | ||
462 | 101 | write(1) (dm(row_pointer(iog)+j,ispin),j=1,numd(iog)) | ||
463 | 102 | enddo | ||
464 | 103 | enddo | ||
465 | 104 | |||
466 | 105 | close(1) | ||
467 | 106 | |||
468 | 107 | |||
469 | 108 | end program dm_noncol_sign_flip4 | ||
470 | 0 | 109 | ||
471 | === modified file 'Util/DensityMatrix/makefile' | |||
472 | --- Util/DensityMatrix/makefile 2016-01-25 16:00:16 +0000 | |||
473 | +++ Util/DensityMatrix/makefile 2018-04-11 09:36:55 +0000 | |||
474 | @@ -21,7 +21,7 @@ | |||
475 | 21 | .SUFFIXES: .f .F .o .a .f90 .F90 | 21 | .SUFFIXES: .f .F .o .a .f90 .F90 |
476 | 22 | # | 22 | # |
477 | 23 | default: dm2cdf cdf2dm | 23 | default: dm2cdf cdf2dm |
479 | 24 | all: dm2cdf cdf2dm dmfilter | 24 | all: dm2cdf cdf2dm dmfilter dm_noncol_sign_flip4 |
480 | 25 | # | 25 | # |
481 | 26 | OBJDIR=Obj | 26 | OBJDIR=Obj |
482 | 27 | include ../../$(OBJDIR)/arch.make | 27 | include ../../$(OBJDIR)/arch.make |
483 | @@ -46,8 +46,11 @@ | |||
484 | 46 | dmfilter: dmfilter.o | 46 | dmfilter: dmfilter.o |
485 | 47 | $(FC) $(LDFLAGS) -o $@ dmfilter.o | 47 | $(FC) $(LDFLAGS) -o $@ dmfilter.o |
486 | 48 | # | 48 | # |
487 | 49 | dm_noncol_sign_flip4: dm_noncol_sign_flip4.o | ||
488 | 50 | $(FC) $(LDFLAGS) -o $@ dm_noncol_sign_flip4.o | ||
489 | 51 | # | ||
490 | 49 | clean: | 52 | clean: |
492 | 50 | rm -f *.o dm2cdf cdf2dm dmfilter *.o *.*d | 53 | rm -f *.o dm2cdf cdf2dm dmfilter dm_noncol_sign_flip4 *.o *.*d |
493 | 51 | # | 54 | # |
494 | 52 | 55 | ||
495 | 53 | 56 | ||
496 | 54 | 57 | ||
497 | === modified file 'version.info' | |||
498 | --- version.info 2018-04-09 14:08:42 +0000 | |||
499 | +++ version.info 2018-04-11 09:36:55 +0000 | |||
500 | @@ -1,1 +1,1 @@ | |||
502 | 1 | siesta-4.0--561 | 1 | siesta-4.0--561--spin-560 |
LGTM with the small changes. I think we should just delete the lines that you have commented out (by choosing better alternatives). No need to have them there... :)