atomicrex  0.1
An advanced atomistic model building tool
CDIPotential.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 
29 /************************************************************
30  * Class for pair-wise interactions that are concentration
31  * dependent.
32  *
33  * Each interaction (between two species A and B) consists of
34  * a potential function V(r) and an interpolation function h(x).
35  * The concentration x is computed from the local density
36  * of the matrix species S.
37  ************************************************************/
39 {
40 public:
41 
43  CDIPairInteraction(const FPString& id, FitJob* job, int atomTypeA, int atomTypeB, int matrix, const std::shared_ptr<FunctionBase>& V, const std::shared_ptr<FunctionBase>& h)
44  : FitObject(id, job), _atomTypeA(atomTypeA), _atomTypeB(atomTypeB), _matrix(matrix), _V(V), _sigmaInverseArgument(new FunctionInverseArgument("CDIPHFunction", job, h)) {
45  registerSubObject(V.get());
46  registerSubObject(h.get());
47  }
48 
50  int atomTypeA() const { return _atomTypeA; }
51  int atomTypeB() const { return _atomTypeB; }
52 
54  int matrix() const { return _matrix; }
55 
57  bool interacting(int type_i, int type_j) const {
58  if(type_i == _atomTypeA && type_j == _atomTypeB) return true;
59  if(type_i == _atomTypeB && type_j == _atomTypeA) return true;
60  return false;
61  }
62 
64  const std::shared_ptr<FunctionBase>& V() const { return _V; }
65 
67  const std::shared_ptr<FunctionInverseArgument>& h() const { return _sigmaInverseArgument; }
68 
69 private:
70 
73  int _atomTypeA, _atomTypeB, _matrix;
74 
76  std::shared_ptr<FunctionBase> _V;
77 
79  std::shared_ptr<FunctionInverseArgument> _sigmaInverseArgument;
80 };
81 
82 
83 /************************************************************
84  * Composition-dependent interatomic potential (CDIP).
85  ************************************************************/
86 class CDIPotential : public Potential
87 {
88 public:
89 
91  CDIPotential(const FPString& id, FitJob* job) : Potential(id, job, "CDIP"),
92  _linearizedMode(false), _legacyMode(false) {}
93 
95  virtual double cutoff() const override { return _cutoff; }
96 
98  virtual double computeEnergy(AtomicStructure& structure, NeighborList& neighborList) override;
99 
101  virtual double computeEnergyAndForces(AtomicStructure& structure, NeighborList& neighborList) override;
102 
104  virtual void outputResults() override;
105 
107  void writePotential(const FPString& filename) const;
108 
110  void writeTables(const FPString& basename) const;
111 
112 public:
113 
115  virtual void parse(XML::Element potentialElement) override;
116 
119  virtual XML::OElement generateXMLDefinition() override;
120 
121 private:
122 
124  void parseSigmas(XML::Element parentElement);
125 
127  void parseInteractions(XML::Element parentElement);
128 
130  double _cutoff;
131 
134  int _linearizedMode;
135 
139  int _legacyMode;
140 
142  std::vector<std::shared_ptr<FunctionBase>> _sigmas;
143 
145  std::vector<std::shared_ptr<CDIPairInteraction>> _pairInteractions;
146 
148  FPString _exportPotentialFile;
149 
151  FPString _exportFunctionsFile;
152 };
153 
154 } // End of namespace
Base class for maintaining structures.
Definition: AtomicStructure.h:42
CDIPairInteraction(const FPString &id, FitJob *job, int atomTypeA, int atomTypeB, int matrix, const std::shared_ptr< FunctionBase > &V, const std::shared_ptr< FunctionBase > &h)
Constructor.
Definition: CDIPotential.h:43
const std::shared_ptr< FunctionBase > & V() const
Returns the pair potential function.
Definition: CDIPotential.h:64
int matrix() const
Returns the atomic species whose concentration controls the interaction strength. ...
Definition: CDIPotential.h:54
virtual void parse(XML::Element element)
Parses the base parameters, common to structures, groups, and potentials, from the XML element in the...
Definition: FitObject.cpp:149
Definition: NeighborList.h:58
void registerSubObject(FitObject *subobject, bool deleteOnShutdown=false)
Registers a sub-object.
Definition: FitObject.cpp:57
Definition: CDIPotential.h:86
int atomTypeA() const
Returns the atom type indices whose interaction is described by this object.
Definition: CDIPotential.h:50
CDIPotential(const FPString &id, FitJob *job)
Constructor.
Definition: CDIPotential.h:91
Definition: Functions.h:406
Definition: CDIPotential.h:38
virtual double cutoff() const override
Returns the maximum cutoff of the potential.
Definition: CDIPotential.h:95
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
const std::shared_ptr< FunctionInverseArgument > & h() const
Returns the interpolation function.
Definition: CDIPotential.h:67
Base class for potential.
Definition: Potential.h:41
bool interacting(int type_i, int type_j) const
Returns whether the interaction between the two given atom types is described by this pair interactio...
Definition: CDIPotential.h:57