38 use,
intrinsic :: iso_fortran_env
91 logical :: complex_ylms
92 logical :: initialized
95 integer,
allocatable :: atom(:)
96 integer,
allocatable :: level(:)
97 integer,
allocatable :: ddim(:)
98 logical :: alternative
100 integer,
allocatable :: cst(:, :)
101 integer,
allocatable :: ck(:, :)
102 real(4),
allocatable :: dbuff_single(:, :, :, :)
103 complex(4),
allocatable :: zbuff_single(:, :, :, :)
104 real(real64),
allocatable :: dbuff(:, :, :, :)
105 complex(real64),
allocatable :: zbuff(:, :, :, :)
106 logical :: save_memory
107 logical :: initialized_orbitals
108 real(real64) :: orbital_scale_factor
111 logical,
allocatable :: is_empty(:)
117 real(real64),
allocatable :: radius(:)
118 real(real64) :: lapdist
122 integer,
allocatable :: basis_atom(:)
123 integer,
allocatable :: basis_orb(:)
124 integer,
allocatable :: atom_orb_basis(:, :)
125 integer,
allocatable :: norb_atom(:)
127 integer :: lsize(1:2)
128 integer :: nproc(1:2)
129 integer :: myroc(1:2)
130 integer :: desc(1:BLACS_DLEN)
131 logical,
allocatable :: calc_atom(:)
132 real(real64) :: diag_tol
133 type(submesh_t),
allocatable :: sphere(:)
134 type(batch_t),
allocatable :: orbitals(:)
135 logical,
allocatable :: is_orbital_initialized(:)
139 integer,
parameter :: &
140 INITRHO_PARAMAGNETIC = 1, &
148 subroutine lcao_init(this, namespace, space, gr, ions, st)
149 type(lcao_t),
intent(out) :: this
150 type(namespace_t),
intent(in) :: namespace
151 type(electron_space_t),
intent(in) :: space
152 type(grid_t),
intent(in) :: gr
153 type(ions_t),
intent(in) :: ions
154 type(states_elec_t),
intent(in) :: st
156 integer :: ia, n, iorb, jj, maxj, idim
157 integer :: ii, ll, mm, norbs, ii_tmp
158 integer :: mode_default
159 real(real64) :: max_orb_radius, maxradius
164 this%initialized = .
true.
167 this%alternative = .false.
171 mode_default = option__lcaostart__lcao_states
172 if (ions%only_user_def) mode_default = option__lcaostart__lcao_none
221 if (this%mode == option__lcaostart__lcao_none)
then
235 call parse_variable(namespace,
'LCAOAlternative', .false., this%alternative)
238 if (st%d%ispin ==
spinors .and. this%alternative)
then
239 message(1) =
"LCAOAlternative is not working for spinors."
242 if (space%is_periodic() .and. this%alternative)
then
260 call parse_variable(namespace,
'LCAOComplexYlms', .false., this%complex_ylms)
262 this%complex_ylms = .false.
273 call parse_variable(namespace,
'LCAOSaveMemory', .false., this%save_memory)
277 call io_mkdir(
'debug/lcao', namespace)
278 iunit_o =
io_open(
'debug/lcao/orbitals', namespace, action=
'write')
279 write(iunit_o,
'(7a6)')
'iorb',
'atom',
'level',
'i',
'l',
'm',
'spin'
282 if (.not. this%alternative)
then
303 call parse_variable(namespace,
'LCAOMaximumOrbitalRadius', 20.0_real64, max_orb_radius, unit =
units_inp%length)
309 do ia = 1, ions%natoms
310 maxj = max(maxj, ions%atom(ia)%species%get_niwfs())
311 this%maxorbs = this%maxorbs + ions%atom(ia)%species%get_niwfs()
314 this%maxorbs = this%maxorbs*st%d%dim
316 if (this%maxorbs == 0)
then
317 call messages_write(
'The are no atomic orbitals available, cannot do LCAO.')
319 this%mode = option__lcaostart__lcao_none
326 safe_allocate( this%atom(1:this%maxorbs))
327 safe_allocate(this%level(1:this%maxorbs))
328 safe_allocate( this%ddim(1:this%maxorbs))
330 safe_allocate(this%is_empty(1:this%maxorbs))
331 this%is_empty = .false.
334 this%lapdist = maxval(abs(gr%idx%enlarge)*gr%spacing)
337 safe_allocate(this%radius(1:ions%natoms))
339 do ia = 1, ions%natoms
340 norbs = ions%atom(ia)%species%get_niwfs()
344 call ions%atom(ia)%species%get_iwf_ilm(iorb, 1, ii, ll, mm)
346 if(ions%atom(ia)%species%is_full())
call ions%atom(ia)%species%get_iwf_n( iorb, 1, ii)
347 maxradius = max(maxradius, ions%atom(ia)%species%get_iwf_radius( ii, is = 1))
350 maxradius = min(maxradius,
m_two*maxval(gr%box%bounding_box_l(1:space%dim)))
352 this%radius(ia) = maxradius
384 do ia = 1, ions%natoms
386 if (jj > ions%atom(ia)%species%get_niwfs()) cycle
387 call ions%atom(ia)%species%get_iwf_ilm(jj, idim, ii, ll, mm)
389 if(ions%atom(ia)%species%is_full())
then
391 call ions%atom(ia)%species%get_iwf_n( ii_tmp, 1, ii)
393 if (this%orbital_scale_factor*ions%atom(ia)%species%get_iwf_radius( ii, is = 1) >= max_orb_radius) cycle
396 this%level(iorb) = jj
397 this%ddim(iorb) = idim
400 write(iunit_o,
'(7i6)') iorb, this%atom(iorb), this%level(iorb), ii, ll, mm, this%ddim(iorb)
413 if (this%maxorbs /= iorb - 1)
then
418 call messages_write(
' orbitals cannot be used for the LCAO calculation,')
420 call messages_write(
' their radii exceeds LCAOMaximumOrbitalRadius (')
425 this%maxorbs = iorb - 1
428 if (this%maxorbs < st%nst)
then
429 call messages_write(
'Cannot do LCAO for all states because there are not enough atomic orbitals.')
469 if (n > 0 .and. n <= st%nst .and. st%nst <= this%maxorbs)
then
472 else if (n > st%nst .and. n <= this%maxorbs)
then
475 else if (n == 0)
then
477 this%norbs = min(this%maxorbs, 2*st%nst)
480 this%norbs = this%maxorbs
483 assert(this%norbs <= this%maxorbs)
485 safe_allocate(this%cst(1:this%norbs, 1:st%d%spin_channels))
486 safe_allocate(this%ck(1:this%norbs, 1:st%d%spin_channels))
487 this%initialized_orbitals = .false.
497 integer :: iatom, iorb, norbs
498 real(real64) :: maxradius
501 integer :: jatom, jorb, jbasis, ilbasis, jlbasis, proc(1:2),
info, nbl
505 call messages_write(
'Info: Using LCAO alternative implementation.')
542 call parse_variable(namespace,
'LCAOExtraOrbitals', .false., this%derivative)
549 if (this%derivative)
then
552 if (st%nst * st%smear%el_per_state > st%qtot)
then
553 message(1) =
"Lower-lying empty states may be missed with LCAOExtraOrbitals."
566 call parse_variable(namespace,
'LCAODiagTol', 1e-10_real64, this%diag_tol)
568 if (this%derivative)
then
574 safe_allocate(this%sphere(1:ions%natoms))
575 safe_allocate(this%orbitals(1:ions%natoms))
576 safe_allocate(this%is_orbital_initialized(1:ions%natoms))
577 this%is_orbital_initialized = .false.
579 safe_allocate(this%norb_atom(1:ions%natoms))
583 do iatom = 1, ions%natoms
584 this%norb_atom(iatom) = this%mult*ions%atom(iatom)%species%get_niwfs()
585 this%maxorb = max(this%maxorb, ions%atom(iatom)%species%get_niwfs())
586 this%norbs = this%norbs + ions%atom(iatom)%species%get_niwfs()
589 this%maxorb = this%maxorb*this%mult
590 this%norbs = this%norbs*this%mult
592 safe_allocate(this%basis_atom(1:this%norbs))
593 safe_allocate(this%basis_orb(1:this%norbs))
594 safe_allocate(this%atom_orb_basis(1:ions%natoms, 1:this%maxorb))
599 do iatom = 1, ions%natoms
600 norbs = ions%atom(iatom)%species%get_niwfs()
602 do iorb = 1, this%mult*norbs
604 this%atom_orb_basis(iatom, iorb) = ibasis
605 this%basis_atom(ibasis) = iatom
606 this%basis_orb(ibasis) = iorb
610 call ions%atom(iatom)%species%get_iwf_ilm(iorb, 1, ii, ll, mm)
611 write(iunit_o,
'(7i6)') ibasis, iatom, iorb, ii, ll, mm, 1
621 this%lapdist = maxval(abs(gr%idx%enlarge)*gr%spacing)
624 safe_allocate(this%radius(1:ions%natoms))
626 do iatom = 1, ions%natoms
627 norbs = ions%atom(iatom)%species%get_niwfs()
631 call ions%atom(iatom)%species%get_iwf_ilm(iorb, 1, ii, ll, mm)
633 if(ions%atom(iatom)%species%is_full())
call ions%atom(iatom)%species%get_iwf_n( iorb, 1, ii)
634 maxradius = max(maxradius, ions%atom(iatom)%species%get_iwf_radius( ii, is = 1))
637 if (this%derivative) maxradius = maxradius + this%lapdist
639 maxradius = min(maxradius,
m_two*maxval(gr%box%bounding_box_l(1:space%dim)))
641 this%radius(iatom) = maxradius
644 safe_allocate(this%calc_atom(1:ions%natoms))
645 this%calc_atom = .
true.
648#ifndef HAVE_SCALAPACK
649 this%parallel = .false.
651 this%parallel = (st%parallel_in_states .or. gr%parallel_in_domains) &
654 if (this%parallel)
then
655 nbl = min(16, this%norbs)
658 this%lsize(1) = max(1,
numroc(this%norbs, nbl, st%dom_st_proc_grid%myrow, 0, st%dom_st_proc_grid%nprow))
659 this%lsize(2) = max(1,
numroc(this%norbs, nbl, st%dom_st_proc_grid%mycol, 0, st%dom_st_proc_grid%npcol))
661 this%nproc(1) = st%dom_st_proc_grid%nprow
662 this%nproc(2) = st%dom_st_proc_grid%npcol
663 this%myroc(1) = st%dom_st_proc_grid%myrow
664 this%myroc(2) = st%dom_st_proc_grid%mycol
666 call descinit(this%desc(1), this%norbs, this%norbs, nbl, nbl, 0, 0, &
667 st%dom_st_proc_grid%context, this%lsize(1),
info)
670 write(
message(1),
'(a,i6)')
'descinit for BLACS failed with error code ',
info
674 this%calc_atom = .false.
675 do iatom = 1, ions%natoms
676 ibasis = this%atom_orb_basis(iatom, 1)
678 do jatom = 1, ions%natoms
679 jbasis = this%atom_orb_basis(jatom, 1)
681 do iorb = 1, this%norb_atom(iatom)
682 do jorb = 1, this%norb_atom(jatom)
684 ilbasis, jlbasis, proc(1), proc(2))
686 this%calc_atom(this%basis_atom(jbasis)) = &
687 this%calc_atom(this%basis_atom(jbasis)) .or. proc(2) == this%myroc(2)
705 subroutine lcao_run(namespace, space, gr, ions, ext_partners, st, ks, hm, st_start, lmm_r)
708 type(
grid_t),
intent(in) :: gr
709 type(
ions_t),
intent(in) :: ions
712 type(
v_ks_t),
intent(inout) :: ks
714 integer,
optional,
intent(in) :: st_start
715 real(real64),
optional,
intent(in) :: lmm_r
718 integer :: st_start_random, required_min_nst
720 logical :: is_orbital_dependent
724 if (
present(st_start))
then
727 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
728 calc_eigenval=.not.
present(st_start), calc_current=.false.)
730 assert(st_start >= 1)
731 if (st_start > st%nst)
then
739 call lcao_init(lcao, namespace, space, gr, ions, st)
751 if (.not.
present(st_start))
then
752 call lcao_guess_density(lcao, namespace, st, gr, hm, ions, st%qtot, st%d%ispin, st%d%spin_channels, st%rho)
755 assert(
present(lmm_r))
761 message(1) =
'Info: Setting up Hamiltonian.'
765 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.false., &
766 calc_current=.false., calc_energy=.false., force_semilocal=is_orbital_dependent)
769 st%eigenval = 1e10_real64
778 if (
present(st_start))
then
779 write(
message(1),
'(a,i8,a)')
'Performing LCAO for states ', st_start,
' and above'
783 call lcao_wf(lcao, st, gr, ions, hm, namespace, start = st_start)
789 select case (st%d%ispin)
791 required_min_nst = int(st%qtot/2)
793 required_min_nst = int(st%qtot/2)
795 required_min_nst = int(st%qtot)
798 if (lcao%norbs <= required_min_nst .and. lcao%norbs < st%nst)
then
799 st%eigenval(lcao%norbs+1:,:) =
m_zero
803 if (.not.
present(st_start))
then
808 if (lcao%mode == option__lcaostart__lcao_full)
then
809 call v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, &
810 calc_eigenval = .false., calc_current=.false.)
812 assert(
present(lmm_r))
819 if (.not. lcao_done .or. lcao%norbs < st%nst)
then
822 st_start_random = lcao%norbs + 1
826 if (
present(st_start)) st_start_random = max(st_start, st_start_random)
828 if (st_start_random > 1)
then
829 write(
message(1),
'(a,i8,a)')
'Generating random wavefunctions for states ', st_start_random,
' and above'
840 if (.not. lcao_done)
then
843 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
844 calc_eigenval=.not.
present(st_start), calc_current=.false.)
845 if (.not.
present(st_start))
then
851 else if (
present(st_start))
then
853 if (st_start > 1)
then
870 type(
lcao_t),
intent(inout) :: this
874 safe_deallocate_a(this%calc_atom)
875 safe_deallocate_a(this%norb_atom)
876 safe_deallocate_a(this%basis_atom)
877 safe_deallocate_a(this%basis_orb)
878 safe_deallocate_a(this%atom_orb_basis)
879 safe_deallocate_a(this%radius)
880 safe_deallocate_a(this%sphere)
881 safe_deallocate_a(this%orbitals)
883 safe_deallocate_a(this%atom)
884 safe_deallocate_a(this%level)
885 safe_deallocate_a(this%ddim)
886 safe_deallocate_a(this%cst)
887 safe_deallocate_a(this%ck)
888 safe_deallocate_a(this%dbuff_single)
889 safe_deallocate_a(this%zbuff_single)
890 safe_deallocate_a(this%dbuff)
891 safe_deallocate_a(this%zbuff)
893 this%initialized = .false.
899 subroutine lcao_wf(this, st, gr, ions, hm, namespace, start)
900 type(
lcao_t),
intent(inout) :: this
902 type(
grid_t),
intent(in) :: gr
903 type(
ions_t),
intent(in) :: ions
906 integer,
optional,
intent(in) :: start
910 assert(this%initialized)
916 if (
present(start)) start_ = start
918 if (this%alternative)
then
920 call dlcao_alt_wf(this, st, gr, ions, hm, namespace, start_)
922 call zlcao_alt_wf(this, st, gr, ions, hm, namespace, start_)
926 call dlcao_wf(this, st, gr, ions, hm, namespace, start_)
928 call zlcao_wf(this, st, gr, ions, hm, namespace, start_)
938 type(
lcao_t),
intent(in) :: this
942 available = this%initialized .and. this%mode /= option__lcaostart__lcao_none
950 type(
lcao_t),
intent(in) :: this
961 type(
lcao_t),
intent(in) :: this
962 integer,
intent(in) :: ig
963 integer,
intent(in) :: jg
964 integer,
intent(out) :: il
965 integer,
intent(out) :: jl
966 integer,
intent(out) :: prow
967 integer,
intent(out) :: pcol
971 call infog2l(ig, jg, this%desc(1), this%nproc(1), this%nproc(2), this%myroc(1), this%myroc(2), &
988 type(
lcao_t),
intent(inout) :: this
989 integer,
intent(in) :: iatom
993 if (this%is_orbital_initialized(iatom))
then
994 call this%orbitals(iatom)%end()
995 this%is_orbital_initialized(iatom) = .false.
1005 type(
lcao_t),
intent(inout) :: this
1007 class(
mesh_t),
intent(in) :: mesh
1008 type(
ions_t),
target,
intent(in) :: ions
1009 integer,
intent(in) :: iatom
1010 integer,
intent(in) :: spin_channels
1011 real(real64),
intent(inout) :: rho(:, :)
1013 real(real64),
allocatable :: dorbital(:, :)
1014 complex(real64),
allocatable :: zorbital(:, :)
1015 real(real64),
allocatable :: factors(:)
1016 real(real64) :: factor, aa
1017 integer :: iorb, ip, ii, ll, mm, ispin
1018 type(
ps_t),
pointer :: ps
1019 logical :: use_stored_orbitals
1025 use_stored_orbitals = ions%atom(iatom)%species%is_ps() &
1027 .and. st%d%dim == 1 .and. .not. ions%space%is_periodic()
1031 if (use_stored_orbitals)
then
1033 assert(.not. ions%space%is_periodic())
1035 select type(spec=>ions%atom(iatom)%species)
1042 if (.not. this%alternative)
then
1045 safe_allocate(dorbital(1:mesh%np, 1:st%d%dim))
1047 safe_allocate(zorbital(1:mesh%np, 1:st%d%dim))
1050 do iorb = 1, this%norbs
1051 if (iatom /= this%atom(iorb)) cycle
1053 call ions%atom(iatom)%species%get_iwf_ilm(this%level(iorb), 1, ii, ll, mm)
1054 factor = ps%conf%occ(ii, 1)/(
m_two*ll +
m_one)
1057 call dget_ao(this, st, mesh, ions, iorb, 1, dorbital, use_psi = .
true.)
1060 rho(ip, 1) = rho(ip, 1) + factor*dorbital(ip, 1)**2
1063 call zget_ao(this, st, mesh, ions, iorb, 1, zorbital, use_psi = .
true.)
1066 rho(ip, 1) = rho(ip, 1) + factor*abs(zorbital(ip, 1))**2
1072 safe_deallocate_a(dorbital)
1073 safe_deallocate_a(zorbital)
1081 safe_allocate(factors(1:this%norb_atom(iatom)/this%mult))
1083 do iorb = 1, this%norb_atom(iatom)/this%mult
1084 call ions%atom(iatom)%species%get_iwf_ilm(iorb, 1, ii, ll, mm)
1085 factors(iorb) = ps%conf%occ(ii, 1)/(
m_two*ll +
m_one)
1089 do ip = 1, this%sphere(iatom)%np
1091 do iorb = 1, this%norb_atom(iatom)/this%mult
1092 aa = aa + factors(iorb)*this%orbitals(iatom)%dff_linear(ip, iorb)**2
1094 rho(this%sphere(iatom)%map(ip), 1) = rho(this%sphere(iatom)%map(ip), 1) + aa
1097 safe_deallocate_a(factors)
1103 ions%pos(:, iatom), mesh, spin_channels, rho)
1108 do ispin = 1, spin_channels
1111 rho(ip, ispin) = max(rho(ip, ispin),
m_zero)
1120 subroutine lcao_guess_density(this, namespace, st, gr, hm, ions, qtot, ispin, spin_channels, rho)
1121 type(
lcao_t),
intent(inout) :: this
1124 type(
grid_t),
intent(in) :: gr
1126 type(
ions_t),
intent(in) :: ions
1127 real(real64),
intent(in) :: qtot
1128 integer,
intent(in) :: ispin, spin_channels
1129 real(real64),
contiguous,
intent(out) :: rho(:, :)
1131 integer :: ia, is, idir, gmd_opt, ip
1134 real(real64) :: rr, rnd, phi, theta, mag(1:3), lmag, n1, n2,arg
1135 real(real64),
allocatable :: atom_rho(:,:)
1136 logical :: parallelized_in_atoms
1140 parallelized_in_atoms = .false.
1142 if (spin_channels == 1)
then
1143 gmd_opt = initrho_paramagnetic
1176 message(1) =
"GuessMagnetDensity cannot be used for Hartree-Fock and generalized Kohn-Sham calculation."
1177 message(2) =
"Please perform a LDA or GGA calculation first and restart from this calculation."
1182 select case (gmd_opt)
1183 case (initrho_paramagnetic)
1184 safe_allocate(atom_rho(1:gr%np, 1:spin_channels))
1186 parallelized_in_atoms = .
true.
1188 do ia = ions%atoms_dist%start, ions%atoms_dist%end
1193 if (spin_channels == 2)
then
1196 rho(ip, 1) =
m_half*(rho(ip, 1) + rho(ip, 2))
1197 rho(ip, 2) = rho(ip, 1)
1202 safe_allocate(atom_rho(1:gr%np, 1:2))
1204 parallelized_in_atoms = .
true.
1207 do ia = ions%atoms_dist%start, ions%atoms_dist%end
1209 rho(1:gr%np, 1:2) = rho(1:gr%np, 1:2) + atom_rho(1:gr%np, 1:2)
1213 safe_allocate(atom_rho(1:gr%np, 1:2))
1214 do ia = 1, ions%natoms
1221 rho(1:gr%np, 1:2) = rho(1:gr%np, 1:2) + atom_rho(1:gr%np, 1:2)
1223 rho(1:gr%np, 1) = rho(1:gr%np, 1) + atom_rho(1:gr%np, 2)
1224 rho(1:gr%np, 2) = rho(1:gr%np, 2) + atom_rho(1:gr%np, 1)
1226 elseif (ispin ==
spinors)
then
1257 if (
parse_block(namespace,
'AtomsMagnetDirection', blk) < 0)
then
1258 message(1) =
"AtomsMagnetDirection block is not defined."
1263 message(1) =
"AtomsMagnetDirection block has the wrong number of rows."
1267 safe_allocate(atom_rho(1:gr%np, 1:2))
1268 do ia = 1, ions%natoms
1274 elseif (ispin ==
spinors)
then
1277 if (abs(mag(idir)) < 1.0e-20_real64) mag(idir) =
m_zero
1279 lmag = norm2(mag(1:3))
1289 if (lmag > n1 + n2)
then
1290 mag = mag*(n1 + n2)/lmag
1298 atom_rho(ip, 1) =
m_half*(atom_rho(ip, 1) + atom_rho(ip, 2))
1299 rho(ip, 1) = rho(ip, 1) + atom_rho(ip, 1)
1300 rho(ip, 2) = rho(ip, 2) + atom_rho(ip, 1)
1307 if (n1 - n2 < lmag)
then
1308 call lalg_axpy(gr%np, (lmag - n1 + n2)/
m_two/n2, atom_rho(:, 2), atom_rho(:, 1))
1310 elseif (n1 - n2 > lmag)
then
1311 call lalg_axpy(gr%np, (n1 - n2 - lmag)/
m_two/n1, atom_rho(:, 1), atom_rho(:, 2))
1319 if (mag(1) >
m_zero)
then
1326 elseif (ispin ==
spinors)
then
1328 theta =
acos(mag(3)/lmag)
1332 elseif (mag(2) <
m_zero)
then
1334 elseif (mag(2) >
m_zero)
then
1339 arg = mag(1)/
sin(theta)/lmag
1342 if (mag(2) <
m_zero)
then
1356 if (ions%atoms_dist%parallel .and. parallelized_in_atoms)
then
1358 do is = 1, spin_channels
1359 call lalg_copy(gr%np, rho(:,is), atom_rho(:,1))
1360 call ions%atoms_dist%mpi_grp%allreduce(atom_rho(1, 1), rho(1, is), gr%np, mpi_double_precision, mpi_sum)
1366 do is = 1, spin_channels
1369 if (gr%parallel_in_domains)
then
1370 call gr%allreduce(rr)
1373 write(
message(1),
'(a,f13.6)')
'Info: Unnormalized total charge = ', rr
1381 do is = 1, spin_channels
1384 if (gr%parallel_in_domains)
then
1385 call gr%allreduce(rr)
1388 write(
message(1),
'(a,f13.6)')
'Info: Renormalized total charge = ', rr
1391 if (st%symmetrize_density)
then
1392 do is = 1, st%d%nspin
1397 safe_deallocate_a(atom_rho)
1403 class(
mesh_t),
intent(in) :: mesh
1404 real(real64),
intent(inout) :: rho(:,:)
1405 real(real64),
intent(in) :: atom_rho(:,:)
1406 real(real64),
intent(in) :: theta, phi
1414 rho(ip, 1) = rho(ip, 1) +
cos(theta)**2*atom_rho(ip, 1) +
sin(theta)**2*atom_rho(ip, 2)
1415 rho(ip, 2) = rho(ip, 2) +
sin(theta)**2*atom_rho(ip, 1) +
cos(theta)**2*atom_rho(ip, 2)
1416 rho(ip, 3) = rho(ip, 3) +
cos(theta)*
sin(theta)*
cos(phi)*(atom_rho(ip, 1)-atom_rho(ip, 2))
1417 rho(ip, 4) = rho(ip, 4) -
cos(theta)*
sin(theta)*
sin(phi)*(atom_rho(ip, 1)-atom_rho(ip, 2))
1426 type(
lcao_t),
intent(inout) :: this
1429 type(
grid_t),
intent(in) :: gr
1430 type(
ions_t),
intent(in) :: ions
1431 integer,
optional,
intent(in) :: start
1437 if (.not. this%alternative)
then
1457#include "lcao_inc.F90"
1460#include "complex.F90"
1461#include "lcao_inc.F90"
constant times a vector plus a vector
Copies a vector x, to a vector y.
scales a vector by a constant
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
double acos(double __x) __attribute__((__nothrow__
double sin(double __x) __attribute__((__nothrow__
double cos(double __x) __attribute__((__nothrow__
This module implements batches of mesh functions.
This module contains interfaces for BLACS routines Interfaces are from http:
This module provides the BLACS processor grid.
logical pure function, public blacs_proc_grid_null(this)
Module implementing boundary conditions in Octopus.
type(debug_t), save, public debug
integer, parameter, public unpolarized
Parameters...
integer, parameter, public spinors
integer, parameter, public spin_polarized
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_pi
some mathematical constants
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
real(real64), parameter, public m_one
real(real64), parameter, public m_three
This module implements the underlying real-space grid.
subroutine, public dgrid_symmetrize_scalar_field(gr, field, suppress_warning)
integer, parameter, public generalized_kohn_sham_dft
integer, parameter, public hartree
integer, parameter, public hartree_fock
integer, parameter, public kohn_sham_dft
This module defines classes and functions for interaction partners.
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)
This module contains interfaces for LAPACK routines.
subroutine, public lcao_init_orbitals(this, namespace, st, gr, ions, start)
subroutine, public lcao_wf(this, st, gr, ions, hm, namespace, start)
subroutine zlcao_alt_init_orbitals(this, namespace, st, gr, ions, start)
subroutine zget_ao(this, st, mesh, ions, iorb, ispin, ao, use_psi)
subroutine, public lcao_end(this)
subroutine, public lcao_run(namespace, space, gr, ions, ext_partners, st, ks, hm, st_start, lmm_r)
subroutine zlcao_alt_wf(this, st, gr, ions, hm, namespace, start)
The alternative implementation.
subroutine dlcao_wf(this, st, gr, ions, hm, namespace, start)
subroutine dlcao_alt_init_orbitals(this, namespace, st, gr, ions, start)
subroutine, public lcao_init(this, namespace, space, gr, ions, st)
subroutine zlcao_wf(this, st, gr, ions, hm, namespace, start)
subroutine dlcao_alt_wf(this, st, gr, ions, hm, namespace, start)
The alternative implementation.
subroutine lcao_guess_density(this, namespace, st, gr, hm, ions, qtot, ispin, spin_channels, rho)
builds a density which is the sum of the atomic densities
integer, parameter initrho_userdef
integer, parameter initrho_random
subroutine lcao_alt_end_orbital(this, iatom)
This function deallocates a set of an atomic orbitals for an atom. It can be called when the batch is...
subroutine lcao_local_index(this, ig, jg, il, jl, prow, pcol)
integer function, public lcao_num_orbitals(this)
subroutine dinit_orbitals(this, namespace, st, gr, ions, start)
subroutine dget_ao(this, st, mesh, ions, iorb, ispin, ao, use_psi)
subroutine dlcao_alt_get_orbital(this, sphere, ions, ispin, iatom, norbs)
This function generates the set of an atomic orbitals for an atom and stores it in the batch orbitalb...
subroutine zinit_orbitals(this, namespace, st, gr, ions, start)
subroutine lcao_atom_density(this, st, mesh, ions, iatom, spin_channels, rho)
subroutine accumulate_rotated_density(mesh, rho, atom_rho, theta, phi)
integer, parameter initrho_ferromagnetic
logical function, public lcao_is_available(this)
subroutine, public write_magnetic_moments(mesh, st, ions, boundaries, lmm_r, iunit, namespace)
This module is intended to contain "only mathematical" functions and procedures.
This module defines various routines, operating on mesh functions.
real(real64) function, public dmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
subroutine, public messages_new_line()
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_experimental(name, namespace)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
logical function, public parse_is_defined(namespace, name)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
integer(int64), parameter, public splitmix64_321
This module contains interfaces for ScaLAPACK routines Interfaces are from http:
integer, parameter, public smear_semiconductor
integer, parameter, public smear_fixed_occ
subroutine, public species_atom_density(species, namespace, space, latt, pos, mesh, spin_channels, rho)
pure logical function, public states_are_complex(st)
pure logical function, public states_are_real(st)
subroutine, public states_elec_orthogonalize(st, namespace, mesh)
Orthonormalizes nst orbitals in mesh (honours state parallelization).
This module defines routines to write information about states.
subroutine, public states_elec_write_eigenvalues(nst, st, space, kpoints, error, st_start, compact, iunit, namespace)
write the eigenvalues for some states to a file.
subroutine, public states_elec_fermi(st, namespace, mesh, compute_spin)
calculate the Fermi level for the states in this object
subroutine, public states_elec_generate_random(st, mesh, kpoints, ist_start_, ist_end_, ikpt_start_, ikpt_end_, normalized)
randomize states
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_system_t), public units_inp
the units systems for reading and writing
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
subroutine, public v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, calc_eigenval, calc_current)
logical pure function, public xc_is_orbital_dependent(xcs)
Is the xc family orbital dependent.
integer, parameter, public sic_pz_oep
Perdew-Zunger SIC (OEP way)
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.