Skip to content

Commit

Permalink
Replace mixer implementations with more modern variants
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderhe committed Jun 6, 2024
1 parent 0b2aa17 commit 3c913c6
Show file tree
Hide file tree
Showing 15 changed files with 924 additions and 565 deletions.
2 changes: 1 addition & 1 deletion sktools/src/sktools/calculators/slateratom.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def write(self, workdir):
out.append("{:s} \t\t{:s} write eigenvectors".format(
self._LOGICALSTRS[False], self._COMMENT))
out.append("{} {:g} \t\t{:s} broyden mixer, mixing factor".format(
self._LOGICALSTRS[True], 0.1, self._COMMENT))
2, 0.1, self._COMMENT))

# Occupations
for ll, occperl in enumerate(self._atomconfig.occupations):
Expand Down
8 changes: 7 additions & 1 deletion slateratom/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(sources-f90
avgpot.f90
broyden.f90
blas.f90
blasroutines.f90
broydenmixer.f90
core_overlap.f90
coulomb_hfex.f90
coulomb_potential.f90
Expand All @@ -12,8 +14,12 @@ set(sources-f90
hamiltonian.f90
input.f90
integration.f90
lapack.f90
lapackroutines.f90
mixer.f90
numerical_differentiation.f90
output.f90
simplemixer.f90
total_energy.f90
utilities.f90
xcfunctionals.f90
Expand Down
48 changes: 48 additions & 0 deletions slateratom/lib/blas.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
!> Interface wrapper for the blas routines.
!!
!! ALL BLAS routines which are called from the main code must be included here.
module blas

use common_accuracy, only : rdp
public

interface


!> Performs the rank 1 operation
!! A := alpha*x*y**T + A,
subroutine dger(mm, nn, alpha, xx, incx, yy, incy, aa, lda)
import rdp

!> Matrix sizing
integer, intent(in) :: mm

!> Matrix size
integer, intent(in) :: nn

!> Scale factor
real(rdp), intent(in) :: alpha

!> Vector
real(rdp), intent(in) :: xx(*)

!> Stride
integer, intent(in) :: incx

!> Vector
real(rdp), intent(in) :: yy(*)

!> Stride
integer, intent(in) :: incy

!> Leading matrix dimension
integer, intent(in) :: lda

!> Matrix A
real(rdp), intent(inout) :: aa(lda, *)

end subroutine dger

end interface

end module blas
49 changes: 49 additions & 0 deletions slateratom/lib/blasroutines.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
!> Contains F90 wrapper functions for some commonly used blas calls needed in the code.
!! The interface of all BLAS calls must be defined in the module blas.
module blasroutines

use common_accuracy, only : rdp
use blas, only : dger
implicit none

private
public :: ger


!> Rank 1 update of a matrix A := alpha*x*y' + A
!! Wrapper for the level 2 blas routine xger to perform the rank 1 update of a general matrix
interface ger
module procedure ger_dble
end interface ger


contains

!> Double precision rank 1 update of a general matrix
subroutine ger_dble(a, alpha, x, y)

!> Contains the matrix for the update
real(rdp), intent(inout) :: a(:,:)

!> Scaling value for the update contribution
real(rdp), intent(in) :: alpha

!> Vector of values for the update
real(rdp), intent(in) :: x(:)

!> Vector of values for the update
real(rdp), intent(in) :: y(:)

integer :: n, m

! @:ASSERT(size(a,dim=1) == size(x))
! @:ASSERT(size(a,dim=2) == size(y))

m = size(x)
n = size(y)

call dger(m, n, alpha, x, 1, y, 1, a, m)

end subroutine ger_dble

end module blasroutines
Loading

0 comments on commit 3c913c6

Please sign in to comment.