示例#1
0
	void doOneOmega(SizeType it, RealType omega, SizeType threadNum)
	{
		HilbertStateType phiKet0 = phiKet0_;
		HilbertStateType phiKet1 = phiKet1_;
		RealType epsilon = 0.1;
		ComplexType z = ComplexType(omega, epsilon);
		OpDiagonalFactoryType opDiagonalFactory(params_.engine);
		for (SizeType dynType = 0; dynType < 2; ++dynType) {

			RealType signForDen = (dynType == 1) ? -1.0 : 1.0;
			OneOverZminusHType eih(z, signForDen, params_.Eg, params_.engine);
			DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
			if (dynType == 0)
				eihOp.applyTo(phiKet0);
			else
				eihOp.applyTo(phiKet1);
		}

		for (SizeType site1 = 0; site1 < params_.sites; ++site1) {
			result_(it, site1) = doOneOmegaOneSitePair(site1,
			                                          threadNum,
			                                          phiKet0,
			                                          phiKet1);
			std::cerr<<"site1="<<site1<<" "<<result_(it, site1)<<"\n";
		}
	}
示例#2
0
void doOneBeta(const EngineType& engine,
               std::vector<size_t>& ne,
               OpLibFactoryType& opLibFactory,
               size_t site,
               size_t sigma,
               RealType beta)
{
	RealType sum = 0;
	RealType sum2 = 0;
	RealType denominator = 0;
	FreeFermions::Combinations combinations(engine.size(),ne[0]);
	size_t factorToMakeItSmaller = 1;
	for (size_t i = 0; i<combinations.size(); ++i) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		EtoTheBetaHType ebh(beta,engine,0);
		DiagonalOperatorType& eibOp = opDiagonalFactory(ebh);
		
		std::vector<size_t> vTmp(engine.size(),0);
		for (size_t j=0;j<combinations(i).size();++j) vTmp[combinations(i)[j]]=1;
		std::vector<std::vector<size_t> > occupations(1,vTmp);
		HilbertStateType thisState(engine,occupations);
		HilbertStateType phi = thisState;
		eibOp.applyTo(phi);
		denominator += scalarProduct(thisState,phi)*factorToMakeItSmaller;
		LibraryOperatorType& myOp2 = opLibFactory(LibraryOperatorType::N,site,sigma);
		myOp2.applyTo(phi);
		sum += scalarProduct(thisState,phi)*factorToMakeItSmaller;
		myOp2.applyTo(phi);
		sum2 += scalarProduct(thisState,phi)*factorToMakeItSmaller;
	}
	std::cout<<beta<<" "<<sum<<" "<<denominator<<" "<<sum/denominator<<" "<<sum2/denominator<<"\n";	
}
示例#3
0
int main(int argc,char *argv[])
{
	int opt;
	size_t n =0,electronsUp=0,total=0;
	RealType offset = 0;
	std::vector<size_t> sites;
	std::vector<std::string> str;
	bool ladder = false;
	RealType step = 0;
	while ((opt = getopt(argc, argv, "n:e:s:t:o:i:l")) != -1) {
		switch (opt) {
		case 'n':
			n = atoi(optarg);
			break;
		case 'e':
			electronsUp = atoi(optarg);
			break;
		case 's':
			PsimagLite::tokenizer(optarg,str,",");
			for (size_t i=0;i<str.size();i++)
				sites.push_back(atoi(str[i].c_str()));
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'l':
			ladder = true;
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}
	if (n==0 || total==0) throw std::runtime_error("Wrong usage\n");

	size_t dof = 1; // spinless

	GeometryParamsType geometryParams;
	geometryParams.sites = n;
	GeometryLibraryType* geometry;

	if (!ladder) {
		geometryParams.type = GeometryLibraryType::CHAIN;
		geometry = new GeometryLibraryType(geometryParams);
	} else {
		geometryParams.type = GeometryLibraryType::LADDER;
		geometryParams.leg = 2;
		geometryParams.hopping.resize(2);
		geometryParams.hopping[0] = 1.0;
		geometryParams.hopping[1] = 0.5;
		geometry = new GeometryLibraryType(geometryParams);
	}

	std::cerr<<geometry;
	
	ConcurrencyType concurrency(argc,argv);
	EngineType engine(*geometry,concurrency,dof,true);

	std::vector<size_t> ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	size_t sigma =0;
	OpNormalFactoryType opNormalFactory(engine);
	OperatorType& myOp = opNormalFactory(OperatorType::DESTRUCTION,sites[0],sigma);
	HilbertStateType phi2 = gs;
	myOp.applyTo(phi2);
	
//	FieldType density = scalarProduct(phi2,phi2);
//	std::cerr<<"density="<<density<<"\n";
	
	std::cout<<"#site="<<sites[0]<<"\n";
	std::cout<<"#site2="<<sites[1]<<"\n";
	for (size_t it = 0; it<total; it++) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		RealType time = it * step + offset;
		EtoTheIhTimeType eih(time,engine,0);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		HilbertStateType phi = gs;
		myOp.applyTo(phi);
		eihOp.applyTo(phi);
		OperatorType& myOp2 = opNormalFactory(OperatorType::DESTRUCTION,sites[1],sigma);
		myOp2.applyTo(phi);
		std::cout<<time<<" "<<scalarProduct(phi,phi)<<"\n";
	}
	
	delete geometry;
}
示例#4
0
int main(int argc,char *argv[])
{
	int opt;
	PsimagLite::String file("");
	SizeType total=0;
	RealType offset = 0;
	RealType step = 0;
	SizeType site3 = 0;

	while ((opt = getopt(argc, argv, "f:t:o:i:p:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'p':
			site3 = atoi(optarg);
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}

	if (file=="") {
		throw std::runtime_error("Wrong usage\n");
	}

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);
	PsimagLite::Vector<SizeType>::Type sites;
	GeometryParamsType::readVector(sites,file,"TSPSites");
	sites.resize(3);
	sites[2] = site3;

	SizeType dof = 1; // spinless

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;
	
	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),dof,true);

	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	SizeType sigma =0;
	OpNormalFactoryType opNormalFactory(engine);
	OperatorType& myOp = opNormalFactory(OperatorType::DESTRUCTION,sites[0],sigma);
	HilbertStateType phi2 = gs;
	myOp.applyTo(phi2);
	
