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 file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef FISAPT_LOCAL2_H
30 #define FISAPT_LOCAL2_H
31 
32 #include <vector>
33 #include <map>
34 #include <memory>
35 
36 namespace psi {
37 
38 class Matrix;
39 class BasisSet;
40 class Options;
41 
42 namespace fisapt {
43 
45 
46 protected:
47 
48  // => Overall Parameters <= //
49 
51  int print_;
53  int debug_;
55  int bench_;
56 
58  double convergence_;
60  int maxiter_;
61 
62  // => IAO Parameters <= //
63 
67  int power_;
69  double condition_;
70 
72  std::shared_ptr<Matrix> C_;
74  std::shared_ptr<BasisSet> primary_;
76  std::shared_ptr<BasisSet> minao_;
77 
78  // => Stars Parameters <= //
79 
81  bool use_stars_;
85  std::vector<int> stars_;
86 
87  // => IAO Data <= //
88 
90  std::vector<int> true_atoms_;
92  std::vector<int> true_iaos_;
94  std::vector<int> iaos_to_atoms_;
95 
97  std::shared_ptr<Matrix> S_;
99  std::shared_ptr<Matrix> A_;
100 
101 
103  void common_init();
104 
106  void build_iaos();
108  static std::map<std::string, std::shared_ptr<Matrix> > localize_task(
109  std::shared_ptr<Matrix> L, // Matrix of <i|m> [nocc x nmin]
110  const std::vector<std::vector<int> >& minao_inds, // List of minao indices per active center
111  const std::vector<std::pair<int, int> >& rot_inds, // List of allowed rotations (unique)
112  double convergence, // Convergence criterion
113  int maxiter, // Maximum number of iterations
114  int power // Localization metric power
115  );
117  static std::shared_ptr<Matrix> reorder_orbitals(
118  std::shared_ptr<Matrix> F,
119  const std::vector<int>& ranges);
121  std::shared_ptr<Matrix> orbital_charges(
122  std::shared_ptr<Matrix> L
123  );
124 
125 
126 public:
127 
128  // => Constructors <= //
129 
131  std::shared_ptr<BasisSet> primary,
132  std::shared_ptr<BasisSet> minao,
133  std::shared_ptr<Matrix> C);
134 
135  virtual ~IBOLocalizer2();
136 
138  static std::shared_ptr<IBOLocalizer2> build(
139  std::shared_ptr<BasisSet> primary,
140  std::shared_ptr<BasisSet> minao,
141  std::shared_ptr<Matrix> C,
142  Options& options);
143 
144  // => Computers <= //
145 
147  virtual void print_header() const;
148 
150  std::map<std::string, std::shared_ptr<Matrix> > localize(
151  std::shared_ptr<Matrix> Cocc, // Orbitals to localize [nbf x nmo], must live in C above
152  std::shared_ptr<Matrix> Focc, // Fock matrix of orbitals to localize [nmo x nmo]
153  const std::vector<int>& ranges = std::vector<int>() // [0, nfocc, nocc] will separately localize core and valence
154  );
156  void print_charges(double scale = 2.0);
157 
158  // => Knobs <= //
159 
160  void set_print(int print) { print_ = print; }
161  void set_debug(int debug) { debug_ = debug; }
162  void set_bench(int bench) { bench_ = bench; }
163  void set_convergence(double convergence) { convergence_ = convergence; }
164  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
165  void set_use_ghosts(bool use_ghosts) { use_ghosts_ = use_ghosts; }
166  void set_condition(double condition) { condition_ = condition; }
167  void set_power(double power) { power_ = power; }
168  void set_use_stars(bool use_stars) { use_stars_ = use_stars; }
169  void set_stars_completeness(double stars_completeness) { stars_completeness_ = stars_completeness; }
170  void set_stars(const std::vector<int>& stars) { stars_ = stars; }
171 
172 };
173 
174 } // Namespace fisapt
175 
176 } // Namespace psi
177 
178 #endif
std::shared_ptr< Matrix > S_
Overlap matrix in full basis.
Definition: local2.h:97
void build_iaos()
Build the IAOs.
Definition: local2.cc:119
std::vector< int > true_iaos_
Map from non-ghosted IAOs to full IAOs: true_iaos[ind_true] = ind_full.
Definition: local2.h:92
double convergence_
Relative convergence criteria.
Definition: local2.h:58
int debug_
Debug flug.
Definition: local2.h:53
void set_convergence(double convergence)
Definition: local2.h:163
std::vector< int > true_atoms_
Map from non-ghosted to full atoms: true_atoms[ind_true] = ind_full.
Definition: local2.h:90
std::shared_ptr< Matrix > C_
Occupied orbitals, in primary basis.
Definition: local2.h:72
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:344
virtual ~IBOLocalizer2()
Definition: local2.cc:60
void set_condition(double condition)
Definition: local2.h:166
void set_power(double power)
Definition: local2.h:167
void set_bench(int bench)
Definition: local2.h:162
std::shared_ptr< Matrix > A_
Non-ghosted IAOs in full basis.
Definition: local2.h:99
IBOLocalizer2(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > minao, std::shared_ptr< Matrix > C)
Definition: local2.cc:44
std::shared_ptr< BasisSet > minao_
MinAO orbital baiss set.
Definition: local2.h:76
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:238
std::shared_ptr< Matrix > orbital_charges(std::shared_ptr< Matrix > L)
Orbital atomic charges (natom x nmo)
Definition: local2.cc:545
void common_init()
Set defaults.
Definition: local2.cc:63
void set_stars_completeness(double stars_completeness)
Definition: local2.h:169
void set_use_stars(bool use_stars)
Definition: local2.h:168
PsiReturnType fisapt(SharedWavefunction ref_wfn, Options &options)
Definition: fisapt/wrapper.cc:40
void print_charges(double scale=2.0)
Print the charges.
Definition: local2.cc:564
Definition: liboptions.h:355
int bench_
Bench flag.
Definition: local2.h:55
int print_
Print flag.
Definition: local2.h:51
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:77
int power_
IAO localization power (4 or 2)
Definition: local2.h:67
std::vector< int > iaos_to_atoms_
Map from non-ghosted IAOs to non-ghosted atoms.
Definition: local2.h:94
double condition_
Metric condition for IAO.
Definition: local2.h:69
std::shared_ptr< BasisSet > primary_
Primary orbital basis set.
Definition: local2.h:74
void set_maxiter(int maxiter)
Definition: local2.h:164
std::vector< int > stars_
List of centers for stars.
Definition: local2.h:85
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:369
double stars_completeness_
Charge completeness for two-center orbitals.
Definition: local2.h:83
bool use_ghosts_
Use ghost IAOs?
Definition: local2.h:65
Definition: local2.h:44
void set_debug(int debug)
Definition: local2.h:161
virtual void print_header() const
Print out the localization algorithm and parameters.
Definition: local2.cc:106
bool use_stars_
Do stars treatment?
Definition: local2.h:81
void set_use_ghosts(bool use_ghosts)
Definition: local2.h:165
void set_print(int print)
Definition: local2.h:160
void set_stars(const std::vector< int > &stars)
Definition: local2.h:170
int maxiter_
Maximum number of iterations.
Definition: local2.h:60