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


C++ Linked::length方法代码示例

本文整理汇总了C++中Linked::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Linked::length方法的具体用法?C++ Linked::length怎么用?C++ Linked::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Linked的用法示例。


在下文中一共展示了Linked::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: voronoi

void Interstitial::voronoi(const ISO& iso, const Symmetry& symmetry, double tol)
{	
	
	// Clear space
	clear();
	
	// Output
	Output::newline();
	Output::print("Searching for interstitial sites using Voronoi method");
	Output::increase();
	
	// Set up image iterator
	ImageIterator images;
	images.setCell(iso.basis(), 12);
	
	// Loop over unique atoms in the structure
	int i, j, k;
	List<double> weights;
	OList<Vector3D> points;
	OList<Vector3D> vertices;
	Linked<Vector3D> intPoints;
	for (i = 0; i < symmetry.orbits().length(); ++i)
	{
		
		// Reset variables
		weights.length(0);
		points.length(0);
		vertices.length(0);
		
		// Loop over atoms in the structure
		for (j = 0; j < iso.atoms().length(); ++j)
		{
			for (k = 0; k < iso.atoms()[j].length(); ++k)
			{
				
				// Loop over images
				images.reset(symmetry.orbits()[i].atoms()[0]->fractional(), iso.atoms()[j][k].fractional());
				while (!images.finished())
				{
					
					// Skip if atoms are the same
					if (++images < 1e-8)
						continue;
					
					// Save current point
					points += symmetry.orbits()[i].atoms()[0]->cartesian() + images.cartVector();
					weights += 0.5;
				}
			}
		}
		
		// Calculate Voronoi volume
		symmetry.orbits()[i].atoms()[0]->cartesian().voronoi(points, weights, tol, &vertices);
		
		// Save points
		for (j = 0; j < vertices.length(); ++j)
		{
			intPoints += iso.basis().getFractional(vertices[j]);
			ISO::moveIntoCell(*intPoints.last());
		}
	}
	
	// Reduce points to unique ones
	bool found;
	double curDistance;
	Vector3D rotPoint;
	Vector3D equivPoint;
	Vector3D origin(0.0);
	Linked<double> distances;
	Linked<double>::iterator itDist;
	Linked<Vector3D>::iterator it;
	Linked<Vector3D> uniquePoints;
	Linked<Vector3D>::iterator itUnique;
	for (it = intPoints.begin(); it != intPoints.end(); ++it)
	{
		
		// Get current distance to origin
		curDistance = iso.basis().distance(*it, FRACTIONAL, origin, FRACTIONAL);
		
		// Loop over points that were already saved
		found = false;
		itDist = distances.begin();
		itUnique = uniquePoints.begin();
		for (; itDist != distances.end(); ++itDist, ++itUnique)
		{
			
			// Current points are not the same
			if (Num<double>::abs(curDistance - *itDist) <= tol)
			{
				if (iso.basis().distance(*it, FRACTIONAL, *itUnique, FRACTIONAL) <= tol)
				{
					found = true;
					break;
				}
			}
			
			// Loop over symmetry operations
			for (i = 0; i < symmetry.operations().length(); ++i)
			{
				
//.........这里部分代码省略.........
开发者ID:bbucior,项目名称:mint,代码行数:101,代码来源:interstitial.cpp

示例2: evaluate

void Interstitial::evaluate(const ISO& iso, const Symmetry& symmetry, int numPointsPerAtom, double tol, double scale)
{
	
	// Clear space
	clear();
	
	// Output
	Output::newline();
	Output::print("Searching for interstitial sites using ");
	Output::print(numPointsPerAtom);
	Output::print(" starting point");
	if (numPointsPerAtom != 1)
		Output::print("s");
	Output::print(" per atom and a scale of ");
	Output::print(scale);
	Output::increase();
	
	// Constants used in generating points on sphere around each atom
	double phiScale = Constants::pi * (3 - sqrt(5));
	double yScale = 2.0 / numPointsPerAtom;
	
	// Loop over unique atoms in the structure
	int i, j, k;
	int count = 0;
	double y;
	double r;
	double phi;
	double curDistance;
	double nearDistance;
	double startDistance;
	Vector3D curPoint;
	Linked<Vector3D > points;
	for (i = 0; i < symmetry.orbits().length(); ++i)
	{
		
		// Get the distance to nearest atom in the structure
		nearDistance = -1;
		for (j = 0; j < iso.atoms().length(); ++j)
		{
			for (k = 0; k < iso.atoms()[j].length(); ++k)
			{
				curDistance = iso.basis().distance(symmetry.orbits()[i].atoms()[0]->fractional(), FRACTIONAL, \
					iso.atoms()[j][k].fractional(), FRACTIONAL);
				if (curDistance > 0)
				{
					if ((nearDistance == -1) || (curDistance < nearDistance))
						nearDistance = curDistance;
				}
			}
		}
		
		// Set the starting distance away from atom
		startDistance = nearDistance / 2;
		
		// Loop over starting points
		for (j = 0; j < numPointsPerAtom; ++j)
		{
			
			// Check if running current point on current processor
			if ((++count + Multi::rank()) % Multi::worldSize() == 0)
			{
				
				// Get current starting point
				y = j * yScale - 1 + (yScale / 2);
				r = sqrt(1 - y*y);
				phi = j * phiScale; 
				curPoint.set(symmetry.orbits()[i].atoms()[0]->cartesian()[0] + startDistance*r*cos(phi), \
					symmetry.orbits()[i].atoms()[0]->cartesian()[1] + startDistance*y, \
					symmetry.orbits()[i].atoms()[0]->cartesian()[2] + startDistance*r*sin(phi));
				
				// Minimize the current point
				if (!minimizePoint(curPoint, iso, scale))
					continue;
				
				// Save current point in fractional coordinates
				points += iso.basis().getFractional(curPoint);
				ISO::moveIntoCell(*points.last());
			}
		}
	}
	
	// Reduce list of points to unique ones
	int m;
	bool found;
	int numLoops;
	Vector3D rotPoint;
	Vector3D equivPoint;
	Vector3D origin(0.0);
	Linked<double> distances;
	Linked<double>::iterator itDist;
	Linked<Vector3D> uniquePoints;
	Linked<Vector3D>::iterator it;
	Linked<Vector3D>::iterator itUnique;
	for (i = 0; i < Multi::worldSize(); ++i)
	{
		
		// Send number of points in list on current processor
		numLoops = points.length();
		Multi::broadcast(numLoops, i);
		
//.........这里部分代码省略.........
开发者ID:bbucior,项目名称:mint,代码行数:101,代码来源:interstitial.cpp


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