Esempio n. 1
0
Matrix makeLD22_channel(Matrix H)
{
	Matrix tempH(8,8);
	double rt = 1 / sqrt((double)2);

	tempH(0,0) = rt * H(0,0);
	tempH(1,0) = rt * H(0,1);
	tempH(2,0) = rt * H(0,2);
	tempH(3,0) = rt * H(0,3);
	tempH(4,0) = rt * H(1,0);
	tempH(5,0) = rt * H(1,1);
	tempH(6,0) = rt * H(1,2);
	tempH(7,0) = rt * H(1,3);

	tempH(0,1) = -rt * H(0,2);
	tempH(1,1) = -rt * H(0,3);
	tempH(2,1) = rt * H(0,0);
	tempH(3,1) = rt * H(0,1);
	tempH(4,1) = -rt * H(1,2);
	tempH(5,1) = -rt * H(1,3);
	tempH(6,1) = rt * H(1,0);
	tempH(7,1) = rt * H(1,1);

	tempH(0,2) = rt * H(0,1);
	tempH(1,2) = rt * H(0,0);
	tempH(2,2) = rt * H(0,3);
	tempH(3,2) = rt * H(0,2);
	tempH(4,2) = rt * H(1,1);
	tempH(5,2) = rt * H(1,0);
	tempH(6,2) = rt * H(1,3);
	tempH(7,2) = rt * H(1,2);

	tempH(0,3) = -rt * H(0,3);
	tempH(1,3) = -rt * H(0,2);
	tempH(2,3) = rt * H(0,1);
	tempH(3,3) = rt * H(0,0);
	tempH(4,3) = -rt * H(1,3);
	tempH(5,3) = -rt * H(1,2);
	tempH(6,3) = rt * H(1,1);
	tempH(7,3) = rt * H(1,0);

	tempH(0,4) = rt * H(0,0);
	tempH(1,4) = -rt * H(0,1);
	tempH(2,4) = rt * H(0,2);
	tempH(3,4) = -rt * H(0,3);
	tempH(4,4) = rt * H(1,0);
	tempH(5,4) = -rt * H(1,1);
	tempH(6,4) = rt * H(1,2);
	tempH(7,4) = -rt * H(1,3);

	tempH(0,5) = -rt * H(0,2);
	tempH(1,5) = rt * H(0,3);
	tempH(2,5) = rt * H(0,0);
	tempH(3,5) = -rt * H(0,1);
	tempH(4,5) = -rt * H(1,2);
	tempH(5,5) = rt * H(1,3);
	tempH(6,5) = rt * H(1,0);
	tempH(7,5) = -rt * H(1,1);

	tempH(0,6) = rt * H(0,1);
	tempH(1,6) = -rt * H(0,0);
	tempH(2,6) = rt * H(0,3);
	tempH(3,6) = -rt * H(0,2);
	tempH(4,6) = rt * H(1,1);
	tempH(5,6) = -rt * H(1,0);
	tempH(6,6) = rt * H(1,3);
	tempH(7,6) = -rt * H(1,2);

	tempH(0,7) = -rt * H(0,3);
	tempH(1,7) = rt * H(0,2);
	tempH(2,7) = rt * H(0,1);
	tempH(3,7) = -rt * H(0,0);
	tempH(4,7) = -rt * H(1,3);
	tempH(5,7) = rt * H(1,2);
	tempH(6,7) = rt * H(1,1);
	tempH(7,7) = -rt * H(1,0);


	return tempH;
}
Esempio n. 2
0
int RSOSObs<T,U>::parallelReceive()
{
	if(!this->MPIEnabled)
		return NOTALLOWED;

#ifndef NOBRANCH
	cavgQ.clear();
	cavgQ2.clear();
	avgH.clear();
	avgH2.clear();
	avgN.clear();
	avgN2.clear();
#endif

	//Wait for all processes to get here
	MPI_Barrier(MPI_COMM_WORLD);
	for(int procId=1;procId<this->procCount;procId++)
	{
		int tag,recv;
		MPI_Status stat;

		MPI_Send(&recv,1,MPI_INT,procId,tag,MPI_COMM_WORLD);
#if DEBUG >= 2
		fprintf(this->log,"RSOSObs Sending notification to process:%d\n",procId);
		fflush(this->log);
#endif

		MPI_Recv(&this->ltime,1,MPI_UNSIGNED,procId,tag,MPI_COMM_WORLD,&stat);

		this->freeEnergy.mpiReceive(procId);

		this->Qx.mpiReceive(procId);
		this->Qx2.mpiReceive(procId);

		this->eH.mpiReceive(procId);
		this->eN.mpiReceive(procId);

#ifndef NOBRANCH
		int lsize;
		MPI_Recv(&lsize,1,MPI_INT,procId,tag,MPI_COMM_WORLD,&stat);
		vector<vect<double>> tempcQ(lsize);
		vector<vect<double>> tempcQ2(lsize);
		if(this->cavgQ.size()<lsize)
		{
			cavgQ.resize(lsize);
			cavgQ2.resize(lsize);
			avgH.resize(lsize);
			avgH2.resize(lsize);
			avgN.resize(lsize);
			avgN2.resize(lsize);
		}

		MPI_Recv(tempcQ.data(),lsize*3,MPI_DOUBLE,procId,tag,MPI_COMM_WORLD,&stat);
		MPI_Recv(tempcQ2.data(),lsize*3,MPI_DOUBLE,procId,tag,MPI_COMM_WORLD,&stat);

		vector<double> tempH(lsize), tempH2(lsize);
		vector<int> tempN(lsize), tempN2(lsize);
		MPI_Recv(tempH.data(),lsize,MPI_DOUBLE,procId,tag,MPI_COMM_WORLD,&stat);
		MPI_Recv(tempH2.data(),lsize,MPI_DOUBLE,procId,tag,MPI_COMM_WORLD,&stat);
		MPI_Recv(tempN.data(),lsize,MPI_INT,procId,tag,MPI_COMM_WORLD,&stat);
		MPI_Recv(tempN2.data(),lsize,MPI_INT,procId,tag,MPI_COMM_WORLD,&stat);

		for(int i = 0;i<lsize;i++)
		{
			cavgQ[i].x += tempcQ[i].x;
			cavgQ2[i].x += tempcQ2[i].x;
			avgH[i] += tempH[i];
			avgH2[i] += tempH2[i];
			avgN[i] += tempN[i];
			avgN2[i] += tempN2[i];
		}


#endif

#if DEBUG >= 2
		fprintf(this->log,"RSOSObs Finished receiving from process:%d\n",procId);
		fflush(this->log);
#endif
	}

	//Compute observables
	this->Zcount++;
	double it = 1.0/(this->ltime*this->dt);
	double lqx = (Qx/freeEnergy).value();
	this->Q.x += it*lqx;
	this->Q2.x += it*it*lqx*lqx;

	double lvx = it*((Qx2/freeEnergy).value() - lqx*lqx);
	this->V.x += lvx;
	this->V2.x += lvx*lvx;

	double offset = log(this->totalWalkers);
	double temp = it*(freeEnergy.logValue()-offset);
	this->fe += temp;
	this->fe2 += temp*temp;

	double lqN = (eN/freeEnergy).value()*it;
	double lqH = (eH/freeEnergy).value()*it;
	this->gN += lqN;
	this->N2 += lqN*lqN;
	this->H += lqH;
	this->H2 += lqH*lqH;

#ifndef NOBRANCH
	//Average Trajectory
	int lsize = cavgQ.size();
	double ait = it/lsize;
	double avgqx = 0.0, avgqx2 = 0.0;

	double avgh = 0.0, avgh2 = 0.0;
	double avgn = 0.0, avgn2 = 0.0;

#if 1
	ofstream dif(this->baseFileName + "A",std::ofstream::out);
#endif
	for(int i = 0;i<lsize;i++)
	{
		double lqx = cavgQ[i].x/this->totalWalkers;
		avgqx += lqx;
		double lqx2 = (cavgQ2[i].x/totalWalkers - lqx*lqx);
		avgqx2 += lqx2;

		double lh = (avgH[i]/totalWalkers);
		avgh += lh;
		double lh2 = (avgH2[i]/totalWalkers - lh*lh);
		avgh2 += lh2;

		double ln = (avgN[i]/totalWalkers);
		avgn += ln;
		double ln2 = (avgN2[i]/totalWalkers - ln*ln);
		avgn2 += ln2;
#if 1
		dif<<i<<" "<<lqx*it<<" "<<lqx2*it<<
				" "<<lh*it<<" "<<ln*it<<endl;
#endif
	}
#if 1
	dif<<"--------------------------\n";
	dif.close();
#endif

	avgqx2 *= ait;
	avgqx *= ait;
	avgh *= ait;
	avgn2 *= ait;
	avgn *= ait;

#endif

	lqx*=it;
	ofstream wif(this->baseFileName + "E",std::ofstream::app);
	wif<<ltime*dt<<" "<<temp<<" "<<lqx<<" "<<lvx
			<<" "<<lqN<<" "<<lqH<<endl;
	wif.close();
#ifndef NOBRANCH
	ofstream aif(this->baseFileName + "D",std::ofstream::app);
	aif<<(this->ltime*this->dt)*lsize<<" "<<avgqx<<" "<<avgqx2
			<<" "<<avgh<<" "<<avgh2<<" "<<avgn<<" "<<avgn2<<endl;
	aif.close();
#endif

	//Reset for next collection
	freeEnergy.resetValue();
	Qx.resetValue();
	Qx2.resetValue();
	eH.resetValue();
	eN.resetValue();

#ifndef NOBRANCH
#endif

}
Esempio n. 3
0
Matrix makeV22_channel(Matrix H)
{
	Matrix tempH(8,8);

	tempH(0,0) = H(0,0);
	tempH(1,0) = 0;
	tempH(2,0) = H(0,2);
	tempH(3,0) = 0;
	tempH(4,0) = H(1,0);
	tempH(5,0) = 0;
	tempH(6,0) = H(1,2);
	tempH(7,0) = 0;

	tempH(0,1) = -H(0,2);
	tempH(1,1) = 0;
	tempH(2,1) = H(0,0);
	tempH(3,1) = 0;
	tempH(4,1) = -H(1,2);
	tempH(5,1) = 0;
	tempH(6,1) = H(1,0);
	tempH(7,1) = 0;

	tempH(0,2) = H(0,1);
	tempH(1,2) = 0;
	tempH(2,2) = H(0,3);
	tempH(3,2) = 0;
	tempH(4,2) = H(1,1);
	tempH(5,2) = 0;
	tempH(6,2) = H(1,3);
	tempH(7,2) = 0;

	tempH(0,3) = -H(0,3);
	tempH(1,3) = 0;
	tempH(2,3) = H(0,1);
	tempH(3,3) = 0;
	tempH(4,3) = -H(1,3);
	tempH(5,3) = 0;
	tempH(6,3) = H(1,1);
	tempH(7,3) = 0;

	tempH(0,4) = 0;
	tempH(1,4) = H(0,0);
	tempH(2,4) = 0;
	tempH(3,4) = H(0,2);
	tempH(4,4) = 0;
	tempH(5,4) = H(1,0);
	tempH(6,4) = 0;
	tempH(7,4) = H(1,2);

	tempH(0,5) = 0;
	tempH(1,5) = -H(0,2);
	tempH(2,5) = 0;
	tempH(3,5) = H(0,0);
	tempH(4,5) = 0;
	tempH(5,5) = -H(1,2);
	tempH(6,5) = 0;
	tempH(7,5) = H(1,0);

	tempH(0,6) = 0;
	tempH(1,6) = H(0,1);
	tempH(2,6) = 0;
	tempH(3,6) = H(0,3);
	tempH(4,6) = 0;
	tempH(5,6) = H(1,1);
	tempH(6,6) = 0;
	tempH(7,6) = H(1,3);

	tempH(0,7) = 0;
	tempH(1,7) = -H(0,3);
	tempH(2,7) = 0;
	tempH(3,7) = H(0,1);
	tempH(4,7) = 0;
	tempH(5,7) = -H(1,3);
	tempH(6,7) = 0;
	tempH(7,7) = H(1,1);

	return tempH;
}