Loading...
Searching...
No Matches
EMT.h
Go to the documentation of this file.
1
2
3#ifndef _EMT_H
4#define _EMT_H
5
7#include "Potential.h"
8#include "TinyMatrix.h"
9#include <vector>
10using std::vector;
11
12class AtomsBase;
13class Atoms;
14class GhostAtoms;
15class NeighborList;
16struct emt_parameters;
17
19
24class EMT : public AsapPotential {
25public:
28
30 virtual ~EMT();
31 void SetSubtractE0(bool subtractE0) { this->subtractE0 = subtractE0; }
32
33 virtual void SetAtoms(Atoms *atoms);
34 virtual const Vec *GetCartesianForces();
35 virtual const double *GetPotentialEnergies();
36 virtual double GetPotentialEnergy();
37 virtual const symTensor *GetStresses(const Vec *momenta = 0);
38 virtual void GetStress(double stress[6], const Vec *momenta = 0);
40 virtual void CheckNeighborLists();
41
42 virtual double GetCutoffRadius() const { return rNbCut; }
43 virtual double GetLatticeConstant() const;
44 virtual int GetNumberOfAtoms() const { return nAtoms; }
45
48 virtual void SetContinuumElement(int z);
49 virtual void UpdateSuperCell(const SuperCell *newSuperCell);
50
51 // Quasicontinuum stuff
52 virtual double CalculateLatticeEnergy(const Vec a[3]);
53 virtual void CalculateDerivatives(const Vec a[3], double dEdaDota[6]);
54 virtual double GetData() const { return dataSigma1; }
55
57 const double *GetSigma1(int n) { return &sigma1[n][0]; }
59 const double *GetSigma2(int n) { return &sigma2[n][0]; }
60
63
65 NeighborList *GetNeighborList() const { return nblist; }
66
67protected:
69 virtual void InitParameters();
71 virtual void Allocate();
73 virtual void AllocateStress();
75 virtual void CalculateIDs();
77 virtual void CalculateSigmas(int calculatesigma2 = 1);
79
82 virtual void CalculateEnergiesAfterSigmas(double *Epot = 0);
83
86 double stress[][6] = 0);
87
90 double stress[][6] = 0);
91
93 virtual void CalculateStuff(const Vec a[3], double &sigma1, double &sigma2,
94 double *diffs2, double *wght, double *dsigma1,
95 double *dsigma2);
96
97private: // Methods.
99
103 void sigma_batch(int *self, int *other, Vec rnb[], double *sq_dist, int zs,
104 int zo, int n, int calculatesigma2);
105
107
111 void force_batch(int *self, int *other, Vec rnb[], double *sq_dist,
112 double dEdss[], double dEdso[], int zs, int zo, int n,
113 Vec *force, double (*stress)[6]);
114
115protected: // Data
118 int nAtoms;
119 int nSize;
123
128
129 std::vector<const emt_parameters *> parameters;
135 double rFermi, rNbCut;
138 // int maxleaflen; // Lenght of the longest leaf.
140
142
145 vector<vector<double>> sigma1;
146 vector<vector<double>> sigma2;
147
149
150 vector<double> Ec;
151 vector<double> Eas;
152 vector<double> potentialenergy;
153 vector<double> radius;
154 vector<double> dEds;
155 vector<Vec> force;
157
160 vector<double> stress;
162
165
167 vector<int> id;
168
169 /* The buffers for batch processing */
170 // static const int BUFLEN; // The batch--buffer size. Avoid powers of 2
171 // static const int NMAXELEMENTS;
172
174 double totalvolume;
175
177 int (*coef)[6];
178 double dataSigma1;
179
181 struct {
182 int ids;
192};
193
194#endif // ! _EMT_H
TinyMatrix< double > TinyDoubleMatrix
Definition TinyMatrix.h:24
Abstract base class of all potentials.
Definition Potential.h:29
The main list of atoms class.
Definition Atoms.h:36
int nSize
Number of atoms including ghost atoms.
Definition EMT.h:119
int nelements
The number of different elements in the simulation.
Definition EMT.h:133
int(* coef)[6]
For the quasicontinuum stuff.
Definition EMT.h:177
struct EMT::@046145273270354152231013235041337011202147127021 counters
A structure of counters to check if recalculations are necessary.
virtual void CalculateForcesAfterEnergiesSingle(Vec *forces, double stress[][6]=0)
Calculate forces in a system with only one element.
virtual void SetContinuumElement(int z)
Specify the element in the continuum region of a QuasiContinuum simulation.
virtual ~EMT()
Delete the EMT potential.
int stresses
Definition EMT.h:189
vector< Vec > force
Definition EMT.h:155
int fullstresses
Definition EMT.h:190
int sigma2isvalid
For consistency checks.
Definition EMT.h:139
vector< double > stress
The stresses. Always remember to use six per atoms!
Definition EMT.h:160
virtual void UpdateSuperCell(const SuperCell *newSuperCell)
Tell the Potential that a new SuperCell has been assigned to the atoms.
virtual double CalculateLatticeEnergy(const Vec a[3])
Calculate the energy of an atom in a regular fcc(?) lattice.
vector< vector< double > > sigma2
Definition EMT.h:146
virtual void CalculateDerivatives(const Vec a[3], double dEdaDota[6])
Calculate derivative of the energy of an atom in a regular lattice.
const emt_parameters * continuumelement
The element in the continuum region.
Definition EMT.h:130
const TinyDoubleMatrix * chi
The Chi matrix of EMT.
Definition EMT.h:132
int energies
Definition EMT.h:187
double unnormalizedstress[6]
The total stress before division by volume.
Definition EMT.h:173
vector< double > radius
Definition EMT.h:153
virtual void CalculateStuff(const Vec a[3], double &sigma1, double &sigma2, double *diffs2, double *wght, double *dsigma1, double *dsigma2)
Internal function used for the QuasiContinuum stuff.
virtual void CalculateForcesAfterEnergies(Vec *forces, double stress[][6]=0)
Calculate forces in a multicomponent system.
virtual void GetStress(double stress[6], const Vec *momenta=0)
Calculate the total stress of the system.
virtual void AllocateStress()
(Re)allocate storage for stresses
EMTParameterProvider * provider
The source of the EMT parameters.
Definition EMT.h:121
int ids
Definition EMT.h:182
virtual double GetLatticeConstant() const
Return the lattice constant of the material, if well-defined.
bool ownProvider
May we delete the provider?
Definition EMT.h:122
double cutoffslope
Cutoff slope.
Definition EMT.h:137
NeighborList * nblist
The neighborlist object.
Definition EMT.h:120
int nSizeRes
If there are ghostatoms, some extra space is reserved for the arrays.
Definition EMT.h:163
int forces
Definition EMT.h:188
vector< double > potentialenergy
Definition EMT.h:152
virtual void CalculateEnergiesAfterSigmas(double *Epot=0)
Calculate energies once sigma1 is known.
double dataSigma1
For the quasicontinuum stuff.
Definition EMT.h:178
virtual double GetCutoffRadius() const
Return the cutoff radius used in the potential.
Definition EMT.h:42
bool subtractE0
Whether we subtract E0 from atomic energies (defines the zero of potential energy; if we don't subtra...
Definition EMT.h:124
EMT(EMTParameterProvider *prov=0)
Create an EMT potential optionally using a parameter provider.
vector< int > id
The atomic numbers are translated into IDs, integers in [0, nelements-1].
Definition EMT.h:167
double totalvolume
Total volume during stresscalculation.
Definition EMT.h:174
int nAtoms
The number of (real) atoms.
Definition EMT.h:118
GhostAtoms * ghostatoms
Non-NULL if atoms are GhostAtoms.
Definition EMT.h:117
NeighborList * GetNeighborList() const
Return a pointer to the neighbor list.
Definition EMT.h:65
double rNbCut
Definition EMT.h:135
int nHalfNeighbors
For the quasicontinuum stuff.
Definition EMT.h:176
void sigma_batch(int *self, int *other, Vec rnb[], double *sq_dist, int zs, int zo, int n, int calculatesigma2)
sigma_batch does the hard work in CalculateSigmas().
virtual const symTensor * GetStresses(const Vec *momenta=0)
Calculate the stress on all atoms.
virtual void Allocate()
(Re)allocate storage for forces, energies and intermediate results.
virtual const double * GetPotentialEnergies()
Calculate the energy of all atoms.
Atoms * atoms
The atoms we are working on.
Definition EMT.h:116
const double * GetSigma2(int n)
Return a pointer to the EMT "density" sigma2.
Definition EMT.h:59
virtual void InitParameters()
Initialization of the EMT parameters.
std::vector< const emt_parameters * > parameters
The EMT parameters.
Definition EMT.h:129
virtual void SetAtoms(Atoms *atoms)
Set the atoms belonging to this potential.
void force_batch(int *self, int *other, Vec rnb[], double *sq_dist, double dEdss[], double dEdso[], int zs, int zo, int n, Vec *force, double(*stress)[6])
force_batch does the hard work in CalculateForcesAfterEnergy().
int beforeforces
Definition EMT.h:186
void PrintParameters()
Print the EMT parameters.
int nAtomsRes
Definition EMT.h:163
vector< vector< double > > sigma1
Temporary data for the atoms.
Definition EMT.h:145
virtual const Vec * GetCartesianForces()
Calculate the forces on all atoms and return the result.
const double * GetSigma1(int n)
Return a pointer to the EMT "density" sigma1.
Definition EMT.h:57
virtual double GetPotentialEnergy()
Calculate the total energy of the system.
virtual double GetData() const
Get data used by the QuasiContinuum method.
Definition EMT.h:54
vector< double > Eas
Definition EMT.h:151
double rFermi
Cutoff parameters (from EMTParameterProvider).
Definition EMT.h:135
virtual int GetNumberOfAtoms() const
Get the number of atoms.
Definition EMT.h:44
void SetSubtractE0(bool subtractE0)
Definition EMT.h:31
virtual void CalculateSigmas(int calculatesigma2=1)
Calculate sigma1 and perhaps sigma2.
virtual void CheckNeighborLists()
Check that neighbor lists are up to date, update them if not.
vector< double > dEds
Definition EMT.h:154
virtual void CalculateIDs()
Calculate type numbers from the atomic numbers.
vector< double > Ec
Each atom has a single Ec, Eas, radius etc.
Definition EMT.h:150
"Half" neighbor lists for atoms.
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
double symTensor[6]
Definition Potential.h:13