--- trunk/OOPSE/libmdtools/Atom.cpp 2003/03/26 21:04:38 409 +++ trunk/OOPSE/libmdtools/Atom.cpp 2003/07/14 21:48:43 599 @@ -1,5 +1,18 @@ +#include + +using namespace std; + #include "Atom.hpp" +double* Atom::pos; // the position array +double* Atom::vel; // the velocity array +double* Atom::frc; // the forc array +double* Atom::trq; // the torque vector ( space fixed ) +double* Atom::Amat; // the rotation matrix +double* Atom::mu; // the array of dipole moments +double* Atom::ul; // the lab frame unit directional vector +int Atom::nElements; + Atom::Atom(int theIndex) { c_n_hyd = 0; has_dipole = 0; @@ -25,9 +38,11 @@ Atom::Atom(int theIndex) { Azz = Axx+8; } -void Atom::createArrays (int nElements) { +void Atom::createArrays (int the_nElements) { int i; + nElements = the_nElements; + pos = new double[nElements*3]; vel = new double[nElements*3]; frc = new double[nElements*3]; @@ -117,11 +132,11 @@ void Atom::addAtoms(int nAdded, double* Apos, double* for(i = 0; i < 3*nAdded; i++) { j = i + 3*nElements; - new_pos[j] = pos[i]; - new_vel[j] = vel[i]; - new_frc[j] = frc[i]; - new_trq[j] = trq[i]; - new_ul[j] = ul[i]; + new_pos[j] = Apos[i]; + new_vel[j] = Avel[i]; + new_frc[j] = Afrc[i]; + new_trq[j] = Atrq[i]; + new_ul[j] = Aul[i]; } for (i = 0; i < 9*nElements; i++) { @@ -130,7 +145,7 @@ void Atom::addAtoms(int nAdded, double* Apos, double* for(i = 0; i < 9*nAdded; i++) { j = i + 9*nElements; - new_Amat[j] = Amat[i]; + new_Amat[j] = AAmat[i]; } for (i = 0; i < nElements; i++) { @@ -139,7 +154,7 @@ void Atom::addAtoms(int nAdded, double* Apos, double* for(i = 0; i < nAdded; i++) { j = i + nElements; - new_mu[j] = mu[i]; + new_mu[j] = Amu[i]; } delete[] pos; @@ -228,4 +243,47 @@ void Atom::deleteRange(int startIndex, int stopIndex) mu = new_mu; nElements = nNew; +} + + +void Atom::getPos( double theP[3] ){ + + theP[0] = pos[offsetX]; + theP[1] = pos[offsetY]; + theP[2] = pos[offsetZ]; } + +void Atom::setPos( double theP[3] ){ + + pos[offsetX] = theP[0]; + pos[offsetY] = theP[1]; + pos[offsetZ] = theP[2]; +} + +void Atom::getVel( double theV[3] ){ + + theV[0] = vel[offsetX]; + theV[1] = vel[offsetY]; + theV[2] = vel[offsetZ]; +} + +void Atom::setVel( double theV[3] ){ + + vel[offsetX] = theV[0]; + vel[offsetY] = theV[1]; + vel[offsetZ] = theV[2]; +} + +void Atom::getFrc( double theF[3] ){ + + theF[0] = frc[offsetX]; + theF[1] = frc[offsetY]; + theF[2] = frc[offsetZ]; +} + +void Atom::addFrc( double theF[3] ){ + + frc[offsetX] += theF[0]; + frc[offsetY] += theF[1]; + frc[offsetZ] += theF[2]; +}