63 type(lda_u_t),
intent(in) :: this
64 character(len=*),
intent(in) :: dir
65 type(states_elec_t),
intent(in) :: st
66 type(namespace_t),
intent(in) :: namespace
68 integer :: iunit, ios, ispin, im, imp, ios2, inn
69 type(orbitalset_t),
pointer :: os, os2
73 if (st%system_grp%is_root())
then
74 iunit =
io_open(trim(dir) //
"/occ_matrices", namespace, action=
'write')
75 write(iunit,
'(a)')
' Occupation matrices '
77 do ios = 1, this%norbsets
78 os => this%orbsets(ios)
80 do ispin = 1,st%d%nspin
81 write(iunit,
'(a, i4, a, i4)')
' Orbital set ', ios,
' spin ', ispin
84 write(iunit,
'(1x)',advance=
'no')
87 do imp = 1, os%norbs-1
88 write(iunit,
'(f14.8)', advance=
'no') this%dn(im, imp, ispin, ios)
90 write(iunit,
'(f14.8)') this%dn(im, os%norbs, ispin, ios)
92 do imp = 1, os%norbs-1
93 write(iunit,
'(f14.8,f14.8)', advance=
'no') this%zn(im, imp, ispin, ios)
95 write(iunit,
'(f14.8,f14.8)') this%zn(im, os%norbs, ispin, ios)
103 iunit =
io_open(trim(dir) //
"/renorm_occ_matrices", namespace, action=
'write')
104 write(iunit,
'(a)')
' Renormalized occupation matrices '
106 do ios = 1, this%norbsets
107 os => this%orbsets(ios)
108 do ispin = 1, st%d%nspin
109 write(iunit,
'(a, i4, a, i4)')
' Orbital set ', ios,
' spin ', ispin
112 write(iunit,
'(1x)',advance=
'no')
115 do imp = 1, os%norbs-1
116 write(iunit,
'(f14.8)', advance=
'no') this%dn_alt(im, imp, ispin, ios)
118 write(iunit,
'(f14.8)') this%dn_alt(im, os%norbs, ispin, ios)
120 do imp = 1, os%norbs-1
121 write(iunit,
'(f14.8,f14.8)', advance=
'no') this%zn_alt(im, imp, ispin, ios)
123 write(iunit,
'(f14.8,f14.8)') this%zn_alt(im, os%norbs, ispin, ios)
131 if(this%intersite)
then
132 iunit =
io_open(trim(dir) //
"/intersite_occ_matrices", namespace, action=
'write')
133 write(iunit,
'(a)')
' Intersite occupation matrices '
134 do ios = 1, this%norbsets
135 os => this%orbsets(ios)
136 do ispin = 1, st%d%nspin
137 write(iunit,
'(a, i4, a, i4)')
' Orbital set ', ios,
' spin ', ispin
138 do inn = 1, os%nneighbors
139 write(iunit,
'(a, i4)')
' Neighbour ', inn
140 ios2 = os%map_os(inn)
141 os2 => this%orbsets(ios2)
144 write(iunit,
'(1x)',advance=
'no')
147 do imp = 1, os2%norbs - 1
148 write(iunit,
'(f14.8)', advance=
'no') this%dn_ij(im, imp, ispin, ios, inn)
150 write(iunit,
'(f14.8)') this%dn_ij(im, os2%norbs, ispin, ios, inn)
152 do imp = 1, os2%norbs - 1
153 write(iunit,
'(f14.8,f14.8)', advance=
'no') this%zn_ij(im, imp, ispin, ios, inn)
155 write(iunit,
'(f14.8,f14.8)') this%zn_ij(im, os2%norbs, ispin, ios, inn)
171 type(
lda_u_t),
intent(in) :: this
172 character(len=*),
intent(in) :: dir
176 integer :: iunit, ios
180 if (st%system_grp%is_root())
then
181 iunit =
io_open(trim(dir) //
"/effectiveU", namespace, action=
'write')
185 write(iunit,
'(a,6x,14x,a)')
' Orbital',
'U'
186 do ios = 1, this%norbsets
187 if (.not. this%basisfromstates)
then
188 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
189 if (this%orbsets(ios)%nn /= 0)
then
190 write(iunit,
'(i4,a10, 2x, i1, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
191 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
194 write(iunit,
'(i4,a10, 3x, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
199 if (this%orbsets(ios)%nn /= 0)
then
200 write(iunit,
'(i4,a10, 2x, i1, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
201 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
202 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
205 write(iunit,
'(i4,a10, 3x, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
207 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
218 write(iunit,
'(a,6x,14x,a)')
' Orbital',
'J'
219 do ios = 1, this%norbsets
220 if (.not. this%basisfromstates)
then
221 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
222 if (this%orbsets(ios)%nn /= 0)
then
223 write(iunit,
'(i4,a10, 2x, i1, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
224 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
227 write(iunit,
'(i4,a10, 3x, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
232 if (this%orbsets(ios)%nn /= 0)
then
233 write(iunit,
'(i4,a10, 2x, i1, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
234 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
235 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
238 write(iunit,
'(i4,a10, 3x, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
240 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
257 type(
lda_u_t),
intent(in) :: this
259 character(len=*),
intent(in) :: dir
262 integer :: iunit, ios
263 real(real64),
allocatable :: kanamori(:,:)
267 if (st%system_grp%is_root())
then
268 safe_allocate(kanamori(1:3,1:this%norbsets))
272 iunit =
io_open(trim(dir) //
"/kanamoriU", namespace, action=
'write')
275 write(iunit,
'(a,6x,14x,a)')
' Orbital',
'U'
276 do ios = 1, this%norbsets
277 if (.not. this%basisfromstates)
then
278 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
279 if (this%orbsets(ios)%nn /= 0)
then
280 write(iunit,
'(i4,a10, 2x, i1, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
281 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
284 write(iunit,
'(i4,a10, 3x, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
289 if (this%orbsets(ios)%nn /= 0)
then
290 write(iunit,
'(i4,a10, 2x, i1, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
291 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
292 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
295 write(iunit,
'(i4,a10, 3x, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
297 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
308 write(iunit,
'(a,6x,14x,a)')
' Orbital',
'Up'
309 do ios = 1, this%norbsets
310 if (.not. this%basisfromstates)
then
311 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
312 if (this%orbsets(ios)%nn /= 0)
then
313 write(iunit,
'(i4,a10, 2x, i1, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
314 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
317 write(iunit,
'(i4,a10, 3x, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
322 if (this%orbsets(ios)%nn /= 0)
then
323 write(iunit,
'(i4,a10, 2x, i1, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
324 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
325 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
328 write(iunit,
'(i4,a10, 3x, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
330 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
340 write(iunit,
'(a,6x,14x,a)')
' Orbital',
'J'
341 do ios = 1, this%norbsets
342 if (.not. this%basisfromstates)
then
343 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
344 if (this%orbsets(ios)%nn /= 0)
then
345 write(iunit,
'(i4,a10, 2x, i1, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
346 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
349 write(iunit,
'(i4,a10, 3x, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
354 if (this%orbsets(ios)%nn /= 0)
then
355 write(iunit,
'(i4,a10, 2x, i1, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
356 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
357 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
360 write(iunit,
'(i4,a10, 3x, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
362 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
374 safe_deallocate_a(kanamori)
385 type(
lda_u_t),
intent(in) :: this
386 character(len=*),
intent(in) :: dir
387 type(
ions_t),
intent(in) :: ions
388 class(
mesh_t),
intent(in) :: mesh
392 integer :: iunit, ia, ios, im
393 real(real64),
allocatable :: mm(:,:)
395 if (.not. st%system_grp%is_root())
return
400 iunit =
io_open(trim(dir)//
"/magnetization.xsf", namespace, action=
'write', position=
'asis')
402 if (this%nspins > 1)
then
403 safe_allocate(mm(1:3, 1:ions%natoms))
406 do ios = 1, this%norbsets
407 ia = this%orbsets(ios)%iatom
408 do im = 1, this%orbsets(ios)%norbs
410 mm(3, ia) = mm(3, ia) + this%dn(im,im,1,ios) - this%dn(im,im,2,ios)
412 mm(3, ia) = mm(3, ia) + real(this%zn(im,im,1,ios) - this%zn(im,im,2,ios), real64)
414 if (this%nspins /= this%spin_channels)
then
415 mm(1, ia) = mm(1, ia) + 2*real(this%zn(im,im,3,ios), real64)
416 mm(2, ia) = mm(2, ia) - 2*aimag(this%zn(im,im,3,ios))
421 call write_xsf_geometry(iunit, ions%space, ions%latt, ions%pos, ions%atom, mesh, forces = mm)
422 safe_deallocate_a(mm)
432 type(
lda_u_t),
intent(in) :: this
433 integer,
optional,
intent(in) :: iunit
434 type(
namespace_t),
optional,
intent(in) :: namespace
441 write(
message(2),
'(a,6x,14x,a)')
' Orbital',
'U'
444 do ios = 1, this%norbsets
445 if (.not. this%basisfromstates)
then
446 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
447 if (this%orbsets(ios)%nn /= 0)
then
448 write(
message(1),
'(i4,a10, 2x, i1, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
449 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
452 write(
message(1),
'(i4,a10, 3x, a1, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
457 if (this%orbsets(ios)%nn /= 0)
then
458 write(
message(1),
'(i4,a10, 2x, i1, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
459 this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
460 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
463 write(
message(1),
'(i4,a10, 3x, a1, i1, a2, f15.6)') ios, trim(this%orbsets(ios)%spec%get_label()), &
465 int(
m_two*(this%orbsets(ios)%jj)),
'/2', &
480 type(
lda_u_t),
intent(in) :: this
481 integer,
optional,
intent(in) :: iunit
482 type(
namespace_t),
optional,
intent(in) :: namespace
484 integer :: ios, icopies, ios2
486 if (.not. this%intersite)
return
491 write(
message(2),
'(a,14x,a)')
' Orbital',
'V'
494 do ios = 1, this%norbsets
495 do icopies = 1, this%orbsets(ios)%nneighbors
496 ios2 = this%orbsets(ios)%map_os(icopies)
497 if (.not.this%basisfromstates)
then
498 if (this%orbsets(ios)%ndim == 1 .or. this%basis%combine_j_orbitals)
then
499 if (this%orbsets(ios)%nn /= 0)
then
500 write(
message(1),
'(i4,a10, 2x, i1, a1, i4, 1x, i1, a1, f7.3, f15.6)') ios, &
501 trim(this%orbsets(ios)%spec%get_label()), this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), ios2, &
502 this%orbsets(ios2)%nn,
l_notation(this%orbsets(ios2)%ll), &
507 write(
message(1),
'(i4,a10, 3x, a1, i4, 1x, a1, f7.3, f15.6)') ios, &
508 trim(this%orbsets(ios)%spec%get_label()),
l_notation(this%orbsets(ios)%ll), ios2, &
514 if (this%orbsets(ios)%nn /= 0)
then
515 write(
message(1),
'(i4,a10, 2x, i1, a1, i1, a2, i4, f7.3, f15.6)') ios, &
516 trim(this%orbsets(ios)%spec%get_label()), this%orbsets(ios)%nn,
l_notation(this%orbsets(ios)%ll), &
517 int(
m_two*(this%orbsets(ios)%jj)),
'/2', ios2, &
522 write(
message(1),
'(i4,a10, 3x, a1, i1, a2, i4, f7.3, f15.6)') ios, &
523 trim(this%orbsets(ios)%spec%get_label()),
l_notation(this%orbsets(ios)%ll), &
524 int(
m_two*(this%orbsets(ios)%jj)),
'/2', ios2, &
531 write(
message(1),
'(i4,a10, i4, f7.3, f15.6)') ios,
'states', ios2, &
545 subroutine lda_u_dump(restart, namespace, this, st, mesh, ierr)
548 type(
lda_u_t),
intent(in) :: this
550 class(
mesh_t),
intent(in) :: mesh
551 integer,
intent(out) :: ierr
553 integer :: err, occsize, ios, ncount
554 real(real64),
allocatable :: ueff(:), docc(:), veff(:)
555 complex(real64),
allocatable :: zocc(:)
561 if (restart%skip())
then
566 message(1) =
"Debug: Writing DFT+U restart."
569 occsize = this%maxnorbs*this%maxnorbs*this%nspins*this%norbsets
572 if (this%intersite)
then
573 occsize = occsize + 2*this%maxnorbs*this%maxnorbs*this%nspins*this%norbsets*this%maxneighbors
579 safe_allocate(docc(1:occsize))
582 call restart%write_binary(
"lda_u_occ", occsize, docc, err)
583 if (err /= 0) ierr = ierr + 1
584 safe_deallocate_a(docc)
586 safe_allocate(zocc(1:occsize))
589 call restart%write_binary(
"lda_u_occ", occsize, zocc, err)
590 if (err /= 0) ierr = ierr + 1
591 safe_deallocate_a(zocc)
596 safe_allocate(ueff(1:this%norbsets))
599 call restart%write_binary(
"lda_u_Ueff", this%norbsets, ueff, err)
600 safe_deallocate_a(ueff)
601 if (err /= 0) ierr = ierr + 1
603 if (this%intersite .and. this%maxneighbors > 0)
then
605 do ios = 1, this%norbsets
606 ncount = ncount + this%orbsets(ios)%nneighbors
608 safe_allocate(veff(1:ncount))
610 call restart%write_binary(
"lda_u_Veff", ncount, veff, err)
611 safe_deallocate_a(veff)
612 if (err /= 0) ierr = ierr + 1
618 message(1) =
"Debug: Writing DFT+U restart done."
626 subroutine lda_u_load(restart, this, st, dftu_energy, ierr, occ_only, u_only)
628 type(
lda_u_t),
intent(inout) :: this
630 real(real64),
intent(out) :: dftu_energy
631 integer,
intent(out) :: ierr
632 logical,
optional,
intent(in) :: occ_only
633 logical,
optional,
intent(in) :: u_only
635 integer :: err, occsize, ncount, ios
636 real(real64),
allocatable :: ueff(:), docc(:), veff(:)
637 complex(real64),
allocatable :: zocc(:)
643 if (restart%skip())
then
648 message(1) =
"Debug: Reading DFT+U restart."
653 safe_allocate(ueff(1:this%norbsets))
654 call restart%read_binary(
"lda_u_Ueff", this%norbsets, ueff, err)
660 safe_deallocate_a(ueff)
662 if (this%intersite .and. this%maxneighbors > 0)
then
664 do ios = 1, this%norbsets
665 ncount = ncount + this%orbsets(ios)%nneighbors
667 safe_allocate(veff(1:ncount))
668 call restart%read_binary(
"lda_u_Veff", ncount, veff, err)
674 safe_deallocate_a(veff)
680 occsize = this%maxnorbs*this%maxnorbs*this%nspins*this%norbsets
683 if (this%intersite)
then
684 occsize = occsize + 2*this%maxnorbs*this%maxnorbs*this%nspins*this%norbsets*this%maxneighbors
690 safe_allocate(docc(1:occsize))
691 call restart%read_binary(
"lda_u_occ", occsize, docc, err)
697 safe_deallocate_a(docc)
699 safe_allocate(zocc(1:occsize))
700 call restart%read_binary(
"lda_u_occ", occsize, zocc, err)
706 safe_deallocate_a(zocc)
718 message(1) =
"Debug: Reading DFT+U restart done."
726 type(
lda_u_t),
intent(in) :: this
729 class(
mesh_t),
intent(in) :: mesh
730 integer,
intent(out) :: ierr
732 integer :: coulomb_int_file, idim1, idim2, err
733 integer :: ios, im, imp, impp, imppp
734 character(len=256) :: lines(3)
735 logical :: complex_coulomb_integrals
746 message(1) =
"Debug: Writing Coulomb integrals restart."
749 complex_coulomb_integrals = .false.
750 do ios = 1, this%norbsets
751 if (this%orbsets(ios)%ndim > 1) complex_coulomb_integrals = .
true.
754 coulomb_int_file = restart%open(
'coulomb_integrals')
759 write(lines(1),
'(a20,i21)')
"norb=", this%norbsets
760 write(lines(2),
'(a20,i21)')
"dim=", st%d%dim
761 write(lines(3),
'(a20,i21)')
"checksum=", mesh%idx%checksum
762 call restart%write(coulomb_int_file, lines, 3, err)
763 if (err /= 0) ierr = ierr - 2
765 ios_cycle:
do ios = 1, this%norbsets
766 do im = 1, this%orbsets(ios)%norbs
767 do imp = 1, this%orbsets(ios)%norbs
768 do impp = 1, this%orbsets(ios)%norbs
769 do imppp = 1, this%orbsets(ios)%norbs
770 if(.not. complex_coulomb_integrals)
then
771 write(lines(1),
'(i4,i4,i4,i4,i4,e20.12)') ios, im, imp, impp, imppp, this%coulomb(im, imp, impp, imppp, ios)
773 do idim1 = 1, st%d%dim
774 do idim2 = 1, st%d%dim
775 write(lines(1),
'(i4,i4,i4,i4,i4,i4,i4,2e20.12)') ios, im, imp, impp, imppp, idim1, idim2, &
776 real(this%zcoulomb(im, imp, impp, imppp, idim1, idim2, ios), real64) , &
777 aimag(this%zcoulomb(im, imp, impp, imppp, idim1, idim2, ios))
781 call restart%write(coulomb_int_file, lines, 1, err)
791 call restart%close(coulomb_int_file)
793 message(1) =
"Debug: Writing Coulomb integrals restart done."
character(len=1), dimension(0:3), parameter, public l_notation
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
complex(real64), parameter, public m_z0
subroutine, public write_xsf_geometry(iunit, space, latt, pos, atoms, mesh, forces, index)
for format specification see: http:
subroutine, public io_close(iunit, grp)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public lda_u_write_occupation_matrices(dir, this, st, namespace)
Prints the occupation matrices at the end of the scf calculation.
subroutine, public lda_u_write_kanamoriu(dir, st, this, namespace)
subroutine, public lda_u_dump(restart, namespace, this, st, mesh, ierr)
subroutine, public lda_u_write_u(this, iunit, namespace)
subroutine, public lda_u_load(restart, this, st, dftu_energy, ierr, occ_only, u_only)
subroutine lda_u_dump_coulomb_integrals(this, restart, st, mesh, ierr)
subroutine, public lda_u_write_effectiveu(dir, this, st, namespace)
subroutine, public lda_u_write_magnetization(dir, this, ions, mesh, st, namespace)
subroutine, public lda_u_write_v(this, iunit, namespace)
subroutine, public lda_u_get_effectiveu(this, Ueff)
subroutine, public lda_u_set_effectiveu(this, Ueff)
subroutine, public dlda_u_get_occupations(this, occ)
subroutine, public zcompute_dftu_energy(this, energy, st)
This routine computes the value of the double counting term in the DFT+U energy.
integer, parameter, public dft_u_empirical
subroutine, public compute_acbno_u_kanamori(this, st, kanamori)
subroutine, public zlda_u_update_potential(this, st)
This routine computes the potential that, once multiplied by the projector Pmm' and summed over m and...
subroutine, public dlda_u_set_occupations(this, occ)
subroutine, public lda_u_get_effectivev(this, Veff)
subroutine, public lda_u_set_effectivev(this, Veff)
integer, parameter, public dft_u_acbn0
subroutine, public zlda_u_get_occupations(this, occ)
subroutine, public dcompute_dftu_energy(this, energy, st)
This routine computes the value of the double counting term in the DFT+U energy.
subroutine, public dlda_u_update_potential(this, st)
This routine computes the potential that, once multiplied by the projector Pmm' and summed over m and...
subroutine, public zlda_u_set_occupations(this, occ)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module handles the communicators for the various parallelization strategies.
pure logical function, public states_are_real(st)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
Class to describe DFT+U parameters.
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.