24 #include "../Atomicrex.h" 25 #include "NeighborList.h" 26 #include "../job/FitObject.h" 27 #include "../properties/FitProperty.h" 28 #include "../properties/AtomVectorProperty.h" 29 #include "../dof/AtomCoordinatesDOF.h" 81 void setupSimulationCell(
const Matrix3& cellVectors,
const Point3& cellOrigin = Point3::Origin(),
const std::array<bool,3>&
pbc = std::array<bool,3>{{
true,
true,
true}});
112 bool hasPBC(
size_t dimension)
const {
return _pbc[dimension]; }
118 const std::array<bool,3>&
pbc()
const {
return _pbc; }
172 std::copy(newPositions.begin(), newPositions.end(), _atomPositions.begin());
186 int atomType(
int i)
const {
return _atomTypes[i]; }
189 const std::vector<int>&
atomTypes()
const {
return _atomTypes; }
195 const std::vector<int>&
atomTags()
const {
return _atomTags; }
210 const std::vector< std::pair<int,int> >&
forwardMapping()
const {
return _forwardMapping; }
217 T*
perAtomData() {
return _perAtomPotentialData.empty() ? nullptr :
reinterpret_cast<T*
>(&_perAtomPotentialData.front()); }
221 auto nl = _neighborLists.find(potential);
222 BOOST_ASSERT(nl != _neighborLists.end());
267 double computeEnergy(
bool computeForces,
bool isFitting,
bool suppressRelaxation =
false);
273 bool relax(
bool isFitting);
302 const std::array<double,6>&
virial()
const {
return _virial; }
308 std::array<double,6>&
virial() {
return _virial; }
333 void computeElasticConstants(
bool isFitting);
339 Matrix3 _simulationCell;
341 Point3 _simulationCellOrigin;
343 Matrix3 _reciprocalSimulationCell;
345 std::array<bool,3> _pbc;
354 double _skinThickness;
356 std::vector<Point3> _atomPositions;
358 std::vector<Point3> _lastNeighborUpdatePositions;
360 Matrix3 _lastSimulationCell;
362 Vector3I _ghostAtomImages;
364 std::vector<Point3> _atomDisplacements;
366 std::vector<Point3> _atomInitialPositions;
368 std::vector<int> _atomTypes;
370 std::vector<int> _atomTags;
372 std::vector<std::pair<int,int>> _forwardMapping;
374 std::vector<int> _reverseMapping;
376 std::vector<unsigned char> _perAtomPotentialData;
378 std::vector<Vector3> _ghostAtomPBCImages;
381 std::map<const Potential*, NeighborList> _neighborLists;
394 std::array<double,6> _virial;
const std::vector< int > & atomTypes() const
Returns the array of types of all atoms in the cell (const version).
Definition: AtomicStructure.h:189
int atomType(int i) const
Returns the type of a i-th atom.
Definition: AtomicStructure.h:186
Base class for maintaining structures.
Definition: AtomicStructure.h:42
double pressureTensor(int voigtIndex) const
Returns a component of the pressure tensor.
Definition: AtomicStructure.h:314
const Matrix3 & reciprocalSimulationCell() const
The inverse of the simulation cell matrix used to transform absolute coordinates to reduced coordinat...
Definition: AtomicStructure.h:105
neighbor lists require updating
Definition: AtomicStructure.h:51
void setAtomPositions(const std::vector< Point3 > &newPositions)
Sets the array of positions of all atoms in the structure cell.
Definition: AtomicStructure.h:170
Point3 reducedToAbsolute(const Point3 &reducedPoint) const
Converts a point given in reduced cell coordinates to a point in absolute coordinates.
Definition: AtomicStructure.h:132
void deformSimulationCell(const Matrix3 &deformation)
Applies an affine transformation to the cell and the atoms.
Definition: AtomicStructure.cpp:118
void setDirty(DirtyFlags flags)
Marks parts of the structure that must be updated before the next energy calculation.
Definition: AtomicStructure.h:229
double computeEnergy(bool computeForces, bool isFitting, bool suppressRelaxation=false)
Computes the total energy and optionally the forces for this structure.
Definition: AtomicStructure.cpp:528
void writeToPoscarFile(const FPString &filename, bool includeGhostAtoms=false) const
Exports the structure to a POSCAR file.
Definition: AtomicStructure.cpp:796
virtual bool computeProperties(bool isFitting) override
Computes all enabled properties of the structures.
Definition: AtomicStructure.cpp:400
Definition: NeighborList.h:58
Point3 wrapReducedPoint(Point3 p) const
Wraps a point given in reduced coordinated to be inside the simulation cell.
Definition: AtomicStructure.cpp:162
bool isDirty(DirtyFlags parts) const
Tests whether certain parts of the structure must be updated before the next energy calculation...
Definition: AtomicStructure.h:232
std::vector< int > & atomTypes()
Returns the array of types of all atoms in the cell (non-const version).
Definition: AtomicStructure.h:192
Vector3 reducedToAbsolute(const Vector3 &reducedVec) const
Converts a vector given in reduced cell coordinates to a vector in absolute coordinates.
Definition: AtomicStructure.h:138
const std::vector< Point3 > & atomInitialPositions() const
Returns the initial positions of the all real atoms they had at the beginning of the job...
Definition: AtomicStructure.h:183
const std::vector< Point3 > & atomPositions() const
Returns the array of positions of all atoms (including ghosts) in the structure (const version)...
Definition: AtomicStructure.h:161
const std::array< double, 6 > & virial() const
Returns the virial tensor computed by the force routine.
Definition: AtomicStructure.h:302
const std::vector< Vector3 > & values() const
Returns the current computed values of the vector property.
Definition: AtomVectorProperty.h:72
std::vector< Point3 > & atomPositions()
Returns the array of positions of all atoms (including ghosts) in the structure cell (non-const versi...
Definition: AtomicStructure.h:164
const std::array< bool, 3 > & pbc() const
Returns the periodic boundary condition flags.
Definition: AtomicStructure.h:118
int numLocalAtoms() const
Returns the number of (real) atoms in the structure cell.
Definition: AtomicStructure.h:152
AtomCoordinatesDOF _atomCoordinatesDOF
This DOF encapsulates the atomic degrees of freedom.
Definition: AtomicStructure.h:422
Vector3I periodicImage(const Point3 &p) const
Determines the periodic image of the cell the given point is located in.
Definition: AtomicStructure.cpp:135
T * perAtomData()
Returns a pointer to the memory buffer that stores temporary per-atom data used by the potential rout...
Definition: AtomicStructure.h:217
virtual void dofValueChanged(DegreeOfFreedom &dof) override
This callback function is called by the DOFs of the structure each time when their values changes...
Definition: AtomicStructure.h:241
DirtyFlags
Flags that indicate which parts of the structure need to be updated prior to the next energy calculat...
Definition: AtomicStructure.h:49
bool relax(bool isFitting)
Relaxes the structural degrees of freedom such that the total energy is minimized.
Definition: AtomicStructure.cpp:440
AtomVectorProperty & atomForcesProperty()
Returns the property for the atomic force vectors.
Definition: AtomicStructure.h:207
const std::vector< int > & reverseMapping() const
Returns an array of integers that maps the ghost atoms to the real atoms.
Definition: AtomicStructure.h:213
virtual void dofValueChanged(DegreeOfFreedom &dof)
This callback function is called by the DOFs of this fit object each time when their values changes...
Definition: FitObject.h:95
virtual void updateStructure()
Updates the structure, creates ghost atoms and builds neighbor lists.
Definition: AtomicStructure.cpp:200
ScalarFitProperty _pressureTensorProperty[6]
The components of the cell's pressure tensor.
Definition: AtomicStructure.h:409
Vector3 absoluteToReduced(const Vector3 &worldVec) const
Converts a vector given in absolute coordinates to a point in vector cell coordinates.
Definition: AtomicStructure.h:141
This DOF manages the atomic positions in a structure.
Definition: AtomCoordinatesDOF.h:37
std::vector< Vector3 > & atomForces()
Returns the array of force vectors (non-const version).
Definition: AtomicStructure.h:204
std::array< double, 6 > & virial()
Returns a reference to the virial tensor.
Definition: AtomicStructure.h:308
double pressure() const
Returns the hydrostatic part of the pressure tensor.
Definition: AtomicStructure.h:320
const std::vector< Vector3 > & atomForces() const
Returns the array of force vectors (const version).
Definition: AtomicStructure.h:201
Point3 absoluteToReduced(const Point3 &worldPoint) const
Converts a point given in absolute coordinates to a point in reduced cell coordinates.
Definition: AtomicStructure.h:135
AtomVectorProperty _atomForcesProperty
The force vector.
Definition: AtomicStructure.h:419
ScalarFitProperty _pressureProperty
One third of the trace of the cell's pressure tensor.
Definition: AtomicStructure.h:411
void clearDirty(DirtyFlags parts)
Resets the dirty flags.
Definition: AtomicStructure.h:235
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
ScalarFitProperty _atomicVolumeProperty
The average volume per atom in the structure cell.
Definition: AtomicStructure.h:406
double totalEnergy() const
Returns the total potential energy of this structure after computeEnergy() has been called...
Definition: AtomicStructure.h:299
Point3 wrapPoint(Point3 p) const
Wraps a point to be inside the simulation cell if periodic boundary conditions are enabled...
Definition: AtomicStructure.cpp:146
void setAtomCount(int numLocalAtoms)
Resizes the atoms array.
Definition: AtomicStructure.cpp:177
void writeToFile()
Exports the structure to file if a filename has been provided.
Definition: AtomicStructure.cpp:780
ghost atom positions require updating
Definition: AtomicStructure.h:53
ScalarFitProperty _totalVolumeProperty
The total volume of the structure cell.
Definition: AtomicStructure.h:404
const std::vector< Point3 > & atomDisplacements() const
Returns the array of displacements of all atoms in the structure cell wrt a reference structure (cons...
Definition: AtomicStructure.h:177
bool hasPBC(size_t dimension) const
Returns whether periodic boundary conditions are enabled in the given spatial dimension.
Definition: AtomicStructure.h:112
std::string FPString
The default string type used throughout the code:
Definition: Atomicrex.h:70
int numGhostAtoms() const
Returns the number of ghost atoms in the structure cell.
Definition: AtomicStructure.h:155
void setupSimulationCell(const Matrix3 &cellVectors, const Point3 &cellOrigin=Point3::Origin(), const std::array< bool, 3 > &pbc=std::array< bool, 3 >{{true, true, true}})
Set up the simulation cell.
Definition: AtomicStructure.cpp:97
std::vector< int > & atomTags()
Returns the array of IDs of the atoms in the cell (non-const version).
Definition: AtomicStructure.h:198
Definition: XMLUtilities.h:69
Definition: FitObject.h:42
OutputFormat
Possible formats for writing the structure to file.
Definition: AtomicStructure.h:61
virtual void parse(XML::Element structureElement) override
Parses the structure-specific parameters in the XML element in the job file.
Definition: AtomicStructure.cpp:910
ScalarFitProperty _elasticConstantProperties[21]
The elastic constants.
Definition: AtomicStructure.h:416
const Matrix3 & simulationCell() const
Returns global simulation cell matrix.
Definition: AtomicStructure.h:93
FitJob * job() const
Returns a pointer to the job to which this object belongs.
Definition: FitObject.h:150
const Point3 & simulationCellOrigin() const
The origin point of the global simulation cell in world coordinates.
Definition: AtomicStructure.h:99
Base class for all degrees of freedom a potential or a structure may have.
Definition: DegreeOfFreedom.h:46
std::vector< Point3 > & atomDisplacements()
Returns the array of displacements of all atoms in the structure cell wrt a reference structure (non-...
Definition: AtomicStructure.h:180
const std::vector< int > & atomTags() const
Returns the array of IDs of the atoms in the cell (const version).
Definition: AtomicStructure.h:195
ScalarFitProperty _atomicEnergyProperty
Output of the per atom energy calculation that can be used for fitting.
Definition: AtomicStructure.h:401
degree(s) of freedom requires updating
Definition: AtomicStructure.h:55
const std::vector< std::pair< int, int > > & forwardMapping() const
Returns an array of integer pairs that map the real atoms to the ghost atoms.
Definition: AtomicStructure.h:210
Definition: FitProperty.h:126
void writeToDumpFile(const FPString &filename, bool includeGhostAtoms=false) const
Exports the structure to a LAMMPS dump file.
Definition: AtomicStructure.cpp:848
ScalarFitProperty _totalEnergyProperty
Output of the energy calculation that can be used for fitting.
Definition: AtomicStructure.h:399
ScalarFitProperty _bulkModulusProperty
The bulk modulus of the lattice.
Definition: AtomicStructure.h:414
Definition: AtomVectorProperty.h:32
int numAtoms() const
Returns the total number of atoms in the structure cell including real and ghost atoms.
Definition: AtomicStructure.h:158
Base class for potential.
Definition: Potential.h:41