Giter Club home page Giter Club logo

fortran_davidson's Introduction

Build Status Pipeline DOI

Davidson Eigensolver

This package contains a Modern Fortran implementation of the Davidson diagonalization algorithms. Different schemas are available to compute the correction.

Available correction methods are:

  • DPR: Diagonal-Preconditioned-Residue
  • GJD: Generalized Jacobi Davidson

Note:

The Davidson method is suitable for diagonal-dominant symmetric matrices, that are quite common in certain scientific problems like electronic structure. The Davidson method could be not practical for other kinds of symmetric matrices.

Usage

The following program call the eigensolver subroutine from the davidson module and computes the lowest 3 eigenvalues and corresponding eigenvectors, using the GJD method with a tolerance of 1e-8 and 100 maximum iteration.

program main
  use numeric_kinds, only: dp
  use davidson, only: generalized_eigensolver, generate_diagonal_dominant
 
  implicit none

  integer, parameter :: dim = 50
  integer, parameter :: lowest = 3
  real(dp), dimension(dim, dim) :: matrix, second_matrix
  real(dp), dimension(lowest) :: eigenvalues
  real(dp), dimension(dim, lowest) :: eigenvectors
  real(dp) :: tolerance
  integer:: max_dim_subspace, max_iterations, lowest

  matrix = generate_diagonal_dominant(dim, 1d-4)
  second_matrix = generate_diagonal_dominant(dim, 1d-4, 1.0_dp)
  max_iterations = 1000
  max_dim_subspace = 20
  tolerance = 1d-8
  call generalized_eigensolver(matrix, eigenvalues, eigenvectors, lowest, "GJD", max_iterations, &
       tolerance, final_iterations, max_dim_subspace, second_matrix)
  print *, eigenvalues
  print *, eigenvectors

end program main

The helper generate_diagonal_dominant function generates a diagonal dominant matrix with entries to the diagonal close to row number (i=1, number_of_rows) and random number of the order 1e-4 on the off-diagonal entries.

Variables:

  • matrix (in) matrix to diagonalize
  • eigenvalues (out) resulting eigenvalues
  • eigenvectors (out) resulting eigenvectors
  • lowest(in) number of eigenvalues to compute
  • method(in) Either "DPR" or "GJD"
  • max_iterations(in) maximum number of iterations
  • tolerance(in) Numerical tolerance for convergence
  • final_iterations(output) returns the number of iterations that were needed to converge
  • max_dim_subspace(in, optional) Dimension of the subspace of search
  • second_matrix(in, optional) Optional matrix to compute the generalized eigenvalue problem

References:

Installation and Testing

To compile execute:

cmake -H. -Bbuild && cmake --build build

To use another compiler (e.g. ifort):

cmake -H. -Bbuild -DCMAKE_Fortran_COMPILER=ifort && cmake --build build

To run the test:

cmake -H. -Bbuild -DENABLE_TEST=ON && cmake --build build
cd build && ctest -V

To Debug compile as:

cmake -H. -Bbuild  -DCMAKE_BUILD_TYPE=Debug && cmake --build build

Dependencies

This packages assumes that you have installed the following packages:

Optionally, If an MKL library is available the package will try to find it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.