• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adc-connect / adcc / 13870935425

15 Mar 2025 07:57AM UTC coverage: 73.946% (+0.3%) from 73.683%
13870935425

Pull #191

github

web-flow
Merge 898f3aab3 into cc4761121
Pull Request #191: Fix orthgonality loss in Davidson using Gram-Schmidt reorthogonalisation

1132 of 1808 branches covered (62.61%)

Branch coverage included in aggregate %.

46 of 47 new or added lines in 3 files covered. (97.87%)

2 existing lines in 2 files now uncovered.

7110 of 9338 relevant lines covered (76.14%)

192687.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.0
/adcc/solver/SolverStateBase.py
1
#!/usr/bin/env python3
2
## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab
3
## ---------------------------------------------------------------------
4
##
5
## Copyright (C) 2018 by the adcc authors
6
##
7
## This file is part of adcc.
8
##
9
## adcc is free software: you can redistribute it and/or modify
10
## it under the terms of the GNU General Public License as published
11
## by the Free Software Foundation, either version 3 of the License, or
12
## (at your option) any later version.
13
##
14
## adcc is distributed in the hope that it will be useful,
15
## but WITHOUT ANY WARRANTY; without even the implied warranty of
16
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
## GNU General Public License for more details.
18
##
19
## You should have received a copy of the GNU General Public License
20
## along with adcc. If not, see <http://www.gnu.org/licenses/>.
21
##
22
## ---------------------------------------------------------------------
23
from adcc.timings import Timer
2✔
24

25

26
class EigenSolverStateBase:
2✔
27
    def __init__(self, matrix):
2✔
28
        """Initialise an EigenSolverStateBase.
29

30
        Parameters
31
        ----------
32
        matrix
33
            Matrix to be diagonalised.
34
        """
35
        self.matrix = matrix
2✔
36
        self.eigenvalues = None           # Current eigenvalues
2✔
37
        self.eigenvectors = None          # Current eigenvectors
2✔
38
        self.residual_norms = None        # Current residual norms
2✔
39
        self.converged = False            # Flag whether iteration is converged
2✔
40
        self.n_iter = 0                   # Number of iterations
2✔
41
        self.n_applies = 0                # Number of applies
2✔
42
        self.reortho_triggers = []        # List of reorthogonalisation triggers
2✔
43
        self.timer = Timer()              # Construct a new timer
2✔
44

45
    def describe(self):
2✔
46
        text = ""
×
47

48
        problem = str(self.matrix)
×
49
        algorithm = getattr(self, "algorithm", "")
×
50

51
        if self.converged:
×
52
            conv = "converged"
×
53
        else:
54
            conv = "NOT CONVERGED"
×
55

56
        text += "+" + 60 * "-" + "+\n"
×
57
        text += "| {0:<41s}  {1:>15s} |\n".format(algorithm, conv)
×
58
        text += ("| {0:30s} n_iter={1:<3d}  n_applies={2:<5d} |\n"
×
59
                 "".format(problem[:30], self.n_iter, self.n_applies))
NEW
60
        text += ("| n_reortho={0:<7d}  max_overlap_before_reortho={1:<10s}   |\n"
×
61
                 "".format(len(self.reortho_triggers),
62
                           "{:<10.4E}".format(max(self.reortho_triggers))
63
                           if len(self.reortho_triggers) > 0 else "N/A"))
64
        text += "+" + 60 * "-" + "+\n"
×
65
        text += ("|  #     eigenvalue  res. norm       "
×
66
                 "dominant elements       |\n")
67

68
        body = "| {0:2d} {1:14.7g}  {2:9.4g}               TODO            |\n"
×
69
        for i, vec in enumerate(self.eigenvectors):
×
70
            text += body.format(i, self.eigenvalues[i], self.residual_norms[i])
×
71
        text += "+" + 60 * "-" + "+"
×
72
        return text
×
73

74
    def _repr_pretty_(self, pp, cycle):
2✔
75
        if cycle:
×
76
            pp.text("SolverState(...)")
×
77
        else:
78
            pp.text(self.describe())
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc