本文整理汇总了C++中plane::assessSquareDistanceToPlane方法的典型用法代码示例。如果您正苦于以下问题:C++ plane::assessSquareDistanceToPlane方法的具体用法?C++ plane::assessSquareDistanceToPlane怎么用?C++ plane::assessSquareDistanceToPlane使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plane
的用法示例。
在下文中一共展示了plane::assessSquareDistanceToPlane方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
vector<float> assess(const plane& P){ //Assess the atom flags with respect to plane
vector <size_t> atomsInPlane;
for (int iA=0; iA<Atoms.size(); iA++){
int PositionToPlane = P.assessPlane(Atoms[iA]);
if (!PositionToPlane) {
Atoms[iA].Flags|=In_Plane;
atomsInPlane.push_back(iA);
}
else if (PositionToPlane<0) Atoms[iA].Flags|=Under_Plane;
}
//Assess the activity around Sb.
int Cnt = 0;
for (int iSb=0; iSb<Sb.size(); iSb++){
const float Threshold = 1.1;
/* Add an assessment of atom with respect to the distance of the plane */
float SquareDistance = P.assessSquareDistanceToPlane (Atoms[Sb[iSb]]);
if (SquareDistance > Threshold*Threshold ||
(!(Atoms[Sb[iSb]].Flags & (In_Plane|Under_Plane)))) continue;
const size_t NofPerihperals(10); //Number of peripheral Sn/Sb atoms
atom Peripheral [NofPerihperals];
for (int i=0; i<NofPerihperals; i++) Peripheral[i].displace(Atoms[Sb[iSb]]);
//Position all the peripheral atoms
Peripheral[0].displace (0,0,1); Peripheral[1].displace (0,0,-1);
Peripheral[2].displace (-0.5, -0.5, -0.5);Peripheral[3].displace (-0.5, -0.5, +0.5);
Peripheral[4].displace (-0.5, +0.5, -0.5);Peripheral[5].displace (-0.5, +0.5, +0.5);
Peripheral[6].displace (+0.5, -0.5, -0.5);Peripheral[7].displace (+0.5, -0.5, +0.5);
Peripheral[8].displace (+0.5, +0.5, -0.5);Peripheral[9].displace (+0.5, +0.5, +0.5);
Atoms[Sb[iSb]].Flags |= Active; // Assuming the centre Sb is active;
for (int i=0; i<NofPerihperals; i++) {
int indexPeriph = search (Peripheral[i]);
if (indexPeriph==-1) continue; //Searching out of boundary of the supercell
if ((Atoms[indexPeriph].Flags & (In_Plane|Under_Plane))) {
//If this both are in/under plane
if (!(Atoms[indexPeriph].Flags & Dop)) {
Atoms[indexPeriph].Flags |= Active; //Activate peripheral atom
}
else {
Atoms[Sb [iSb]].Flags &= (-1-Active); //De-activate the centre atom
}
}
//printf ("\n");
}
}
/** Assess the surface activity**/
int CountActive = 0;
for (int i=0; i<atomsInPlane.size(); i++) {
CountActive += (Atoms[atomsInPlane[i]].Flags & Active)? 1:0; //If active, then add 1
}
vector <float> results (2);
results[0] = Sb.size()/ double (Atoms.size());
results[1] = CountActive / double (atomsInPlane.size());
#ifdef OUTPUT_ATOM_COORDINATES
/*Real coordinates X, Y, Z will be involved here*/
string OutputFilename ("SurfaceAtoms_");
OutputFilename.push_back ('0'+P.H);
OutputFilename.push_back ('0'+P.K);
OutputFilename.push_back ('0'+P.L);
OutputFilename = OutputFilename + ".txt";
ofstream ExportPlane (OutputFilename.c_str());
atom newX;
atom newY;
atom newZ (P.H/a, P.K/a, P.L/c);
float Normalizer = newZ.Abs();
newZ.A/=Normalizer; newZ.B/=Normalizer; newZ.C/=Normalizer;
float SmallestDistance=10;
for (int iA=-1; iA<=1; iA++){
for (int iB=-1; iB<=1; iB++){
for (int iC=-1; iC<=1; iC++){
if (isZero(iA*P.H+iB*P.K+iC*P.L) && (iA||iB||iC)) {
float X = iA*a;
float Y = iB*a;
float Z = iC*c;
float Distance = sqrt(X*X + Y*Y + Z*Z);
if (Distance <SmallestDistance) {
newX = atom(X, Y, Z);
SmallestDistance = Distance;
}
}
}
}
//.........这里部分代码省略.........