64 type(lda_u_t),
intent(in) :: this
65 character(len=*),
intent(in) :: dir
66 type(states_elec_t),
intent(in) :: st
67 type(namespace_t),
intent(in) :: namespace
69 integer :: iunit, ios, ispin, im, imp, ios2, inn
70 type(orbitalset_t),
pointer :: os, os2
75 iunit =
io_open(trim(dir) //
"/occ_matrices", namespace, action=
'write')
76 write(iunit,
'(a)')
' Occupation matrices '
78 do ios = 1, this%norbsets
79 os => this%orbsets(ios)
81 do ispin = 1,st%d%nspin
82 write(iunit,
'(a, i4, a, i4)')
' Orbital set ', ios,
' spin ', ispin
85 write(iunit,
'(1x)',advance=
'no')
88 do imp = 1, os%norbs-1
89 write(iunit,
'(f14.8)', advance=
'no') this%dn(im, imp, ispin, ios)
91 write(iunit,
'(f14.8)') this%dn(im, os%norbs, ispin, ios)
93 do imp = 1, os%norbs-1
94 write(iunit,
'(f14.8,f14.8)', advance=
'no') this%zn(im, imp, ispin, ios)
96 write(iunit,
'(f14.8,f14.8)') this%zn(im, os%norbs, ispin, ios)
104 iunit =
io_open(trim(dir) //
"/renorm_occ_matrices", namespace, action=
'write')
105 write(iunit,
'(a)')
' Renormalized occupation matrices '
107 do ios = 1, this%norbsets
108 os => this%orbsets(ios)
109 do ispin = 1, st%d%nspin
110 write(iunit,
'(a, i4, a, i4)')
' Orbital set ', ios,
' spin ', ispin
113 write(iunit,
'(1x)',advance=
'no')
116 do imp = 1, os%norbs-1
117 write(iunit,
'(f14.8)', advance=
'no') this%dn_alt(im, imp, ispin, ios)
119 write(iunit,
'(f14.8)') this%dn_alt(im, os%norbs, ispin, ios)
121 do imp = 1, os%norbs-1
122 write(iunit,
'(f14.8,f14.8)', advance=
'no') this%zn_alt(im, imp, ispin, ios)
124 write(iunit,
'(f14.8,f14.8)') this%zn_alt(im, os%norbs, ispin, ios)
132 if(this%intersite)
then
133 iunit =
io_open(trim(dir) //
"/intersite_occ_matrices", namespace, action=
'write')
134 write(iunit,
'(a)')
' Intersite occupation matrices '
135 do ios = 1, this%norbsets
136 os => this%orbsets(ios)
137 do ispin = 1, st%d%nspin
138 write(iunit,
'(a, i4, a, i4)')
' Orbital set ', ios,
' spin ', ispin
139 do inn = 1, os%nneighbors
140 write(iunit,
'(a, i4)')
' Neighbour ', inn
141 ios2 = os%map_os(inn)
142 os2 => this%orbsets(ios2)
145 write(iunit,
'(1x)',advance=
'no')
148 do imp = 1, os2%norbs - 1
149 write(iunit,
'(f14.8)', advance=
'no') this%dn_ij(im, imp, ispin, ios, inn)
151 write(iunit,
'(f14.8)') this%dn_ij(im, os2%norbs, ispin, ios, inn)
153 do imp = 1, os2%norbs - 1
154 write(iunit,
'(f14.8,f14.8)', advance=
'no') this%zn_ij(im, imp, ispin, ios, inn)
156 write(iunit,
'(f14.8,f14.8)') this%zn_ij(im, os2%norbs, ispin, ios, inn)
172 type(
lda_u_t),
intent(in) :: this
173 character(len=*),
intent(in) :: dir
176 integer :: iunit, ios
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(:,:)
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(:,:)
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(:)
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))
583 if (err /= 0) ierr = ierr + 1
584 safe_deallocate_a(docc)
586 safe_allocate(zocc(1:occsize))
590 if (err /= 0) ierr = ierr + 1
591 safe_deallocate_a(zocc)
596 safe_allocate(ueff(1:this%norbsets))
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))
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(:)
648 message(1) =
"Debug: Reading DFT+U restart."
653 safe_allocate(ueff(1:this%norbsets))
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))
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))
697 safe_deallocate_a(docc)
699 safe_allocate(zocc(1:occsize))
706 safe_deallocate_a(zocc)
718 message(1) =
"Debug: Reading DFT+U restart done."
726 type(
lda_u_t),
intent(in) :: this
730 class(
mesh_t),
intent(in) :: mesh
731 integer,
intent(out) :: ierr
733 integer :: coulomb_int_file, idim1, idim2, err
734 integer :: ios, im, imp, impp, imppp
735 character(len=256) :: lines(3)
736 logical :: complex_coulomb_integrals
747 message(1) =
"Debug: Writing Coulomb integrals restart."
750 complex_coulomb_integrals = .false.
751 do ios = 1, this%norbsets
752 if (this%orbsets(ios)%ndim > 1) complex_coulomb_integrals = .
true.
755 coulomb_int_file =
restart_open(restart,
'coulomb_integrals')
760 write(lines(1),
'(a20,i21)')
"norb=", this%norbsets
761 write(lines(2),
'(a20,i21)')
"dim=", st%d%dim
762 write(lines(3),
'(a20,i21)')
"checksum=", mesh%idx%checksum
764 if (err /= 0) ierr = ierr - 2
766 ios_cycle:
do ios = 1, this%norbsets
767 do im = 1, this%orbsets(ios)%norbs
768 do imp = 1, this%orbsets(ios)%norbs
769 do impp = 1, this%orbsets(ios)%norbs
770 do imppp = 1, this%orbsets(ios)%norbs
771 if(.not. complex_coulomb_integrals)
then
772 write(lines(1),
'(i4,i4,i4,i4,i4,e20.12)') ios, im, imp, impp, imppp, this%coulomb(im, imp, impp, imppp, ios)
774 do idim1 = 1, st%d%dim
775 do idim2 = 1, st%d%dim
776 write(lines(1),
'(i4,i4,i4,i4,i4,i4,i4,2e20.12)') ios, im, imp, impp, imppp, idim1, idim2, &
777 real(this%zcoulomb(im, imp, impp, imppp, idim1, idim2, ios), real64) , &
778 aimag(this%zcoulomb(im, imp, impp, imppp, idim1, idim2, ios))
794 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, namespace, restart, st, mesh, ierr)
subroutine, public lda_u_write_magnetization(dir, this, ions, mesh, st, namespace)
subroutine, public lda_u_write_effectiveu(dir, this, 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)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
This module handles the communicators for the various parallelization strategies.
subroutine, public restart_close(restart, iunit)
Close a file previously opened with restart_open.
subroutine, public restart_write(restart, iunit, lines, nlines, ierr)
logical pure function, public restart_skip(restart)
Returns true if the restart information should neither be read nor written. This might happen because...
integer function, public restart_open(restart, filename, status, position, silent)
Open file "filename" found inside the current restart directory. Depending on the type of restart,...
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.