Psi4
local2.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef FISAPT_LOCAL2_H
29 #define FISAPT_LOCAL2_H
30 
31 #include <vector>
32 #include <memory>
33 
34 namespace psi {
35 
36 class Matrix;
37 class BasisSet;
38 
39 namespace fisapt {
40 
42 
43 protected:
44 
45  // => Overall Parameters <= //
46 
48  int print_;
50  int debug_;
52  int bench_;
53 
55  double convergence_;
57  int maxiter_;
58 
59  // => IAO Parameters <= //
60 
64  int power_;
66  double condition_;
67 
69  std::shared_ptr<Matrix> C_;
71  std::shared_ptr<BasisSet> primary_;
73  std::shared_ptr<BasisSet> minao_;
74 
75  // => Stars Parameters <= //
76 
78  bool use_stars_;
82  std::vector<int> stars_;
83 
84  // => IAO Data <= //
85 
87  std::vector<int> true_atoms_;
89  std::vector<int> true_iaos_;
91  std::vector<int> iaos_to_atoms_;
92 
94  std::shared_ptr<Matrix> S_;
96  std::shared_ptr<Matrix> A_;
97 
98 
100  void common_init();
101 
103  void build_iaos();
105  static std::map<std::string, std::shared_ptr<Matrix> > localize_task(
106  std::shared_ptr<Matrix> L, // Matrix of <i|m> [nocc x nmin]
107  const std::vector<std::vector<int> >& minao_inds, // List of minao indices per active center
108  const std::vector<std::pair<int, int> >& rot_inds, // List of allowed rotations (unique)
109  double convergence, // Convergence criterion
110  int maxiter, // Maximum number of iterations
111  int power // Localization metric power
112  );
114  static std::shared_ptr<Matrix> reorder_orbitals(
115  std::shared_ptr<Matrix> F,
116  const std::vector<int>& ranges);
118  std::shared_ptr<Matrix> orbital_charges(
119  std::shared_ptr<Matrix> L
120  );
121 
122 
123 public:
124 
125  // => Constructors <= //
126 
128  std::shared_ptr<BasisSet> primary,
129  std::shared_ptr<BasisSet> minao,
130  std::shared_ptr<Matrix> C);
131 
132  virtual ~IBOLocalizer2();
133 
135  static std::shared_ptr<IBOLocalizer2> build(
136  std::shared_ptr<BasisSet> primary,
137  std::shared_ptr<BasisSet> minao,
138  std::shared_ptr<Matrix> C,
139  Options& options);
140 
141  // => Computers <= //
142 
144  virtual void print_header() const;
145 
147  std::map<std::string, std::shared_ptr<Matrix> > localize(
148  std::shared_ptr<Matrix> Cocc, // Orbitals to localize [nbf x nmo], must live in C above
149  std::shared_ptr<Matrix> Focc, // Fock matrix of orbitals to localize [nmo x nmo]
150  const std::vector<int>& ranges = std::vector<int>() // [0, nfocc, nocc] will separately localize core and valence
151  );
153  void print_charges(double scale = 2.0);
154 
155  // => Knobs <= //
156 
157  void set_print(int print) { print_ = print; }
158  void set_debug(int debug) { debug_ = debug; }
159  void set_bench(int bench) { bench_ = bench; }
160  void set_convergence(double convergence) { convergence_ = convergence; }
161  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
162  void set_use_ghosts(bool use_ghosts) { use_ghosts_ = use_ghosts; }
163  void set_condition(double condition) { condition_ = condition; }
164  void set_power(double power) { power_ = power; }
165  void set_use_stars(bool use_stars) { use_stars_ = use_stars; }
166  void set_stars_completeness(double stars_completeness) { stars_completeness_ = stars_completeness; }
167  void set_stars(const std::vector<int>& stars) { stars_ = stars; }
168 
169 };
170 
171 } // Namespace fisapt
172 
173 } // Namespace psi
174 
175 #endif
std::shared_ptr< Matrix > S_
Overlap matrix in full basis.
Definition: local2.h:94
void build_iaos()
Build the IAOs.
Definition: local2.cc:117
std::vector< int > true_iaos_
Map from non-ghosted IAOs to full IAOs: true_iaos[ind_true] = ind_full.
Definition: local2.h:89
double convergence_
Relative convergence criteria.
Definition: local2.h:55
int debug_
Debug flug.
Definition: local2.h:50
void set_convergence(double convergence)
Definition: local2.h:160
std::vector< int > true_atoms_
Map from non-ghosted to full atoms: true_atoms[ind_true] = ind_full.
Definition: local2.h:87
std::shared_ptr< Matrix > C_
Occupied orbitals, in primary basis.
Definition: local2.h:69
static std::shared_ptr< Matrix > reorder_orbitals(std::shared_ptr< Matrix > F, const std::vector< int > &ranges)
Energy-ordered local orbital permutation [nmo(local) x nmo(ordered)].
Definition: local2.cc:342
virtual ~IBOLocalizer2()
Definition: local2.cc:58
void set_condition(double condition)
Definition: local2.h:163
void set_power(double power)
Definition: local2.h:164
void set_bench(int bench)
Definition: local2.h:159
std::shared_ptr< Matrix > A_
Non-ghosted IAOs in full basis.
Definition: local2.h:96
IBOLocalizer2(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > minao, std::shared_ptr< Matrix > C)
Definition: local2.cc:42
std::shared_ptr< BasisSet > minao_
MinAO orbital baiss set.
Definition: local2.h:73
static std::map< std::string, std::shared_ptr< Matrix > > localize_task(std::shared_ptr< Matrix > L, const std::vector< std::vector< int > > &minao_inds, const std::vector< std::pair< int, int > > &rot_inds, double convergence, int maxiter, int power)
Localization task (returns U and L)
Definition: local2.cc:236
std::shared_ptr< Matrix > orbital_charges(std::shared_ptr< Matrix > L)
Orbital atomic charges (natom x nmo)
Definition: local2.cc:543
void common_init()
Set defaults.
Definition: local2.cc:61
void set_stars_completeness(double stars_completeness)
Definition: local2.h:166
void set_use_stars(bool use_stars)
Definition: local2.h:165
void print_charges(double scale=2.0)
Print the charges.
Definition: local2.cc:562
Definition: liboptions.h:359
int bench_
Bench flag.
Definition: local2.h:52
int print_
Print flag.
Definition: local2.h:48
static std::shared_ptr< IBOLocalizer2 > build(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > minao, std::shared_ptr< Matrix > C, Options &options)
Build IBO with defaults from Options object (including MINAO_BASIS)
Definition: local2.cc:75
int power_
IAO localization power (4 or 2)
Definition: local2.h:64
PsiReturnType fisapt(SharedWavefunction, Options &)
Definition: fisapt/wrapper.cc:39
std::vector< int > iaos_to_atoms_
Map from non-ghosted IAOs to non-ghosted atoms.
Definition: local2.h:91
double condition_
Metric condition for IAO.
Definition: local2.h:66
std::shared_ptr< BasisSet > primary_
Primary orbital basis set.
Definition: local2.h:71
void set_maxiter(int maxiter)
Definition: local2.h:161
std::vector< int > stars_
List of centers for stars.
Definition: local2.h:82
std::map< std::string, std::shared_ptr< Matrix > > localize(std::shared_ptr< Matrix > Cocc, std::shared_ptr< Matrix > Focc, const std::vector< int > &ranges=std::vector< int >())
Localize the orbitals, returns the matrices L [nbf x nmo], U [nmo(dlocal) x nmo(local)], and F [nmo x nmo].
Definition: local2.cc:367
double stars_completeness_
Charge completeness for two-center orbitals.
Definition: local2.h:80
bool use_ghosts_
Use ghost IAOs?
Definition: local2.h:62
Definition: local2.h:41
void set_debug(int debug)
Definition: local2.h:158
virtual void print_header() const
Print out the localization algorithm and parameters.
Definition: local2.cc:104
bool use_stars_
Do stars treatment?
Definition: local2.h:78
void set_use_ghosts(bool use_ghosts)
Definition: local2.h:162
void set_print(int print)
Definition: local2.h:157
void set_stars(const std::vector< int > &stars)
Definition: local2.h:167
int maxiter_
Maximum number of iterations.
Definition: local2.h:57