当前位置: 首页>>代码示例>>C++>>正文


C++ plane::assessSquareDistanceToPlane方法代码示例

本文整理汇总了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;
					}
				}
			}
		}
//.........这里部分代码省略.........
开发者ID:halfpastseven,项目名称:ATO_Surface_Activity,代码行数:101,代码来源:CrystalPlane.cpp


注:本文中的plane::assessSquareDistanceToPlane方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。