00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "fcclattice.h"
00019 #include "cluster.h"
00020 #include "coordinate.h"
00021 #include <cmath>
00022
00023 FCC_Lattice::FCC_Lattice()
00024 {}
00025
00026 void FCC_Lattice::createLattice(int baseSize, double reducedDensity, Cluster &cluster) const
00027 {
00028 double latticeSize = 0.0;
00029 Coordinate start1, start2, start3, start4;
00030 int numAtoms = 0;
00031
00032 cluster.clear();
00033 latticeSize = pow((4.0/reducedDensity),(1.0/3.0));
00034 int size = 4 * int(pow((double)baseSize, 3.0));
00035 for (int i = 0; i < size; i++)
00036 cluster.addAtom(Atom());
00037 start2.x=start1.x+(latticeSize/2.0);
00038 start2.y=start2.y+(latticeSize/2.0);
00039 start2.z=start1.z;
00040 start3.x=start1.x;
00041 start3.y=start1.y+(latticeSize/2.0);
00042 start3.z=start1.z+(latticeSize/2.0);
00043 start4.x=start1.x+(latticeSize/2.0);
00044 start4.y=start1.y;
00045 start4.z=start1.z+(latticeSize/2.0);
00046 for (int i = 0; i < baseSize; i++)
00047 for (int j = 0; j < baseSize; j++)
00048 for (int k = 0; k < baseSize; k++)
00049 {
00050 cluster[numAtoms].properties.position.x = start1.x+double(i)*latticeSize;
00051 cluster[numAtoms].properties.position.y = start1.y+double(j)*latticeSize;
00052 cluster[numAtoms].properties.position.z = start1.z+double(k)*latticeSize;
00053 numAtoms++;
00054 }
00055 for (int i = 0; i < baseSize; i++)
00056 for (int j = 0; j < baseSize; j++)
00057 for (int k = 0; k < baseSize; k++)
00058 {
00059 cluster[numAtoms].properties.position.x = start2.x+double(i)*latticeSize;
00060 cluster[numAtoms].properties.position.y = start2.y+double(j)*latticeSize;
00061 cluster[numAtoms].properties.position.z = start2.z+double(k)*latticeSize;
00062 numAtoms++;
00063 }
00064 for (int i = 0; i < baseSize; i++)
00065 for (int j = 0; j < baseSize; j++)
00066 for (int k = 0; k < baseSize; k++)
00067 {
00068 cluster[numAtoms].properties.position.x = start3.x+double(i)*latticeSize;
00069 cluster[numAtoms].properties.position.y = start3.y+double(j)*latticeSize;
00070 cluster[numAtoms].properties.position.z = start3.z+double(k)*latticeSize;
00071 numAtoms++;
00072 }
00073 for (int i = 0; i < baseSize; i++)
00074 for (int j = 0; j < baseSize; j++)
00075 for (int k = 0; k < baseSize; k++)
00076 {
00077 cluster[numAtoms].properties.position.x = start4.x+double(i)*latticeSize;
00078 cluster[numAtoms].properties.position.y = start4.y+double(j)*latticeSize;
00079 cluster[numAtoms].properties.position.z = start4.z+double(k)*latticeSize;
00080 numAtoms++;
00081 }
00082 cluster.calculateCentreMass();
00083 cluster.setPositionCentreMass(Coordinate(0.0, 0.0, 0.0));
00084 adjustPosCenMass(cluster);
00085 cluster.calculateCentreMass();
00086 }
00087
00088 void FCC_Lattice::adjustPosCenMass(Cluster& cluster) const
00089 {
00090 Coordinate centre;
00091
00092 for (int i = 0; i < cluster.size(); i++)
00093 centre += cluster[i].properties.position;
00094 centre /= cluster.size();
00095 for (int i = 0; i < cluster.size(); i++)
00096 cluster[i].properties.position -= (centre + cluster.positionCentreMass());
00097 }