This repository was archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLattice.cpp
More file actions
148 lines (118 loc) · 3.94 KB
/
Copy pathLattice.cpp
File metadata and controls
148 lines (118 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Lattice.cpp: implementation of the Lattice class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "LatticeRelaxation.h"
#include "Lattice.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Lattice::~Lattice()
{
}
long Lattice::getNumberOfAtoms()
{
return atoms.size();
}
long Lattice::getNumberOfMoveableAtoms()
{
long numberOfMoveableAtoms = 0;
std::deque<Atom*>::const_iterator atomsIterator;
for (atomsIterator = atoms.begin(); atomsIterator != atoms.end(); atomsIterator++) {
Atom* atom = *atomsIterator;
if (atom->moveable) {
numberOfMoveableAtoms++;
}
}
return numberOfMoveableAtoms;
}
/*
bool isMoveable(Atom& atom) {
return atom.moveable;
}
void Lattice::sortAtomsMoveableFirst() {
std::stable_partition(atoms.begin(),atoms.end(),isMoveable);
}
std::deque<AtomPair> Lattice::getMoveableNeighbourAtoms(const double maximumDistance)
{
long numberOfMoveableAtoms = getNumberOfMoveableAtoms();
long numberOfAtoms = getNumberOfAtoms();
std::deque<AtomPair> atomPairs;
std::deque<Atom*>::const_iterator atomsIt1, atomsIt2;
for (atomsIt1 = atoms.begin(); atomsIt1 != atoms.end(); atomsIt1++) {
Atom* atom1 = *atomsIt1;
for (atomsIt2 = atomsIt1 + 1; atomsIt2 != atoms.end(); atomsIt2++) {
Atom* atom2 = *atomsIt2;
if (fabs(atom1->r.x - atom2->r.x) > maximumDistance) continue;
if (fabs(atom1->r.y - atom2->r.y) > maximumDistance) continue;
if (fabs(atom1->r.z - atom2->r.z) > maximumDistance) continue;
Vector diff = atom1->r - atom2->r;
if (diff.getLength() < maximumDistance) {
atomPairs.push_back(AtomPair(atom1,atom2));
}
}
}
for (long i = 0; i < numberOfMoveableAtoms; i++) {
Atom& atomI = atoms[i];
for (long j = i + 1; j < numberOfAtoms; j++) {
Atom& atomJ = atoms[j];
if (fabs(atomI.r.x - atomJ.r.x) > maximumDistance) continue;
if (fabs(atomI.r.y - atomJ.r.y) > maximumDistance) continue;
if (fabs(atomI.r.z - atomJ.r.z) > maximumDistance) continue;
Vector diff = atomI.r - atomJ.r;
if (diff.getLength() < maximumDistance) {
atomPairs.push_back(AtomPair(&atomI,&atomJ));
}
}
}
return atomPairs;
}
*/
void Lattice::calculateAtomNeighbours(const double maximumDistance)
{
std::deque<Atom*>::const_iterator atomsIt1, atomsIt2;
for (atomsIt1 = atoms.begin(); atomsIt1 != atoms.end(); atomsIt1++) {
Atom* atom1 = *atomsIt1;
atom1->neigbours.clear();
atom1->mutexNeigbours.clear();
}
for (atomsIt1 = atoms.begin(); atomsIt1 != atoms.end(); atomsIt1++) {
Atom* atom1 = *atomsIt1;
//if (atom1->moveable) {
for (atomsIt2 = atomsIt1 + 1; atomsIt2 != atoms.end(); atomsIt2++) {
Atom* atom2 = *atomsIt2;
if (fabs(atom1->r.x - atom2->r.x) > maximumDistance) continue;
if (fabs(atom1->r.y - atom2->r.y) > maximumDistance) continue;
if (fabs(atom1->r.z - atom2->r.z) > maximumDistance) continue;
Vector diff = atom1->r - atom2->r;
if (diff.getLength() < maximumDistance) {
atom1->neigbours.push_back(atom2);
atom1->mutexNeigbours.push_back(atom2);
atom2->neigbours.push_back(atom1);
}
}
//}
}
/*long numberOfMoveableAtoms = getNumberOfMoveableAtoms();
long numberOfAtoms = getNumberOfAtoms();
for (long i = 0; i < numberOfMoveableAtoms; i++) {
Atom* atomI = atoms[i];
for (long j = i + 1; j < numberOfAtoms; j++) {
Atom* atomJ = atoms[j];
if (fabs(atomI->r.x - atomJ->r.x) > maximumDistance) continue;
if (fabs(atomI->r.y - atomJ->r.y) > maximumDistance) continue;
if (fabs(atomI->r.z - atomJ->r.z) > maximumDistance) continue;
Vector diff = atomI->r - atomJ->r;
if (diff.getLength() < maximumDistance) {
//atomPairs.push_back(AtomPair(&atomI,&atomJ));
atomI->neigbours.push_back(atomJ);
atomJ->neigbours.push_back(atomI);
}
}
}*/
}