eOn client
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
EffectiveMediumTheory.cpp
Go to the documentation of this file.
1
/*
2
** This file is part of eOn.
3
**
4
** SPDX-License-Identifier: BSD-3-Clause
5
**
6
** Copyright (c) 2010--present, eOn Development Team
7
** All rights reserved.
8
**
9
** Repo:
10
** https://github.com/TheochemUI/eOn
11
*/
12
13
#include "
eon/potentials/EMT/EffectiveMediumTheory.h
"
14
15
#include <cstring>
16
#include <vector>
17
18
void
EffectiveMediumTheory::cleanMemory
() {
19
delete
EMTObj
;
20
EMTObj
=
nullptr
;
21
delete
SuperCellObj
;
22
SuperCellObj
=
nullptr
;
23
delete
AtomsObj
;
24
AtomsObj
=
nullptr
;
25
delete
EMTParameterObj
;
26
EMTParameterObj
=
nullptr
;
27
}
28
29
// pointer to number of atoms, pointer to array of positions
30
// pointer to array of forces, pointer to internal energy
31
// adress to supercell size
32
void
EffectiveMediumTheory::force
(
long
N,
const
double
*R,
const
int
*atomicNrs,
33
double
*F,
double
*U,
double
*variance,
34
const
double
*box) {
35
variance =
nullptr
;
36
37
// Copy positions (Asap may modify them internally)
38
std::vector<double> pos(R, R + 3 * N);
39
40
// Reinitialize if atom count changed
41
if
(
numberOfAtoms
!= N) {
42
numberOfAtoms
= N;
43
cleanMemory
();
44
45
Vec
tempBasis[3] = {
46
Vec
(box[0], box[1], box[2]),
47
Vec
(box[3], box[4], box[5]),
48
Vec
(box[6], box[7], box[8]),
49
};
50
51
SuperCellObj
=
new
SuperCell
(tempBasis,
periodicity
);
52
AtomsObj
=
new
Atoms
(
reinterpret_cast<
Vec
*
>
(pos.data()), N,
SuperCellObj
);
53
54
std::vector<int> atomicNrsTemp(atomicNrs, atomicNrs + N);
55
AtomsObj
->SetAtomicNumbers(atomicNrsTemp.data());
56
57
if
(
emtRasmussen
) {
58
EMTParameterObj
=
new
EMTRasmussenParameterProvider
();
59
EMTObj
=
new
EMT
(
EMTParameterObj
);
60
}
else
{
61
EMTObj
=
new
EMT
(
nullptr
);
62
}
63
AtomsObj
->SetCalculator(
EMTObj
);
64
}
65
66
AtomsObj
->SetCartesianPositions(
reinterpret_cast<
Vec
*
>
(pos.data()));
67
68
// Update the box
69
Vec
tempBasis[3] = {
70
Vec
(box[0], box[1], box[2]),
71
Vec
(box[3], box[4], box[5]),
72
Vec
(box[6], box[7], box[8]),
73
};
74
AtomsObj
->SetUnitCell(tempBasis,
true
);
75
76
*U =
EMTObj
->GetPotentialEnergy();
77
78
const
Vec
*tempF =
EMTObj
->GetCartesianForces();
79
std::memcpy(F, tempF, N *
sizeof
(
Vec
));
80
}
EffectiveMediumTheory.h
Atoms
The main list of atoms class.
Definition
Atoms.h:36
EMTRasmussenParameterProvider
Definition
EMTRasmussenParameterProvider.h:29
EMT
The Effective Medium Theory (EMT) potential.
Definition
EMT.h:24
EffectiveMediumTheory::AtomsObj
Atoms * AtomsObj
Definition
EffectiveMediumTheory.h:35
EffectiveMediumTheory::force
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
Definition
EffectiveMediumTheory.cpp:32
EffectiveMediumTheory::SuperCellObj
SuperCell * SuperCellObj
Definition
EffectiveMediumTheory.h:38
EffectiveMediumTheory::periodicity
bool periodicity[3]
Definition
EffectiveMediumTheory.h:34
EffectiveMediumTheory::numberOfAtoms
long numberOfAtoms
Definition
EffectiveMediumTheory.h:33
EffectiveMediumTheory::emtRasmussen
bool emtRasmussen
Definition
EffectiveMediumTheory.h:32
EffectiveMediumTheory::cleanMemory
void cleanMemory()
Definition
EffectiveMediumTheory.cpp:18
EffectiveMediumTheory::EMTParameterObj
EMTDefaultParameterProvider * EMTParameterObj
Definition
EffectiveMediumTheory.h:36
EffectiveMediumTheory::EMTObj
EMT * EMTObj
Definition
EffectiveMediumTheory.h:37
SuperCell
The SuperCell defines the size, shape and boundary condx of a simulation.
Definition
SuperCell.h:20
Vec
A 3-vector useful for postions etc.
Definition
Vec.h:18
client
potentials
EMT
EffectiveMediumTheory.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf