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-2018 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  protected:
46  // => Overall Parameters <= //
47 
49  int print_;
51  int debug_;
53  int bench_;
54 
56  double convergence_;
58  int maxiter_;
59 
60  // => IAO Parameters <= //
61 
65  int power_;
67  double condition_;
68 
70  std::shared_ptr<Matrix> C_;
72  std::shared_ptr<BasisSet> primary_;
74  std::shared_ptr<BasisSet> minao_;
75 
76  // => Stars Parameters <= //
77 
79  bool use_stars_;
83  std::vector<int> stars_;
84 
85  // => IAO Data <= //
86 
88  std::vector<int> true_atoms_;
90  std::vector<int> true_iaos_;
92  std::vector<int> iaos_to_atoms_;
93 
95  std::shared_ptr<Matrix> S_;
97  std::shared_ptr<Matrix> A_;
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(std::shared_ptr<Matrix> F, const std::vector<int>& ranges);
116  std::shared_ptr<Matrix> orbital_charges(std::shared_ptr<Matrix> L);
117 
118  public:
119  // => Constructors <= //
120 
121  IBOLocalizer2(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> minao, std::shared_ptr<Matrix> C);
122 
123  virtual ~IBOLocalizer2();
124 
126  static std::shared_ptr<IBOLocalizer2> build(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> minao,
127  std::shared_ptr<Matrix> C, Options& options);
128 
129  // => Computers <= //
130 
132  virtual void print_header() const;
133 
135  std::map<std::string, std::shared_ptr<Matrix> > localize(
136  std::shared_ptr<Matrix> Cocc, // Orbitals to localize [nbf x nmo], must live in C above
137  std::shared_ptr<Matrix> Focc, // Fock matrix of orbitals to localize [nmo x nmo]
138  const std::vector<int>& ranges =
139  std::vector<int>() // [0, nfocc, nocc] will separately localize core and valence
140  );
142  void print_charges(double scale = 2.0);
143 
144  // => Knobs <= //
145 
146  void set_print(int print) { print_ = print; }
147  void set_debug(int debug) { debug_ = debug; }
148  void set_bench(int bench) { bench_ = bench; }
149  void set_convergence(double convergence) { convergence_ = convergence; }
150  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
151  void set_use_ghosts(bool use_ghosts) { use_ghosts_ = use_ghosts; }
152  void set_condition(double condition) { condition_ = condition; }
153  void set_power(double power) { power_ = power; }
154  void set_use_stars(bool use_stars) { use_stars_ = use_stars; }
155  void set_stars_completeness(double stars_completeness) { stars_completeness_ = stars_completeness; }
156  void set_stars(const std::vector<int>& stars) { stars_ = stars; }
157 };
158 
159 } // Namespace fisapt
160 
161 } // Namespace psi
162 
163 #endif
std::shared_ptr< Matrix > S_
Overlap matrix in full basis.
Definition: local2.h:95
void build_iaos()
Build the IAOs.
Definition: local2.cc:108
std::vector< int > true_iaos_
Map from non-ghosted IAOs to full IAOs: true_iaos[ind_true] = ind_full.
Definition: local2.h:90
double convergence_
Relative convergence criteria.
Definition: local2.h:56
int debug_
Debug flug.
Definition: local2.h:51
void set_convergence(double convergence)
Definition: local2.h:149
std::vector< int > true_atoms_
Map from non-ghosted to full atoms: true_atoms[ind_true] = ind_full.
Definition: local2.h:88
std::shared_ptr< Matrix > C_
Occupied orbitals, in primary basis.
Definition: local2.h:70
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:323
virtual ~IBOLocalizer2()
Definition: local2.cc:57
void set_condition(double condition)
Definition: local2.h:152
void set_power(double power)
Definition: local2.h:153
void set_bench(int bench)
Definition: local2.h:148
std::shared_ptr< Matrix > A_
Non-ghosted IAOs in full basis.
Definition: local2.h:97
IBOLocalizer2(std::shared_ptr< BasisSet > primary, std::shared_ptr< BasisSet > minao, std::shared_ptr< Matrix > C)
Definition: local2.cc:46
std::shared_ptr< BasisSet > minao_
MinAO orbital baiss set.
Definition: local2.h:74
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:225
std::shared_ptr< Matrix > orbital_charges(std::shared_ptr< Matrix > L)
Orbital atomic charges (natom x nmo)
Definition: local2.cc:521
void common_init()
Set defaults.
Definition: local2.cc:58
void set_stars_completeness(double stars_completeness)
Definition: local2.h:155
void set_use_stars(bool use_stars)
Definition: local2.h:154
void print_charges(double scale=2.0)
Print the charges.
Definition: local2.cc:538
Definition: liboptions.h:353
int bench_
Bench flag.
Definition: local2.h:53
int print_
Print flag.
Definition: local2.h:49
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:71
int power_
IAO localization power (4 or 2)
Definition: local2.h:65
std::vector< int > iaos_to_atoms_
Map from non-ghosted IAOs to non-ghosted atoms.
Definition: local2.h:92
double condition_
Metric condition for IAO.
Definition: local2.h:67
std::shared_ptr< BasisSet > primary_
Primary orbital basis set.
Definition: local2.h:72
void set_maxiter(int maxiter)
Definition: local2.h:150
std::vector< int > stars_
List of centers for stars.
Definition: local2.h:83
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:345
double stars_completeness_
Charge completeness for two-center orbitals.
Definition: local2.h:81
bool use_ghosts_
Use ghost IAOs?
Definition: local2.h:63
Definition: local2.h:44
void set_debug(int debug)
Definition: local2.h:147
virtual void print_header() const
Print out the localization algorithm and parameters.
Definition: local2.cc:96
bool use_stars_
Do stars treatment?
Definition: local2.h:79
void set_use_ghosts(bool use_ghosts)
Definition: local2.h:151
void set_print(int print)
Definition: local2.h:146
void set_stars(const std::vector< int > &stars)
Definition: local2.h:156
int maxiter_
Maximum number of iterations.
Definition: local2.h:58