//	FieldType density = scalarProduct(phi2,phi2);
//	std::cerr<<"density="<<density<<"\n";
	
	std::cout<<"#site="<<sites[0]<<"\n";
	std::cout<<"#site2="<<sites[1]<<"\n";
	for (SizeType it = 0; it<total; it++) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		RealType time = it * step + offset;
		EtoTheIhTimeType eih(time,engine,0);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		HilbertStateType phi = gs;
		myOp.applyTo(phi);
		eihOp.applyTo(phi);
		OperatorType& myOp2 = opNormalFactory(OperatorType::DESTRUCTION,sites[1],sigma);
		myOp2.applyTo(phi);
		std::cout<<time<<" "<<scalarProduct(phi,phi)<<"\n";
	}
}
示例#5
0
int main(int argc,char *argv[])
{
	int opt;
	size_t n =0,electronsUp=0,total=0;
	RealType offset = 0;
	std::vector<size_t> sites;
	std::vector<std::string> str;
	RealType step = 0;
	GeometryParamsType geometryParams;
	std::vector<RealType> v;

	while ((opt = getopt(argc, argv, "n:e:b:s:t:o:i:g:p:")) != -1) {
		switch (opt) {
		case 'n':
			n = atoi(optarg);
			break;
		case 'e':
			electronsUp = atoi(optarg);
			break;
		case 's':
			str.clear();
			PsimagLite::tokenizer(optarg,str,",");
			for (size_t i=0;i<str.size();i++) {
				sites.push_back(atoi(str[i].c_str()));
			}
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'g':
			str.clear();
			PsimagLite::tokenizer(optarg,str,",");
			setMyGeometry(geometryParams,str);
			break;
		case 'p':
			readPotential(v,optarg);
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}
	if (n==0 || total==0) throw std::runtime_error("Wrong usage\n");
	
	size_t dof = 2; // spin up and down
	geometryParams.sites = n;
	GeometryLibraryType geometry(geometryParams);

	if (geometryParams.type!=GeometryLibraryType::KTWONIFFOUR) {
		geometry.addPotential(v);
	}

	std::cerr<<geometry;
	
	ConcurrencyType concurrency(argc,argv);
	EngineType engine(geometry,concurrency,dof,false);
	
	std::vector<size_t> ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	bool verbose = false;
	HilbertStateType gs(engine,ne,debug);
	
// 	size_t sigma3 = 0;
	
	FieldType superdensity = calcSuperDensity(sites[0],sites[1],gs,engine);
	std::cout<<"#superdensity="<<superdensity<<"\n";
	std::cout<<"#site="<<sites[0]<<" site2="<<sites[1]<<"\n";
	
	PsimagLite::Range<ConcurrencyType> range(0,total,concurrency);
	enum {SPIN_UP,SPIN_DOWN};
	
	while(!range.end()) {
		size_t it = range.index();

		OpNormalFactoryType opNormalFactory(engine);
		OpLibFactoryType opLibFactory(engine);
		OpDiagonalFactoryType opDiagonalFactory(engine);
		
		RealType time = it * step + offset;
		EtoTheIhTimeType eih(time,engine,0);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		
// 		HilbertStateType savedVector = gs;
//		FieldType savedValue = 0;
// 		FieldType sum = 0;
		std::vector<HilbertStateType*> savedVector(4);
		
		for (size_t sigma = 0;sigma<2;sigma++) {
			HilbertStateType phi = gs;
			LibraryOperatorType& myOp = opLibFactory(
				LibraryOperatorType::N,sites[0],1-sigma);
			myOp.applyTo(phi);
			
			OperatorType& myOp2 = opNormalFactory(OperatorType::CREATION,
												  sites[0],sigma);
			myOp2.applyTo(phi);
			
			for (size_t sigma2 = 0;sigma2 < 2;sigma2++) {
				savedVector[sigma+sigma2*2] = new HilbertStateType(phi);
				
				
				LibraryOperatorType& myOp3 = opLibFactory(
					LibraryOperatorType::NBAR,sites[1],1-sigma2);
				myOp3.applyTo(*savedVector[sigma+sigma2*2]);
				
				OperatorType& myOp4 = opNormalFactory(
					OperatorType::DESTRUCTION,sites[1],sigma2);
				myOp4.applyTo(*savedVector[sigma+sigma2*2]);
				
				if (verbose) std::cerr<<"Applying exp(iHt)\n";
				eihOp.applyTo(*savedVector[sigma+sigma2*2]);
				
				if (verbose) std::cerr<<"Applying c_{p down}\n";
				OperatorType& myOp6 = opNormalFactory(
					OperatorType::DESTRUCTION,sites[2],SPIN_DOWN);
				myOp6.applyTo(*savedVector[sigma+sigma2*2]);
				
				if (verbose) std::cerr<<"Applying c_{p up}\n";
				OperatorType& myOp7 = opNormalFactory(
					OperatorType::DESTRUCTION,sites[2],SPIN_UP);
				myOp7.applyTo(*savedVector[sigma+sigma2*2]);
				
// 				if (verbose) std::cerr<<"Adding "<<sigma<<" "<<sigma2<<" "<<it<<"\n";
// 				
// 				if (sigma ==0 && sigma2 ==0) savedVector = phi3;
// 				if (sigma ==1 && sigma2 ==1) {
// 					savedValue = scalarProduct(phi3,savedVector);
// 				}
// 				sum += scalarProduct(phi3,phi3);
// 				if (verbose) std::cerr<<"Done with scalar product\n";
			}
		}
		FieldType sum = 0;
		size_t total = savedVector.size()*savedVector.size()/2;
		for (size_t x=0;x<total;x++) {
			size_t sigma = (x & 3);
			size_t sigma2 = (x & 12);
			sigma2 >>= 2;
			sum += scalarProduct(*savedVector[sigma],*savedVector[sigma2]);
		}
		for (size_t x=0;x<savedVector.size();x++) delete savedVector[x];
		
		std::cout<<time<<" "<<(2.0*sum)<<"\n";
		range.next();
	}
}
示例#6
0
int main(int argc,char *argv[])
{
	int opt;
	PsimagLite::String file("");
	SizeType total=0;
	RealType offset = 0;
	RealType step = 0;
	SizeType dynType = DYN_TYPE_0;

	while ((opt = getopt(argc, argv, "f:t:o:i:d")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'd':
			dynType = DYN_TYPE_1;
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}

	if (file=="") {
		throw std::runtime_error("Wrong usage\n");
	}

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);
	PsimagLite::Vector<SizeType>::Type sites;
	GeometryParamsType::readVector(sites,file,"TSPSites");

	SizeType dof = 1; // spinless

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;

	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),dof,true);

	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	RealType Eg = 0;
	for (SizeType i=0;i<ne[0];i++) Eg += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*Eg<<"\n";

	SizeType sigma =0;
	OpNormalFactoryType opNormalFactory(engine);
	SizeType creatOrDest = (dynType == DYN_TYPE_1) ? OperatorType::CREATION : OperatorType::DESTRUCTION;

	OperatorType& opKet = opNormalFactory(creatOrDest,sites[0],sigma);
	HilbertStateType phiKet = gs;
	opKet.applyTo(phiKet);

	if (sites.size() == 1) {
		sites.resize(2);
		sites[1] = sites[0];
	}

	OperatorType& opBra = opNormalFactory(creatOrDest,sites[1],sigma);
	HilbertStateType phiBra = gs;
	opBra.applyTo(phiBra);

	FieldType density = scalarProduct(phiBra,phiKet);
	std::cerr<<"density="<<density<<"\n";

	std::cout<<"#site="<<sites[0]<<"\n";
	std::cout<<"#site2="<<sites[1]<<"\n";

	RealType epsilon = 1e-2;
	for (SizeType it = 0; it<total; it++) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		RealType omega = it * step + offset;
		ComplexType z = ComplexType(omega,epsilon);
		int sign = (dynType== DYN_TYPE_1) ? -1 : 1;
		OneOverZminusHType eih(z,sign,Eg,engine);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		HilbertStateType phi3 = phiKet;
		eihOp.applyTo(phi3);
		FieldType tmpC = scalarProduct(phiBra,phi3);

		std::cout<<omega<<" "<<std::imag(tmpC)<<" "<<std::real(tmpC)<<"\n";
	}
}