Skip to content

Commit

Permalink
changes to structure class
Browse files Browse the repository at this point in the history
removed push_back functionality, only setCoordinates publically
available

added third, optional boolean argument to class constructor, setting it
to false only sets coordinates and does not calculate properties
  • Loading branch information
Trombach committed Oct 10, 2018
1 parent 3794613 commit 93d2dea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
10 changes: 6 additions & 4 deletions potential.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ pairPotential::pairPotential (void) {}

double pairPotential::calcEnergy (const column_vector &v)
{
structure S;
vector<coord3d> coordinates;
for (long i = 0; i < v.size() / 3; ++i)
{
coord3d sphere(v(3 * i), v(3 * i + 1), v(3 * i + 2));
S.push_back(sphere);
coordinates.push_back(sphere);
}
structure S(0, coordinates, false);
double f(0);
for (int i = 0; i < S.nAtoms(); ++i) {
for (int j = i + 1; j < S.nAtoms(); ++j) {
Expand Down Expand Up @@ -55,12 +56,13 @@ double pairPotential::calcEnergy (structure &S)

const column_vector pairPotential::calcGradient (const column_vector &v)
{
structure S;
vector<coord3d> coordinates;
for (long i = 0; i < v.size() / 3; ++i)
{
coord3d sphere(v(3 * i), v(3 * i + 1), v(3 * i + 2));
S.push_back(sphere);
coordinates.push_back(sphere);
}
structure S(0, coordinates, false);
vector<coord3d> gradients (S.nAtoms(), coord3d());
for (int i = 0; i < S.nAtoms(); i++)
{
Expand Down
30 changes: 11 additions & 19 deletions structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,17 @@ class structure {
{}

/* constructor calculates several properties based on coordinates on creation */
structure (int number, std::vector<coord3d> coordinates) : _energy(0),
_number(number),
_coordinates(coordinates),
_hessian(0),
_interPartDist(),
_bondVector(),
_adjMatrix_eigenvalues()
structure ( int number,
std::vector<coord3d> coordinates,
bool calcProp = true) : _energy(0),
_number(number),
_hessian(0),
_interPartDist(),
_bondVector(),
_adjMatrix_eigenvalues()
{
this->shiftToCoM();

std::vector< std::vector<double> > inertiaTensor = this->momentOfInertia();
_momentOfInertia = diag(inertiaTensor);

matrix3d axis = this->m3d_principalAxis ();
this->rotateToPrincipalAxis(axis);

this->propertyInterPartDist();

this->propertyDistMatrix();
if (calcProp) this->setCoordinates(coordinates);
else _coordinates = coordinates;
}


Expand Down Expand Up @@ -105,7 +97,7 @@ class structure {

int nAtoms() { return (this->getCoordinates()).size(); }

void push_back(coord3d spheres) { _coordinates.push_back(spheres); }
//void push_back(coord3d spheres) { _coordinates.push_back(spheres); }

structure &operator*= (const double &y)
{
Expand Down

0 comments on commit 93d2dea

Please sign in to comment.