atomicrex  0.1
An advanced atomistic model building tool
MEAMPotential.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 "Potential.h"
25 #include "functions/Functions.h"
26 
27 namespace atomicrex {
28 
75 class MEAMPotential : public Potential
76 {
77 public:
78 
80  MEAMPotential(const FPString& id, FitJob* job) : Potential(id, job, "MEAM") {}
81 
83  virtual double cutoff() const override { return _cutoff; }
84 
86  virtual double computeEnergyAndForces(AtomicStructure& structure, NeighborList& neighborList) override;
87 
89  virtual double computeEnergy(AtomicStructure& structure, NeighborList& neighborList) override;
90 
92  virtual void parse(XML::Element potentialElement) override;
93 
96  virtual size_t perAtomDataSize() const override { return sizeof(double); }
97 
100  virtual size_t perBondDataSize() const override { return sizeof(MEAMBondData); }
101 
103  FunctionBase* pairPotential(int speciesA, int speciesB) const {
104  return _pairPotentialMap[speciesA * job()->numAtomTypes() + speciesB];
105  }
106 
108  FunctionBase* electronDensity(int speciesA, int speciesB) const {
109  return _electronDensityMap[speciesA * job()->numAtomTypes() + speciesB];
110  }
111 
113  FunctionBase* embeddingEnergy(int species) const {
114  return _embeddingEnergyMap[species];
115  }
116 
118  FunctionBase* ffunction(int speciesA, int speciesB) const {
119  return _ffunctionMap[speciesA * job()->numAtomTypes() + speciesB];
120  }
121 
123  FunctionBase* gfunction(int speciesA, int speciesB, int speciesC) const {
124  return _gfunctionMap[speciesA * job()->numAtomTypes() * job()->numAtomTypes() + speciesB * job()->numAtomTypes() + speciesC];
125  }
126 
129  for(const auto& f : _functions)
130  if(f && f->id() == id) return f.get();
131  return nullptr;
132  }
133 
135  virtual void outputResults() override;
136 
138  void writeTables(const FPString& basename) const;
139 
140 private:
141 
143  std::vector<std::shared_ptr<FunctionBase>> _functions;
144 
146  std::vector<FunctionBase*> _pairPotentialMap;
147 
149  std::vector<FunctionBase*> _electronDensityMap;
150 
152  std::vector<FunctionBase*> _embeddingEnergyMap;
153 
155  std::vector<FunctionBase*> _ffunctionMap;
156 
158  std::vector<FunctionBase*> _gfunctionMap;
159 
161  double _cutoff;
162 
164  FPString _exportFunctionsFile;
165 
166  // Helper data structure used to store temporary per-bond values during energy/force calculation.
167  struct MEAMBondData {
168  double f, fprime;
169  };
170 };
171 
172 } // End of namespace
Base class for maintaining structures.
Definition: AtomicStructure.h:42
int numAtomTypes() const
Returns the number of atom types used in this job.
Definition: FitJob.h:63
FunctionBase * pairPotential(int speciesA, int speciesB) const
Returns the pair potential function for the interaction between the given atom types.
Definition: MEAMPotential.h:103
Definition: NeighborList.h:58
MEAMPotential(const FPString &id, FitJob *job)
Constructor.
Definition: MEAMPotential.h:80
void writeTables(const FPString &basename) const
Writes the tabulated functionals to a set of text files for visualization with Gnuplot.
Definition: MEAMPotential.cpp:429
FunctionBase * ffunction(int speciesA, int speciesB) const
Returns the f-function for the given pair of atom types.
Definition: MEAMPotential.h:118
virtual double computeEnergyAndForces(AtomicStructure &structure, NeighborList &neighborList) override
Computes the total energy and forces of the structure.
Definition: MEAMPotential.cpp:92
FunctionBase * electronDensity(int speciesA, int speciesB) const
Returns the electron density function for the given pair of atom types.
Definition: MEAMPotential.h:108
virtual size_t perAtomDataSize() const override
Definition: MEAMPotential.h:96
FunctionBase * embeddingEnergy(int species) const
Returns the embedding energy function for the given atom type.
Definition: MEAMPotential.h:113
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
virtual double cutoff() const override
Returns the maximum cutoff of the potential.
Definition: MEAMPotential.h:83
const FPString & id() const
Returns the identifier of this object instance.
Definition: FitObject.h:138
This class defines general modified embedded atom method (MEAM) potentials.
Definition: MEAMPotential.h:75
std::string FPString
The default string type used throughout the code:
Definition: Atomicrex.h:70
FunctionBase * gfunction(int speciesA, int speciesB, int speciesC) const
Returns the f-function for the given triplet of atom types.
Definition: MEAMPotential.h:123
Definition: XMLUtilities.h:69
Definition: FitJob.h:37
virtual size_t perBondDataSize() const override
Definition: MEAMPotential.h:100
FitJob * job() const
Returns a pointer to the job to which this object belongs.
Definition: FitObject.h:150
virtual double computeEnergy(AtomicStructure &structure, NeighborList &neighborList) override
Computes the total energy of the structure.
Definition: MEAMPotential.cpp:35
Base class for all one-dimensional functions that can be fitted.
Definition: Functions.h:35
virtual void parse(XML::Element potentialElement) override
Parses any potential-specific parameters in the XML element in the job file.
Definition: MEAMPotential.cpp:290
virtual void outputResults() override
This function is called by the fit job on shutdown, i.e. after the fitting process has finished...
Definition: MEAMPotential.cpp:416
FunctionBase * findFunctionById(const FPString &id) const
Returns the function with the given ID, or nullptr if no such function is defined.
Definition: MEAMPotential.h:128
Base class for potential.
Definition: Potential.h:41