Skip to content

Commit

Permalink
Misc CdSalcList cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathonMisiewicz committed Jan 18, 2018
1 parent 654cf4b commit 6b7d071
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
32 changes: 11 additions & 21 deletions psi4/src/psi4/libmints/cdsalclist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CdSalcList::CdSalcList(std::shared_ptr<Molecule> mol, std::shared_ptr<MatrixFact
throw PSIEXCEPTION("CdSalcList::CdSalcList: Molecule point group has not been set.");
}

int natom = molecule_->natom();
const int natom = molecule_->natom();
ncd_ = 3 * natom;

// Immediately create the rotation and translation vectors to be projected out.
Expand All @@ -112,9 +112,9 @@ CdSalcList::CdSalcList(std::shared_ptr<Molecule> mol, std::shared_ptr<MatrixFact
// X.eivprint(ev);

// Pull out data to local variables to reduce memory lookup
double X00 = X(0, 0), X01 = X(0, 1), X02 = X(0, 2);
double X10 = X(1, 0), X11 = X(1, 1), X12 = X(1, 2);
double X20 = X(2, 0), X21 = X(2, 1), X22 = X(2, 2);
const double X00 = X(0, 0), X01 = X(0, 1), X02 = X(0, 2);
const double X10 = X(1, 0), X11 = X(1, 1), X12 = X(1, 2);
const double X20 = X(2, 0), X21 = X(2, 1), X22 = X(2, 2);

// Matrix constraints("COM & Rotational Constraints", 6, 3*natom);
double tval0, tval1, tval2;
Expand Down Expand Up @@ -175,8 +175,8 @@ CdSalcList::CdSalcList(std::shared_ptr<Molecule> mol, std::shared_ptr<MatrixFact
double *salc = new double[ncd_];

// Obtain handy reference to point group.
PointGroup &pg = *molecule_->point_group().get();
CharacterTable char_table = pg.char_table();
const PointGroup &pg = *molecule_->point_group().get();
const CharacterTable char_table = pg.char_table();
nirrep_ = char_table.nirrep();

// I don't know up front how many I have per irrep
Expand Down Expand Up @@ -230,18 +230,17 @@ CdSalcList::CdSalcList(std::shared_ptr<Molecule> mol, std::shared_ptr<MatrixFact
if (stab_order == 0)
throw PSIEXCEPTION("CdSalcList::CdSalcList: Stabilizer order is 0 this is not possible.");

int nonzero = 0;
bool nonzero = false;
for (int cd = 0; cd < ncd_; ++cd) {
// Normalize the salc
salc[cd] /= sqrt((double)nirrep_ * stab_order);

// Count number of nonzeros
if (std::fabs(salc[cd]) > 1e-10) ++nonzero;
if (std::fabs(salc[cd]) > 1e-10) nonzero = true;
}

// We're only interested in doing the following if there are nonzeros
// AND the irrep that we're on is what the user wants.
// if (nonzero && (1 << irrep) & needed_irreps) {
if (nonzero && (1 << irrep) & needed_irreps) {
// Store the salc so we can project out constraints below
salcs.copy_to_row(irrep, cdsalcpi_[irrep], salc);
Expand Down Expand Up @@ -326,7 +325,7 @@ std::string CdSalcList::name_of_component(int component) {
return name;
}

SharedMatrix CdSalcList::matrix() {
SharedMatrix CdSalcList::matrix() const {
auto temp = std::make_shared<Matrix>("Cartesian/SALC transformation", ncd(), 3 * molecule_->natom());

for (size_t i = 0; i < ncd(); ++i) {
Expand All @@ -342,19 +341,10 @@ SharedMatrix CdSalcList::matrix() {
return temp;
}

SharedMatrix CdSalcList::matrix_irrep(int h) {
// cdsalcpi_ does not get updated after projected out translation and rotations
// why? if it ever is, I can use it.
// SharedMatrix temp = std::make_shared<Matrix>("Cartesian/SALC transformation", cdsalcpi_[h],
// 3*molecule_->natom());
SharedMatrix CdSalcList::matrix_irrep(int h) const {
auto temp = std::make_shared<Matrix>("Cartesian/SALC transformation", cdsalcpi_[h], 3 * molecule_->natom());

int cnt = 0;
for (size_t i = 0; i < ncd(); ++i)
if (salcs_[i].irrep() == h) ++cnt;

auto temp = std::make_shared<Matrix>("Cartesian/SALC transformation", cnt, 3 * molecule_->natom());

cnt = 0;
for (size_t i = 0; i < ncd(); ++i) {
if (salcs_[i].irrep() == h) {
int nc = salcs_[i].ncomponent();
Expand Down
11 changes: 5 additions & 6 deletions psi4/src/psi4/libmints/cdsalclist.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ class CdSalcList
int needed_irreps=0xFF,
bool project_out_translations=true,
bool project_out_rotations=true);
virtual ~CdSalcList();
~CdSalcList();

/*! Returns the number of combintations. It may not be 3n-5 or 3n-6.
* The value returned depends on needed_irreps and the project_out*
* settings.
/*! Returns the number of SALCs. It may not be 3n-5 or 3n-6. The value
* returned depends on needed_irreps and the project_out* settings.
*/
size_t ncd() const { return salcs_.size(); }

Expand All @@ -180,8 +179,8 @@ class CdSalcList

const CdSalcWRTAtom& atom_salc(int i) const { return atom_salcs_[i]; }

SharedMatrix matrix();
SharedMatrix matrix_irrep(int h); // return only salcs of a given irrep
SharedMatrix matrix() const;
SharedMatrix matrix_irrep(int h) const; // return only salcs of a given irrep
//SharedMatrix matrix_projected_out() const;

void print() const;
Expand Down

0 comments on commit 6b7d071

Please sign in to comment.