Psi4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
psi::PseudospectralGrid Class Reference

#include <cubature.h>

Inheritance diagram for psi::PseudospectralGrid:
psi::MolecularGrid

Public Member Functions

 PseudospectralGrid (std::shared_ptr< Molecule > molecule, std::shared_ptr< BasisSet > primary, Options &options)
 Constructor to use for autogeneration. More...
 
 PseudospectralGrid (std::shared_ptr< Molecule > molecule, std::shared_ptr< BasisSet > primary, const std::string &filename, Options &options)
 Construtor to use for semiautomatic generation with grid file. More...
 
virtual ~PseudospectralGrid ()
 
- Public Member Functions inherited from psi::MolecularGrid
 MolecularGrid (std::shared_ptr< Molecule > molecule)
 
virtual ~MolecularGrid ()
 
void buildGridFromOptions (MolecularGridOptions const &opt)
 Build the grid. More...
 
void buildGridFromOptions (MolecularGridOptions const &opt, const std::vector< std::vector< double > > &rs, const std::vector< std::vector< double > > &ws, const std::vector< std::vector< int > > &Ls)
 Build the grid. More...
 
void print (std::string OutFileRMR="outfile", int print=2) const
 Print information about the grid. More...
 
void print_details (std::string OutFileRMR="outfile", int print=2) const
 
std::shared_ptr< Matrixorientation () const
 Orientation matrix. More...
 
const std::vector
< std::shared_ptr< RadialGrid > > & 
radial_grids () const
 Radial grids, per atom. More...
 
const std::vector< std::vector
< std::shared_ptr
< SphericalGrid > > > & 
spherical_grids () const
 Spherical grids, per atom and radial point. More...
 
int * index () const
 index_[fast_index] = slow_index. You do not own this More...
 
int npoints () const
 Number of grid points. More...
 
int max_points () const
 Maximum number of grid points in a block. More...
 
int max_functions () const
 Maximum number of funtions in a block. More...
 
double * x () const
 The x points. You do not own this. More...
 
double * y () const
 The y points. You do not own this. More...
 
double * z () const
 The z points. You do not own this. More...
 
double * w () const
 The weights, normalized to 1 on R3. You do not own this. More...
 
std::shared_ptr< BasisExtentsextents () const
 Pointer to basis extents. More...
 
const std::vector
< std::shared_ptr
< BlockOPoints > > & 
blocks () const
 Set of spatially sieved blocks of points, generated by sieve() internally. More...
 
void set_debug (int debug)
 

Protected Member Functions

void buildGridFromOptions ()
 Master builder methods. More...
 
void buildGridFromFile ()
 
- Protected Member Functions inherited from psi::MolecularGrid
void postProcess (std::shared_ptr< BasisExtents > extents, int max_points, int min_points, double max_radius)
 Sieve and block. More...
 
void remove_distant_points (double Rcut)
 
void block (int max_points, int min_points, double max_radius)
 

Protected Attributes

std::shared_ptr< BasisSetprimary_
 The primary basis. More...
 
std::string filename_
 The filename used to optionally build the grid. More...
 
Optionsoptions_
 The Options object. More...
 
- Protected Attributes inherited from psi::MolecularGrid
int debug_
 
std::shared_ptr< Moleculemolecule_
 The molecule this grid is built on. More...
 
int npoints_
 Total points for this molecule. More...
 
int max_points_
 Maximum number of points in a block. More...
 
int max_functions_
 Maximum number of functions in a block. More...
 
double * x_
 Full x points. More...
 
double * y_
 Full y points. More...
 
double * z_
 Full z points. More...
 
double * w_
 Full weights. More...
 
std::shared_ptr< Matrixorientation_
 Orientation matrix. More...
 
std::vector< std::shared_ptr
< RadialGrid > > 
radial_grids_
 Radial grids, per atom. More...
 
std::vector< std::vector
< std::shared_ptr
< SphericalGrid > > > 
spherical_grids_
 Spherical grids, per atom and radial point. More...
 
int * index_
 index_[fast_index] = slow_index More...
 
std::vector< std::shared_ptr
< BlockOPoints > > 
blocks_
 Vector of blocks. More...
 
std::shared_ptr< BasisExtentsextents_
 Points to basis extents, built internally. More...
 
std::shared_ptr< BasisSetprimary_
 BasisSet from extents_. More...
 
MolecularGridOptions options_
 A copy of the options used, for printing purposes. More...
 

Constructor & Destructor Documentation

psi::PseudospectralGrid::PseudospectralGrid ( std::shared_ptr< Molecule molecule,
std::shared_ptr< BasisSet primary,
Options options 
)

Constructor to use for autogeneration.

psi::PseudospectralGrid::PseudospectralGrid ( std::shared_ptr< Molecule molecule,
std::shared_ptr< BasisSet primary,
const std::string &  filename,
Options options 
)

Construtor to use for semiautomatic generation with grid file.

psi::PseudospectralGrid::~PseudospectralGrid ( )
virtual

Member Function Documentation

void psi::PseudospectralGrid::buildGridFromFile ( )
protected
std::string PSIDATADIR = Process::environment("PSIDATADIR");
std::string gridname = PSIDATADIR + "grids/" + filename_ + ".grid";

cout << gridname;

Phase I: read the grid in std::vector<std::vector<std::pair<int, std::pair<double, double> > > > array; array.resize(molecule_->natom());

