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 
56 {
57  public:
58 
59  // run-time selection mechanism
61 
62  // default constructor required by RTS system
64 
65  // constructor
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
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
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
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
RadialIntegrals const & rad_inner() const
Definition: NoPreconditioner.h:97
Class that calculates and manages the radial integrals for given B-spline bases.
Definition: radial.h:89
CommandLine const * cmd_
Definition: NoPreconditioner.h:107
RadialIntegrals * rad_inner_
Definition: NoPreconditioner.h:158
std::shared_ptr< LUft > luS_
Definition: NoPreconditioner.h:175
BlockSymBandMatrix< Complex > calc_A_block(int ill, int illp, bool twoel=true) const
Definition: NoPreconditioner.cpp:421
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: NoPreconditioner.cpp:1510
std::array< Array< cArrays >, 2 > Xp_
Definition: NoPreconditioner.h:166
std::vector< BlockSymBandMatrix< Complex > > E_blocks_
Definition: NoPreconditioner.h:147
std::vector< CooMatrix< LU_int_t, Complex > > Cu_blocks_
Definition: NoPreconditioner.h:145
int max_n_
Definition: NoPreconditioner.h:152
Solution driver without actual preconditioner.
Definition: NoPreconditioner.h:55
B-spline environment.
Definition: bspline.h:57
Angular basis.
Definition: ang.h:44
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: NoPreconditioner.cpp:498
RadialIntegrals * rad_panel_
Definition: NoPreconditioner.h:158
~NoPreconditioner()
Definition: NoPreconditioner.cpp:89
Command line parameters.
Definition: io.h:57
preconditionerRunTimeSelectionDefinitions(NoPreconditioner, "none") NoPreconditioner()
RadialIntegrals * rad_full_
Definition: NoPreconditioner.h:158
RadialIntegrals const & rad_panel() const
Definition: NoPreconditioner.h:99
virtual void finish()
Clean up memory etc.
Definition: NoPreconditioner.cpp:1515
virtual void rhs(BlockArray< Complex > &chi, int ienergy, int instate) const
Calculate the right-hand side.
Definition: NoPreconditioner.cpp:821
virtual std::string description() const
Description of the preconditioner.
Definition: NoPreconditioner.cpp:96
std::vector< BlockSymBandMatrix< Complex > > A_blocks_
Definition: NoPreconditioner.h:142
std::vector< std::pair< int, int > > Nchan_
Definition: NoPreconditioner.h:155
Input parameters.
Definition: io.h:321
MPI info.
Definition: parallel.h:50
AngularBasis const * ang_
Definition: NoPreconditioner.h:116
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
std::vector< std::vector< SymBandMatrix< Complex > > > B1_blocks_
Definition: NoPreconditioner.h:143
RadialIntegrals const & rad_full() const
Definition: NoPreconditioner.h:98
std::array< Array< cArrays >, 2 > Sp_
Definition: NoPreconditioner.h:166
Parallel const * par_
Definition: NoPreconditioner.h:110
virtual std::pair< int, int > bstates(Real E, int l1, int l2) const
Get the number of allowed bound states.
Definition: NoPreconditioner.cpp:392
std::vector< CooMatrix< LU_int_t, Complex > > Fl_blocks_
Definition: NoPreconditioner.h:149
std::vector< std::vector< SymBandMatrix< Complex > > > B2_blocks_
Definition: NoPreconditioner.h:144
std::array< cArrays, 2 > Eb_
Definition: NoPreconditioner.h:169
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
Preconditioner template.
Definition: preconditioners.h:62
std::array< std::vector< HlData >, 2 > Hl_
Definition: NoPreconditioner.h:172
virtual void setup()
Initialize the preconditioner.
Definition: NoPreconditioner.cpp:101
std::vector< CooMatrix< LU_int_t, Complex > > Cl_blocks_
Definition: NoPreconditioner.h:146
Real E_
Definition: NoPreconditioner.h:104
std::vector< CooMatrix< LU_int_t, Complex > > Fu_blocks_
Definition: NoPreconditioner.h:148
InputFile const * inp_
Definition: NoPreconditioner.h:113