Hex: src/preconditioners/NoPreconditioner.h Source File

| Hex 2.2 Hydrogen-electron collision solver

NoPreconditioner.h
Go to the documentation of this file.
1 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2 // //
3 // / / / / __ \ \ / / //
4 // / /__ / / / _ \ \ \/ / //
5 // / ___ / | |/_/ / /\ \ //
6 // / / / / \_\ / / \ \ //
7 // //
8 // //
9 // Copyright (c) 2017, Jakub Benda, Charles University in Prague //
10 // //
11 // MIT License: //
12 // //
13 // Permission is hereby granted, free of charge, to any person obtaining a //
14 // copy of this software and associated documentation files (the "Software"), //
15 // to deal in the Software without restriction, including without limitation //
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense, //
17 // and/or sell copies of the Software, and to permit persons to whom the //
18 // Software is furnished to do so, subject to the following conditions: //
19 // //
20 // The above copyright notice and this permission notice shall be included //
21 // in all copies or substantial portions of the Software. //
22 // //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS //
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //
26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, //
27 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF //
28 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. //
29 // //
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31
32 #ifndef HEX_ECS_NOPRECONDITIONER_H
33 #define HEX_ECS_NOPRECONDITIONER_H
34
35 // --------------------------------------------------------------------------------- //
36
37 #include "preconditioners.h"
38 #include "hldata.h"
39
40 // --------------------------------------------------------------------------------- //
41
55 class NoPreconditioner : public PreconditionerBase
56 {
57 public:
58
59 // run-time selection mechanism
60 preconditionerRunTimeSelectionDefinitions(NoPreconditioner, "none")
61
62 // default constructor required by RTS system
63 NoPreconditioner ();
64
65 // constructor
66 NoPreconditioner
67 (
68 CommandLine const & cmd,
69 InputFile const & inp,
70 Parallel const & par,
71 AngularBasis const & ang,
72 Bspline const & bspline_inner,
73 Bspline const & bspline_full,
74 Bspline const & bspline_panel_x,
75 Bspline const & bspline_panel_y
76 );
77
78 // destructor
79 ~NoPreconditioner ();
80
81 // description of the preconditioner
82 virtual std::string description () const;
83
84 // member functions
85 virtual void setup ();
86 virtual void update (Real E);
87 virtual std::pair<int,int> bstates (Real E, int l1, int l2) const;
88 virtual void finish ();
89 virtual void rhs (BlockArray<Complex> & chi, int ienergy, int instate) const;
90 virtual void multiply (BlockArray<Complex> const & p, BlockArray<Complex> & q, MatrixSelection::Selection tri = MatrixSelection::Both) const;
91 virtual void precondition (BlockArray<Complex> const & r, BlockArray<Complex> & z) const;
92
93 // internal routines
94 BlockSymBandMatrix<Complex> calc_A_block (int ill, int illp, bool twoel = true) const;
95
96 // access to the radial integrals
97 RadialIntegrals const & rad_inner () const { return *rad_inner_; }
98 RadialIntegrals const & rad_full () const { return *rad_full_; }
99 RadialIntegrals const & rad_panel () const { return *rad_panel_; }
100
101 protected:
102
103 // energy
104 Real E_;
105
106 // command line switches
107 CommandLine const * cmd_;
108
109 // parallel environment
110 Parallel const * par_;
111
112 // input parameters
113 InputFile const * inp_;
114
115 // coupled states
116 AngularBasis const * ang_;
117
118 // Sub-blocks composing the angular blocks of the full matrix:
119 // ┏━━━━━━┯━━━━━━━┯━━━┓
120 // ┃ A │ Cu │Fu ┃
121 // ┃ │ │ ┃
122 // ┠──────┼───┬───┼───┨
123 // ┃ │B1 │ 0 │ 0 ┃
124 // ┃ Cl ├───┼───┤ ┃
125 // ┃ │ 0 │B2 │ ┃
126 // ┠──────┼───┴───┼───┨
127 // ┃ Fl │ 0 │ E ┃
128 // ┗━━━━━━┷━━━━━━━┷━━━┛
129 // The individual sub-blocks have the following meaning:
130 // 1. A is the rectangular inner-domain two-dimensional hamiltonian on the real grid.
131 // 2. B1, B2 are the rectangular outer region one-electron hamiltonians on the full grid.
132 // Each of them can be composed of diagonal blocks corresponding to the individual
133 // scattering channels. The channels may and may not be coupled to each other.
134 // 3. Cu, Cl is the coupling of the asymptotic channels to the inner region. They are
135 // stored as COO matrices with the dimension of the full matrix.
136 // 4. E is the two-dimensional hamiltonian block that supplies the non-reflective
137 // boundary condition to other channels than those managed by B1 and B2.
138 // 5. Fu, Fl couple the inner region to the non-reflective boundary conditiion
139 // tail. It essentially projects out the asymptotic channels, so that the boundary
140 // condition is applied only on the closed channels.
141 // The blocks marked with zero never contain non-zero elements.
142 std::vector<BlockSymBandMatrix<Complex>> A_blocks_;
143 std::vector<std::vector<SymBandMatrix<Complex>>> B1_blocks_;
144 std::vector<std::vector<SymBandMatrix<Complex>>> B2_blocks_;
145 std::vector<CooMatrix<LU_int_t,Complex>> Cu_blocks_;
146 std::vector<CooMatrix<LU_int_t,Complex>> Cl_blocks_;
147 std::vector<BlockSymBandMatrix<Complex>> E_blocks_;
148 std::vector<CooMatrix<LU_int_t,Complex>> Fu_blocks_;
149 std::vector<CooMatrix<LU_int_t,Complex>> Fl_blocks_;
150
151 // maximal bound state principal quantum number for given energy
152 int max_n_;
153
154 // number of channels considered when r1 -> inf and r2 -> inf, respectively
155 std::vector<std::pair<int,int>> Nchan_;
156
157 // radial integrals for inner, full and panel basis
158 RadialIntegrals *rad_inner_, *rad_full_, *rad_panel_;
159
160 // Eigenstates (expansions) of the inner one-electron hamiltonian for all relevant angular momenta and their overlaps.
161 // They are normalized so that
162 // 1. (Xp|Xp) = 1 (xGEMM does that),
163 // 2. largest component of Xp is real (xGEMM does that),
164 // 3. the first component is positive (additional condition required by Hex).
165 // The last condition makes the states compatible with the function gsl_sf_hydrogenicR.
166 std::array<Array<cArrays>,2> Xp_, Sp_;
167
168 // eigen-energies (in Ry) of the pseudostates contained in Xp_ for each angular momentum
169 std::array<cArrays,2> Eb_;
170
171 // one-electron hamiltonian data (for atomic electron and the projectile)
172 mutable std::array<std::vector<HlData>,2> Hl_;
173
174 // occasionally useful LU decomposition of the overlap matrix
175 std::shared_ptr<LUft> luS_;
176 };
177
178 // --------------------------------------------------------------------------------- //
179
180 #endif // HEX_ECS_NOPRECONDITIONER_H
NoPreconditioner::rad_inner
RadialIntegrals const & rad_inner() const
Definition: NoPreconditioner.h:97
RadialIntegrals
Class that calculates and manages the radial integrals for given B-spline bases.
Definition: radial.h:89
NoPreconditioner::cmd_
CommandLine const * cmd_
Definition: NoPreconditioner.h:107
NoPreconditioner::rad_inner_
RadialIntegrals * rad_inner_
Definition: NoPreconditioner.h:158
NoPreconditioner::luS_
std::shared_ptr< LUft > luS_
Definition: NoPreconditioner.h:175
NoPreconditioner::calc_A_block
BlockSymBandMatrix< Complex > calc_A_block(int ill, int illp, bool twoel=true) const
Definition: NoPreconditioner.cpp:421
NoPreconditioner::precondition
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: NoPreconditioner.cpp:1510
NoPreconditioner::Xp_
std::array< Array< cArrays >, 2 > Xp_
Definition: NoPreconditioner.h:166
NoPreconditioner::E_blocks_
std::vector< BlockSymBandMatrix< Complex > > E_blocks_
Definition: NoPreconditioner.h:147
NoPreconditioner::Cu_blocks_
std::vector< CooMatrix< LU_int_t, Complex > > Cu_blocks_
Definition: NoPreconditioner.h:145
NoPreconditioner::max_n_
int max_n_
Definition: NoPreconditioner.h:152
NoPreconditioner
Solution driver without actual preconditioner.
Definition: NoPreconditioner.h:55
Bspline
B-spline environment.
Definition: bspline.h:57
AngularBasis
Angular basis.
Definition: ang.h:44
NoPreconditioner::update
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: NoPreconditioner.cpp:498
hldata.h
NoPreconditioner::rad_panel_
RadialIntegrals * rad_panel_
Definition: NoPreconditioner.h:158
NoPreconditioner::~NoPreconditioner
~NoPreconditioner()
Definition: NoPreconditioner.cpp:89
CommandLine
Command line parameters.
Definition: io.h:57
NoPreconditioner::preconditionerRunTimeSelectionDefinitions
preconditionerRunTimeSelectionDefinitions(NoPreconditioner, "none") NoPreconditioner()
NoPreconditioner::rad_full_
RadialIntegrals * rad_full_
Definition: NoPreconditioner.h:158
NoPreconditioner::rad_panel
RadialIntegrals const & rad_panel() const
Definition: NoPreconditioner.h:99
NoPreconditioner::finish
virtual void finish()
Clean up memory etc.
Definition: NoPreconditioner.cpp:1515
NoPreconditioner::rhs
virtual void rhs(BlockArray< Complex > &chi, int ienergy, int instate) const
Calculate the right-hand side.
Definition: NoPreconditioner.cpp:821
NoPreconditioner::description
virtual std::string description() const
Description of the preconditioner.
Definition: NoPreconditioner.cpp:96
NoPreconditioner::A_blocks_
std::vector< BlockSymBandMatrix< Complex > > A_blocks_
Definition: NoPreconditioner.h:142
NoPreconditioner::Nchan_
std::vector< std::pair< int, int > > Nchan_
Definition: NoPreconditioner.h:155
InputFile
Input parameters.
Definition: io.h:321
Parallel
MPI info.
Definition: parallel.h:50
NoPreconditioner::ang_
AngularBasis const * ang_
Definition: NoPreconditioner.h:116
NoPreconditioner::NoPreconditioner
NoPreconditioner(CommandLine const &cmd, InputFile const &inp, Parallel const &par, AngularBasis const &ang, Bspline const &bspline_inner, Bspline const &bspline_full, Bspline const &bspline_panel_x, Bspline const &bspline_panel_y)
Definition: NoPreconditioner.cpp:56
preconditioners.h
NoPreconditioner::B1_blocks_
std::vector< std::vector< SymBandMatrix< Complex > > > B1_blocks_
Definition: NoPreconditioner.h:143
NoPreconditioner::rad_full
RadialIntegrals const & rad_full() const
Definition: NoPreconditioner.h:98
NoPreconditioner::Sp_
std::array< Array< cArrays >, 2 > Sp_
Definition: NoPreconditioner.h:166
NoPreconditioner::par_
Parallel const * par_
Definition: NoPreconditioner.h:110
NoPreconditioner::bstates
virtual std::pair< int, int > bstates(Real E, int l1, int l2) const
Get the number of allowed bound states.
Definition: NoPreconditioner.cpp:392
NoPreconditioner::Fl_blocks_
std::vector< CooMatrix< LU_int_t, Complex > > Fl_blocks_
Definition: NoPreconditioner.h:149
NoPreconditioner::B2_blocks_
std::vector< std::vector< SymBandMatrix< Complex > > > B2_blocks_
Definition: NoPreconditioner.h:144
NoPreconditioner::Eb_
std::array< cArrays, 2 > Eb_
Definition: NoPreconditioner.h:169
NoPreconditioner::multiply
virtual void multiply(BlockArray< Complex > const &p, BlockArray< Complex > &q, MatrixSelection::Selection tri=MatrixSelection::Both) const
Multiply by the matrix equation.
Definition: NoPreconditioner.cpp:1233
PreconditionerBase
Preconditioner template.
Definition: preconditioners.h:62
NoPreconditioner::Hl_
std::array< std::vector< HlData >, 2 > Hl_
Definition: NoPreconditioner.h:172
NoPreconditioner::setup
virtual void setup()
Initialize the preconditioner.
Definition: NoPreconditioner.cpp:101
NoPreconditioner::Cl_blocks_
std::vector< CooMatrix< LU_int_t, Complex > > Cl_blocks_
Definition: NoPreconditioner.h:146
NoPreconditioner::E_
Real E_
Definition: NoPreconditioner.h:104
NoPreconditioner::Fu_blocks_
std::vector< CooMatrix< LU_int_t, Complex > > Fu_blocks_
Definition: NoPreconditioner.h:148
NoPreconditioner::inp_
InputFile const * inp_
Definition: NoPreconditioner.h:113