81#include "./base/base_uses.f90"
89 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'lri_environment_methods'
114 IF (lri_env%ppl_ri)
THEN
115 CALL calculate_lri_ppl_integrals(lri_env, qs_env, .false.)
131 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_lri_integrals'
133 INTEGER :: handle, iac, iatom, ikind, ilist, jatom, &
134 jkind, jneighbor, mepos, nba, nbb, &
135 nfa, nfb, nkind, nlist, nn, nneighbor, &
137 LOGICAL :: e1c, use_virial
138 REAL(kind=
dp) :: cmem, cpff, cpsr, cptt, dab
139 REAL(kind=
dp),
DIMENSION(3) :: rab
147 DIMENSION(:),
POINTER :: nl_iterator
153 CALL timeset(routinen, handle)
154 NULLIFY (cell, dft_control, fbasa, fbasb, lrii, lri_ints, nl_iterator, &
155 obasa, obasb, particle_set, soo_list, virial)
157 lri_env%stat%pairs_tt = 0.0_dp
158 lri_env%stat%pairs_sr = 0.0_dp
159 lri_env%stat%pairs_ff = 0.0_dp
160 lri_env%stat%overlap_error = 0.0_dp
161 lri_env%stat%abai_mem = 0.0_dp
163 IF (
ASSOCIATED(lri_env%soo_list))
THEN
164 soo_list => lri_env%soo_list
166 CALL get_qs_env(qs_env=qs_env, cell=cell, dft_control=dft_control, &
167 nkind=nkind, particle_set=particle_set, virial=virial)
168 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
172 IF (
ASSOCIATED(lri_env%lri_ints))
THEN
178 lri_ints => lri_env%lri_ints
196 nlist=nlist, ilist=ilist, nnode=nneighbor, inode=jneighbor, &
197 iatom=iatom, jatom=jatom, r=rab)
198 iac = ikind + nkind*(jkind - 1)
199 dab = sqrt(sum(rab*rab))
201 obasa => lri_env%orb_basis(ikind)%gto_basis_set
202 obasb => lri_env%orb_basis(jkind)%gto_basis_set
203 fbasa => lri_env%ri_basis(ikind)%gto_basis_set
204 fbasb => lri_env%ri_basis(jkind)%gto_basis_set
206 IF (.NOT.
ASSOCIATED(obasa)) cycle
207 IF (.NOT.
ASSOCIATED(obasb)) cycle
209 lrii => lri_ints%lri_atom(iac)%lri_node(ilist)%lri_int(jneighbor)
213 IF (iatom == jatom .AND. dab < lri_env%delta) e1c = .true.
216 IF (iatom == jatom .AND. dab < lri_env%delta)
THEN
217 lrii%calc_force_pair = .false.
220 IF (iatom == jatom .AND. .NOT. use_virial)
THEN
221 lrii%calc_force_pair = .false.
223 lrii%calc_force_pair = .true.
227 IF (e1c .AND. lri_env%exact_1c_terms)
THEN
245 nba=nba, nbb=nbb, nfa=nfa, nfb=nfb, skip_sab=(.NOT. lrii%lrisr))
246 CALL lri_int2(lri_env, lrii, lriint, rab, obasa, obasb, fbasa, fbasb, &
247 iatom, jatom, ikind, jkind)
250 CALL lri_comp(lriint%abaint, lrii%abascr, lrii%cabai)
253 CALL lri_comp(lriint%abaint, lrii%abascr, lrii%cabai)
255 CALL lri_comp(lriint%abbint, lrii%abbscr, lrii%cabbi)
259 lrii%soo(1:nba, 1:nbb) = lriint%sooint(1:nba, 1:nbb)
267 lrii%sinv(1:nfa, 1:nfa) = lri_env%bas_prop(ikind)%ri_ovlp_inv(1:nfa, 1:nfa)
268 lrii%n(1:nfa) = lri_env%bas_prop(ikind)%int_fbas(1:nfa)
269 CALL dgemv(
"N", nfa, nfa, 1.0_dp, lrii%sinv(1, 1), nfa, &
270 lrii%n(1), 1, 0.0_dp, lrii%sn, 1)
271 lrii%nsn = sum(lrii%sn(1:nfa)*lrii%n(1:nfa))
274 CALL inverse_lri_overlap(lri_env, lrii%sinv, lri_env%bas_prop(ikind)%ri_ovlp, &
275 lri_env%bas_prop(jkind)%ri_ovlp, lriint%sabint)
276 lrii%n(1:nfa) = lri_env%bas_prop(ikind)%int_fbas(1:nfa)
277 lrii%n(nfa + 1:nn) = lri_env%bas_prop(jkind)%int_fbas(1:nfb)
278 CALL dgemv(
"N", nn, nn, 1.0_dp, lrii%sinv(1, 1), nn, &
279 lrii%n(1), 1, 0.0_dp, lrii%sn, 1)
280 lrii%nsn = sum(lrii%sn(1:nn)*lrii%n(1:nn))
282 IF (lri_env%store_integrals)
THEN
283 IF (
ALLOCATED(lrii%sab))
DEALLOCATE (lrii%sab)
284 ALLOCATE (lrii%sab(nfa, nfb))
285 lrii%sab(1:nfa, 1:nfb) = lriint%sabint(1:nfa, 1:nfb)
293 cpassert(.NOT. lri_env%store_integrals)
295 lrii%na(1:nfa) = lri_env%bas_prop(ikind)%int_fbas(1:nfa)
296 lrii%nb(1:nfb) = lri_env%bas_prop(jkind)%int_fbas(1:nfb)
297 CALL dgemv(
"N", nfa, nfa, 1.0_dp, lrii%asinv(1, 1), nfa, &
298 lrii%na(1), 1, 0.0_dp, lrii%sna, 1)
299 lrii%nsna = sum(lrii%sna(1:nfa)*lrii%na(1:nfa))
300 CALL dgemv(
"N", nfb, nfb, 1.0_dp, lrii%bsinv(1, 1), nfb, &
301 lrii%nb(1), 1, 0.0_dp, lrii%snb, 1)
302 lrii%nsnb = sum(lrii%snb(1:nfb)*lrii%nb(1:nfb))
311 lri_env%stat%pairs_tt = lri_env%stat%pairs_tt + cptt
312 lri_env%stat%pairs_sr = lri_env%stat%pairs_sr + cpsr
313 lri_env%stat%pairs_ff = lri_env%stat%pairs_ff + cpff
314 lri_env%stat%abai_mem = lri_env%stat%abai_mem + cmem
321 IF (lri_env%debug)
THEN
322 CALL output_debug_info(lri_env, qs_env, lri_ints, soo_list)
327 CALL timestop(handle)
345 INTEGER,
DIMENSION(:),
INTENT(IN) :: atomlist
347 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lri_kg_rho_update'
349 INTEGER :: handle, ispin, nspins
350 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r
357 CALL timeset(routinen, handle)
359 cpassert(
ASSOCIATED(rho_struct))
361 CALL get_qs_env(qs_env, dft_control=dft_control, para_env=para_env)
363 CALL qs_rho_get(rho_struct, rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
365 nspins = dft_control%nspins
367 cpassert(.NOT. dft_control%use_kinetic_energy_density)
368 cpassert(.NOT. lri_env%exact_1c_terms)
372 lri_density%lri_coefs(ispin)%lri_kinds, tot_rho_r(ispin), &
373 "LRI_AUX", lri_env%exact_1c_terms, pmat=pmat_diag, atomlist=atomlist)
376 CALL qs_rho_set(rho_struct, rho_r_valid=.true., rho_g_valid=.true.)
378 CALL timestop(handle)
390 SUBROUTINE calculate_lri_ppl_integrals(lri_env, qs_env, calculate_forces)
394 LOGICAL,
INTENT(IN) :: calculate_forces
396 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_lri_ppl_integrals'
398 INTEGER :: handle, ikind, ispin, na, nb, nkind, &
400 LOGICAL :: use_virial
409 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
412 CALL timeset(routinen, handle)
414 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, &
415 particle_set=particle_set, atomic_kind_set=atomic_kind_set)
416 IF (calculate_forces)
THEN
417 cpassert(
ASSOCIATED(lri_env%lri_ppl_ints))
418 CALL get_qs_env(qs_env, lri_density=lri_density)
419 nspin =
SIZE(lri_density%lri_coefs, 1)
421 IF (
ASSOCIATED(lri_env%lri_ppl_ints))
THEN
427 CALL get_qs_env(qs_env, sac_lri=sac_lri, force=force, virial=virial, para_env=para_env)
428 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
429 use_virial = use_virial .AND. calculate_forces
432 ALLOCATE (lri_ppl_coef(nkind))
434 na =
SIZE(lri_env%lri_ppl_ints%lri_ppl(ikind)%v_int, 1)
435 nb =
SIZE(lri_env%lri_ppl_ints%lri_ppl(ikind)%v_int, 2)
436 NULLIFY (lri_ppl_coef(ikind)%acoef)
437 NULLIFY (lri_ppl_coef(ikind)%v_int)
438 NULLIFY (lri_ppl_coef(ikind)%v_dadr)
439 NULLIFY (lri_ppl_coef(ikind)%v_dfdr)
440 ALLOCATE (lri_ppl_coef(ikind)%v_int(na, nb))
441 lri_ppl_coef(ikind)%v_int = 0.0_dp
442 IF (calculate_forces)
THEN
443 ALLOCATE (lri_ppl_coef(ikind)%acoef(na, nb))
444 lri_ppl_coef(ikind)%acoef = 0.0_dp
446 lri_ppl_coef(ikind)%acoef(1:na, 1:nb) = lri_ppl_coef(ikind)%acoef(1:na, 1:nb) + &
447 lri_density%lri_coefs(ispin)%lri_kinds(ikind)%acoef(1:na, 1:nb)
452 CALL build_core_ppl_ri(lri_ppl_coef, force, virial, calculate_forces, use_virial, &
453 qs_kind_set, atomic_kind_set, particle_set, sac_lri, &
456 IF (.NOT. calculate_forces)
THEN
458 CALL para_env%sum(lri_ppl_coef(ikind)%v_int)
459 lri_env%lri_ppl_ints%lri_ppl(ikind)%v_int = lri_ppl_coef(ikind)%v_int
464 IF (
ASSOCIATED(lri_ppl_coef(ikind)%acoef))
DEALLOCATE (lri_ppl_coef(ikind)%acoef)
465 IF (
ASSOCIATED(lri_ppl_coef(ikind)%v_int))
DEALLOCATE (lri_ppl_coef(ikind)%v_int)
466 IF (
ASSOCIATED(lri_ppl_coef(ikind)%v_dadr))
DEALLOCATE (lri_ppl_coef(ikind)%v_dadr)
467 IF (
ASSOCIATED(lri_ppl_coef(ikind)%v_dfdr))
DEALLOCATE (lri_ppl_coef(ikind)%v_dfdr)
469 DEALLOCATE (lri_ppl_coef)
471 CALL timestop(handle)
473 END SUBROUTINE calculate_lri_ppl_integrals
481 SUBROUTINE calculate_lri_overlap_aabb(lri_env, qs_env)
486 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_lri_overlap_aabb'
488 INTEGER :: handle, iac, iatom, ikind, ilist, jatom, &
489 jkind, jneighbor, nba, nbb, nkind, &
492 REAL(kind=
dp),
DIMENSION(3) :: rab
498 DIMENSION(:),
POINTER :: nl_iterator
503 CALL timeset(routinen, handle)
504 NULLIFY (cell, lriir, lri_ints_rho, nl_iterator, obasa, obasb, &
505 particle_set, soo_list)
507 IF (
ASSOCIATED(lri_env%soo_list))
THEN
508 soo_list => lri_env%soo_list
510 CALL get_qs_env(qs_env=qs_env, nkind=nkind, particle_set=particle_set, &
513 IF (
ASSOCIATED(lri_env%lri_ints_rho))
THEN
518 lri_ints_rho => lri_env%lri_ints_rho
524 nlist=nlist, ilist=ilist, nnode=nneighbor, inode=jneighbor, &
525 iatom=iatom, jatom=jatom, r=rab)
527 iac = ikind + nkind*(jkind - 1)
528 dab = sqrt(sum(rab*rab))
530 obasa => lri_env%orb_basis(ikind)%gto_basis_set
531 obasb => lri_env%orb_basis(jkind)%gto_basis_set
532 IF (.NOT.
ASSOCIATED(obasa)) cycle
533 IF (.NOT.
ASSOCIATED(obasb)) cycle
535 lriir => lri_ints_rho%lri_atom(iac)%lri_node(ilist)%lri_int_rho(jneighbor)
550 CALL timestop(handle)
552 END SUBROUTINE calculate_lri_overlap_aabb
568 lri_rho_struct, atomic_kind_set, para_env, response_density)
574 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
578 LOGICAL,
INTENT(IN) :: response_density
580 CALL calculate_avec_lri(lri_env, lri_density, pmatrix, cell_to_index, response_density)
581 CALL distribute_lri_density_on_the_grid(lri_env, lri_density, qs_env, &
582 lri_rho_struct, atomic_kind_set, para_env, &
603 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
604 LOGICAL,
INTENT(IN),
OPTIONAL :: response_density
606 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_avec_lri'
608 INTEGER :: handle, i, iac, iatom, ic, ikind, ilist, ispin, jatom, jkind, jneighbor, mepos, &
609 nba, nbb, nfa, nfb, nkind, nlist, nn, nneighbor, nspin, nthread
610 INTEGER,
DIMENSION(3) :: cell
611 LOGICAL :: found, lresponse, trans, use_cell_mapping
612 REAL(kind=
dp) :: dab, rab(3), threshold
613 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: m
614 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: int3, paa, pab, pbb
615 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pbij
621 DIMENSION(:),
POINTER :: nl_iterator
625 CALL timeset(routinen, handle)
626 NULLIFY (lrii, lri_rho, nl_iterator, pbij, pmat, soo_list)
629 IF (
PRESENT(response_density)) lresponse = response_density
631 IF (
ASSOCIATED(lri_env%soo_list))
THEN
632 soo_list => lri_env%soo_list
634 nspin =
SIZE(pmatrix, 1)
635 use_cell_mapping = (
SIZE(pmatrix, 2) > 1)
636 nkind = lri_env%lri_ints%nkind
640 IF (
ASSOCIATED(lri_density))
THEN
643 ALLOCATE (lri_density)
646 lri_density%nspin = nspin
652 lri_rho => lri_density%lri_rhos(ispin)%lri_list
664 CALL get_iterator_info(nl_iterator, mepos=mepos, ikind=ikind, jkind=jkind, iatom=iatom, &
665 jatom=jatom, nlist=nlist, ilist=ilist, nnode=nneighbor, inode=jneighbor, &
668 iac = ikind + nkind*(jkind - 1)
669 dab = sqrt(sum(rab*rab))
671 IF (.NOT.
ASSOCIATED(lri_env%lri_ints%lri_atom(iac)%lri_node)) cycle
672 IF (iatom == jatom .AND. dab < lri_env%delta .AND. lri_env%exact_1c_terms) cycle
674 IF (use_cell_mapping)
THEN
675 ic = cell_to_index(cell(1), cell(2), cell(3))
680 pmat => pmatrix(ispin, ic)%matrix
684 IF (iatom <= jatom)
THEN
685 CALL dbcsr_get_block_p(matrix=pmat, row=iatom, col=jatom, block=pbij, found=found)
688 CALL dbcsr_get_block_p(matrix=pmat, row=jatom, col=iatom, block=pbij, found=found)
693 lrho => lri_rho%lri_atom(iac)%lri_node(ilist)%lri_rhoab(jneighbor)
694 lrii => lri_env%lri_ints%lri_atom(iac)%lri_node(ilist)%lri_int(jneighbor)
704 ALLOCATE (pab(nba, nbb))
706 pab(1:nba, 1:nbb) = transpose(pbij(1:nbb, 1:nba))
708 pab(1:nba, 1:nbb) = pbij(1:nba, 1:nbb)
711 ALLOCATE (int3(nba, nbb))
714 lrho%charge = sum(pab(1:nba, 1:nbb)*lrii%soo(1:nba, 1:nbb))
717 lrho%tvec(i) = sum(pab(1:nba, 1:nbb)*int3(1:nba, 1:nbb))
719 IF (dab > lri_env%delta)
THEN
722 lrho%tvec(nfa + i) = sum(pab(1:nba, 1:nbb)*int3(1:nba, 1:nbb))
726 IF (iatom == jatom .AND. dab < lri_env%delta)
THEN
727 lrho%nst = sum(lrho%tvec(1:nfa)*lrii%sn(1:nfa))
729 lrho%nst = sum(lrho%tvec(1:nn)*lrii%sn(1:nn))
731 lrho%lambda = (lrho%charge - lrho%nst)/lrii%nsn
736 IF (iatom == jatom .AND. dab < lri_env%delta)
THEN
737 m(1:nfa) = lrho%tvec(1:nfa) + lrho%lambda*lrii%n(1:nfa)
738 CALL dgemv(
"N", nfa, nfa, 1.0_dp, lrii%sinv(1, 1), nfa, &
739 m(1), 1, 0.0_dp, lrho%avec, 1)
741 m(1:nn) = lrho%tvec(1:nn) + lrho%lambda*lrii%n(1:nn)
742 CALL dgemv(
"N", nn, nn, 1.0_dp, lrii%sinv(1, 1), nn, &
743 m(1), 1, 0.0_dp, lrho%avec, 1)
750 ALLOCATE (paa(nba, nbb), pbb(nba, nbb))
751 paa(1:nba, 1:nbb) = pab(1:nba, 1:nbb)*lri_env%wmat(ikind, jkind)%mat(1:nba, 1:nbb)
752 pbb(1:nba, 1:nbb) = pab(1:nba, 1:nbb)*(1._dp - lri_env%wmat(ikind, jkind)%mat(1:nba, 1:nbb))
754 threshold = lri_env%eps_o3_int/max(sum(abs(paa(1:nba, 1:nbb))), 1.0e-14_dp)
755 lrho%chargea = sum(paa(1:nba, 1:nbb)*lrii%soo(1:nba, 1:nbb))
757 IF (lrii%abascr(i) > threshold)
THEN
759 lrho%tveca(i) = sum(paa(1:nba, 1:nbb)*int3(1:nba, 1:nbb))
761 lrho%tveca(i) = 0.0_dp
764 threshold = lri_env%eps_o3_int/max(sum(abs(pbb(1:nba, 1:nbb))), 1.0e-14_dp)
765 lrho%chargeb = sum(pbb(1:nba, 1:nbb)*lrii%soo(1:nba, 1:nbb))
767 IF (lrii%abbscr(i) > threshold)
THEN
769 lrho%tvecb(i) = sum(pbb(1:nba, 1:nbb)*int3(1:nba, 1:nbb))
771 lrho%tvecb(i) = 0.0_dp
775 lrho%nsta = sum(lrho%tveca(1:nfa)*lrii%sna(1:nfa))
776 lrho%nstb = sum(lrho%tvecb(1:nfb)*lrii%snb(1:nfb))
777 lrho%lambdaa = (lrho%chargea - lrho%nsta)/lrii%nsna
778 lrho%lambdab = (lrho%chargeb - lrho%nstb)/lrii%nsnb
781 m(1:nfa) = lrho%tveca(1:nfa) + lrho%lambdaa*lrii%na(1:nfa)
782 CALL dgemv(
"N", nfa, nfa, 1.0_dp, lrii%asinv(1, 1), nfa, &
783 m(1), 1, 0.0_dp, lrho%aveca, 1)
786 m(1:nfb) = lrho%tvecb(1:nfb) + lrho%lambdab*lrii%nb(1:nfb)
787 CALL dgemv(
"N", nfb, nfb, 1.0_dp, lrii%bsinv(1, 1), nfb, &
788 m(1), 1, 0.0_dp, lrho%avecb, 1)
791 DEALLOCATE (paa, pbb)
794 DEALLOCATE (pab, int3)
804 CALL timestop(handle)
818 SUBROUTINE distribute_lri_density_on_the_grid(lri_env, lri_density, qs_env, &
819 lri_rho_struct, atomic_kind_set, para_env, &
828 LOGICAL,
INTENT(IN) :: response_density
830 CHARACTER(LEN=*),
PARAMETER :: routinen =
'distribute_lri_density_on_the_grid'
832 INTEGER :: atom_a, atom_b, handle, iac, iatom, &
833 ikind, ilist, ispin, jatom, jkind, &
834 jneighbor, natom, nfa, nfb, nkind, &
836 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
837 REAL(kind=
dp) :: dab, fw, rab(3), str
838 REAL(kind=
dp),
DIMENSION(:),
POINTER :: aci, acj, tot_rho_r
840 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
847 DIMENSION(:),
POINTER :: nl_iterator
854 CALL timeset(routinen, handle)
855 NULLIFY (aci, acj, atomic_kind, lri_coef, lri_rho, &
856 nl_iterator, soo_list, rho_r, rho_g, tot_rho_r)
858 IF (
ASSOCIATED(lri_env%soo_list))
THEN
859 soo_list => lri_env%soo_list
861 lri_env%stat%rho_tt = 0.0_dp
862 lri_env%stat%rho_sr = 0.0_dp
863 lri_env%stat%rho_ff = 0.0_dp
864 lri_env%stat%rho_1c = 0.0_dp
866 nspin = lri_density%nspin
867 nkind = lri_env%lri_ints%nkind
870 atom_of_kind=atom_of_kind)
876 lri_coef => lri_density%lri_coefs(ispin)%lri_kinds
877 lri_rho => lri_density%lri_rhos(ispin)%lri_list
883 iatom=iatom, jatom=jatom, ilist=ilist, inode=jneighbor, r=rab)
884 dab = sqrt(sum(rab*rab))
885 atom_a = atom_of_kind(iatom)
886 atom_b = atom_of_kind(jatom)
887 aci => lri_coef(ikind)%acoef(atom_a, :)
888 acj => lri_coef(jkind)%acoef(atom_b, :)
889 iac = ikind + nkind*(jkind - 1)
890 lrho => lri_rho%lri_atom(iac)%lri_node(ilist)%lri_rhoab(jneighbor)
891 lrii => lri_env%lri_ints%lri_atom(iac)%lri_node(ilist)%lri_int(jneighbor)
896 IF (iatom == jatom .AND. dab < lri_env%delta)
THEN
898 IF (.NOT. lri_env%exact_1c_terms)
THEN
899 aci(1:nfa) = aci(1:nfa) + lrho%avec(1:nfa)
900 lri_env%stat%rho_sr = lri_env%stat%rho_sr + sum(lrho%avec(:)*lrii%n(:))
903 IF (iatom == jatom)
THEN
910 aci(1:nfa) = aci(1:nfa) + fw*lrho%avec(1:nfa)
911 acj(1:nfb) = acj(1:nfb) + fw*lrho%avec(nfa + 1:nfa + nfb)
912 lri_env%stat%rho_sr = lri_env%stat%rho_sr + fw*sum(lrho%avec(:)*lrii%n(:))
917 IF (iatom == jatom)
THEN
922 aci(1:nfa) = aci(1:nfa) + fw*lrho%aveca(1:nfa)
923 acj(1:nfb) = acj(1:nfb) + fw*lrho%avecb(1:nfb)
924 lri_env%stat%rho_sr = lri_env%stat%rho_sr + fw*sum(lrho%aveca(:)*lrii%na(:))
925 lri_env%stat%rho_sr = lri_env%stat%rho_sr + fw*sum(lrho%avecb(:)*lrii%nb(:))
933 atomic_kind => atomic_kind_set(ikind)
936 aci => lri_coef(ikind)%acoef(iatom, :)
937 CALL para_env%sum(aci)
944 CALL qs_rho_get(lri_rho_struct, rho_r=rho_r, rho_g=rho_g, &
947 IF (lri_env%exact_1c_terms)
THEN
949 CALL get_qs_env(qs_env, rho=rho, matrix_s_kp=matrix_s)
951 CALL dbcsr_create(pmat_diag, name=
"Block diagonal density", template=matrix_p(1, 1)%matrix)
954 CALL dbcsr_dot(matrix_s(1, 1)%matrix, pmat_diag, str)
955 lri_env%stat%rho_1c = lri_env%stat%rho_1c + str
959 IF (.NOT. response_density)
THEN
961 rho_r(ispin), qs_env, &
962 lri_density%lri_coefs(ispin)%lri_kinds, tot_rho_r(ispin), &
963 "LRI_AUX", lri_env%exact_1c_terms, pmat=pmat_diag)
966 rho_r(ispin), qs_env, &
967 lri_density%lri_coefs(ispin)%lri_kinds, tot_rho_r(ispin), &
968 "P_LRI_AUX", lri_env%exact_1c_terms, pmat=pmat_diag)
970 lri_env%stat%rho_tt = lri_env%stat%rho_tt + tot_rho_r(ispin)
977 CALL timestop(handle)
979 END SUBROUTINE distribute_lri_density_on_the_grid
989 SUBROUTINE inverse_lri_overlap(lri_env, sinv, sa, sb, sab)
992 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: sinv
993 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: sa, sb, sab
995 CHARACTER(LEN=*),
PARAMETER :: routinen =
'inverse_lri_overlap'
997 INTEGER :: handle, info, n, nfa, nfb, nn
998 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iwork
999 REAL(kind=
dp) :: anorm, delta, rcond, rskip
1000 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: work
1001 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: s
1002 REAL(kind=
dp),
EXTERNAL :: dlange
1004 CALL timeset(routinen, handle)
1012 s(1:nfa, 1:nfa) = sa(1:nfa, 1:nfa)
1013 s(1:nfa, nfa + 1:nn) = sab(1:nfa, 1:nfb)
1014 s(nfa + 1:nn, 1:nfa) = transpose(sab(1:nfa, 1:nfb))
1015 s(nfa + 1:nn, nfa + 1:nn) = sb(1:nfb, 1:nfb)
1020 SELECT CASE (lri_env%lri_overlap_inv)
1029 ALLOCATE (work(3*n), iwork(n))
1031 anorm = dlange(
'1', n, n, sinv, n, work)
1033 CALL dpotrf(
'U', n, sinv, n, info)
1036 CALL dpocon(
'U', n, sinv, n, anorm, rcond, work, iwork, info)
1038 cpabort(
"DPOCON failed")
1040 IF (log(1._dp/rcond) > lri_env%cond_max)
THEN
1048 DEALLOCATE (work, iwork)
1050 cpabort(
"No initialization for LRI overlap available?")
1053 delta = inv_test(s, sinv)
1055 lri_env%stat%overlap_error = max(delta, lri_env%stat%overlap_error)
1060 CALL timestop(handle)
1062 END SUBROUTINE inverse_lri_overlap
1070 FUNCTION inv_test(amat, ainv)
RESULT(delta)
1071 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: amat, ainv
1072 REAL(kind=
dp) :: delta
1075 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: work
1078 ALLOCATE (work(n, n))
1079 work(1:n, 1:n) = matmul(amat(1:n, 1:n), ainv(1:n, 1:n))
1081 work(i, i) = work(i, i) - 1.0_dp
1083 delta = maxval(abs(work))
1085 END FUNCTION inv_test
1094 SUBROUTINE output_debug_info(lri_env, qs_env, lri_ints, soo_list)
1102 CHARACTER(LEN=*),
PARAMETER :: routinen =
'output_debug_info'
1104 INTEGER :: handle, iac, ikind, ilist, iunit, jkind, &
1106 REAL(kind=
dp) :: dmax_aabb, dmax_ab, dmax_aba, dmax_abb, &
1114 DIMENSION(:),
POINTER :: nl_iterator
1117 CALL timeset(routinen, handle)
1118 NULLIFY (input, logger, lrii, lriir, nl_iterator, para_env)
1119 CALL get_qs_env(qs_env, dft_control=dft_control, input=input, nkind=nkind, &
1131 ilist=ilist, inode=jneighbor)
1133 iac = ikind + nkind*(jkind - 1)
1134 lrii => lri_ints%lri_atom(iac)%lri_node(ilist)%lri_int(jneighbor)
1136 dmax_ab = max(dmax_ab, lrii%dmax_ab)
1137 dmax_oo = max(dmax_oo, lrii%dmax_oo)
1138 dmax_aba = max(dmax_aba, lrii%dmax_aba)
1139 dmax_abb = max(dmax_abb, lrii%dmax_abb)
1141 IF (dft_control%qs_control%lri_optbas)
THEN
1142 lriir => lri_env%lri_ints_rho%lri_atom(iac)%lri_node(ilist)%lri_int_rho(jneighbor)
1143 dmax_aabb = max(dmax_aabb, lriir%dmax_aabb)
1149 CALL para_env%max(dmax_ab)
1150 CALL para_env%max(dmax_oo)
1151 CALL para_env%max(dmax_aba)
1152 CALL para_env%max(dmax_abb)
1153 CALL para_env%max(dmax_aabb)
1157 extension=
".lridebug")
1160 WRITE (iunit, fmt=
"(/,T2,A)")
"DEBUG INFO FOR LRI INTEGRALS"
1161 WRITE (iunit, fmt=
"(T2,A,T69,ES12.5)")
"Maximal deviation of integrals "// &
1162 "[ai|bi]; fit basis", dmax_ab
1163 WRITE (iunit, fmt=
"(T2,A,T69,ES12.5)")
"Maximal deviation of integrals "// &
1164 "[a|b]; orbital basis", dmax_oo
1165 WRITE (iunit, fmt=
"(T2,A,T69,ES12.5)")
"Maximal deviation of integrals "// &
1166 "[a|b|ai]", dmax_aba
1167 WRITE (iunit, fmt=
"(T2,A,T69,ES12.5)")
"Maximal deviation of integrals "// &
1168 "[a|b|bi]", dmax_abb
1169 IF (dft_control%qs_control%lri_optbas)
THEN
1170 WRITE (iunit, fmt=
"(T2,A,T69,ES12.5,/)")
"Maximal deviation of integrals "// &
1171 "[aa|bb]; orbital basis", &
1177 "PRINT%PROGRAM_RUN_INFO")
1178 CALL timestop(handle)
1180 END SUBROUTINE output_debug_info
1191 LOGICAL,
INTENT(IN) :: calculate_forces
1193 INTEGER :: ikind, natom, nfa, nkind
1194 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: v_int
1197 CALL get_qs_env(qs_env, lri_env=lri_env, nkind=nkind)
1200 natom =
SIZE(lri_v_int(ikind)%v_int, 1)
1201 nfa =
SIZE(lri_v_int(ikind)%v_int, 2)
1202 v_int => lri_env%lri_ppl_ints%lri_ppl(ikind)%v_int
1203 cpassert(
SIZE(v_int, 1) == natom)
1204 cpassert(
SIZE(v_int, 2) == nfa)
1205 lri_v_int(ikind)%v_int(:, :) = lri_v_int(ikind)%v_int(:, :) + v_int(:, :)
1208 IF (calculate_forces)
THEN
1209 CALL calculate_lri_ppl_integrals(lri_env, qs_env, calculate_forces)
1223 REAL(kind=
dp),
INTENT(INOUT) :: ecore_ppl_ri
1225 INTEGER :: ikind, natom, nfa, nkind
1226 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: v_int
1229 CALL get_qs_env(qs_env, lri_env=lri_env, nkind=nkind)
1231 natom =
SIZE(lri_v_int(ikind)%v_int, 1)
1232 nfa =
SIZE(lri_v_int(ikind)%v_int, 2)
1233 v_int => lri_env%lri_ppl_ints%lri_ppl(ikind)%v_int
1234 cpassert(
SIZE(v_int, 1) == natom)
1235 cpassert(
SIZE(v_int, 2) == nfa)
1236 ecore_ppl_ri = ecore_ppl_ri + sum(v_int(:, :)*lri_v_int(ikind)%acoef(:, :))
1250 LOGICAL,
OPTIONAL :: ltddfpt
1254 LOGICAL :: my_ltddfpt
1255 REAL(kind=
dp) :: abai_mem, coef_mem, oint_mem, overlap_error, pairs_ff, pairs_sr, pairs_tt, &
1256 ppli_mem, ppx, rho_1c, rho_ff, rho_sr, rho_tt, rhos_mem
1262 my_ltddfpt = .false.
1263 IF (
PRESENT(ltddfpt)) my_ltddfpt = ltddfpt
1265 IF (.NOT. my_ltddfpt)
THEN
1266 CALL get_qs_env(qs_env, lri_env=lri_env, input=input, para_env=para_env)
1268 CALL get_qs_env(qs_env, input=input, para_env=para_env)
1270 lri_env => tddfpt_lri_env
1273 IF (lri_env%statistics)
THEN
1276 pairs_tt = lri_env%stat%pairs_tt
1277 CALL para_env%sum(pairs_tt)
1278 pairs_sr = lri_env%stat%pairs_sr
1279 CALL para_env%sum(pairs_sr)
1280 pairs_ff = lri_env%stat%pairs_ff
1281 CALL para_env%sum(pairs_ff)
1282 overlap_error = lri_env%stat%overlap_error
1283 CALL para_env%sum(overlap_error)
1284 rho_tt = -lri_env%stat%rho_tt
1285 rho_sr = lri_env%stat%rho_sr
1286 CALL para_env%sum(rho_sr)
1287 rho_ff = lri_env%stat%rho_ff
1288 CALL para_env%sum(rho_ff)
1289 IF (lri_env%exact_1c_terms)
THEN
1290 rho_1c = lri_env%stat%rho_1c
1295 coef_mem = lri_env%stat%coef_mem*ppx
1296 CALL para_env%sum(coef_mem)
1297 oint_mem = lri_env%stat%oint_mem*ppx
1298 CALL para_env%sum(oint_mem)
1299 rhos_mem = lri_env%stat%rhos_mem*ppx
1300 CALL para_env%sum(rhos_mem)
1301 abai_mem = lri_env%stat%abai_mem*ppx
1302 CALL para_env%sum(abai_mem)
1303 IF (lri_env%ppl_ri)
THEN
1304 ppli_mem = lri_env%stat%ppli_mem*ppx
1305 CALL para_env%sum(ppli_mem)
1311 WRITE (iunit, fmt=
"(/,T2,A,A,A)")
"********************************", &
1312 " LRI STATISTICS ",
"*******************************"
1314 WRITE (iunit, fmt=
"(T4,A,T63,F16.0)")
"Total number of atom pairs", pairs_tt
1315 ppx = pairs_sr/pairs_tt*100._dp
1316 WRITE (iunit, fmt=
"(T4,A,T52,A,F5.1,A,T63,F16.0)")
"Near field atom pairs", &
1317 "[", ppx,
"%]", pairs_sr
1318 ppx = pairs_ff/pairs_tt*100._dp
1319 WRITE (iunit, fmt=
"(T4,A,T52,A,F5.1,A,T63,F16.0)")
"Far field atom pairs", &
1320 "[", ppx,
"%]", pairs_ff
1322 WRITE (iunit, fmt=
"(T4,A,T63,G16.8)")
"Max. error in pair overlap inversion", overlap_error
1324 WRITE (iunit, fmt=
"(T4,A,T63,F16.2)")
"Total charge approximated", rho_tt
1325 ppx = rho_sr/rho_tt*100._dp
1326 WRITE (iunit, fmt=
"(T4,A,T52,A,F5.1,A,T63,F16.2)")
"Near field charge", &
1327 "[", ppx,
"%]", rho_sr
1328 ppx = rho_ff/rho_tt*100._dp
1329 WRITE (iunit, fmt=
"(T4,A,T52,A,F5.1,A,T63,F16.2)")
"Far field charge", &
1330 "[", ppx,
"%]", rho_ff
1331 IF (lri_env%exact_1c_terms)
THEN
1332 ppx = rho_1c/rho_tt*100._dp
1333 WRITE (iunit, fmt=
"(T4,A,T52,A,F5.1,A,T63,F16.2)")
"One center charge", &
1334 "[", ppx,
"%]", rho_1c
1337 WRITE (iunit, fmt=
"(T4,A,T63,F9.0,A)")
"Max. memory/task for expansion coeficients", coef_mem,
" Mbytes"
1338 WRITE (iunit, fmt=
"(T4,A,T63,F9.0,A)")
"Max. memory/task for overlap matrices", oint_mem,
" Mbytes"
1339 WRITE (iunit, fmt=
"(T4,A,T63,F9.0,A)")
"Max. memory/task for density expansions", rhos_mem,
" Mbytes"
1340 WRITE (iunit, fmt=
"(T4,A,T63,F9.0,A)")
"Max. memory/task for aba/abb integrals", abai_mem,
" Mbytes"
1341 IF (lri_env%ppl_ri)
THEN
1342 WRITE (iunit, fmt=
"(T4,A,T63,F9.0,A)")
"Max. memory/task for ppl integrals", ppli_mem,
" Mbytes"
1345 WRITE (iunit, fmt=
"(T2,A,A)")
"********************************", &
1346 "***********************************************"
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
Calculation of the local pseudopotential contribution to the core Hamiltonian <a|V(local)|b> = <a|Sum...
subroutine, public build_core_ppl_ri(lri_ppl_coef, force, virial, calculate_forces, use_virial, qs_kind_set, atomic_kind_set, particle_set, sac_ppl, basis_type)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_replicate_all(matrix)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
subroutine, public dbcsr_get_block_diag(matrix, diag)
Copies the diagonal blocks of matrix into diag.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Calculation of contracted, spherical Gaussian integrals using the (OS) integral scheme....
subroutine, public int_overlap_aabb_os(saabb, oba, obb, rab, debug, dmax)
calculate overlap integrals (aa,bb)
Defines the basic variable types.
integer, parameter, public dp
integral compression (fix point accuracy)
subroutine, public lri_decomp_i(aval, cont, ival)
...
real(kind=dp) function, public lri_cont_mem(cont)
...
subroutine, public lri_comp(aval, amax, cont)
...
Calculates integral matrices for LRIGPW method lri : local resolution of the identity.
subroutine, public v_int_ppl_update(qs_env, lri_v_int, calculate_forces)
...
subroutine, public calculate_lri_integrals(lri_env, qs_env)
calculates integrals needed for the LRI density fitting, integrals are calculated once,...
subroutine, public lri_print_stat(qs_env, ltddfpt, tddfpt_lri_env)
...
subroutine, public lri_kg_rho_update(rho_struct, qs_env, lri_env, lri_density, atomlist)
...
subroutine, public calculate_lri_densities(lri_env, lri_density, qs_env, pmatrix, cell_to_index, lri_rho_struct, atomic_kind_set, para_env, response_density)
performs the fitting of the density and distributes the fitted density on the grid
subroutine, public calculate_avec_lri(lri_env, lri_density, pmatrix, cell_to_index, response_density)
performs the fitting of the density; solves the linear system of equations; yield the expansion coeff...
subroutine, public build_lri_matrices(lri_env, qs_env)
creates and initializes an lri_env
subroutine, public v_int_ppl_energy(qs_env, lri_v_int, ecore_ppl_ri)
...
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
subroutine, public allocate_lri_ints_rho(lri_env, lri_ints_rho, nkind)
allocate lri_ints_rho, storing integral for the exact density
subroutine, public deallocate_lri_ppl_ints(lri_ppl_ints)
deallocates the given lri_ppl_ints
subroutine, public allocate_lri_ppl_ints(lri_env, lri_ppl_ints, atomic_kind_set)
allocate lri_ppl_ints, matrices that store LRI integrals
subroutine, public allocate_lri_coefs(lri_env, lri_density, atomic_kind_set)
creates and initializes lri_coefs
subroutine, public lri_density_release(lri_density)
releases the given lri_density
subroutine, public allocate_lri_ints(lri_env, lri_ints, nkind)
allocate lri_ints, matrices that store LRI integrals
subroutine, public deallocate_lri_ints(lri_ints)
deallocates the given lri_ints
subroutine, public deallocate_lri_ints_rho(lri_ints_rho)
deallocates the given lri_ints_rho
subroutine, public lri_density_create(lri_density)
creates and initializes an lri_density environment
subroutine, public allocate_lri_rhos(lri_env, lri_rhos, nspin, nkind)
creates and initializes lri_rhos
Calculates integrals for LRIGPW method lri : local resolution of the identity.
subroutine, public deallocate_int_type(lriint, lridint)
...
subroutine, public allocate_int_type(lriint, lridint, nba, nbb, nfa, nfb, skip_sab, skip_soo, skip_aba, skip_abb, skip_dsab, skip_dsoo, skip_daba, skip_dabb)
...
subroutine, public lri_int2(lri_env, lrii, lriint, rab, obasa, obasb, fbasa, fbasb, iatom, jatom, ikind, jkind)
calcuates the lri integrals using solid harmonic Gaussians
Collection of simple mathematical functions and subroutines.
subroutine, public get_pseudo_inverse_svd(a, a_pinverse, rskip, determinant, sval)
returns the pseudoinverse of a real, square matrix using singular value decomposition
subroutine, public get_pseudo_inverse_diag(a, a_pinverse, rskip)
returns the pseudoinverse of a real, symmetric and positive definite matrix using diagonalization.
subroutine, public invmat_symm(a, potrf, uplo)
returns inverse of real symmetric, positive definite matrix
Interface to the message passing library MPI.
Define the data structure for the particle information.
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_lri_rho_elec(lri_rho_g, lri_rho_r, qs_env, lri_coef, total_rho, basis_type, exact_1c_terms, pmat, atomlist)
Collocates the fitted lri density on a grid.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.