Beispiel #1
0
int Conf::readConf()
{
	ifstream iconf("configure");
	if(!iconf)
	{
		cout << "Cannot open configure file" << endl;
		return 1;
	}
	iconf >> city;
	iconf.close();

	ifstream ifile(("configure_" + city).c_str());
	if(!ifile)
	{
		cout << "Cannot open " + city + " configure file" << endl;
		return 1;
	}
	string s;
	while(ifile >> s)
	{
		if(s == "nodeFile")
			ifile >> nodeFilePath;
		else if(s == "edgeFile")
			ifile >> edgeFilePath;
		else if(s == "trajectoryFile")
Beispiel #2
0
int Evolve::gutz() //counts number of doubly-occupied sites
{
    int j,n;
    n=0;
    for(j=0;j<n_sites;j++)
    {
        if(iconf(j)==2)
        {
            n++;
        }
    }
    return n;
}
Beispiel #3
0
double Evolve::calculate_eloc() //called from the main if metropolis says ok. Calles propose_hop to get the K. Iconf is untouched.
{
    int response;
    double K,gutz_save;

    gutz_save=gutz_new;//salviamo  il parametro attuale, perchè propose_hop lo cambia
    eloc=0;

    for(start=0;start<n_sites;start++)
    {
        for(direction=0;direction<2;direction++)
        {
            if(iconf(start)==2) //se lo stato è doppiamente occupato devo fare due volte
            {
                for(chooser_if_double=0;chooser_if_double<2;chooser_if_double++)
                {
                    response=propose_hop_sistematic();//cerco i vicini accessibili. Questo dà 0 oppure 1 e modifica iconf (tanto l'abbiamo salvato)
                    if(response==1)
                    {
                        K=get_K(); //come se stessi evolvendo. Serve per eloc
                        eloc=eloc-t*K;
                    }
                }
            }
            else //faccio una volta sola
            {
                response=propose_hop_sistematic();//cerco i vicini accessibili. Questo dà 0 oppure 1 e modifica iconf (tanto l'abbiamo salvato)
                if(response==1)
                {
                    K=get_K(); //come se stessi evolvendo. Serve per eloc
                    eloc=eloc-t*K;
                }
            }
        }
    }
    eloc=eloc+U*gutz_save;//la parte diagonale dell' energia locale dipende dal numero di siti doppiamente occupati.
    return eloc;
}
Beispiel #4
0
int Evolve::propose_hop_sistematic() //iconf is untouched, produces leave, arrive, gutz_old and gutz_new.
{
    gutz_old=gutz(); //current number of doubly-occupied sites
    gutz_new=gutz_old;
    old_occupation=iconf(start); //store the start site value; il prossimo "if" incasina iconf(start) quindi alla fine devo rimetterlo a posto

    if (iconf(start)==2) //if site is doubly occupied fictiously remove a spin
    {
        gutz_new=gutz_new-1;        //site will not be doubly occupied anymore

        if (chooser_if_double==0) //choose to hop the down
        {
            iconf(start)=-1;
        }
        else      //choose to hop the up
        {
            iconf(start)=1;
        }
    }

    if(direction==0) //left hopping, explicitate arrival sites with PBC
    {
        arrive=(start+n_sites-1) % n_sites;
    }
    else             //right hopping, explicitate arrival sites with PBC
    {
        arrive=(start+n_sites+1) % n_sites;
    }

    up_or_down=iconf(start); //store what I'm hopping (needed in case hop is accepted)

    if((iconf(start)!=iconf(arrive)) && (iconf(arrive)!=2)) //say if the hopping is possible
    {
        if((iconf(start)==1) && (iconf(arrive)==0)) //start site is up, arrive is empty
        {
            leave=kelup(start)-1; //store the value of the column I have left
            iconf(start)=old_occupation;
            return 1;
        }
        if((iconf(start)==1) && (iconf(arrive)==-1)) //start site is up, arrive is down
        {
            leave=kelup(start)-1; //store the value of the column I have left
            gutz_new=gutz_new+1; //there is one more doubly occupied site!
            iconf(start)=old_occupation;
            return 1;
        }
        if((iconf(start)==-1) && (iconf(arrive)==0)) //start site is down, arrive is empty
        {
            leave=keldo(start)-1; //store the value of the column I have left
            iconf(start)=old_occupation;
            return 1;
        }
        if((iconf(start)==-1) && (iconf(arrive)==1)) //start site is down, arrive is up
        {
            leave=keldo(start)-1; //store the value of the column I have left
            gutz_new=gutz_new+1; //there is one more doubly occupied site!
            iconf(start)=old_occupation;
            return 1;
        }
   }
   iconf(start)=old_occupation; //put back the old situation in start site. At the end of this mess iconf has not changed!
   return 0;
};
Beispiel #5
0
void Evolve::evolve_iconf() //if metropolis is happy evolves iconf using info from propose_hop
{
    int doubleocc=0; //default: the start site is not doubly occupied

    if (iconf(start)==2) //if start site is doubly occupied fictiously remove a spin
    {
        if (up_or_down==1) //choose to hop the down
        {
            iconf(start)=1;
            doubleocc=-1; //remember there was also an up
        }
        else      //choose to hop the up
        {
            iconf(start)=-1;
            doubleocc=1; //remember there was also a down
        }
    }
    if((iconf(start)==1) && (iconf(arrive)==0)) //start site is up, arrive is empty
    {
        iconf(start)=doubleocc; //reput in start site the spins I fictiously took away, if it was doubly occupied
        iconf(arrive)=1; //set the spin in arrival site
        kels_evolve();
        return;
    }
    if((iconf(start)==1) && (iconf(arrive)==-1)) //start site is up, arrive is down
    {
        iconf(start)=doubleocc; //reput in start site the spins I fictiously took away, if it was doubly occupied
        iconf(arrive)=2; //set the spin in arrival site
        kels_evolve();
        return;
    }
   if((iconf(start)==-1) && (iconf(arrive)==0)) //start site is down, arrive is empty
    {
        iconf(start)=doubleocc; //reput in start site the spins I fictiously took away, if it was doubly occupied
        iconf(arrive)=-1; //set the spin in arrival site
        kels_evolve();
        return;
    }
    if((iconf(start)==-1) && (iconf(arrive)==1)) //start site is down, arrive is up
    {
        iconf(start)=doubleocc; //reput in start site the spins I fictiously took away, if it was doubly occupied
        iconf(arrive)=2; //set the spin in arrival site
        kels_evolve();
        return;
    }
};