diff --git a/potential.cc b/potential.cc index 08d6bbc..eedd931 100644 --- a/potential.cc +++ b/potential.cc @@ -22,12 +22,13 @@ pairPotential::pairPotential (void) {} double pairPotential::calcEnergy (const column_vector &v) { - structure S; + vector 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) { @@ -55,12 +56,13 @@ double pairPotential::calcEnergy (structure &S) const column_vector pairPotential::calcGradient (const column_vector &v) { - structure S; + vector 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 gradients (S.nAtoms(), coord3d()); for (int i = 0; i < S.nAtoms(); i++) { diff --git a/structure.h b/structure.h index 79041dd..1266eac 100644 --- a/structure.h +++ b/structure.h @@ -35,25 +35,17 @@ class structure { {} /* constructor calculates several properties based on coordinates on creation */ - structure (int number, std::vector coordinates) : _energy(0), - _number(number), - _coordinates(coordinates), - _hessian(0), - _interPartDist(), - _bondVector(), - _adjMatrix_eigenvalues() + structure ( int number, + std::vector coordinates, + bool calcProp = true) : _energy(0), + _number(number), + _hessian(0), + _interPartDist(), + _bondVector(), + _adjMatrix_eigenvalues() { - this->shiftToCoM(); - - std::vector< std::vector > 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; } @@ -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) {