Exemple #1
0
int main(int argc, char* argv[]){
  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);

  if(myrank==0){
    cout << "starting program" << endl;
    cout << "numprocs" << numprocs << endl;
  }
  
  time_t tStart = time(NULL);
 
  kx = Q/2;
  ky = 1.94643;
  Nkpoints = 300;
  wLower = E(0,M_PI);
  wUpper = 0;
  Nf = 50;

  VectorXcd Epg = VectorXcd::Zero(2*Nf-1);
  double norm;
  double norm_private;
  VectorXcd one = VectorXcd::Ones(2*Nf-1);
  
  VectorXd wd = VectorXd::LinSpaced(2*Nf-1,wLower,wUpper);
  VectorXcd w = VectorXcd::Zero(2*Nf-1);
  for(int i=0; i<2*Nf-1; i++)
    w[i]=wd[i];


  while(true){
    
    if (myrank==0){
      cout << "Enter new D0_pg \n" << endl;
      cin >> D0_pg;
      D0_pg /= tval;
    }

    MPI_Bcast(&D0_pg, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
    
  
    if (D0_pg == 0){
	  MPI_Finalize();
	  return 0;
    }
    

    MPI_Barrier(MPI_COMM_WORLD);

  if (1==1){ //pseudogap
    Epg = VectorXcd::Zero(2*Nf-1);
    norm = 0;
    norm_private = 0;
    

    if(myrank==0)
      cout << endl << "Calculating pseudogap selfenergies..." << endl;
  
    MPI_Barrier(MPI_COMM_WORLD);

    //calc_phonon_selfenergy(kx, ky, Eph_private, Ephm_private);
    calc_pseudogap_selfenergy(kx,ky,Epg,norm_private);
      
    //set up double[] for reduction
    complex<double> Epg_private_array[2*Nf-1];
    complex<double> Epg_array[2*Nf-1];
    for(int i=0;i<2*Nf-1;i++){
      Epg_private_array[i] = Epg[i];
    }

    MPI_Reduce(&Epg_private_array, &Epg_array, 2*Nf-1, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, MPI_COMM_WORLD);
    MPI_Reduce(&norm_private, &norm, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);

    if(myrank==0)
      cout << "the norm is: " << norm << endl;

    if (myrank==0){   
      for(int i=0;i<2*Nf-1;i++){
	Epg[i] = Epg_array[i];
      }
      Epg /= norm;

      cout<<"Time taken "<< time(NULL)-tStart<<endl;

      ofstream myfile;
      myfile.open("Epg.dat");
      for (int i=0; i<2*Nf-1; i++){
	myfile << real(Epg[i]) << " " << imag(Epg[i]) << endl;
      }
      myfile.close();
      
      VectorXcd G = VectorXcd::Zero(2*Nf-1);
      //VectorXd A = VectorXd::Zero(2*Nf-1);
      double A[2*Nf-1]; 
      G = one.cwiseQuotient(w + (1j*gammae + E(kx,ky))*one - Epg);
      ///A = -imag(G);
      for (int i=0;i<2*Nf-1;i++){
      	 A[i] = -imag(G[i]);
	 cout << A[i] << endl;
      }

      double* biggest;
      double* first = A;
      double* last = first + 2*Nf-1;
      biggest = max_element(first,last);
      cout  << "freq at max " << w[distance(first,biggest)]*tval << endl;
      
      //double maxIndex;
      //G.maxCoeff(&maxIndex);
      
      //cout << maxIndex << endl;

      cout << endl <<  "Done With Program" << endl;
    }
  }

  }
Exemple #2
0
void calc_pseudogap_selfenergy(double kx,double ky, VectorXcd &Epg, double &norm){
   MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
   int namelen;
   char processor_name[MPI_MAX_PROCESSOR_NAME];
   MPI_Get_processor_name(processor_name, &namelen);

   cout << "hello rank " << myrank << " " << processor_name << endl;
   
   VectorXcd one = VectorXcd::Ones(2*Nf-1);
   VectorXd wd = VectorXd::LinSpaced(2*Nf-1,wLower,wUpper);
   VectorXcd w = VectorXcd::Zero(2*Nf-1);

   for(int i=0; i<2*Nf-1; i++)
     w[i]=wd[i];

   int Nk = Nkpoints;
   double totalN = pow(2*Nk,2)*(2*Nkz);
   if (Nkz==1)
     totalN = pow(2*Nk,2);
   double pgap = PseudoGap(kx,ky);
   complex<double> i1(0.0,1.0);

   double qx,qy,qz,px,py,pofq,Energy;

      for (int q1=-Nk+myrank; q1<Nk; q1+=numprocs){ //BZ momentum loop      
         qx = M_PI*q1/Nk;
	 for(int q2=-Nk; q2<Nk; q2++){
	    qy = M_PI*q2/Nk;
	    
	    if (Nkz==1){
	      px = kx - qx;
              py = ky - qy;

	      Energy = E(px,py);

              pofq = 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx-Q,2)+pow(qy,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx+Q,2)+pow(qy,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx,2)+pow(qy-Q,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx,2)+pow(qy+Q,2));
	    
	      //pofq = 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx-Q,2)+pow(qy,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx+Q,2)+pow(qy,2));


	      Epg += pgap*pofq*one.cwiseQuotient(w-one*E(px,py)+i1*gammae*one)/totalN;
	      norm += pofq/totalN;
	    }
	    else{
	    for(int q3=-Nkz; q3<Nkz; q3++){
	      qz = M_PI*q3/Nkz;	

	      px = kx - qx;
              py = ky - qy;

              pofq = 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx-Q,2)+pow(qy,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx+Q,2)+pow(qy,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx,2)+pow(qy-Q,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx,2)+pow(qy+Q,2));
	    
	      //pofq = 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx-Q,2)+pow(qy,2)) + 1.0/M_PI*gammacdw/(pow(gammacdw,2)+pow(qx+Q,2)+pow(qy,2));

	      Epg += pgap*pofq*one.cwiseQuotient(w-one*(E(px,py)-2*tz*cos(qz))+i1*gammae*one)/totalN;
	      norm += pofq/totalN;
	    }
	    }

         }
      } // end BZ loop

}