ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
dftgrid.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, 2011
9  * Copyright (c) 2011, 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 
18 #ifndef ERKALE_DFTGRID
19 #define ERKALE_DFTGRID
20 
21 #include "global.h"
22 #include "basis.h"
23 class Hirshfeld;
24 
27 #define PRUNETHR 1e-8
28 
32 typedef struct {
34  size_t ind;
36  double f;
37 } bf_f_t;
38 
42 typedef struct {
46  double w;
47 
49  size_t f0;
51  size_t nf;
52 } gridpoint_t;
53 
55 typedef struct {
57  size_t atind;
60 
62  double R;
64  double w;
66  int l;
68  double tol;
69 
71  size_t np;
73  size_t nfunc;
74 } angshell_t;
75 
77 typedef struct {
79  double d;
81  double w;
82 } dens_list_t;
83 
85 bool operator<(const dens_list_t & lhs, const dens_list_t & rhs);
86 
88 typedef struct {
90  double rhoa, rhob;
92  double sigmaaa, sigmaab, sigmabb;
94  double lapla, laplb;
96  double taua, taub;
97 } libxc_dens_t;
98 
100 typedef struct {
102  double vrhoa, vrhob;
104  double vsigmaaa, vsigmaab, vsigmabb;
106  double vlapla, vlaplb;
108  double vtaua, vtaub;
109 } libxc_pot_t;
110 
112 typedef struct {
113  libxc_dens_t dens;
114  libxc_pot_t pot;
115 } libxc_debug_t;
116 
164 class AngularGrid {
165  protected:
169  const BasisSet *basp;
172 
174  std::vector<gridpoint_t> grid;
175 
177  std::vector<size_t> pot_shells;
179  arma::uvec pot_bf_ind;
180 
182  std::vector<size_t> shells;
184  arma::uvec bf_i0;
186  arma::uvec bf_N;
187 
189  arma::uvec bf_ind;
191  arma::uvec bf_potind;
192 
194  arma::rowvec w;
196  arma::mat bf;
198  arma::mat bf_x;
200  arma::mat bf_y;
202  arma::mat bf_z;
204  arma::mat bf_lapl;
205 
207  arma::mat bf_hess;
209  arma::mat bf_lx;
211  arma::mat bf_ly;
213  arma::mat bf_lz;
214 
215 
217  arma::mat Pv, Pv_x, Pv_y, Pv_z;
219  arma::mat Pav, Pav_x, Pav_y, Pav_z;
220  arma::mat Pbv, Pbv_x, Pbv_y, Pbv_z;
221 
223  bool do_grad;
225  bool do_lapl;
227  bool do_hess;
229  bool do_lgrad;
230 
232  bool polarized;
233 
235  bool do_gga;
237  bool do_mgga;
238 
239  // LDA stuff:
240 
242  arma::mat rho;
244  arma::vec exc;
246  arma::mat vxc;
247 
248  // GGA stuff
249 
251  arma::mat grho;
253  arma::mat sigma;
255  arma::mat vsigma;
256 
257  // Meta-GGA stuff
258 
260  arma::mat lapl;
262  arma::mat tau;
263 
265  arma::mat vlapl;
267  arma::mat vtau;
268 
269  // VV10 stuff
271  double VV10_thr;
273  arma::mat VV10_arr;
274 
276  libxc_dens_t get_dens(size_t idx) const;
278  libxc_pot_t get_pot(size_t idx) const;
280  libxc_debug_t get_data(size_t idx) const;
281 
283  void lobatto_shell();
285  void lebedev_shell();
287  void update_shell_list();
289  void get_weights();
290 
291  public:
295  AngularGrid(bool lobatto=false);
297  ~AngularGrid();
298 
300  void set_basis(const BasisSet & basis);
302  void set_grid(const angshell_t & shell);
303 
305  std::vector<gridpoint_t> get_grid() const;
306 
308  void check_grad_lapl(int x_func, int c_func);
310  void get_grad_lapl(bool & grad, bool & lapl) const;
312  void set_grad_lapl(bool grad, bool lapl);
314  void set_hess_lgrad(bool hess, bool lgrad);
315 
319  angshell_t construct(const arma::mat & P, double ftol, int x_func, int c_func);
321  angshell_t construct(const arma::mat & Pa, const arma::mat & Pb, double ftol, int x_func, int c_func);
323  angshell_t construct(const arma::cx_vec & C, double ftol, int x_func, int c_func);
324 
326  angshell_t construct_becke(double otol);
328  angshell_t construct_hirshfeld(const Hirshfeld & Hirsh, double otol);
329 
331  void form_grid();
333  void form_hirshfeld_grid(const Hirshfeld & hirsh);
334 
346  void becke_weights(double a=0.7);
348  void hirshfeld_weights(const Hirshfeld & hirsh);
349 
351  void prune_points();
353  void compute_bf();
355  void free();
356 
358  arma::uvec screen_density(double thr=1e-10) const;
359 
361  void update_density(const arma::mat & P);
363  void update_density(const arma::mat & Pa, const arma::mat & Pb);
365  void update_density(const arma::cx_vec & C);
366 
368  void get_density(std::vector<dens_list_t> & list) const;
369 
371  double compute_Nel() const;
372 
374  void print_grid() const;
376  void print_density(FILE *f) const;
378  void print_potential(int func_id, FILE *f) const;
379 
381  void init_xc();
384  void compute_xc(int func_id, bool pot);
386  double eval_Exc() const;
387 
389  void init_VV10(double b, double C, bool pot);
391  void collect_VV10(arma::mat & data, std::vector<size_t> & idx, double b, double C, bool nl) const;
392 
400  void compute_VV10(const std::vector<arma::mat> & nldata, double b, double C);
402  arma::vec compute_VV10_F(const std::vector<arma::mat> & nldata, const std::vector<angshell_t> & nlgrids, double b, double C);
403 
405  void eval_overlap(arma::mat & S) const;
407  void eval_diag_overlap(arma::vec & S) const;
408 
417  void eval_overlap(const arma::cx_mat & Cocc, size_t io, double k, arma::mat & S, double thr) const;
418 
420  void eval_overlap(const arma::cx_mat & Cocc, const arma::vec & Esi, double k, arma::mat & S, double thr) const;
421 
431  void eval_tau_overlap(const arma::cx_mat & Cocc, double k, arma::mat & S, double thr) const;
432 
434  void eval_tau_overlap_deriv(const arma::cx_mat & Cocc, const arma::vec & Esi, double k, arma::mat & S, double thr) const;
435 
437  void eval_Fxc(arma::mat & H) const;
439  void eval_Fxc(arma::mat & Ha, arma::mat & Hb, bool beta=true) const;
440 
442  void eval_diag_Fxc(arma::vec & H) const;
444  void eval_diag_Fxc(arma::vec & Ha, arma::vec & Hb) const;
446  void eval_diag_Fxc_SIC(arma::vec & H) const;
447 
449  arma::vec eval_force_r() const;
451  arma::vec eval_force_u() const;
452 };
453 
475 class DFTGrid {
477  std::vector<AngularGrid> wrk;
479  std::vector<angshell_t> grids;
481  const BasisSet * basp;
483  bool verbose;
484 
486  void prune_shells();
487 
488  public:
490  DFTGrid();
492  DFTGrid(const BasisSet * bas, bool verbose=true, bool lobatto=false);
494  ~DFTGrid();
495 
497  void set_verbose(bool ver);
498 
500  void construct(int nrad, int lmax, int x_func, int c_func, bool strict);
502  void construct(int nrad, int lmax, bool gga, bool mgga, bool strict, bool nl);
504  void construct(const arma::mat & P, double ftol, int x_func, int c_func);
506  void construct(const arma::mat & Pa, const arma::mat & Pb, double ftol, int x_func, int c_func);
508  void construct(const arma::cx_mat & C, double ftol, int x_func, int c_func);
509 
511  void construct_becke(double stol);
513  void construct_hirshfeld(const Hirshfeld & hirsh, double stol);
514 
516  size_t get_Npoints() const;
518  size_t get_Nfuncs() const;
519 
521  double compute_Nel(const arma::mat & P);
523  double compute_Nel(const arma::mat & Pa, const arma::mat & Pb);
524 
526  arma::vec compute_atomic_Nel(const arma::mat & P);
528  arma::vec compute_atomic_Nel(const Hirshfeld & hirsh, const arma::mat & P);
529 
531  void eval_Fxc(int x_func, int c_func, const arma::mat & P, arma::mat & H, double & Exc, double & Nel);
533  void eval_Fxc(int x_func, int c_func, const arma::mat & Pa, const arma::mat & Pb, arma::mat & Ha, arma::mat & Hb, double & Exc, double & Nel);
534 
539  void eval_Fxc(int x_func, int c_func, const arma::cx_mat & C, std::vector<arma::mat> & H, std::vector<double> & Exc, std::vector<double> & Nel, bool fock);
540 
542  void eval_VV10(DFTGrid & nlgrid, double b, double C, const arma::mat & P, arma::mat & H, double & Exc, bool fock=true);
543 
545  arma::mat eval_overlap();
547  arma::mat eval_overlap(size_t inuc);
549  std::vector<arma::mat> eval_overlaps();
550 
552  arma::mat eval_overlap(const arma::cx_mat & Cocc, size_t io, double k, double thr=1e-10);
554  arma::mat eval_overlap(const arma::cx_mat & Cocc, const arma::vec & Esi, double k, double thr=1e-10);
556  arma::mat eval_tau_overlap(const arma::cx_mat & Cocc, double k, double thr=1e-10);
558  arma::mat eval_tau_overlap_deriv(const arma::cx_mat & Cocc, const arma::vec & Esi, double k, double thr=1e-10);
559 
561  arma::mat eval_hirshfeld_overlap(const Hirshfeld & hirsh, size_t inuc);
563  std::vector<arma::mat> eval_hirshfeld_overlaps(const Hirshfeld & hirsh);
564 
566  std::vector<dens_list_t> eval_dens_list(const arma::mat & P);
567 
569  arma::vec eval_force(int x_func, int c_func, const arma::mat & P);
571  arma::vec eval_force(int x_func, int c_func, const arma::mat & Pa, const arma::mat & Pb);
573  arma::vec eval_VV10_force(DFTGrid & nlgrid, double b, double C, const arma::mat & P);
574 
576  void print_grid(std::string met="XC") const;
577 
579  void print_density(const arma::mat & P, std::string densname="density.dat");
581  void print_potential(int func_id, const arma::mat & Pa, const arma::mat & Pb, std::string potname="potential.dat");
582 };
583 
585 template<typename T> void increment_lda(arma::Mat<T> & H, const arma::rowvec & vxc, const arma::Mat<T> & f) {
586  if(f.n_cols != vxc.n_elem) {
587  ERROR_INFO();
588  std::ostringstream oss;
589  oss << "Number of functions " << f.n_cols << " and potential values " << vxc.n_elem << " do not match!\n";
590  throw std::runtime_error(oss.str());
591  }
592  if(H.n_rows != f.n_rows || H.n_cols != f.n_rows) {
593  ERROR_INFO();
594  std::ostringstream oss;
595  oss << "Size of basis function (" << f.n_rows << "," << f.n_cols << ") and Fock matrix (" << H.n_rows << "," << H.n_cols << ") doesn't match!\n";
596  throw std::runtime_error(oss.str());
597  }
598 
599  // Form helper matrix
600  arma::Mat<T> fhlp(f);
601  for(size_t i=0;i<fhlp.n_rows;i++)
602  for(size_t j=0;j<fhlp.n_cols;j++)
603  fhlp(i,j)*=vxc(j);
604  H+=fhlp*arma::trans(f);
605 }
606 
608 template<typename T> void increment_lda(arma::Mat<T> & H, const arma::rowvec & vxc, const arma::Mat<T> & f, const arma::uvec & screen) {
609  if(f.n_cols != vxc.n_elem) {
610  ERROR_INFO();
611  throw std::runtime_error("Sizes of matrices doesn't match!\n");
612  }
613  if(H.n_rows != f.n_rows || H.n_cols != f.n_rows) {
614  ERROR_INFO();
615  throw std::runtime_error("Sizes of basis function and Fock matrices doesn't match!\n");
616  }
617 
618  // Form helper matrix
619  arma::Mat<T> fhlp(f);
620  for(size_t i=0;i<fhlp.n_rows;i++)
621  for(size_t j=0;j<fhlp.n_cols;j++)
622  fhlp(i,j)*=vxc(j);
623  H+=fhlp.cols(screen)*arma::trans(f.cols(screen));
624 }
625 
627 template<typename T> void increment_gga(arma::Mat<T> & H, const arma::mat & gn, const arma::Mat<T> & f, arma::Mat<T> f_x, arma::Mat<T> f_y, arma::Mat<T> f_z) {
628  if(gn.n_cols!=3) {
629  ERROR_INFO();
630  throw std::runtime_error("Grad rho must have three columns!\n");
631  }
632  if(f.n_rows != f_x.n_rows || f.n_cols != f_x.n_cols || f.n_rows != f_y.n_rows || f.n_cols != f_y.n_cols || f.n_rows != f_z.n_rows || f.n_cols != f_z.n_cols) {
633  ERROR_INFO();
634  throw std::runtime_error("Sizes of basis function and derivative matrices doesn't match!\n");
635  }
636  if(H.n_rows != f.n_rows || H.n_cols != f.n_rows) {
637  ERROR_INFO();
638  throw std::runtime_error("Sizes of basis function and Fock matrices doesn't match!\n");
639  }
640 
641  // Compute helper: gamma_{ip} = \sum_c \chi_{ip;c} gr_{p;c}
642  // (N, Np) = (N Np; c) (Np, 3)
643  arma::Mat<T> gamma(f.n_rows,f.n_cols);
644  gamma.zeros();
645  {
646  // Helper
647  arma::rowvec gc;
648 
649  // x gradient
650  gc=arma::trans(gn.col(0));
651  for(size_t j=0;j<f_x.n_cols;j++)
652  for(size_t i=0;i<f_x.n_rows;i++)
653  f_x(i,j)*=gc(j);
654  gamma+=f_x;
655 
656  // x gradient
657  gc=arma::trans(gn.col(1));
658  for(size_t j=0;j<f_y.n_cols;j++)
659  for(size_t i=0;i<f_y.n_rows;i++)
660  f_y(i,j)*=gc(j);
661  gamma+=f_y;
662 
663  // z gradient
664  gc=arma::trans(gn.col(2));
665  for(size_t j=0;j<f_z.n_cols;j++)
666  for(size_t i=0;i<f_z.n_rows;i++)
667  f_z(i,j)*=gc(j);
668  gamma+=f_z;
669  }
670 
671  // Form Fock matrix
672  H+=gamma*arma::trans(f) + f*arma::trans(gamma);
673 }
674 
676 template<typename T> void increment_gga(arma::Mat<T> & H, const arma::mat & gn, const arma::Mat<T> & f, arma::Mat<T> f_x, arma::Mat<T> f_y, arma::Mat<T> f_z, const arma::uvec & screen) {
677  if(gn.n_cols!=3) {
678  ERROR_INFO();
679  throw std::runtime_error("Grad rho must have three columns!\n");
680  }
681  if(f.n_rows != f_x.n_rows || f.n_cols != f_x.n_cols || f.n_rows != f_y.n_rows || f.n_cols != f_y.n_cols || f.n_rows != f_z.n_rows || f.n_cols != f_z.n_cols) {
682  ERROR_INFO();
683  throw std::runtime_error("Sizes of basis function and derivative matrices doesn't match!\n");
684  }
685  if(H.n_rows != f.n_rows || H.n_cols != f.n_rows) {
686  ERROR_INFO();
687  throw std::runtime_error("Sizes of basis function and Fock matrices doesn't match!\n");
688  }
689 
690  // Compute helper: gamma_{ip} = \sum_c \chi_{ip;c} gr_{p;c}
691  // (N, Np) = (N Np; c) (Np, 3)
692  arma::Mat<T> gamma(f.n_rows,f.n_cols);
693  gamma.zeros();
694  {
695  // Helper
696  arma::rowvec gc;
697 
698  // x gradient
699  gc=arma::trans(gn.col(0));
700  for(size_t j=0;j<f_x.n_cols;j++)
701  for(size_t i=0;i<f_x.n_rows;i++)
702  f_x(i,j)*=gc(j);
703  gamma+=f_x;
704 
705  // x gradient
706  gc=arma::trans(gn.col(1));
707  for(size_t j=0;j<f_y.n_cols;j++)
708  for(size_t i=0;i<f_y.n_rows;i++)
709  f_y(i,j)*=gc(j);
710  gamma+=f_y;
711 
712  // z gradient
713  gc=arma::trans(gn.col(2));
714  for(size_t j=0;j<f_z.n_cols;j++)
715  for(size_t i=0;i<f_z.n_rows;i++)
716  f_z(i,j)*=gc(j);
717  gamma+=f_z;
718  }
719 
720  // Form Fock matrix
721  H+=gamma.cols(screen)*arma::trans(f.cols(screen)) + f.cols(screen)*arma::trans(gamma.cols(screen));
722 }
723 
725 template<typename T> void increment_mgga_kin(arma::Mat<T> & H, const arma::rowvec & vtaul, const arma::Mat<T> & f_x, const arma::Mat<T> & f_y, const arma::Mat<T> & f_z) {
726  // This is equivalent to LDA incrementation on the three components!
727  increment_lda<T>(H,vtaul,f_x);
728  increment_lda<T>(H,vtaul,f_y);
729  increment_lda<T>(H,vtaul,f_z);
730 }
731 
732 template<typename T> void increment_mgga_kin(arma::Mat<T> & H, const arma::rowvec & vtaul, const arma::Mat<T> & f_x, const arma::Mat<T> & f_y, const arma::Mat<T> & f_z, const arma::uvec & screen) {
733  // This is equivalent to LDA incrementation on the three components!
734  increment_lda<T>(H,vtaul,f_x,screen);
735  increment_lda<T>(H,vtaul,f_y,screen);
736  increment_lda<T>(H,vtaul,f_z,screen);
737 }
738 
740 template<typename T> void increment_mgga_lapl(arma::Mat<T> & H, const arma::rowvec & vl, const arma::Mat<T> & f, const arma::Mat<T> & f_lapl, const arma::uvec & screen) {
741  if(f.n_rows != f_lapl.n_rows || f.n_cols != f_lapl.n_cols) {
742  ERROR_INFO();
743  throw std::runtime_error("Sizes of basis function and laplacian matrices doesn't match!\n");
744  }
745  if(f.n_cols != vl.n_elem) {
746  ERROR_INFO();
747  throw std::runtime_error("Sizes of basis function matrix and potential doesn't match!\n");
748  }
749  if(H.n_rows != f.n_rows || H.n_cols != f.n_rows) {
750  ERROR_INFO();
751  throw std::runtime_error("Sizes of basis function and Fock matrices doesn't match!\n");
752  }
753 
754  // Absorb the potential into the function values
755  arma::Mat<T> fhlp(f);
756  for(size_t i=0;i<fhlp.n_rows;i++)
757  for(size_t j=0;j<fhlp.n_cols;j++)
758  fhlp(i,j)*=vl(j);
759  // Fock matrix contribution is
760  H+=f_lapl.cols(screen)*arma::trans(fhlp.cols(screen)) + fhlp.cols(screen)*arma::trans(f_lapl.cols(screen));
761 }
762 
763 #endif
const BasisSet * basp
Basis set pointer.
Definition: dftgrid.h:169
double vsigmaaa
Sigma potential.
Definition: dftgrid.h:104
const BasisSet * basp
Basis set.
Definition: dftgrid.h:481
void prune_shells()
Prune shells with no points.
Definition: dftgrid.cpp:2693
arma::mat sigma
Dot products of gradient of electron density, N x Npts; N=1 for closed-shell and 3 for open-shell...
Definition: dftgrid.h:253
double tol
Tolerance threshold.
Definition: dftgrid.h:68
void prune_points()
Prune points with small weight.
Definition: dftgrid.cpp:296
arma::mat bf_z
z gradient
Definition: dftgrid.h:202
double compute_Nel() const
Compute number of electrons.
Definition: dftgrid.cpp:608
std::vector< gridpoint_t > grid
Integration points.
Definition: dftgrid.h:174
arma::mat vlapl
Functional derivative of energy wrt laplacian of electron density.
Definition: dftgrid.h:265
void init_xc()
Initialize XC arrays.
Definition: dftgrid.cpp:626
arma::mat bf_ly
Values of y gradient of laplacian; used for MGGA force.
Definition: dftgrid.h:211
arma::mat eval_overlap()
Evaluate overlap matrix numerically.
Definition: dftgrid.cpp:3159
double R
Radius of shell.
Definition: dftgrid.h:62
void set_verbose(bool ver)
Set verbose operation.
Definition: dftgrid.cpp:2689
void collect_VV10(arma::mat &data, std::vector< size_t > &idx, double b, double C, bool nl) const
Collect VV10 data.
Definition: dftgrid.cpp:926
arma::mat bf_y
y gradient
Definition: dftgrid.h:200
arma::mat Pav
Same for spin-polarized.
Definition: dftgrid.h:219
size_t f0
Index of first basis function on grid point.
Definition: dftgrid.h:49
Definition: dftgrid.h:42
double taua
Kinetic energy density.
Definition: dftgrid.h:96
void eval_overlap(arma::mat &S) const
Evaluate atomic contribution to overlap matrix.
Definition: dftgrid.cpp:1244
void update_density(const arma::mat &P)
Update values of density, restricted calculation.
Definition: dftgrid.cpp:377
arma::mat vsigma
Functional derivative of energy wrt gradient of electron density.
Definition: dftgrid.h:255
double eval_Exc() const
Evaluate exchange/correlation energy.
Definition: dftgrid.cpp:1231
arma::vec eval_force_u() const
Evaluate force, unrestricted.
Definition: dftgrid.cpp:1722
double VV10_thr
Density threshold.
Definition: dftgrid.h:271
arma::rowvec w
Duplicate values of weights here.
Definition: dftgrid.h:194
double vrhoa
Alpha and beta potential.
Definition: dftgrid.h:102
libxc_dens_t get_dens(size_t idx) const
Get density data for wanted point.
Definition: dftgrid.cpp:1120
bool do_mgga
Meta-GGA used? (Set in compute_xc, only affects eval_Fxc)
Definition: dftgrid.h:237
AngularGrid(bool lobatto=false)
Definition: dftgrid.cpp:65
void init_VV10(double b, double C, bool pot)
Initialize VV10 calculation.
Definition: dftgrid.cpp:769
double f
Value of function.
Definition: dftgrid.h:36
coords_t cen
Coordinates of center.
Definition: dftgrid.h:59
void eval_Fxc(int x_func, int c_func, const arma::mat &P, arma::mat &H, double &Exc, double &Nel)
Compute Fock matrix, exchange-correlation energy and integrated electron density, restricted case...
Definition: dftgrid.cpp:3769
arma::mat tau
Kinetic energy density.
Definition: dftgrid.h:262
~DFTGrid()
Destructor.
Definition: dftgrid.cpp:2686
size_t nfunc
Number of functions on shell.
Definition: dftgrid.h:73
void print_density(const arma::mat &P, std::string densname="density.dat")
Print out density data.
Definition: dftgrid.cpp:4360
Info for radial shell.
Definition: dftgrid.h:55
double d
Density at point.
Definition: dftgrid.h:79
arma::vec exc
Energy density, Npts.
Definition: dftgrid.h:244
arma::vec compute_atomic_Nel(const arma::mat &P)
Evaluate amount of electrons in each atomic region.
Definition: dftgrid.cpp:3688
void print_density(FILE *f) const
Print density information.
Definition: dftgrid.cpp:1084
void free()
Free memory.
Definition: dftgrid.cpp:306
double w
Integration weight.
Definition: dftgrid.h:81
void construct_hirshfeld(const Hirshfeld &hirsh, double stol)
Create dummy grid for Hirshfeld charges (only overlap matrix)
Definition: dftgrid.cpp:3080
std::vector< arma::mat > eval_overlaps()
Evaluate overlap matrices numerically.
Definition: dftgrid.cpp:3252
arma::uvec screen_density(double thr=1e-10) const
Screen wrt small density, returns list of points with nonnegligible values.
Definition: dftgrid.cpp:359
bool verbose
Verbose operation?
Definition: dftgrid.h:483
arma::uvec bf_N
Amount of functions on shell.
Definition: dftgrid.h:186
libxc_pot_t get_pot(size_t idx) const
Get potential data for wanted point.
Definition: dftgrid.cpp:1179
void get_density(std::vector< dens_list_t > &list) const
Get density list; used to determine isosurface values for orbital plots.
Definition: dftgrid.cpp:594
arma::mat VV10_arr
Helper array used in kernel computation to avoid memory thrashing.
Definition: dftgrid.h:273
arma::mat bf_lz
Values of z gradient of laplacian; used for MGGA force.
Definition: dftgrid.h:213
void eval_diag_Fxc_SIC(arma::vec &H) const
Evaluate diagonal elements of Fock matrix (for adaptive grid formation), unrestricted calculation...
arma::vec eval_force(int x_func, int c_func, const arma::mat &P)
Evaluate force.
Definition: dftgrid.cpp:4134
void print_grid(std::string met="XC") const
Print out grid information.
Definition: dftgrid.cpp:4469
arma::mat rho
Density, Nrho x Npts.
Definition: dftgrid.h:242
size_t ind
Global index of function.
Definition: dftgrid.h:34
arma::mat bf
Values of important functions in grid points, Nbf * Ngrid.
Definition: dftgrid.h:196
bool do_lgrad
Is gradient of laplacian needed? (For MGGA force)
Definition: dftgrid.h:229
double vlapla
Laplacian potential.
Definition: dftgrid.h:106
void form_grid()
Form radial shell and compute basis functions.
Definition: dftgrid.cpp:2424
void eval_tau_overlap(const arma::cx_mat &Cocc, double k, arma::mat &S, double thr) const
Definition: dftgrid.cpp:1358
void print_potential(int func_id, const arma::mat &Pa, const arma::mat &Pb, std::string potname="potential.dat")
Print out potential data.
Definition: dftgrid.cpp:4412
arma::uvec bf_potind
List of important functions in potentials&#39; list.
Definition: dftgrid.h:191
std::vector< angshell_t > grids
Radial grids.
Definition: dftgrid.h:479
bool use_lobatto
Use Lobatto quadrature? (Default is Lebedev)
Definition: dftgrid.h:171
double rhoa
Alpha and beta density.
Definition: dftgrid.h:90
void eval_tau_overlap_deriv(const arma::cx_mat &Cocc, const arma::vec &Esi, double k, arma::mat &S, double thr) const
Calculate the GGA and meta-GGA type terms for the derivative.
Definition: dftgrid.cpp:1385
void eval_diag_overlap(arma::vec &S) const
Evaluate diagonal elements of overlap matrix.
Definition: dftgrid.cpp:1253
void check_grad_lapl(int x_func, int c_func)
Check necessity of computing gradient and laplacians, necessary for compute_bf!
Definition: dftgrid.cpp:2048
size_t atind
Atomic index.
Definition: dftgrid.h:57
angshell_t info
Shell info.
Definition: dftgrid.h:167
angshell_t construct()
Construct a fixed size grid.
Definition: dftgrid.cpp:2080
angshell_t construct_hirshfeld(const Hirshfeld &Hirsh, double otol)
Construct a dummy grid that is only meant for the overlap matrix (Hirshfeld charges) ...
Definition: dftgrid.cpp:2367
Helper for debugging output: density input.
Definition: dftgrid.h:88
arma::vec eval_force_r() const
Evaluate force, restricted.
Definition: dftgrid.cpp:1912
bool do_gga
GGA functional used? (Set in compute_xc, only affects eval_Fxc)
Definition: dftgrid.h:235
Helper for debugging output: potential output.
Definition: dftgrid.h:100
void compute_bf()
Compute basis functions on grid points.
Definition: dftgrid.cpp:2515
void set_hess_lgrad(bool hess, bool lgrad)
Set necessity of computing Hessian and gradient of Laplacian.
Definition: dftgrid.cpp:2074
void print_potential(int func_id, FILE *f) const
Print potential information.
Definition: dftgrid.cpp:1095
bool do_grad
Is gradient needed?
Definition: dftgrid.h:223
arma::mat eval_hirshfeld_overlap(const Hirshfeld &hirsh, size_t inuc)
Evaluate overlap matrices numerically.
Definition: dftgrid.cpp:3494
arma::uvec pot_bf_ind
List of potentially important functions.
Definition: dftgrid.h:179
void set_grad_lapl(bool grad, bool lapl)
Set necessity of computing gradient and laplacians, necessary for compute_bf!
Definition: dftgrid.cpp:2069
Helper for getting data.
Definition: dftgrid.h:112
arma::mat grho
Gradient of electron density, (3 x Nrho) x Npts.
Definition: dftgrid.h:251
std::vector< size_t > pot_shells
List of potentially important shells.
Definition: dftgrid.h:177
void set_basis(const BasisSet &basis)
Set basis set.
Definition: dftgrid.cpp:75
DFT quadrature grid.
Definition: dftgrid.h:475
double compute_Nel(const arma::mat &P)
Evaluate amount of electrons.
Definition: dftgrid.cpp:3620
arma::uvec bf_i0
Indices of first functions on shell.
Definition: dftgrid.h:184
std::vector< AngularGrid > wrk
Work grids.
Definition: dftgrid.h:477
void update_shell_list()
Update list of important basis functions.
Definition: dftgrid.cpp:2470
size_t np
Number of points on shell.
Definition: dftgrid.h:71
double vtaua
Kinetic energy potential.
Definition: dftgrid.h:108
libxc_debug_t get_data(size_t idx) const
Get density and potential data for wanted point.
Definition: dftgrid.cpp:1172
Basis set.
Definition: basis.h:187
void form_hirshfeld_grid(const Hirshfeld &hirsh)
Form radial shell using Hirshfeld weights and compute basis functions.
Definition: dftgrid.cpp:2447
arma::mat lapl
Laplacian of electron density.
Definition: dftgrid.h:260
arma::mat bf_lx
Values of x gradient of laplacian; used for MGGA force.
Definition: dftgrid.h:209
void compute_xc(int func_id, bool pot)
Definition: dftgrid.cpp:683
arma::mat vxc
Functional derivative of energy wrt electron density, Nrho x Npts.
Definition: dftgrid.h:246
size_t get_Npoints() const
Get amount of points.
Definition: dftgrid.cpp:3145
void lobatto_shell()
Add radial shell in Lobatto angular scheme, w/o Becke partitioning or pruning.
Definition: dftgrid.cpp:87
double lapla
Laplacians.
Definition: dftgrid.h:94
bool do_hess
Is Hessian needed? (For GGA force)
Definition: dftgrid.h:227
void eval_diag_Fxc(arma::vec &H) const
Evaluate diagonal elements of Fock matrix (for adaptive grid formation), restricted calculation...
Definition: dftgrid.cpp:1501
void print_grid() const
Print out grid information.
Definition: dftgrid.cpp:621
DFTGrid()
Dummy constructor.
Definition: dftgrid.cpp:2662
arma::vec eval_VV10_force(DFTGrid &nlgrid, double b, double C, const arma::mat &P)
Evaluate NL force.
Definition: dftgrid.cpp:4262
double sigmaaa
Sigma variables.
Definition: dftgrid.h:92
size_t nf
Number of functions on grid point.
Definition: dftgrid.h:51
std::vector< dens_list_t > eval_dens_list(const arma::mat &P)
Evaluate density.
Definition: dftgrid.cpp:3571
arma::mat bf_hess
Values of Hessians in grid points, (9*Nbf) * Ngrid; used for GGA force.
Definition: dftgrid.h:207
bool do_lapl
Is laplacian needed?
Definition: dftgrid.h:225
Coordinates structure.
Definition: basis.h:50
Angular integration grid on a radial shell of an atom.
Definition: dftgrid.h:164
arma::mat vtau
Functional derivative of energy wrt kinetic energy density.
Definition: dftgrid.h:267
size_t get_Nfuncs() const
Get amount of functions.
Definition: dftgrid.cpp:3152
Hirshfeld atomic densities.
Definition: hirshfeld.h:59
void hirshfeld_weights(const Hirshfeld &hirsh)
Compute Hirshfeld weight for grid points.
Definition: dftgrid.cpp:289
arma::mat bf_x
x gradient
Definition: dftgrid.h:198
void get_weights()
Collect weights from grid into w array.
Definition: dftgrid.cpp:1112
arma::mat eval_tau_overlap(const arma::cx_mat &Cocc, double k, double thr=1e-10)
Evaluate weighted overlap (for PZ-SIC)
Definition: dftgrid.cpp:3396
void construct(int nrad, int lmax, int x_func, int c_func, bool strict)
Create fixed size grid.
Definition: dftgrid.cpp:2699
void compute_VV10(const std::vector< arma::mat > &nldata, double b, double C)
Definition: dftgrid.cpp:966
arma::mat eval_tau_overlap_deriv(const arma::cx_mat &Cocc, const arma::vec &Esi, double k, double thr=1e-10)
Evaluate weighted overlap derivative terms (for PZ-SIC)
Definition: dftgrid.cpp:3445
coords_t r
Coordinates of the point.
Definition: dftgrid.h:44
~AngularGrid()
Destructor.
Definition: dftgrid.cpp:72
double w
Integration weight (both spherical jacobian and Becke weight)
Definition: dftgrid.h:46
void eval_Fxc(arma::mat &H) const
Evaluate Fock matrix, restricted calculation.
Definition: dftgrid.cpp:1447
double w
Radial weight.
Definition: dftgrid.h:64
void get_grad_lapl(bool &grad, bool &lapl) const
Get necessity of computing gradient and laplacians.
Definition: dftgrid.cpp:2064
std::vector< size_t > shells
List of important shells.
Definition: dftgrid.h:182
Helper for determining density cutoffs for plots.
Definition: dftgrid.h:77
void lebedev_shell()
Add radial shell in Lebedev scheme, w/o Becke partitioning or pruning.
Definition: dftgrid.cpp:173
int l
Order of quadrature rule.
Definition: dftgrid.h:66
void construct_becke(double stol)
Create dummy grid for Becke charges (only overlap matrix)
Definition: dftgrid.cpp:3015
void becke_weights(double a=0.7)
Definition: dftgrid.cpp:207
void set_grid(const angshell_t &shell)
Set radial shell.
Definition: dftgrid.cpp:79
arma::vec compute_VV10_F(const std::vector< arma::mat > &nldata, const std::vector< angshell_t > &nlgrids, double b, double C)
Same thing, but also evaluate the grid contribution to the force.
Definition: dftgrid.cpp:1023
void eval_VV10(DFTGrid &nlgrid, double b, double C, const arma::mat &P, arma::mat &H, double &Exc, bool fock=true)
Compute VV10.
Definition: dftgrid.cpp:4022
arma::mat bf_lapl
Values of laplacians in grid points, (3*Nbf) * Ngrid.
Definition: dftgrid.h:204
angshell_t construct_becke(double otol)
Construct a dummy grid that is only meant for the overlap matrix (Becke charges)
Definition: dftgrid.cpp:2310
Definition: dftgrid.h:32
arma::mat Pv
Density helper matrices: P_{uv} chi_v, and P_{uv} nabla(chi_v)
Definition: dftgrid.h:217
bool polarized
Spin-polarized calculation?
Definition: dftgrid.h:232
std::vector< arma::mat > eval_hirshfeld_overlaps(const Hirshfeld &hirsh)
Evaluate overlap matrices numerically.
Definition: dftgrid.cpp:3524
arma::uvec bf_ind
List of important functions.
Definition: dftgrid.h:189
std::vector< gridpoint_t > get_grid() const
Get the quadrature grid.
Definition: dftgrid.cpp:83