regex comment("^\\s*\\!.*"); // line starts with ! regex separator("^\\*\\*\\*\\*"); // line starts with **** regex atom_array("^\\s*([A-Za-z]+)\\s+0.*"); // array of atomic symbols terminated by 0

#define NUMBER "((?:[-+]?\\d*\\.\\d+(?:[DdEe][-+]?\\d+)?)|(?:[-+]?\\d+\\.\\d*(?:[DdEe][-+]?\\d+)?))"

regex grid_shell("^\\s*(\\d+)\\s+" NUMBER ".*"); // match

Hold the result of a regex_match smatch what;

std::vector<std::string> lines; std::string text; ifstream infile(gridname.c_str()); if (!infile) throw PSIEXCEPTION("PseudoGridParser::parse: Unable to open pseudospectral grid file: " + filename); while (infile.good()) { getline(infile, text); lines.push_back(text); }

for (int atom=0; atom<molecule_->natom(); ++atom) {

int lineno = 0;
bool found = false;
while (lineno < lines.size()) {
    string line = lines[lineno++];

Spit out the line for debugging. cout << line << endl;

Ignore blank lines if (line.empty()) continue;

Do some matches if (regex_match(line, what, comment)) { cout << " matched a comment line.\n"; continue; } if (regex_match(line, what, separator)) { cout << " matched a separator line.\n"; continue; } Match: H 0 or: H O... 0 if (regex_match(line, what, atom_array)) { cout << " matched a atom array line.\n"; cout << " what.captures(1)" << what[1].str() << "\n";

Check the captures and see if this basis set is for the atom we need. if (iequals(molecule_->label(atom), what[1].str())) { found = true; line = lines[lineno++];

Need to do the following until we match a "****" which is the end of the basis set while (!regex_match(line, what, separator)) { cout << " Atom line " << line; if (regex_match(line, what, grid_shell)) { int L; double r; if (!from_string<int>(L, what[1], std::dec)) throw PSIEXCEPTION("PseudoGridParser::parse: Unable to convert number of points (order):\n" + line); if (!from_string<double>(r, what[2], std::dec)) throw PSIEXCEPTION("PseudoGridParser::parse: Unable to convert grid shell radius:\n" + line); array[atom].push_back(make_pair(L, make_pair(r,1.0))); } line = lines[lineno++]; } break; } else { continue; } } else { continue; }

} if (found == false) throw PSIEXCEPTION("PseudoGridParser::parser: Unable to find the grid for " + molecule_->label(atom)); }

std::map<int,int> lebedev_orders_to_points = SphericalGrid::lebedevOrdersToPoints();

int npoints = 0; for (int atom = 0; atom < molecule_->natom(); atom++) {

for (std::vector<std::pair<int, std::pair<double, double> > >::iterator it = array[atom].begin(); it != array[atom].end(); it++) {
    std::pair<int, std::pair<double,double> > row = (*it);
    int L = row.first;

    if (lebedev_orders_to_points.count(L) == 0)
        throw PSIEXCEPTION("Grid order does not match available Lebedev grid orders");

    npoints += lebedev_orders_to_points[L];
}

}

if (npoints == 0) throw PSIEXCEPTION("PseudoGridParser: No Grid points in this molecule");

std::vector<AtomicGrid> atoms;

Phase II: build the grid for (int atom = 0; atom < molecule_->natom(); atom++) {

Vector3 center = molecule_->xyz(atom);
double xc = center[0];
double yc = center[1];
double zc = center[2];

for (std::vector<std::pair<int, std::pair<double, double> > >::iterator it = array[atom].begin(); it != array[atom].end(); it++) {
    std::pair<int, std::pair<double,double> > row = (*it);
    int L = row.first;
    double r = row.second.first;
    double w = row.second.second;

    int ngrid = 0;

Defined in integrator_defines.h int max_grid = n_lebedev_; for (int index = 0; index < max_grid; index++) { if (lebedev_orders_[index] == L) ngrid = lebedev_points_[index]; } if (ngrid == 0) throw PSIEXCEPTION("Grid order does not match available Lebedev grid orders");

SphericalQuadrature quad = integrator->getLebedevSpherical(ngrid);

for (int p = 0; p < ngrid; p++) { xp[counter + p] = quad.x[p]; yp[counter + p] = quad.y[p]; zp[counter + p] = quad.z[p]; wp[counter + p] = quad.w[p]; wp[counter + p] = w; } free(quad.x); free(quad.y); free(quad.z); free(quad.w);

Scale to radius for (int l = 0; l < ngrid; l++) { xp[counter + l] *= r; yp[counter + l] *= r; zp[counter + l] *= r; wp[counter + l] *= r*r; }

Center for (int l = 0; l < ngrid; l++) { xp[counter + l] += xc; yp[counter + l] += yc; zp[counter + l] += zc; }

TODO rotate to standard orientation TODO scale for radial weight TODO account for atomic cells

        counter += ngrid;
    }
}
void psi::PseudospectralGrid::buildGridFromOptions ( )
protected

Master builder methods.

Member Data Documentation

std::string psi::PseudospectralGrid::filename_
protected

The filename used to optionally build the grid.

Options& psi::PseudospectralGrid::options_
protected

The Options object.

std::shared_ptr<BasisSet> psi::PseudospectralGrid::primary_
protected

The primary basis.


The documentation for this class was generated from the following files: