Exemplo n.º 1
0
int SysConf::HasZeroDimers(int spin, int layer)
{
	int test = 0;
	bool output = false;
	int index = 0;
	int numberOfZeros = 0;

	for(int iii = 0; iii < NbOfNeights;++iii)
	{
		index = idxConv(NbOfNeights,spin,iii);
	#if BORDER_TYPE == 4
	// ANTI-PERIODIC BORDERS
		test += weightTable[index]*spinConf[idxConv(N,neighboursTable[index],layer)];
	#else
		test += spinConf[idxConv(N,neighboursTable[index],layer)];
	#endif

		if(spinConf[idxConv(N,neighboursTable[index],layer)]==0)
		{
			++numberOfZeros;
		}
	}

	if(abs(test)== 6 - numberOfZeros)
	{
		output = true;
	}

	return output;
};
Exemplo n.º 2
0
double  SysConf::GetNewKinEnergy()
{
	double energyOut = 0;
	double cte = 1./(N*Kz);        // !!! Kz = Delta Beta

	if(N>1)
	{
		for(int nnn = 0; nnn < N - 1; ++nnn)
		{
			for(int iii = 0; iii < L; ++iii)
			{
				if(spinConf[idxConv(N,iii,nnn)]==-spinConf[idxConv(N,iii,nnn+1)])
				{
					energyOut -= cte;
				}
			}
		}

		for(int iii = 0; iii < L; ++iii)
		{
			if(spinConf[idxConv(N,iii,N-1)]==-spinConf[idxConv(N,iii,0)])
			{
				energyOut -= cte;
			}
		}
	}
	else
	{
		energyOut = 0;
	}

	return energyOut;
};
Exemplo n.º 3
0
void TwoDOrderParam::GetSuperlatticeNf(vector<double>& output,int nx, int ny)
{
	int idx = -1;
	for(uint iii = 0; iii < output.size();++iii)
	{
		output[iii] = 0;
	}

	for(int iii = 0; iii < ny/3; ++iii)
	{
		for(int jjj = 0; jjj < nx/3; ++jjj)
		{
			// First line
			// A
			idx = idxConv(nx,3*iii,3*jjj);
			output[0] += m_mean[idx];

			// B
			idx = idxConv(nx,3*iii,3*jjj+1);
			output[1] += m_mean[idx];

			// C
			idx = idxConv(nx,3*iii,3*jjj+2);
			output[2] += m_mean[idx];

			// Second line
			// C
			idx = idxConv(nx,3*iii+1,3*jjj);
			output[2] += m_mean[idx];

			// A
			idx = idxConv(nx,3*iii+1,3*jjj+1);
			output[0] += m_mean[idx];

			// B
			idx = idxConv(nx,3*iii+1,3*jjj+2);
			output[1] += m_mean[idx];

			// Third line
			// B
			idx = idxConv(nx,3*iii+2,3*jjj);
			output[1] += m_mean[idx];

			// C
			idx = idxConv(nx,3*iii+2,3*jjj+1);
			output[2] += m_mean[idx];

			// A
			idx = idxConv(nx,3*iii+2,3*jjj+2);
			output[0] += m_mean[idx];
		}
	}

	for(uint iii = 0; iii < output.size();++iii)
	{
		output[iii] = 3.*output[iii]/m_row_number;
	}

// 	sort(output.begin(), output.end());
}
Exemplo n.º 4
0
double SysConf::CalculateChainEnergy()
{
	double chainEnergy = 0;

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int jjj = 0; jjj < nx + p - 1; ++jjj)
		{
			chainEnergy += spinChain[idxConv(nx+p,nnn,jjj)]*spinChain[idxConv(nx+p,nnn,jjj+1)];
		}
	}

	return abs(chainEnergy)/(N);
};
Exemplo n.º 5
0
void TwoDOrderParam::RectManualGetSuperlatticeNf(vector<double>& output,int nx, int ny, vector<int>& neighTable)
{
	int idx = 2*ny+6;
	int originalIdx = idx;

	for(uint iii = 0; iii < output.size();++iii)
	{
		output[iii] = 0;
	}

	for(int jjj = 1; jjj < nx/2-1; ++jjj)
	{
		// First line
		for(int iii = 1; iii < ny/3-1; ++iii)
		{
			// A
			output[0] += m_mean[idx];
			idx = neighTable[idxConv(6,idx,2)];

			// B
			output[1] += m_mean[idx];
			idx = neighTable[idxConv(6,idx,2)];

			// C
			output[2] += m_mean[idx];
			idx = neighTable[idxConv(6,idx,2)];
		}

		// Move to the side
		idx = neighTable[idxConv(6,originalIdx,1)];
		originalIdx = idx;

		// Second line
		for(int iii = 1; iii < ny/3-1; ++iii)
		{
			// C
			output[2] += m_mean[idx];
			idx = neighTable[idxConv(6,idx,2)];

			// A
			output[0] += m_mean[idx];
			idx = neighTable[idxConv(6,idx,2)];

			// B
			output[1] += m_mean[idx];
			idx = neighTable[idxConv(6,idx,2)];
		}

		// Move to the side
		idx = neighTable[idxConv(6,originalIdx,0)];
		originalIdx = idx;
	}

	for(uint iii = 0; iii < output.size();++iii)
	{
		output[iii] = output[iii]/(2.*(nx/2 - 2)*(ny/3 - 2));
	}

// 	sort(output.begin(), output.end());
}
Exemplo n.º 6
0
int SysConf::GetLocalField(int lll, int nnn)
{
	int output = 0;
	int index = 0;

	for(int iii = 0; iii < NbOfNeights;++iii)
	{
		index = idxConv(NbOfNeights,lll,iii);
	#if BORDER_TYPE == 4
	// ANTI-PERIODIC BORDERS
		output += weightTable[index]*(int)spinConf[idxConv(N,neighboursTable[index],nnn)];
	#else
		output += (int)spinConf[idxConv(N,neighboursTable[index],nnn)];
	#endif
	}

	return output;
}
Exemplo n.º 7
0
void SysConf::BuildEquivalentSpinChain()
{
	int pos = 0;
	int index = 0;
//	spinChain.resize((nx+p)*N,1);	// spinChain[(nx+p)*iii + jjj] = stack iii, spin jjj
//	equivPart.resize(nx*N,0);	// equivPart[(nx)*iii + jjj] = stack iii, spin jjj

	for(int nnn = 0; nnn < N; ++nnn)
	{
		// Set the first nx spins as positive
		for(int jjj = 0; jjj < nx + p; ++jjj)
		{
			spinChain[idxConv(nx+p,nnn,jjj)] = -1;
		}

		// Recover equivalent partition
		for(int jjj = 0; jjj < nx;++jjj)
		{
			equivPart[idxConv(nx,nnn,jjj)] = p;
			pos = L + jjj + 1;

			for(int kkk = 0; kkk < p; ++kkk)
			{

				// The neighbour below SHOULD be neighboursTable[L][2] (see hex offset)
				if(spinConf[idxConv(N,pos,nnn)]==spinConf[idxConv(N,neighboursTable[idxConv(6,pos,2)],nnn)])
				{
					// Then we got the horizontal dimer / frustrated relations
					break;
				}
				else
				{
//					--equivPart[idxConv(nx,nnn,jjj)];
					--equivPart[idxConv(nx,jjj,nnn)];
					pos = neighboursTable[idxConv(6,pos,2)];
				}
			}
		}

		// Set up spin chain
		for(int jjj = 0; jjj < nx; ++jjj)
		{
//			index = nx - 1 + equivPart[idxConv(nx,nnn,jjj)] - jjj;
			index = nx - 1 + equivPart[idxConv(N,jjj,nnn)] - jjj;
			spinChain[idxConv(nx+p,nnn,index)] = 1;
		}
	}
};
Exemplo n.º 8
0
void SysConf::SetParts(int nbOfParts, int nxInitCol, int nyInitRow)
{
	int nxCol = nxInitCol;
	int nyRow = nyInitRow;

	int partIdx   = -1;
	int heightIdx = -1;

	for(int kkk = 0; kkk < nbOfParts; ++kkk)
	{
		for(int nnn = 0; nnn < N; ++nnn)
		{
			heightIdx = idxConv(N,kkk,nnn);
			partIdx   = idxConv(N,idxConv(nx,nyRow,nxCol),nnn);
			equivPart[partIdx] = horizontalDimerPos[heightIdx];
		}
		++nxCol;
		++nyRow;
	}
};
Exemplo n.º 9
0
void SysConf::GetMeanPart(vector<double> &output)
{
    for(int iii = 0; iii < ny; ++iii)
    {
		for(int jjj = 0; jjj < nx; ++jjj)
		{
			output[idxConv(nx,iii,jjj)] = 0;
		}
    }

    for(int iii = 0; iii < ny; ++iii)
    {
		for(int jjj = 0; jjj < nx; ++jjj)
		{
			for(int nnn = 0; nnn < N; ++nnn)
			{
				output[idxConv(nx,iii,jjj)] += (double)equivPart[idxConv(N,idxConv(nx,iii,jjj),nnn)]/N;
			}
		}
    }
};
Exemplo n.º 10
0
void SysConf::CalculateChainCorrelations(vector<double>& CorrSz, vector<double>& CorrStag)
{
	for(int jjj = 0; jjj < nx + p; ++jjj)
	{
		CorrSz[jjj] = 0;
		CorrStag[jjj] = 0;
	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int jjj = 0;jjj < nx + p; ++jjj)
		{
			CorrSz[jjj] 	+= spinChain[idxConv(nx+p,nnn,0)]*spinChain[idxConv(nx+p,nnn,jjj)];
			CorrStag[jjj] 	+= pow(-1,jjj)*spinChain[idxConv(nx+p,nnn,0)]*spinChain[idxConv(nx+p,nnn,jjj)];
		}
	}

	for(int jjj = 0; jjj < nx + p; ++jjj)
	{
		CorrSz[jjj] = CorrSz[jjj]/N;
	}
};
Exemplo n.º 11
0
void  SysConf::GetKinEnergyDensity(vector<double> & KinOut)
{
	double cte = 1./(N*sinh(2.*Kz));  	// !!! Kz = Delta Beta

	if(N>1)
	{
		for(int iii = 0; iii < L; ++iii)
		{
			KinOut[iii] = 0;
			for(int nnn = 0; nnn < N - 1; ++nnn)
			{
				KinOut[iii] += cte*spinConf[idxConv(N,iii,nnn)]*spinConf[idxConv(N,iii,nnn+1)];
			}
		}

		for(int iii = 0; iii < L; ++iii)
		{
			KinOut[iii] += cte*spinConf[idxConv(N,iii,N-1)]*spinConf[idxConv(N,iii,0)];
		}
	}
	else
	{
		for(int iii = 0; iii < L; ++iii)
		{
			KinOut[iii] += cte*spinConf[iii]*spinConf[iii];
		}
	}

//	double cte = 1./(sinh(2.*Kz));  	// !!! Kz = Delta Beta
//	for(int iii = 0; iii < L; ++iii)
//	{
//		energyOut += cte*spinConf[idxConv(N,iii,0)]*spinConf[idxConv(N,iii,1)];
//	}

	for(int iii = 0; iii < L; ++iii)
	{
		KinOut[iii] -= 1./tanh(2.*Kz);
	}
};
Exemplo n.º 12
0
void 	SysConf::GetN3Correlation(double& corr, vector<double>& Star3Network)
{
	int 		spinPos 	= 0;
	int 		neighPos 	= 0;

	int lll = 0;
	int nnn = 0;

	int index = 0;

	corr = 0;

	for(int iii = 0; iii < L; ++iii)
	{
		Star3Network[iii] = 0;
	}

	for(int fff = 0; fff < TotalOldNbF; ++fff)
	{
		spinPos = flippableSpinLists[fff];
		nnn = spinPos % N;
		lll = spinPos / N;

		for(int iii = 0; iii < NbOfNeights; ++iii)
		{
			index = idxConv(NbOfNeights,lll,iii);
			neighPos = idxConv(N,neighboursTable[index],nnn);

			if(flippableSpinPositions[neighPos]!=-1)
			{
				corr += 1./N;
				Star3Network[lll] += 1./N;

				break;
			}
		}
	}
}
Exemplo n.º 13
0
double SysConf::CalculateStagMag()
{
	double stagMag = 0;

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int jjj = 0; jjj < nx + p; ++jjj)
		{
			stagMag += pow(-1,jjj)*spinChain[idxConv(nx+p,nnn,jjj)];
		}
	}

	return abs(stagMag)/((nx+p)*N);
};
Exemplo n.º 14
0
void	SysConf::GetSzSzCorrelation(vector<double>& corr)
{
	//   corr[nnn] 		= Sum_iii [ <A_(iii,0) A_(iii,nnn*dB)>_iii ]
	//   siteMean[iii]	= Sum_nnn [ <A_(iii,nnn)>_nnn ]

	for(int nnn = 0; nnn < N; ++nnn)
	{
		corr[nnn] = 0;
	}

	double firstSpin = 0;

	int nStep = 60;
	int deltaN = N/nStep;
	for(int iii = 0; iii < L; ++iii)
	{
		for(int mmm = 0; mmm < N; mmm += deltaN)
		{
			firstSpin = spinConf[idxConv(N,iii,mmm)];
			for(int nnn = 0; nnn < mmm; ++nnn)
			{
				corr[N - mmm+nnn] += firstSpin*spinConf[idxConv(N,iii,nnn)];
			}

			for(int nnn = mmm; nnn < N; ++nnn)
			{
				corr[nnn-mmm] 	+= firstSpin*spinConf[idxConv(N,iii,nnn)];
			}
		}

	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		corr[nnn] 		= corr[nnn]/(nStep*L);
	}
}
Exemplo n.º 15
0
double  SysConf::GetKinEnergy()
{
	double energyOut = 0;
	double cte = 1./(N*sinh(2.*Kz));  	// !!! Kz = Delta Beta

	if(N>1)
	{
        for(int nnn = 0; nnn < N - 1; ++nnn)
        {
            for(int iii = 0; iii < L; ++iii)
            {
               	energyOut += cte*spinConf[idxConv(N,iii,nnn)]*spinConf[idxConv(N,iii,nnn+1)];
            }
        }

		for(int iii = 0; iii < L; ++iii)
		{
			energyOut += cte*spinConf[idxConv(N,iii,N-1)]*spinConf[idxConv(N,iii,0)];
		}
	}
	else
	{
		for(int iii = 0; iii < L; ++iii)
		{
			energyOut += cte*spinConf[iii]*spinConf[iii];
		}
	}

//	double cte = 1./(sinh(2.*Kz));  	// !!! Kz = Delta Beta
//	for(int iii = 0; iii < L; ++iii)
//	{
//		energyOut += cte*spinConf[idxConv(N,iii,0)]*spinConf[idxConv(N,iii,1)];
//	}

	energyOut -= L/tanh(2.*Kz);
	return energyOut;
};
Exemplo n.º 16
0
void	SysConf::GetN3N3SpacialCorrelation(vector<double>& N3SpatialCorrelation, vector<double>& N3LocalDensities)
{
	int 	spinPos 		= 0;
	int 	distance	 	= 0;
	int		hashPosition	= 0;

	int lll = 0;
	int jjj = 0;

	for(int iii = 0; iii < L; ++iii)
	{
		N3LocalDensities[iii] = 0;
	}

	for(int iii = 0; iii < L*nbOfDists; ++iii)
	{
		N3SpatialCorrelation[iii] = 0;
	}

	// For all flippable spins
	for(int fff = 0; fff < TotalOldNbF; ++fff)
	{
		spinPos = flippableSpinLists[fff];
		lll = spinPos / N;

		N3LocalDensities[lll] += 1./N;
		for(int ggg = 0; ggg < TotalOldNbF; ++ggg)
		{
			jjj = flippableSpinLists[ggg] / N;

			distance = SqrDistancesTable[idxConv(L,lll,jjj)];
			hashPosition = SqrDistancesPos[distance];
			N3SpatialCorrelation[idxConv(nbOfDists,lll,hashPosition)] += 1./N;
		}
	}
}
Exemplo n.º 17
0
double SysConf::GetCoreMagnetization()
{
	double Mag = 0;

	for(int iii = 0; iii < N; ++iii)
	{
		for(int jjj = 0; jjj < nx + p - 1; ++jjj)
		{
			for(int kkk = CoreStart[jjj]; kkk <= CoreEnd[jjj]; ++kkk)
			{
				Mag += (double)spinConf[idxConv(N,kkk,iii)];
			}
		}
	}
	return pow(Mag/(CoreSize*N),2);
}
Exemplo n.º 18
0
double SysConf::GetMagnetization()
{
	double Mag = 0;
	double outMag = 0;

	for(int iii = 0; iii < N; ++iii)
	{
		Mag = 0;
		for(int jjj = 0; jjj < L; ++jjj)
		{
			Mag += (double)spinConf[idxConv(N,jjj,iii)];
		}
		outMag += pow(Mag/L,2)/N;
	}
	return sqrt(outMag);
}
Exemplo n.º 19
0
void SysConf::GetHeights(int nbOfParts, int lll)
{
	int spinIdx = -1;
	int spinPos = -1;
	int nextIdx = -1;
	int nextSpinPos = -1;

	int distance = 0;
	int dimersFound = 0;
	for(int nnn = 0; nnn < N; ++nnn)
	{
		spinIdx 	= lll;
		nextIdx		= neighboursTable[idxConv(NbOfNeights,lll,2)];

		spinPos     = idxConv(N,spinIdx,nnn);
		nextSpinPos = idxConv(N,nextIdx,nnn);

		dimersFound = 0;
		distance    = 0;
		while(dimersFound < nbOfParts)
		{
			if(spinConf[spinPos]==spinConf[nextSpinPos])
			{
				// We've got a dimer!
				horizontalDimerPos[idxConv(N,dimersFound,nnn)] = p - distance + dimersFound;
				++dimersFound;
			}

			// Anyway, go to the next spin!
			++distance;
			spinIdx = nextIdx;
			nextIdx = neighboursTable[idxConv(NbOfNeights,spinIdx,2)];

			if(nextIdx==-1)
			{
				// !!! It should never get here! !!!
				break;
			}

			spinPos     = idxConv(N,spinIdx,nnn);
			nextSpinPos = idxConv(N,nextIdx,nnn);
		}
	}
};
Exemplo n.º 20
0
void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indices, int tess_u, int tess_v, int count_u, int count_v, GEPatchPrimType prim_type, bool computeNormals, bool patchFacing, u32 vertType, int *bytesRead) {
	PROFILE_THIS_SCOPE("bezier");

	DispatchFlush();

	u16 index_lower_bound = 0;
	u16 index_upper_bound = count_u * count_v - 1;
	IndexConverter idxConv(vertType, indices);
	if (indices)
		GetIndexBounds(indices, count_u*count_v, vertType, &index_lower_bound, &index_upper_bound);

	VertexDecoder *origVDecoder = GetVertexDecoder((vertType & 0xFFFFFF) | (gstate.getUVGenMode() << 24));
	*bytesRead = count_u * count_v * origVDecoder->VertexSize();

	// Real hardware seems to draw nothing when given < 4 either U or V.
	// This would result in num_patches_u / num_patches_v being 0.
	if (count_u < 4 || count_v < 4) {
		return;
	}

	// Simplify away bones and morph before proceeding
	// There are normally not a lot of control points so just splitting decoded should be reasonably safe, although not great.
	SimpleVertex *simplified_control_points = (SimpleVertex *)(decoded + 65536 * 12);
	u8 *temp_buffer = decoded + 65536 * 18;

	u32 origVertType = vertType;
	vertType = NormalizeVertices((u8 *)simplified_control_points, temp_buffer, (u8 *)control_points, index_lower_bound, index_upper_bound, vertType);

	VertexDecoder *vdecoder = GetVertexDecoder(vertType);

	int vertexSize = vdecoder->VertexSize();
	if (vertexSize != sizeof(SimpleVertex)) {
		ERROR_LOG(G3D, "Something went really wrong, vertex size: %i vs %i", vertexSize, (int)sizeof(SimpleVertex));
	}

	float *pos = (float*)(decoded + 65536 * 18); // Size 4 float
	float *tex = pos + count_u * count_v * 4; // Size 4 float
	float *col = tex + count_u * count_v * 4; // Size 4 float
	const bool hasColor = (origVertType & GE_VTYPE_COL_MASK) != 0;
	const bool hasTexCoords = (origVertType & GE_VTYPE_TC_MASK) != 0;

	// Bezier patches share less control points than spline patches. Otherwise they are pretty much the same (except bezier don't support the open/close thing)
	int num_patches_u = (count_u - 1) / 3;
	int num_patches_v = (count_v - 1) / 3;
	BezierPatch *patches = nullptr;
	if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) {
		int posStride, texStride, colStride;
		tessDataTransfer->PrepareBuffers(pos, tex, col, posStride, texStride, colStride, count_u * count_v, hasColor, hasTexCoords);
		float *p = pos;
		float *t = tex;
		float *c = col;
		for (int idx = 0; idx < count_u * count_v; idx++) {
			SimpleVertex *point = simplified_control_points + (indices ? idxConv.convert(idx) : idx);
			memcpy(p, point->pos.AsArray(), 3 * sizeof(float));
			p += posStride;
			if (hasTexCoords) {
				memcpy(t, point->uv, 2 * sizeof(float));
				t += texStride;
			}
			if (hasColor) {
				memcpy(c, Vec4f::FromRGBA(point->color_32).AsArray(), 4 * sizeof(float));
				c += colStride;
			}
		}
		if (!hasColor) {
			SimpleVertex *point = simplified_control_points + (indices ? idxConv.convert(0) : 0);
			memcpy(col, Vec4f::FromRGBA(point->color_32).AsArray(), 4 * sizeof(float));
		}
	} else {
		patches = new BezierPatch[num_patches_u * num_patches_v];
		for (int patch_u = 0; patch_u < num_patches_u; patch_u++) {
			for (int patch_v = 0; patch_v < num_patches_v; patch_v++) {
				BezierPatch& patch = patches[patch_u + patch_v * num_patches_u];
				for (int point = 0; point < 16; ++point) {
					int idx = (patch_u * 3 + point % 4) + (patch_v * 3 + point / 4) * count_u;
					patch.points[point] = simplified_control_points + (indices ? idxConv.convert(idx) : idx);
				}
				patch.u_index = patch_u * 3;
				patch.v_index = patch_v * 3;
				patch.index = patch_v * num_patches_u + patch_u;
				patch.primType = prim_type;
				patch.computeNormals = computeNormals;
				patch.patchFacing = patchFacing;
			}
		}
	}

	int count = 0;
	u8 *dest = splineBuffer;

	// We shouldn't really split up into separate 4x4 patches, instead we should do something that works
	// like the splines, so we subdivide across the whole "mega-patch".

	// If specified as 0, uses 1.
	if (tess_u < 1) {
		tess_u = 1;
	}
	if (tess_v < 1) {
		tess_v = 1;
	}

	u16 *inds = quadIndices_;
	if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) {
		tessDataTransfer->SendDataToShader(pos, tex, col, count_u * count_v, hasColor, hasTexCoords);
		TessellateBezierPatchHardware(dest, inds, count, tess_u, tess_v, prim_type);
		numPatches = num_patches_u * num_patches_v;
	} else {
		int maxVertices = SPLINE_BUFFER_SIZE / vertexSize;
		// Downsample until it fits, in case crazy tessellation factors are sent.
		while ((tess_u + 1) * (tess_v + 1) * num_patches_u * num_patches_v > maxVertices) {
			tess_u /= 2;
			tess_v /= 2;
		}
		for (int patch_idx = 0; patch_idx < num_patches_u*num_patches_v; ++patch_idx) {
			const BezierPatch &patch = patches[patch_idx];
			TessellateBezierPatch(dest, inds, count, tess_u, tess_v, patch, origVertType);
		}
		delete[] patches;
	}

	u32 vertTypeWithIndex16 = (vertType & ~GE_VTYPE_IDX_MASK) | GE_VTYPE_IDX_16BIT;

	UVScale prevUVScale;
	if (origVertType & GE_VTYPE_TC_MASK) {
		// We scaled during Normalize already so let's turn it off when drawing.
		prevUVScale = gstate_c.uv;
		gstate_c.uv.uScale = 1.0f;
		gstate_c.uv.vScale = 1.0f;
		gstate_c.uv.uOff = 0;
		gstate_c.uv.vOff = 0;
	}

	uint32_t vertTypeID = GetVertTypeID(vertTypeWithIndex16, gstate.getUVGenMode());
	int generatedBytesRead;
	DispatchSubmitPrim(splineBuffer, quadIndices_, primType[prim_type], count, vertTypeID, &generatedBytesRead);

	DispatchFlush();

	if (origVertType & GE_VTYPE_TC_MASK) {
		gstate_c.uv = prevUVScale;
	}
}
Exemplo n.º 21
0
void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead, SoftwareDrawEngine *drawEngine)
{
	VertexDecoder &vdecoder = *drawEngine->FindVertexDecoder(vertex_type);
	const DecVtxFormat &vtxfmt = vdecoder.GetDecVtxFmt();

	if (bytesRead)
		*bytesRead = vertex_count * vdecoder.VertexSize();

	// Frame skipping.
	if (gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME) {
		return;
	}

	u16 index_lower_bound = 0;
	u16 index_upper_bound = vertex_count - 1;
	IndexConverter idxConv(vertex_type, indices);

	if (indices)
		GetIndexBounds(indices, vertex_count, vertex_type, &index_lower_bound, &index_upper_bound);
	vdecoder.DecodeVerts(buf, vertices, index_lower_bound, index_upper_bound);

	VertexReader vreader(buf, vtxfmt, vertex_type);

	const int max_vtcs_per_prim = 3;
	static VertexData data[max_vtcs_per_prim];
	// This is the index of the next vert in data (or higher, may need modulus.)
	static int data_index = 0;

	static GEPrimitiveType prev_prim = GE_PRIM_POINTS;
	if (prim_type != GE_PRIM_KEEP_PREVIOUS) {
		data_index = 0;
		prev_prim = prim_type;
	} else {
		prim_type = prev_prim;
	}

	int vtcs_per_prim;
	switch (prim_type) {
	case GE_PRIM_POINTS: vtcs_per_prim = 1; break;
	case GE_PRIM_LINES: vtcs_per_prim = 2; break;
	case GE_PRIM_TRIANGLES: vtcs_per_prim = 3; break;
	case GE_PRIM_RECTANGLES: vtcs_per_prim = 2; break;
	default: vtcs_per_prim = 0; break;
	}

	// TODO: Do this in two passes - first process the vertices (before indexing/stripping),
	// then resolve the indices. This lets us avoid transforming shared vertices twice.

	switch (prim_type) {
	case GE_PRIM_POINTS:
	case GE_PRIM_LINES:
	case GE_PRIM_TRIANGLES:
	case GE_PRIM_RECTANGLES:
		{
			for (int vtx = 0; vtx < vertex_count; ++vtx) {
				if (indices) {
					vreader.Goto(idxConv.convert(vtx) - index_lower_bound);
				} else {
					vreader.Goto(vtx);
				}

				data[data_index++] = ReadVertex(vreader);
				if (data_index < vtcs_per_prim) {
					// Keep reading.  Note: an incomplete prim will stay read for GE_PRIM_KEEP_PREVIOUS.
					continue;
				}

				// Okay, we've got enough verts.  Reset the index for next time.
				data_index = 0;
				if (outside_range_flag) {
					// Cull the prim if it was outside, and move to the next prim.
					outside_range_flag = false;
					continue;
				}

				switch (prim_type) {
				case GE_PRIM_TRIANGLES:
				{
					if (!gstate.isCullEnabled() || gstate.isModeClear()) {
						Clipper::ProcessTriangle(data[0], data[1], data[2]);
						Clipper::ProcessTriangle(data[2], data[1], data[0]);
					} else if (!gstate.getCullMode()) {
						Clipper::ProcessTriangle(data[2], data[1], data[0]);
					} else {
						Clipper::ProcessTriangle(data[0], data[1], data[2]);
					}
					break;
				}

				case GE_PRIM_RECTANGLES:
					Clipper::ProcessRect(data[0], data[1]);
					break;

				case GE_PRIM_LINES:
					Clipper::ProcessLine(data[0], data[1]);
					break;

				case GE_PRIM_POINTS:
					Clipper::ProcessPoint(data[0]);
					break;

				default:
					_dbg_assert_msg_(G3D, false, "Unexpected prim type: %d", prim_type);
				}
			}
			break;
		}

	case GE_PRIM_LINE_STRIP:
		{
			// Don't draw a line when loading the first vertex.
			// If data_index is 1 or 2, etc., it means we're continuing a line strip.
			int skip_count = data_index == 0 ? 1 : 0;
			for (int vtx = 0; vtx < vertex_count; ++vtx) {
				if (indices) {
					vreader.Goto(idxConv.convert(vtx) - index_lower_bound);
				} else {
					vreader.Goto(vtx);
				}

				data[(data_index++) & 1] = ReadVertex(vreader);
				if (outside_range_flag) {
					// Drop all primitives containing the current vertex
					skip_count = 2;
					outside_range_flag = false;
					continue;
				}

				if (skip_count) {
					--skip_count;
				} else {
					// We already incremented data_index, so data_index & 1 is previous one.
					Clipper::ProcessLine(data[data_index & 1], data[(data_index & 1) ^ 1]);
				}
			}
			break;
		}

	case GE_PRIM_TRIANGLE_STRIP:
		{
			// Don't draw a triangle when loading the first two vertices.
			int skip_count = data_index >= 2 ? 0 : 2 - data_index;

			for (int vtx = 0; vtx < vertex_count; ++vtx) {
				if (indices) {
					vreader.Goto(idxConv.convert(vtx) - index_lower_bound);
				} else {
					vreader.Goto(vtx);
				}

				data[(data_index++) % 3] = ReadVertex(vreader);
				if (outside_range_flag) {
					// Drop all primitives containing the current vertex
					skip_count = 2;
					outside_range_flag = false;
					continue;
				}

				if (skip_count) {
					--skip_count;
					continue;
				}

				if (!gstate.isCullEnabled() || gstate.isModeClear()) {
					Clipper::ProcessTriangle(data[0], data[1], data[2]);
					Clipper::ProcessTriangle(data[2], data[1], data[0]);
				} else if ((!gstate.getCullMode()) ^ ((data_index - 1) % 2)) {
					// We need to reverse the vertex order for each second primitive,
					// but we additionally need to do that for every primitive if CCW cullmode is used.
					Clipper::ProcessTriangle(data[2], data[1], data[0]);
				} else {
					Clipper::ProcessTriangle(data[0], data[1], data[2]);
				}
			}
			break;
		}

	case GE_PRIM_TRIANGLE_FAN:
		{
			// Don't draw a triangle when loading the first two vertices.
			// (this doesn't count the central one.)
			int skip_count = data_index <= 1 ? 1 : 0;
			int start_vtx = 0;

			// Only read the central vertex if we're not continuing.
			if (data_index == 0) {
				if (indices) {
					vreader.Goto(idxConv.convert(0) - index_lower_bound);
				} else {
					vreader.Goto(0);
				}
				data[0] = ReadVertex(vreader);
				data_index++;
				start_vtx = 1;
			}

			for (int vtx = start_vtx; vtx < vertex_count; ++vtx) {
				if (indices) {
					vreader.Goto(idxConv.convert(vtx) - index_lower_bound);
				} else {
					vreader.Goto(vtx);
				}

				data[2 - ((data_index++) % 2)] = ReadVertex(vreader);
				if (outside_range_flag) {
					// Drop all primitives containing the current vertex
					skip_count = 2;
					outside_range_flag = false;
					continue;
				}

				if (skip_count) {
					--skip_count;
					continue;
				}

				if (!gstate.isCullEnabled() || gstate.isModeClear()) {
					Clipper::ProcessTriangle(data[0], data[1], data[2]);
					Clipper::ProcessTriangle(data[2], data[1], data[0]);
				} else if ((!gstate.getCullMode()) ^ ((data_index - 1) % 2)) {
					// We need to reverse the vertex order for each second primitive,
					// but we additionally need to do that for every primitive if CCW cullmode is used.
					Clipper::ProcessTriangle(data[2], data[1], data[0]);
				} else {
					Clipper::ProcessTriangle(data[0], data[1], data[2]);
				}
			}
			break;
		}

	default:
		ERROR_LOG(G3D, "Unexpected prim type: %d", prim_type);
		break;
	}

	GPUDebug::NotifyDraw();
}
Exemplo n.º 22
0
void	SysConf::GetDimerDimerCorrelation(vector<double>& corr)
{
	//   corr[nnn] 		= Sum_iii [ <A_(iii,0) A_(iii,nnn*dB)>_iii ]
	//   siteMean[iii]	= Sum_nnn [ <A_(iii,nnn)>_nnn ]

	for(int nnn = 0; nnn < N; ++nnn)
	{
		corr[nnn] = 0;
	}

	double 	firstSpin = 0;
	double 	dimer = 0;
	double 	firstDimer = 0;
	int 	posNeigh = 0;
	int 	index = 0;

	int nStep = 60;
	int deltaN = N/nStep;
	for(int iii = 0; iii < L; ++iii)
	{
		for(int mmm = 0; mmm < N; mmm += deltaN)
		{
			firstSpin = spinConf[idxConv(N,iii,mmm)];

			for(int jjj = 0; jjj < NbOfNeights; ++jjj)
			{
				index = idxConv(NbOfNeights,iii,jjj);
				posNeigh  = neighboursTable[index];


			#if BORDER_TYPE == 4
			// ANTI-PERIODIC BORDERS
				firstDimer = (firstSpin*weightTable[index]*spinConf[idxConv(N,posNeigh,mmm)] + 1)/2.;
			#else
				firstDimer = (firstSpin*spinConf[idxConv(N,posNeigh,mmm)] + 1)/2.;
			#endif


				for(int nnn = 0; nnn < mmm; ++nnn)
				{
				#if BORDER_TYPE == 4
				// ANTI-PERIODIC BORDERS
					dimer = (spinConf[idxConv(N,iii,nnn)]*weightTable[index]*spinConf[idxConv(N,posNeigh,nnn)] + 1)/2.;
				#else
					dimer = (spinConf[idxConv(N,iii,nnn)]*spinConf[idxConv(N,posNeigh,nnn)] + 1)/2.;
				#endif
					corr[N - mmm+nnn] += firstDimer*dimer;
				}

				for(int nnn = mmm; nnn < N; ++nnn)
				{
				#if BORDER_TYPE == 4
				// ANTI-PERIODIC BORDERS
					dimer = (spinConf[idxConv(N,iii,nnn)]*weightTable[index]*spinConf[idxConv(N,posNeigh,nnn)] + 1)/2.;
				#else
					dimer = (spinConf[idxConv(N,iii,nnn)]*spinConf[idxConv(N,posNeigh,nnn)] + 1)/2.;
				#endif
					corr[nnn-mmm] 	+= firstDimer*dimer;
				}
			}
		}
	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		corr[nnn] 		= corr[nnn]/(nStep*NbOfNeights*L);
	}
}
Exemplo n.º 23
0
void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indices, int tess_u, int tess_v, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, bool computeNormals, bool patchFacing, u32 vertType, int *bytesRead) {
	PROFILE_THIS_SCOPE("spline");
	DispatchFlush();

	u16 index_lower_bound = 0;
	u16 index_upper_bound = count_u * count_v - 1;
	IndexConverter idxConv(vertType, indices);
	if (indices)
		GetIndexBounds(indices, count_u * count_v, vertType, &index_lower_bound, &index_upper_bound);

	VertexDecoder *origVDecoder = GetVertexDecoder((vertType & 0xFFFFFF) | (gstate.getUVGenMode() << 24));
	*bytesRead = count_u * count_v * origVDecoder->VertexSize();

	// Real hardware seems to draw nothing when given < 4 either U or V.
	if (count_u < 4 || count_v < 4) {
		return;
	}

	// Simplify away bones and morph before proceeding
	SimpleVertex *simplified_control_points = (SimpleVertex *)(decoded + 65536 * 12);
	u8 *temp_buffer = decoded + 65536 * 18;

	u32 origVertType = vertType;
	vertType = NormalizeVertices((u8 *)simplified_control_points, temp_buffer, (u8 *)control_points, index_lower_bound, index_upper_bound, vertType);

	VertexDecoder *vdecoder = GetVertexDecoder(vertType);

	int vertexSize = vdecoder->VertexSize();
	if (vertexSize != sizeof(SimpleVertex)) {
		ERROR_LOG(G3D, "Something went really wrong, vertex size: %i vs %i", vertexSize, (int)sizeof(SimpleVertex));
	}

	// TODO: Do something less idiotic to manage this buffer
	SimpleVertex **points = new SimpleVertex *[count_u * count_v];

	// Make an array of pointers to the control points, to get rid of indices.
	for (int idx = 0; idx < count_u * count_v; idx++) {
		points[idx] = simplified_control_points + (indices ? idxConv.convert(idx) : idx);
	}

	int count = 0;

	u8 *dest = splineBuffer;

	SplinePatchLocal patch;
	patch.tess_u = tess_u;
	patch.tess_v = tess_v;
	patch.type_u = type_u;
	patch.type_v = type_v;
	patch.count_u = count_u;
	patch.count_v = count_v;
	patch.points = points;
	patch.computeNormals = computeNormals;
	patch.primType = prim_type;
	patch.patchFacing = patchFacing;

	if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) {
	
		float *pos = (float*)(decoded + 65536 * 18); // Size 4 float
		float *tex = pos + count_u * count_v * 4; // Size 4 float
		float *col = tex + count_u * count_v * 4; // Size 4 float
		const bool hasColor = (origVertType & GE_VTYPE_COL_MASK) != 0;
		const bool hasTexCoords = (origVertType & GE_VTYPE_TC_MASK) != 0;

		int posStride, texStride, colStride;
		tessDataTransfer->PrepareBuffers(pos, tex, col, posStride, texStride, colStride, count_u * count_v, hasColor, hasTexCoords);
		float *p = pos;
		float *t = tex;
		float *c = col;
		for (int idx = 0; idx < count_u * count_v; idx++) {
			memcpy(p, points[idx]->pos.AsArray(), 3 * sizeof(float));
			p += posStride;
			if (hasTexCoords) {
				memcpy(t, points[idx]->uv, 2 * sizeof(float));
				t += texStride;
			}
			if (hasColor) {
				memcpy(c, Vec4f::FromRGBA(points[idx]->color_32).AsArray(), 4 * sizeof(float));
				c += colStride;
			}
		}
		if (!hasColor)
			memcpy(col, Vec4f::FromRGBA(points[0]->color_32).AsArray(), 4 * sizeof(float));

		tessDataTransfer->SendDataToShader(pos, tex, col, count_u * count_v, hasColor, hasTexCoords);
		TessellateSplinePatchHardware(dest, quadIndices_, count, patch);
		numPatches = (count_u - 3) * (count_v - 3);
	} else {
		int maxVertexCount = SPLINE_BUFFER_SIZE / vertexSize;
		TessellateSplinePatch(dest, quadIndices_, count, patch, origVertType, maxVertexCount);
	}
	delete[] points;

	u32 vertTypeWithIndex16 = (vertType & ~GE_VTYPE_IDX_MASK) | GE_VTYPE_IDX_16BIT;

	UVScale prevUVScale;
	if ((origVertType & GE_VTYPE_TC_MASK) != 0) {
		// We scaled during Normalize already so let's turn it off when drawing.
		prevUVScale = gstate_c.uv;
		gstate_c.uv.uScale = 1.0f;
		gstate_c.uv.vScale = 1.0f;
		gstate_c.uv.uOff = 0.0f;
		gstate_c.uv.vOff = 0.0f;
	}

	uint32_t vertTypeID = GetVertTypeID(vertTypeWithIndex16, gstate.getUVGenMode());

	int generatedBytesRead;
	DispatchSubmitPrim(splineBuffer, quadIndices_, primType[prim_type], count, vertTypeID, &generatedBytesRead);

	DispatchFlush();

	if ((origVertType & GE_VTYPE_TC_MASK) != 0) {
		gstate_c.uv = prevUVScale;
	}
}
Exemplo n.º 24
0
void SysConf::GetSiteNf(vector<double> & NSiteCount,vector<double> & Ncount, vector<double> & Ndimer)
{
	// ---> Dimensions
	//      Ncount		: 4
	//	NSiteCount	: L
	//	MeanDimer	: L * NbOfNeights

	int test_Ncount = 0;

	int index = 0;

	int spinPos = 0;
	int neighPos = 0;

	int spinValue = 0;
	int neighValue = 0;

	// Reset vectors
	for(int iii = 0; iii < 4; ++iii)
		Ncount[iii] = 0;

	for(int iii = 0; iii < L; ++iii)
	{
		NSiteCount[iii] = 0;
		for(int jjj = 0; jjj < NbOfNeights; ++jjj)
		{
			Ndimer[idxConv(NbOfNeights,iii,jjj)] = 0;
		}
	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int lll = 0; lll < L; ++lll)
		{
			// Count the number of dimers
			test_Ncount	= 0;
			spinPos 	= idxConv(N,lll,nnn);
			spinValue 	= (int)spinConf[spinPos];

			if(spinValue!=0)
			{
				for(int iii = 0; iii < NbOfNeights;++iii)
				{
					index 		= idxConv(NbOfNeights,lll,iii);
					neighPos	= idxConv(N,neighboursTable[index],nnn);

				#if BORDER_TYPE == 4
				// ANTI-PERIODIC BORDERS
					neighValue	= weightTable[index]*(int)spinConf[neighPos];
				#else
					neighValue	= (int)spinConf[neighPos];
				#endif

					if(neighValue==spinValue)
					{
						++test_Ncount;
						Ndimer[index] += 1./N;
					}
				}

				Ncount[test_Ncount] 	+= 1./N;
				NSiteCount[lll]		+= (double)test_Ncount/N;
			}

		}
	}
}
Exemplo n.º 25
0
void	SysConf::GetSxSxCorrelation(vector<double>& corr)
{
	//   corr[nnn] 		= Sum_iii [ <A_(iii,0) A_(iii,nnn*dB)>_iii ]
	//   siteMean[iii]	= Sum_nnn [ <A_(iii,nnn)>_nnn ]

	for(int nnn = 0; nnn < N; ++nnn)
	{
		corr[nnn] = 0;
	}

	char firstDummy = 0;
	char secondDummy = 0;

	int firstSx = 0;
	int layerSx = 0;

	int nStep = 30;
	int deltaN = N/nStep;

	int pbcnnn = -1;

	for(int iii = 0; iii < L; ++iii)
	{
		for(int mmm = 0; mmm < N; mmm += deltaN)
		{
			firstDummy = spinConf[idxConv(N,iii,mmm)];
			if(mmm != N - 1)
			{
				secondDummy = -spinConf[idxConv(N,iii,mmm+1)];
			}
			else
			{
				secondDummy = -spinConf[idxConv(N,iii,0)];
			}
			firstSx = ( firstDummy == secondDummy );

			// mmm is the correlation shift

			// -> Dummy zero layer
			corr[0] += 1;

			// -> Calculate it up to nnn = N - 2
			for(int nnn = 1; nnn < N - 1 - mmm; ++nnn)
			{
				firstDummy = spinConf[idxConv(N,iii,mmm+nnn)];
				secondDummy = -spinConf[idxConv(N,iii,mmm+nnn+1)];

				layerSx = ( firstDummy == secondDummy );
				corr[nnn] += firstSx*layerSx;
			}

			// -> Consider the periodic boundary condition for nnn + mmm = N - 1
			if(mmm != N-1)
			{
				pbcnnn = N - 1 - mmm;
				firstDummy = spinConf[idxConv(N,iii,N - 1)];
				secondDummy = -spinConf[idxConv(N,iii,0)];

				layerSx = ( firstDummy == secondDummy );
				corr[pbcnnn] += firstSx*layerSx;
			}

			// -> And then for the rest
			for(int nnn = N - mmm; nnn < N; ++nnn)
			{
				firstDummy = spinConf[idxConv(N,iii,mmm + nnn - N)];
				secondDummy = -spinConf[idxConv(N,iii,mmm + nnn -N +1)];

				layerSx = ( firstDummy == secondDummy );
				corr[nnn] += firstSx*layerSx;
			}
//			firstDummy = spinConf[idxConv(N,iii,mmm)];
//			if(mmm != N - 1)
//			{
//				secondDummy = -spinConf[idxConv(N,iii,mmm+1)];
//			}
//			else
//			{
//				secondDummy = -spinConf[idxConv(N,iii,0)];
//			}
//			firstSx = ( firstDummy == secondDummy );
//
//			// Cover *most* of the layers
//			for(int nnn = 0; nnn < mmm; ++nnn)
//			{
//				firstDummy = spinConf[idxConv(N,iii,nnn)];
//				secondDummy = -spinConf[idxConv(N,iii,nnn+1)];
//				layerSx = ( firstDummy == secondDummy );
//				corr[N - mmm+nnn] += firstSx*layerSx;
//			}
//
//			for(int nnn = mmm; nnn < N - 1; ++nnn)
//			{
//				firstDummy = spinConf[idxConv(N,iii,nnn)];
//				secondDummy = -spinConf[idxConv(N,iii,nnn+1)];
//				layerSx = ( firstDummy == secondDummy );
//				corr[nnn-mmm] += firstSx*layerSx;
//			}
//
//			// Deal with boundary case : nnn = N - 1
//			firstDummy = spinConf[idxConv(N,iii,N - 1)];
//			secondDummy = -spinConf[idxConv(N,iii,0)];
//			layerSx = ( firstDummy == secondDummy );
//			corr[N - 1 - mmm] += firstSx*layerSx;
		}
	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		corr[nnn] 		= corr[nnn]/(nStep*L*Kz*Kz); // Kz = DBeta
	}
}
Exemplo n.º 26
0
void SysConf::GetSiteNf(vector<double> & NSiteCount,vector<double> & Ncount,vector<double> & Ndimer,vector<double> & MeanSublattice)
{
	// ---> Dimensions
	//      Ncount		: 4
	//	NSiteCount	: L
	//	MeanDimer	: L * NbOfNeights

	int test_Ncount = 0;
	int N3Count = 0;

	int index = 0;

	int spinPos = 0;
	int neighPos = 0;

	int spinValue = 0;
	int neighValue = 0;

	// Reset vectors
	for(int iii = 0; iii < 4; ++iii)
	{
		Ncount[iii] = 0;
	}

	for(int iii = 0; iii < L; ++iii)
	{
		NSiteCount[iii] = 0;
		for(int jjj = 0; jjj < NbOfNeights; ++jjj)
		{
			Ndimer[idxConv(NbOfNeights,iii,jjj)] = 0;
		}
	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int lll = 0; lll < L; ++lll)
		{
			// Count the number of dimers
			test_Ncount	= 0;
			spinPos 	= idxConv(N,lll,nnn);
			spinValue 	= (int)spinConf[spinPos];

			if(spinValue!=0)
			{
				for(int iii = 0; iii < NbOfNeights;++iii)
				{
					index 		= idxConv(NbOfNeights,lll,iii);
					neighPos	= idxConv(N,neighboursTable[index],nnn);

				#if BORDER_TYPE == 4
				// ANTI-PERIODIC BORDERS
					neighValue	= weightTable[index]*(int)spinConf[neighPos];
				#else
					neighValue	= (int)spinConf[neighPos];
				#endif

					if(neighValue==spinValue)
					{
						++test_Ncount;
						Ndimer[index] += 1./N;
					}
				}

				DimerDensityProfile[spinPos] = test_Ncount;
				Ncount[test_Ncount] 	+= 1./N;
				NSiteCount[lll]		+= (double)test_Ncount/N;

				if(test_Ncount==3)
				{
					N3_Map[N3Count] = spinPos;
					++N3Count;
				}
			}

		}
	}

	if(SimType.compare("Moessner")==0||SimType.compare("Manual")==0)
	{
		GetSublattice(MeanSublattice,NSiteCount);
	}
}
Exemplo n.º 27
0
void SysConf::GetSiteNf(vector<double> & NSiteCount,vector<double> & Ncount,vector<double> & Ndimer,vector<double> & MeanSublattice,vector<complex<double> >& complexPhaseVector,vector<double>& realPhaseVector,complex<double>& complexPhase,double& realPhase)
{
	// ---> Dimensions
	//      Ncount		: 4
	//	NSiteCount	: L
	//	MeanDimer	: L * NbOfNeights

	int test_Ncount = 0;
	int N3Count = 0;

	int index = 0;

	int spinPos = 0;
	int neighPos = 0;

	int spinValue = 0;
	int neighValue = 0;

	// Reset vectors
	for(int iii = 0; iii < 4; ++iii)
	{
		Ncount[iii] = 0;
	}

	for(int iii = 0; iii < L; ++iii)
	{
		NSiteCount[iii] = 0;
		for(int jjj = 0; jjj < NbOfNeights; ++jjj)
		{
			Ndimer[idxConv(NbOfNeights,iii,jjj)] = 0;
		}
	}

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int lll = 0; lll < L; ++lll)
		{
			// Count the number of dimers
			test_Ncount	= 0;
			spinPos 	= idxConv(N,lll,nnn);
			spinValue 	= (int)spinConf[spinPos];

			if(spinValue!=0)
			{
				for(int iii = 0; iii < NbOfNeights;++iii)
				{
					index 		= idxConv(NbOfNeights,lll,iii);
					neighPos	= idxConv(N,neighboursTable[index],nnn);

				#if BORDER_TYPE == 4
				// ANTI-PERIODIC BORDERS
					neighValue	= weightTable[index]*(int)spinConf[neighPos];
				#else
					neighValue	= (int)spinConf[neighPos];
				#endif

					if(neighValue==spinValue)
					{
						++test_Ncount;
						Ndimer[index] += 1./N;
					}
				}

				DimerDensityProfile[spinPos] = test_Ncount;
				Ncount[test_Ncount] 	+= 1./N;
				NSiteCount[lll]		+= (double)test_Ncount/N;

				if(test_Ncount==3)
				{
					N3_Map[N3Count] = spinPos;
					++N3Count;
				}
			}
		}
	}

	if(SimType.compare("Moessner")==0||SimType.compare("Manual")==0)
	{
		GetSublattice(MeanSublattice,NSiteCount);
	}

	// Calculate the plaquette and columnar indexes
	int Sub0Value = 0;
	int Sub1Value = 0;
	int spinNeigh1 = 0;
	int spinNeigh0 = 0;
	int index0 = 0;
	int index1 = 0;

	for(int iii = 0; iii < N; ++iii)
	{
		complexPhaseVector[iii] = 0;
	}
	int chosenSublattice = -1;

	int lll = 0;
	int nnn = 0;
	for(int iii = 0; iii < N3Count; ++iii)
	{
		spinPos = N3_Map[iii];
		lll = spinPos/N;
		nnn = spinPos%N;

		// Complex phase
		chosenSublattice = SublatticePositions[lll];
		complexPhaseVector[nnn] += Jindex[chosenSublattice];
	}

	complexPhase = complexPhase/((double)N*L);
	realPhase = cos(3*arg(complexPhase));

	complexPhase = 0.;
	for(int iii = 0; iii < N; ++iii)
	{
		complexPhaseVector[iii] = complexPhaseVector[iii]/((double)L);
		realPhaseVector[iii] = cos(3*arg(complexPhaseVector[iii]));
		complexPhase += complexPhaseVector[iii];
	}
	complexPhase = complexPhase/((double)N);
	realPhase = cos(3*arg(complexPhase));
}
Exemplo n.º 28
0
void SysConf::GetNf(vector<double> &Ncount)
{
	int test_Ncount = 0;

	int spinPos = 0;
	int spinValue = 0;

	int neighPos = 0;
	int neighValue = 0;

	int index = 0;
	for(int iii = 0; iii < 4; ++iii)
		Ncount[iii] = 0;

	for(int nnn = 0; nnn < N; ++nnn)
	{
		for(int lll = 0; lll < L; ++lll)
		{
			// Count the number of dimers
			test_Ncount	= 0;
			spinPos 	= idxConv(N,lll,nnn);
			spinValue 	= (int)spinConf[spinPos];

			if(spinValue!=0)
			{
				for(int iii = 0; iii < NbOfNeights;++iii)
				{
					index 		= idxConv(NbOfNeights,lll,iii);
					neighPos	= idxConv(N,neighboursTable[index],nnn);

				#if BORDER_TYPE == 4
				// ANTI-PERIODIC BORDERS
					neighValue	= weightTable[index]*(int)spinConf[neighPos];
				#else
					neighValue	= (int)spinConf[neighPos];
				#endif

					if(neighValue==spinValue)
					{
						++test_Ncount;
					}
				}

				Ncount[test_Ncount] 	+= 1./N;
			}
		}
	}

//	for(int lll = 0; lll < L; ++lll)
//	{
//		for(int nnn = 0; nnn < N; ++nnn)
//		{
//			test = 0;
//			for(int iii = 0; iii < NbOfNeights;++iii)
//			{
//				index = idxConv(NbOfNeights,lll,iii);
//				test += (int)spinConf[idxConv(N,neighboursTable[index],nnn)];
//			}
//
//			switch(test)
//			{
//				case 0:
//					Ncount[3] += 1;
//					break;
//				case 2:
//					Ncount[2]  += 1;
//					break;
//				case -2:
//					Ncount[2]  += 1;
//					break;
//				case 4:
//					Ncount[1]  += 1;
//					break;
//				case -4:
//					Ncount[1]  += 1;
//					break;
//				case 6:
//					Ncount[0]  += 1;
//					break;
//				case -6:
//					Ncount[0]  += 1;
//					break;
//			}
//		}
//	}
//
//	for(int iii = 0; iii < 4; ++iii)
//		Ncount[iii] = Ncount[iii]/N;
}
Exemplo n.º 29
0
void SysConf::SetSublatticeMoessner()
{
	int idx = 0;

	SublatticeSize.resize(3,L/3);

	SublatticePositions.resize(L,0);

	SublatticeA.resize(0);
	SublatticeA.reserve(L/3);

	SublatticeB.resize(0);
	SublatticeB.reserve(L/3);

	SublatticeC.resize(0);
	SublatticeC.reserve(L/3);

	for(int iii = 0; iii < ny/3; ++iii)
	{
		for(int jjj = 0; jjj < nx/3; ++jjj)
		{
			// First line
			// A
			idx = idxConv(nx,3*iii,3*jjj);
			SublatticeA.push_back(idx);
			SublatticePositions[idx] = 0;

			// B
			idx = idxConv(nx,3*iii,3*jjj+1);
			SublatticeB.push_back(idx);
			SublatticePositions[idx] = 1;

			// C
			idx = idxConv(nx,3*iii,3*jjj+2);
			SublatticeC.push_back(idx);
			SublatticePositions[idx] = 2;

			// Second line
			// C
			idx = idxConv(nx,3*iii+1,3*jjj);
			SublatticeC.push_back(idx);
			SublatticePositions[idx] = 2;

			// A
			idx = idxConv(nx,3*iii+1,3*jjj+1);
			SublatticeA.push_back(idx);
			SublatticePositions[idx] = 0;

			// B
			idx = idxConv(nx,3*iii+1,3*jjj+2);
			SublatticeB.push_back(idx);
			SublatticePositions[idx] = 1;

			// Third line
			// B
			idx = idxConv(nx,3*iii+2,3*jjj);
			SublatticeB.push_back(idx);
			SublatticePositions[idx] = 1;

			// C
			idx = idxConv(nx,3*iii+2,3*jjj+1);
			SublatticeC.push_back(idx);
			SublatticePositions[idx] = 2;

			// A
			idx = idxConv(nx,3*iii+2,3*jjj+2);
			SublatticeA.push_back(idx);
			SublatticePositions[idx] = 0;
		}
	}
}
Exemplo n.º 30
0
void SysConf::SetSublatticeManual()
{
	int idx = 0;

	bool countA = true;
	bool countB = true;
	bool countC = true;

	SublatticeSize.resize(3,0);

	SublatticePositions.resize(L,0);

	SublatticeA.resize(0);
	SublatticeA.reserve(L/3);

	SublatticeB.resize(0);
	SublatticeB.reserve(L/3);

	SublatticeC.resize(0);
	SublatticeC.reserve(L/3);

	for(int lll = 0; lll < L/3; ++lll)
	{
		countA = true;
		countB = true;
		countC = true;

		idx = 3*lll;
		for(int kkk = 0; kkk < 6; ++kkk)
		{
			if(neighboursTable[idxConv(6,idx,kkk)]>L-1)
			{
				countA = false;
				break;
			}
		}

		if(countA)
		{
			SublatticeA.push_back(idx);
			++SublatticeSize[0];
			SublatticePositions[idx] = 0;
		}

		idx = 3*lll+1;
		for(int kkk = 0; kkk < 6; ++kkk)
		{
			if(neighboursTable[idxConv(6,idx,kkk)]>L-1)
			{
				countB = false;
				break;
			}
		}

		if(countB)
		{
			SublatticeB.push_back(idx);
			++SublatticeSize[1];
			SublatticePositions[idx] = 1;
		}

		idx = 3*lll+2;
		for(int kkk = 0; kkk < 6; ++kkk)
		{
			if(neighboursTable[idxConv(6,idx,kkk)]>L-1)
			{
				countC = false;
				break;
			}
		}

		if(countC)
		{
			SublatticeC.push_back(idx);
			++SublatticeSize[2];
			SublatticePositions[idx] = 2;
		}
	}
}