Atoms.h

Structures for single and multiple atom positions.

These objects facilitate storage and manipulation of atom positions (and possibly velocities, but not currently), and calculation of non-cartesian components of stored quantities.

struct Atom
#include <Atoms.h>

Simple structure to hold information about a single atom.

Public Functions

void calculateRadius()

Calculate cylindrical radius \(r\) from \(x\) and \(y\) coordinates.

void print()

Print atom type and coordinates.

Public Members

double x
double y
double z
double r
int type
class AtomArray
#include <Atoms.h>

Data structure to hold information about multiple atoms.

Can get and set coordinates from Atom. This object must be instantiated after DatafileReader so that SimData::numAtoms is already defined since this value is used to determine the size of allocated arrays.

Atom positions for all timesteps in a frame are stored, which may lead to memory issues if Options::stepsPerFrame or SimData::numAtoms are very large.

Public Functions

void allocateArrays()

Allocate arrays.

Four arrays are allocated: x, y, z, r; each of which are of length numAtoms * stepsPerFrame. Since the last frame may have more steps than other frames, we use stepsPerFrame = simDataPtr->lastFrame.numSteps.

AtomArray(SimData &simData)

Sole constructor.

Parameters
  • simData: SimData object whose numAtoms member is already defined.

~AtomArray()
void setSimData(SimData &simData)

Set simDataPtr and number of atoms.

void setNumAtoms(int _numAtoms)
void setAtom(int atomNum, int stepInFrame, Atom &atom)

Copy data for atom atomNum at step stepInFrame to atom.

void getAtom(int atomNum, int stepInFrame, Atom &atom)

Copy data for atom atomNum at step stepInFrame from atom.

void printStats()

Print min, max, mean, std. of each x, y, z components of positions.

Public Members

int numAtoms
SimData *simDataPtr
int *type
double *x
double *y
double *z
double *r

Private Functions

void deallocateArrays()
int getIndex(int atomNum, int stepInFrame)

Return index of atom position in arrays.

Private Members

bool allocated

Whether the position arrays have been allocated.