Octopus
eigen_rmmdiis.F90
Go to the documentation of this file.
1!! Copyright (C) 2008 X. Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use batch_oct_m
24 use comm_oct_m
25 use debug_oct_m
26 use global_oct_m
28 use, intrinsic :: iso_fortran_env
30 use loct_oct_m
31 use mesh_oct_m
34 use mpi_oct_m
41
42 implicit none
43
44 private
45 public :: &
50
52 private
53 type(wfs_elec_t), pointer :: batch
54 end type batch_pointer_t
55
56
57contains
58
59 subroutine find_lambda(ca, cb, cc, lambda, ik, ist)
60 real(real64), intent(in) :: ca, cb, cc
61 real(real64), intent(out) :: lambda
62 integer, intent(in) :: ik, ist
63
64 real(real64) :: qq
65
66 push_sub(find_lambda)
67
68
69 ! We follow numerical recipes here to get the two stable solutions
70 qq = -m_half * (cb + sign(sqrt(cb**2 - m_four*ca*cc), cb))
71 lambda = qq/ca
72
73 ! To find the minimum, we want that the derivative changes from negative to positive
74 ! Else, we pick the other solution
75 if(ca*(m_two*lambda)+cb < m_zero) then ! This is a maximum, so we pick the other solution
76 lambda = cc / qq
77 end if
78
79 if(debug%info) then
80 write(message(1), '(2(a,i4),4(a,es12.5))') &
81 'Debug: RMMDIIS Eigensolver - ik', ik, ' ist ', ist, &
82 ' lambda= ', lambda, ' a= ', ca, ' b= ', cb, ' c= ', cc
83 call messages_info(1)
84 end if
85
86 ! restrict the value of lambda to be between 0.1 and 1000
87 ! This is not the same range as in the original RMMDIIS paper,
88 ! but this is ont important as our preconditioner is different, so the norm of the preconditioned
89 ! residue is also changed
90 if (abs(lambda) > 1000.0_real64) lambda = sign(1000.0_real64,lambda)
91 if (abs(lambda) < 0.1_real64) lambda = sign(0.1_real64,lambda)
92
93 pop_sub(find_lambda)
94 end subroutine find_lambda
95
96#include "real.F90"
97#include "eigen_rmmdiis_inc.F90"
98#include "undef.F90"
99
100#include "complex.F90"
101#include "eigen_rmmdiis_inc.F90"
102#include "undef.F90"
103
104end module eigen_rmmdiis_oct_m
105
106
107!! Local Variables:
108!! mode: f90
109!! coding: utf-8
110!! End:
double sqrt(double __x) __attribute__((__nothrow__
This module implements batches of mesh functions.
Definition: batch.F90:133
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:116
type(debug_t), save, public debug
Definition: debug.F90:154
subroutine, public deigensolver_rmmdiis(namespace, mesh, st, hm, pre, tol, niter, converged, ik, diff)
See http:
subroutine, public zeigensolver_rmmdiis(namespace, mesh, st, hm, pre, tol, niter, converged, ik, diff)
See http:
subroutine find_lambda(ca, cb, cc, lambda, ik, ist)
subroutine, public zeigensolver_rmmdiis_min(namespace, mesh, st, hm, pre, niter, converged, ik)
subroutine, public deigensolver_rmmdiis_min(namespace, mesh, st, hm, pre, niter, converged, ik)
real(real64), parameter, public m_two
Definition: global.F90:189
real(real64), parameter, public m_zero
Definition: global.F90:187
real(real64), parameter, public m_four
Definition: global.F90:191
real(real64), parameter, public m_half
Definition: global.F90:193
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:116
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
Definition: messages.F90:624
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160