ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
bader.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * DFT from Hel
7  *
8  * Written by Susi Lehtola, 2013
9  * Copyright (c) 2013, Susi Lehtola
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  */
16 
17 #ifndef ERKALE_BADER
18 #define ERKALE_BADER
19 
20 #include "global.h"
21 #include "basis.h"
22 
24 typedef struct {
26  size_t ix;
28  size_t iy;
30  size_t iz;
31 } baderpoint_t;
32 
34 typedef struct {
36  arma::ivec start;
38  arma::ivec end;
40 
50 class Bader {
52  std::vector<nucleus_t> nuclei;
54  arma::mat nucc;
55 
57  arma::cube dens;
59  arma::icube region;
61  arma::sword Nregions;
63  arma::ivec array_size;
64 
66  arma::vec start;
68  arma::vec spacing;
69 
71  bool verbose;
72 
74  void check_regions(std::string msg="") const;
75 
77  std::vector<grid_partition_t> partitioning(double l=1.0) const;
78 
80  bool in_cube(const arma::ivec & p) const;
82  bool on_edge(const arma::ivec & p) const;
83 
85  bool neighbors_assigned(const arma::ivec & p) const;
87  bool local_maximum(const arma::ivec & p) const;
89  double check_maximum(const arma::ivec & p) const;
91  bool on_boundary(const arma::ivec & p) const;
92 
94  arma::vec gradient(const arma::ivec & p) const;
95 
98  std::vector<arma::ivec> classify_ongrid(arma::ivec p) const;
101  std::vector<arma::ivec> classify_neargrid(arma::ivec p) const;
102 
104  void reorder();
105 
107  void print_neighbors(const arma::ivec & p) const;
108 
110  void analysis_neargrid();
112  void analysis_ongrid();
113 
114  public:
116  Bader(bool verbose=true);
118  ~Bader();
119 
121  void analyse(const BasisSet & basis, const arma::mat & P, bool neargrid=true, double spacing=0.035, double padding=7.5);
122 
124  arma::ivec nuclear_regions() const;
125 
127  arma::vec regional_charges() const;
129  arma::vec nuclear_charges() const;
130 
132  void print_density(double spacing=0.1) const;
134  void print_regions(double spacing=0.1) const;
136  void print_individual_regions(double spacing=0.1) const;
137 
139  arma::vec regional_charges(const BasisSet & basis, const arma::mat & P) const;
141  arma::vec nuclear_charges(const BasisSet & basis, const arma::mat & P) const;
142 
144  std::vector<arma::mat> regional_overlap(const BasisSet & basis) const;
145 };
146 
147 #endif
bool neighbors_assigned(const arma::ivec &p) const
Are the neighbors of the point assigned? nnei gives the maximum displacement to look at...
Definition: bader.cpp:277
arma::vec start
Starting point of grid.
Definition: bader.h:66
arma::sword Nregions
Amount of Bader regions.
Definition: bader.h:61
void analyse(const BasisSet &basis, const arma::mat &P, bool neargrid=true, double spacing=0.035, double padding=7.5)
Fill the grid and run the analysis.
Definition: bader.cpp:41
Definition: bader.h:50
size_t ix
x index
Definition: bader.h:26
arma::icube region
Which Bader region the points belong to.
Definition: bader.h:59
Bader(bool verbose=true)
Constructor.
Definition: bader.cpp:33
bool verbose
Verbose operation?
Definition: bader.h:71
std::vector< arma::ivec > classify_neargrid(arma::ivec p) const
Definition: bader.cpp:452
arma::vec spacing
Grid spacing.
Definition: bader.h:68
bool on_boundary(const arma::ivec &p) const
Is the point on a Bader region boundary?
Definition: bader.cpp:398
std::vector< arma::ivec > classify_ongrid(arma::ivec p) const
Definition: bader.cpp:532
Helper for grid parallellization and basis function calculation.
Definition: bader.h:34
~Bader()
Destructor.
Definition: bader.cpp:38
arma::ivec nuclear_regions() const
Determine nuclear regions.
Definition: bader.cpp:982
void reorder()
Reorder regions to nuclear order.
Definition: bader.cpp:1021
bool on_edge(const arma::ivec &p) const
Is the point on an edge of the cube?
Definition: bader.cpp:206
arma::cube dens
Density array.
Definition: bader.h:57
void analysis_neargrid()
Perform Bader analysis with the near-grid method.
Definition: bader.cpp:596
bool local_maximum(const arma::ivec &p) const
Is the point a local maximum.
Definition: bader.cpp:394
std::vector< nucleus_t > nuclei
List of nuclei.
Definition: bader.h:52
bool in_cube(const arma::ivec &p) const
Check that point is in the cube.
Definition: bader.cpp:195
Helper for tracking points in current path.
Definition: bader.h:24
arma::vec regional_charges() const
Get charges in the Bader regions.
Definition: bader.cpp:1067
Basis set.
Definition: basis.h:187
arma::vec gradient(const arma::ivec &p) const
Compute gradient.
Definition: bader.cpp:406
size_t iz
z index
Definition: bader.h:30
void print_neighbors(const arma::ivec &p) const
Print neighbors of point.
Definition: bader.cpp:428
double check_maximum(const arma::ivec &p) const
Check the strength of the maximum.
Definition: bader.cpp:341
arma::mat nucc
List of nuclear coordinates.
Definition: bader.h:54
std::vector< arma::mat > regional_overlap(const BasisSet &basis) const
Compute Bader regional overlap matrices.
Definition: bader.cpp:1401
arma::ivec start
Minimum index values.
Definition: bader.h:36
arma::vec nuclear_charges() const
Get nuclear charges.
Definition: bader.cpp:1103
void print_regions(double spacing=0.1) const
Write out Bader regions.
Definition: bader.cpp:1178
void check_regions(std::string msg="") const
Check that all points have been classified.
Definition: bader.cpp:217
arma::ivec end
Maximum index values.
Definition: bader.h:38
void print_individual_regions(double spacing=0.1) const
Write out individual Bader regions.
Definition: bader.cpp:1250
std::vector< grid_partition_t > partitioning(double l=1.0) const
Partition grid into boxes with edge length l.
Definition: bader.cpp:238
void analysis_ongrid()
Perform Bader analysis with the on-grid method.
Definition: bader.cpp:885
void print_density(double spacing=0.1) const
Write out electron density.
Definition: bader.cpp:1115
arma::ivec array_size
Array size.
Definition: bader.h:63
size_t iy
y index
Definition: bader.h:28