Loading...
Searching...
No Matches
Atoms.h
Go to the documentation of this file.
1#ifndef ATOMS_H
2#define ATOMS_H
3
4#include <set>
5#include <vector>
6using std::set;
7using std::vector;
8#include "Vec.h" // Needed because we are destroying a vector<Vec> in
9 // Atoms::~Atoms(). (at least with the alpha compiler)
10
11class SuperCell;
12// class Vec;
13class AsapPotential;
14
15// Atomic positions are stored in a vector<Vec>:
16//
17// positions[0, ..., nAtoms - 1] :
18// real atoms
19//
20// positions[nAtoms, ..., nAtoms + nGhosts - 1] :
21// ghost atoms (from QC or Parallel)
22//
23// positions[nAtoms + nGhosts, ..., positions.size() - 1] :
24// image atoms (from periodic boundaries)
25
27
35
36class Atoms {
37public:
40 Atoms(const Vec *p, int n, SuperCell *s);
41
43 virtual ~Atoms() {};
44
46 virtual SuperCell *GetSuperCell() const { return superCell; }
47
49 virtual const Vec *GetUnitCell() const;
50
52 virtual void SetUnitCell(const Vec newbasis[3], bool fix);
53
56
59
61
65 inline void MarkChanged() { ++counter; }
66
68 inline int GetChangeCounter() const { return counter; }
69
71
75 virtual void SetCartesianPositions(const Vec *p);
76
78
86 virtual void GetCartesianPositions(Vec *p) const;
87
89
100 virtual const Vec *GetCartesianPositions() const { return &positions[0]; }
101
103
106 Vec *GetPositionsPtr() { return &positions[0]; }
107
110
113 virtual void GetUnwrappedPositions(vector<Vec> &p) const;
114
117
121 virtual void SetUnwrappedPositions(const Vec *p);
122
124 virtual void NormalizeDifferences(Vec *diff) const;
125
127 virtual void NormalizeDifference(Vec &diff) const;
128
131
138 virtual void NormalizePositions();
139
141
146 virtual void NormalizePosition(Vec &pos) const;
147
149
156 virtual void NormalizePosition(Vec &pos, Vec &scaled_translation) const;
157
159 virtual void ReNormalizePosition(Vec &pos, Vec &scaled_translation) const;
160
162 virtual void SetAtomicNumbers(const int *z);
163
165 virtual const int *GetAtomicNumbers() const { return &types[0]; }
166
168
171 int *GetAtomicNumbersPtr() { return &types[0]; }
172
174 virtual void GetListOfElements(set<int> &elements) const;
175
177 void SetNumberOfImages(int i);
178
180 int GetNumberOfImages() const { return nImages; }
181
183
190 virtual int GetNumberOfAtoms() const { return nAtoms; }
191
193
196 int GetNumberOfRealAtoms() const { return nAtoms; }
197
199 virtual void SetNumberOfAtoms(int n);
200
201protected:
204 vector<Vec> positions;
205 vector<Vec> pos_translations;
208 vector<int> types;
209 int nAtoms;
212};
213
214#endif // ATOMS_H
Abstract base class of all potentials.
Definition Potential.h:29
SuperCell * superCell
A pointer to the supercell.
Definition Atoms.h:203
int GetNumberOfImages() const
Get the number of images. Used by the neighbor list.
Definition Atoms.h:180
int GetChangeCounter() const
Get the change counter.
Definition Atoms.h:68
Vec * GetPositionsPtr()
Return a non-const pointer to the Cartesian positions. DANGEROUS!
Definition Atoms.h:106
Atoms(const Vec *p, int n, SuperCell *s)
Construct Atoms from array of positions, number of elements and a SuperCell.
int * GetAtomicNumbersPtr()
Return a non-const pointer to the atomic numbers. DANGEROUS!
Definition Atoms.h:171
virtual void NormalizePosition(Vec &pos, Vec &scaled_translation) const
Normalize a position which is not owned by the atoms.
int GetNumberOfRealAtoms() const
Get the number of atoms (excluding nodes in a QC simulation).
Definition Atoms.h:196
virtual void SetUnwrappedPositions(const Vec *p)
Set the positions from an array of positions not taking any wrapping into account.
virtual SuperCell * GetSuperCell() const
Return a pointer to the SuperCell object.
Definition Atoms.h:46
virtual void NormalizeDifference(Vec &diff) const
Apply periodic boundary conditions to difference in positions.
AsapPotential * GetPotential() const
Get a pointer to the Potential.
Definition Atoms.h:58
virtual const Vec * GetUnitCell() const
Return the unitcell vectors.
virtual void GetCartesianPositions(Vec *p) const
Return a copy of the Cartesian positions.
virtual void NormalizeDifferences(Vec *diff) const
Apply periodic boundary conditions to differences in positions.
virtual void SetUnitCell(const Vec newbasis[3], bool fix)
Set a new unit cell, rescaling the positions unless fix is true.
vector< int > types
Contains the atomic numbers.
Definition Atoms.h:208
virtual int GetNumberOfAtoms() const
Get the number of atoms (including nodes in a QC simulation).
Definition Atoms.h:190
int nImages
The number of image atoms used by NeighborList.
Definition Atoms.h:210
void SetNumberOfImages(int i)
Set the number of images. Used by the neighbor list.
int nAtoms
The number of atoms in the list.
Definition Atoms.h:209
virtual void SetAtomicNumbers(const int *z)
Set the atomic numbers. Should be done right after construction.
virtual const Vec * GetCartesianPositions() const
Return a const pointer to the Cartesian positions.
Definition Atoms.h:100
vector< Vec > pos_translations
Translations applied to the positions to conform with the periodic boundary conditions.
Definition Atoms.h:205
int counter
Used to track changes.
Definition Atoms.h:211
vector< Vec > positions
Contains the Cartesian positions.
Definition Atoms.h:204
virtual void NormalizePositions()
Apply periodic boundary conditions to the positions.
virtual const int * GetAtomicNumbers() const
Return a const pointer to the atomic numbers.
Definition Atoms.h:165
virtual void SetNumberOfAtoms(int n)
Change the number of atoms.
void MarkChanged()
Update the change pointer.
Definition Atoms.h:65
virtual ~Atoms()
Deletes the atoms. Does not delete Potential or SuperCell.
Definition Atoms.h:43
virtual void ReNormalizePosition(Vec &pos, Vec &scaled_translation) const
Repeat a normalization. See NormalizePosition(a,b).
virtual void SetCalculator(AsapPotential *potential)
Set a Potential. An eventual old Potential is not deallocated.
virtual void NormalizePosition(Vec &pos) const
Normalize a position which is not owned by the atoms.
virtual void GetUnwrappedPositions(vector< Vec > &p) const
Return the positions, hiding that they may have been wrapped due to the boundary conditions.
AsapPotential * potential
A pointer to the potential.
Definition Atoms.h:202
virtual void GetListOfElements(set< int > &elements) const
Get a set of all elements present in the simulations.
virtual void SetCartesianPositions(const Vec *p)
Set the Cartesian positions.
The SuperCell defines the size, shape and boundary condx of a simulation.
Definition SuperCell.h:20
A 3-vector useful for postions etc.
Definition Vec.h:18