Commit 0bf2eadd authored by Miriam Hinzen's avatar Miriam Hinzen

Film-Case Kerker Preconditions in Film Region Only

parent 400cfea6
...@@ -28,7 +28,6 @@ CONTAINS ...@@ -28,7 +28,6 @@ CONTAINS
REAL :: q2(vacuum%nmz), w, rht1(vacuum%nmzd,2,input%jspins) REAL :: q2(vacuum%nmz), w, rht1(vacuum%nmzd,2,input%jspins)
COMPLEX :: x(stars%ng3) COMPLEX :: x(stars%ng3)
CALL timestart("cdntot")
qtot = 0.0 qtot = 0.0
qistot = 0.0 qistot = 0.0
DO jsp = 1,input%jspins DO jsp = 1,input%jspins
...@@ -109,7 +108,10 @@ CONTAINS ...@@ -109,7 +108,10 @@ CONTAINS
REAL qmt(atoms%ntype,input%jspins),qvac(2,input%jspins) REAL qmt(atoms%ntype,input%jspins),qvac(2,input%jspins)
INTEGER, ALLOCATABLE :: lengths(:,:) INTEGER, ALLOCATABLE :: lengths(:,:)
CHARACTER(LEN=20) :: attributes(6), names(6) CHARACTER(LEN=20) :: attributes(6), names(6)
CALL timestart("cdntot")
call cdntot_integrate(stars,atoms,sym,vacuum,input,cell,oneD, den, & call cdntot_integrate(stars,atoms,sym,vacuum,input,cell,oneD, den, &
q, qis, qmt, qvac, qtot, qistot) q, qis, qmt, qvac, qtot, qistot)
......
...@@ -87,9 +87,9 @@ contains ...@@ -87,9 +87,9 @@ contains
! KERKER PRECONDITIONER ! KERKER PRECONDITIONER
IF( input%preconditioning_param /= 0 ) THEN IF( input%preconditioning_param /= 0 ) THEN
CALL timestart("Preconditioner") CALL timestart("Preconditioner")
CALL kerker(field, DIMENSION, mpi, & CALL kerker( field, DIMENSION, mpi, &
stars, atoms, sphhar, vacuum, input, sym, cell, noco, & stars, atoms, sphhar, vacuum, input, sym, cell, noco, &
oneD, inDen, outDen, fsm(it) ) oneD, inDen, outDen, fsm(it) )
!Store modified density in history !Store modified density in history
CALL mixing_history_store(fsm(it)) CALL mixing_history_store(fsm(it))
CALL timestop("Preconditioner") CALL timestop("Preconditioner")
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
! of the MIT license as expressed in the LICENSE file in more detail. ! of the MIT license as expressed in the LICENSE file in more detail.
!-------------------------------------------------------------------------------- !--------------------------------------------------------------------------------
MODULE m_kerker MODULE m_kerker
CONTAINS CONTAINS
SUBROUTINE kerker(field, DIMENSION, mpi, & SUBROUTINE kerker( field, DIMENSION, mpi, &
stars, atoms, sphhar, vacuum, input, sym, cell, noco, & stars, atoms, sphhar, vacuum, input, sym, cell, noco, &
oneD, inDen, outDen, precon_v ) oneD, inDen, outDen, precon_v )
!Implementation of the Kerker preconditioner by M.Hinzen !Implementation of the Kerker preconditioner by M.Hinzen
USE m_vgen_coulomb USE m_vgen_coulomb
USE m_VYukawaFilm USE m_VYukawaFilm
USE m_juDFT USE m_juDFT
...@@ -19,6 +22,7 @@ CONTAINS ...@@ -19,6 +22,7 @@ CONTAINS
USE m_constants USE m_constants
USE m_mpi_bc_potden USE m_mpi_bc_potden
IMPLICIT NONE IMPLICIT NONE
TYPE(t_oneD), INTENT(in) :: oneD TYPE(t_oneD), INTENT(in) :: oneD
TYPE(t_input), INTENT(in) :: input TYPE(t_input), INTENT(in) :: input
TYPE(t_vacuum), INTENT(in) :: vacuum TYPE(t_vacuum), INTENT(in) :: vacuum
...@@ -35,10 +39,9 @@ CONTAINS ...@@ -35,10 +39,9 @@ CONTAINS
TYPE(t_potden), INTENT(in) :: inDen TYPE(t_potden), INTENT(in) :: inDen
TYPE(t_mixvector), INTENT(INOUT) :: precon_v TYPE(t_mixvector), INTENT(INOUT) :: precon_v
!Locals type(t_potden) :: resDen, vYukawa, resDenMod
type(t_potden) :: resDen, vYukawa real :: fix
real :: fix integer :: lh,n
integer :: lh,n
CALL resDen%init( stars, atoms, sphhar, vacuum, noco, input%jspins, POTDEN_TYPE_DEN ) CALL resDen%init( stars, atoms, sphhar, vacuum, noco, input%jspins, POTDEN_TYPE_DEN )
CALL vYukawa%init( stars, atoms, sphhar, vacuum, noco, input%jspins, 4 ) CALL vYukawa%init( stars, atoms, sphhar, vacuum, noco, input%jspins, 4 )
...@@ -53,8 +56,12 @@ CONTAINS ...@@ -53,8 +56,12 @@ CONTAINS
CALL vgen_coulomb( 1, mpi, DIMENSION, oneD, input, field, vacuum, sym, stars, cell, & CALL vgen_coulomb( 1, mpi, DIMENSION, oneD, input, field, vacuum, sym, stars, cell, &
sphhar, atoms, resDen, vYukawa ) sphhar, atoms, resDen, vYukawa )
ELSE ELSE
if( mpi%irank == 0 ) then
call resDenMod%init( stars, atoms, sphhar, vacuum, noco, input%jspins, POTDEN_TYPE_DEN )
call resDenMod%copyPotDen( resDen )
end if
vYukawa%iter = resDen%iter vYukawa%iter = resDen%iter
CALL VYukawaFilm( stars, vacuum, cell, sym, input, mpi, atoms, sphhar, DIMENSION, oneD, resDen, & CALL VYukawaFilm( stars, vacuum, cell, sym, input, mpi, atoms, sphhar, DIMENSION, oneD, noco, resDenMod, &
vYukawa ) vYukawa )
END IF END IF
...@@ -67,8 +74,6 @@ CONTAINS ...@@ -67,8 +74,6 @@ CONTAINS
* vYukawa%mt(1:atoms%jri(n),lh,n,1) * atoms%rmsh(1:atoms%jri(n),n) ** 2 * vYukawa%mt(1:atoms%jri(n),lh,n,1) * atoms%rmsh(1:atoms%jri(n),n) ** 2
END DO END DO
END DO END DO
resDen%vacz = resDen%vacz - input%preconditioning_param ** 2 / fpi_const * vYukawa%vacz
resDen%vacxy = resDen%vacxy - input%preconditioning_param ** 2 / fpi_const * vYukawa%vacxy
IF( input%jspins == 2 ) CALL resDen%ChargeAndMagnetisationToSpins() IF( input%jspins == 2 ) CALL resDen%ChargeAndMagnetisationToSpins()
! fix the preconditioned density ! fix the preconditioned density
CALL outDen%addPotDen( resDen, inDen ) CALL outDen%addPotDen( resDen, inDen )
...@@ -76,6 +81,7 @@ CONTAINS ...@@ -76,6 +81,7 @@ CONTAINS
CALL resDen%subPotDen( outDen, inDen ) CALL resDen%subPotDen( outDen, inDen )
END IF MPI0_c END IF MPI0_c
CALL precon_v%from_density(resden) CALL precon_v%from_density(resden)
! end of preconditioner
END SUBROUTINE kerker END SUBROUTINE kerker
END MODULE m_kerker END MODULE m_kerker
...@@ -42,6 +42,7 @@ MODULE m_types_potden ...@@ -42,6 +42,7 @@ MODULE m_types_potden
procedure :: ChargeAndMagnetisationToSpins procedure :: ChargeAndMagnetisationToSpins
procedure :: addPotDen procedure :: addPotDen
procedure :: subPotDen procedure :: subPotDen
procedure :: copyPotDen
procedure :: distribute procedure :: distribute
procedure :: collect procedure :: collect
END TYPE t_potden END TYPE t_potden
...@@ -233,6 +234,21 @@ CONTAINS ...@@ -233,6 +234,21 @@ CONTAINS
end subroutine end subroutine
subroutine copyPotDen( PotDenCopy, PotDen )
implicit none
class(t_potden), intent(in) :: PotDen
class(t_potden), intent(inout) :: PotDenCopy
PotDenCopy%iter = PotDen%iter
PotDenCopy%potdenType = PotDen%potdenType
PotDenCopy%mt = PotDen%mt
PotDenCopy%pw = PotDen%pw
PotDenCopy%vacz = PotDen%vacz
PotDenCopy%vacxy = PotDen%vacxy
end subroutine copyPotDen
SUBROUTINE init_potden_types(pd,stars,atoms,sphhar,vacuum,noco,jspins,potden_type) SUBROUTINE init_potden_types(pd,stars,atoms,sphhar,vacuum,noco,jspins,potden_type)
USE m_judft USE m_judft
USE m_types_setup USE m_types_setup
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment