atomicrex  0.1
An advanced atomistic model building tool
Potential.h
1 //
3 // Copyright (C) 2017, Alexander Stukowski and Paul Erhart
4 //
5 // This file is part of atomicrex.
6 //
7 // Atomicrex is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Atomicrex is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //
21 
22 #pragma once
23 
24 #include "../Atomicrex.h"
25 #include "../job/FitObject.h"
26 #include "../job/FitJob.h"
27 
28 namespace atomicrex {
29 
30 class AtomicStructure; // Declared in AtomicStructure.h
31 class NeighborList; // Declared in NeighborList.h
32 class DegreeOfFreedom; // Declared in DegreeOfFreedom.h
33 
41 class Potential : public FitObject
42 {
43 public:
44 
46  Potential(const FPString& id, FitJob* job, const FPString& tag = FPString());
47 
49  void enableInteraction(int speciesA, int speciesB) {
50  BOOST_ASSERT(_interactionFlags.size() == job()->numAtomTypes());
51  BOOST_ASSERT(speciesA >= 0 && speciesA < _interactionFlags.size());
52  BOOST_ASSERT(_interactionFlags[speciesA].size() == job()->numAtomTypes());
53  BOOST_ASSERT(speciesB >= 0 && speciesB < _interactionFlags[speciesA].size());
54  BOOST_ASSERT(_atomTypeFlags.size() == job()->numAtomTypes());
55  _interactionFlags[speciesA][speciesB] = true;
56  _interactionFlags[speciesB][speciesA] = true;
57  _atomTypeFlags[speciesA] = true;
58  _atomTypeFlags[speciesB] = true;
59  }
60 
62  bool interacting(int speciesA, int speciesB) const {
63  BOOST_ASSERT(_interactionFlags.size() == job()->numAtomTypes());
64  BOOST_ASSERT(speciesA >= 0 && speciesA < _interactionFlags.size());
65  BOOST_ASSERT(_interactionFlags[speciesA].size() == job()->numAtomTypes());
66  BOOST_ASSERT(speciesB >= 0 && speciesB < _interactionFlags[speciesA].size());
67  return _interactionFlags[speciesA][speciesB];
68  }
69 
72  bool isAtomTypeEnabled(int species) const {
73  BOOST_ASSERT(_atomTypeFlags.size() == job()->numAtomTypes());
74  BOOST_ASSERT(species >= 0 && species < _atomTypeFlags.size());
75  return _atomTypeFlags[species];
76  }
77 
79  virtual double cutoff() const = 0;
80 
82  virtual double computeEnergyAndForces(AtomicStructure& structure, NeighborList& neighborList) = 0;
83 
85  virtual double computeEnergy(AtomicStructure& structure, NeighborList& neighborList) = 0;
86 
89  virtual void outputResults();
90 
94  virtual size_t perAtomDataSize() const { return 0; }
95 
99  virtual size_t perBondDataSize() const { return 0; }
100 
101 public:
102 
104  virtual void parse(XML::Element potentialElement) override;
105 
109  virtual void preparePotential() {}
110 
114 
115 private:
116 
119  std::vector<bool> _atomTypeFlags;
120 
123  std::vector<std::vector<bool>> _interactionFlags;
124 
126  FPString _outputDefinitionFile;
127 };
128 
129 } // End of namespace
Base class for maintaining structures.
Definition: AtomicStructure.h:42
virtual double computeEnergyAndForces(AtomicStructure &structure, NeighborList &neighborList)=0
Computes the total energy and forces of the structure.
int numAtomTypes() const
Returns the number of atom types used in this job.
Definition: FitJob.h:63
virtual void parse(XML::Element potentialElement) override
Parses any potential-specific parameters in the XML element in the job file.
Definition: Potential.cpp:76
void enableInteraction(int speciesA, int speciesB)
Enables the interaction between two atom types.
Definition: Potential.h:49
Definition: NeighborList.h:58
virtual void preparePotential()
Definition: Potential.h:109
const FPString & tag() const
Returns the assigned tag string.
Definition: FitObject.h:144
bool interacting(int speciesA, int speciesB) const
Returns whether the interaction between two atom types is enabled for this potential.
Definition: Potential.h:62
bool isAtomTypeEnabled(int species) const
Definition: Potential.h:72
Potential(const FPString &id, FitJob *job, const FPString &tag=FPString())
Constructor.
Definition: Potential.cpp:35
virtual double cutoff() const =0
Returns the maximum cutoff of the potential.
virtual size_t perAtomDataSize() const
Definition: Potential.h:94
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
std::string FPString
The default string type used throughout the code:
Definition: Atomicrex.h:70
Definition: XMLUtilities.h:226
Definition: XMLUtilities.h:69
Definition: FitObject.h:42
Definition: FitJob.h:37
FitJob * job() const
Returns a pointer to the job to which this object belongs.
Definition: FitObject.h:150
virtual size_t perBondDataSize() const
Definition: Potential.h:99
virtual void outputResults()
Definition: Potential.cpp:52
virtual double computeEnergy(AtomicStructure &structure, NeighborList &neighborList)=0
Computes the total energy of the structure.
virtual XML::OElement generateXMLDefinition()
Definition: Potential.h:113
Base class for potential.
Definition: Potential.h:41