예제 #1
0
void uhfsolve::setupF(){
    //set up the Fock matrix
    double Di = 0;
    double Ex = 0;
    double DiMinusEx = 0;
    for(int p=0;p<nStates;p++){
        for(int q=0;q<nStates;q++){
            //F(p,q) = Bs.h(p,q);
            Fu(p,q) = Bs.h(p,q);
            Fd(p,q) = Bs.h(p,q);
            for(int r=0;r<nStates;r++){
                for(int s=0;s<nStates;s++){
                    //Di = Bs.v(p,r)(q,s);
                    //Ex = Bs.v(p,r)(s,q);

                    Di = Bs.v(p,q)(r,s);
                    Ex = Bs.v(p,s)(r,q);
                    DiMinusEx = Di-Ex;
                    //F(p,q) += 0.5*coupledMatrixTilde(p,q,r,s)*P(r,s);  //Alt. 2 27/5 2014
                    Fu(p,q) += Pu(s,r)*(Di-Ex) + Pd(s,r)*Di;
                    Fd(p,q) += Pd(s,r)*(Di-Ex) + Pu(s,r)*Di;
                }
            }
        }
    }
}
예제 #2
0
void uhfsolve::setupP(){
    //setup density matrix, make a first guess
    //P.zeros(); //we don't have any reason to do this any other ways yet.
    //P.eye();
    //Pu.eye();
    //Pd.eye();
    //Pu.zeros(nStates, nElectronsU);
    //Pd.zeros(nStates, nElectronsD);


    //Pu = dampingFactor*Pu + (1-dampingFactor)*Cu.submat(0,0,nStates-1, nElectronsU-1)*Cu.submat(0,0,nStates-1, nElectronsU-1).t();
    //Pd = dampingFactor*Pd + (1-dampingFactor)*Cd.submat(0,0,nStates-1, nElectronsD-1)*Cd.submat(0,0,nStates-1, nElectronsD-1).t();

    //Pu = dampingFactor*Pu + (1-dampingFactor)*Cu.submat(0,0,nStates, nElectronsU)*Cu.submat(0,0,nStates, nElectronsU).t();
    //Pd = dampingFactor*Pd + (1-dampingFactor)*Cd.submat(0,0,nStates, nElectronsD)*Cd.submat(0,0,nStates, nElectronsD).t();

    //Pu = Cu.submat(0,0,nStates, nElectronsU)*Cu.submat(0,0,nStates, nElectronsU).t();
    //Pd = Cd.submat(0,0,nStates, nElectronsD)*Cd.submat(0,0,nStates, nElectronsD).t();;

    //Pu = Cu*Cu.t();
    //Pd = Cd*Cd.t();

    Pu = Cu.submat(0,0,nStates-1, nElectronsU-1)*Cu.submat(0,0,nStates-1, nElectronsU-1).t(); //new
    Pu(0,1) = 0.1; //non-interacting initial condition
    Pd = Cd.submat(0,0,nStates-1, nElectronsD-1)*Cd.submat(0,0,nStates-1, nElectronsD-1).t();
}
예제 #3
0
파일: one.c 프로젝트: saykind/advection
double *cubic(double dx, double u1, double v1, double u2, double v2) {
	double a, b, c, d;
	double *dd = (double *) malloc(2*sizeof(double));
	d = u2;
	c = v2;
	b = (3*u1+v1*dx+2*c*dx-3*d)/(dx*dx);
	a = (2*u1+v1*dx+1*c*dx-2*d)/(dx*dx*dx);
	dd[0] = Pu(a,b,c,d,-K*dx);
	dd[1] = Pv(a,b,c,d,-K*dx);
	return dd;
}
예제 #4
0
파일: stabraw.c 프로젝트: kstephens/ll
int ct_stab_parse(const char *ofile, int option, ...)
{
  FILE *fp;

  if ( ! (fp = fopen(ofile, "rb")) ) {
#ifdef __CYGWIN32__
    const char *suffixes[] = { ".exe", ".com", 0 };
    int i;

    for ( i = 0; suffixes[i]; i ++ ) {
      char op[MAXPATHLEN + 1];

      strcpy(op, ofile);
      strcat(op, suffixes[i]);

      if ( (fp = fopen(op, "rb")) )
	break;
    }
    if ( ! suffixes[i] ) 
#endif
    {
      fprintf(stderr, "ct_stab_parse: cannot open '%s'\n", ofile);
      return -1;
    }
  }


#define Pm(x) fprintf(stderr, "%s\n", (char *) (x));
#define Pu(x) fprintf(stderr, "%s = %lu\n", #x, (unsigned long) (x))
#define Px(x) fprintf(stderr, "%s = %08lx\n", #x, (unsigned long) (x))
#define Ps(x) fprintf(stderr, "%s = \"%s\"\n", #x, (char *) (x))
#define Pss(x,s) fprintf(stderr, "%s = \"%*s\"\n", #x, (int) (s), (char *) (x))

#if 0 
  {
    struct external_filehdr fh;

    fseek(fp, 0, 0);
    fread(&fh, sizeof(fh), 1, fp);

    Pm("external_filehdr");
    Px(fh.f_magic);
    Px(fh.f_nscns);
    Px(fh.f_timdat);
    Px(fh.f_symptr);
    Px(fh.f_nsyms);
    Px(fh.f_opthdr);
    Px(fh.f_flags);

  }

  {
    AOUTHDR fh;

    fseek(fp, 0, 0);
    fread(&fh, sizeof(fh), 1, fp);

    Pm("AOUTHDR");
    Px(fh.magic);
    Px(fh.vstamp);
    Px(fh.tsize);
    Px(fh.dsize);
    Px(fh.bsize);
    Px(fh.entry);
    Px(fh.text_start);
    Px(fh.data_start);
  }
#endif
  
  {
    FILHDR fh;

    fseek(fp, 0, 0);
    fread(&fh, sizeof(fh), 1, fp);

    Pm("FILHDR");
    Px(fh.e_magic);
    Px(fh.e_cblp);
    Px(fh.e_cp);
    Px(fh.e_crlc);
    Px(fh.e_cparhdr);
    Px(fh.e_minalloc);
    Px(fh.e_maxalloc);
    Px(fh.e_ss);
    Px(fh.e_sp);
    Px(fh.e_csum);
    Px(fh.e_ip);
    Px(fh.e_cs);
    Px(fh.e_lfarlc);
    Px(fh.e_ovno);
    /* fh.e_res[4][2] */
    Px(fh.e_oemid);
    Px(fh.e_oeminfo);
    /* fh.e_res2[10][2] */
    Px(fh.e_lfanew);
    /* fh.dos_message[16][4] */
    Px(fh.nt_signature);

    Pm("From standard header");
    Px(fh.f_magic);
    Px(fh.f_nscns);
    Px(fh.f_timdat);
    Px(fh.f_symptr);
    Px(fh.f_nsyms);
    Px(fh.f_opthdr);
    Px(fh.f_flags);
    
    //   exit (1);

    fseek(fp, fh.f_opthdr, SEEK_CUR);

    {
      int i;

      Pm("Sections");
      for ( i = 0; i < fh.f_nscns; i ++ ) {
	SCNHDR sh;

	fread(&sh, sizeof(sh), 1, fp);
	Pm("");
	Pss(sh.s_name, sizeof(sh.s_name));
	Px(sh.s_paddr);
	Px(sh.s_vaddr);
	Pu(sh.s_size);
#if 0
	Px(sh.s_scnptr);
	Px(sh.s_relptr);
	Pu(sh.s_nreloc);
	Pu(sh.s_nlnno);
	Px(sh.s_flags);
#endif

      }
    }

    if ( fh.f_opthdr == sizeof(AOUTHDR) ) {
      AOUTHDR aoh;

      Pm("AOUTHDR");
      fread(&aoh, sizeof(aoh), 1, fp);
      Px(aoh.magic);
      Px(aoh.vstamp);
      Px(aoh.tsize);
      Px(aoh.dsize);
      Px(aoh.bsize);
      Px(aoh.entry);
      Px(aoh.text_start);
      Px(aoh.data_start);
    }

    exit(1);

    {
      int i;
      
      fseek(fp, fh.f_symptr, 0);
    
      Pm("Reading symbols");
      for ( i = 0; i < fh.f_nsyms; i ++ ) {
	SYMENT se;

	fread(&se, sizeof(se), 1, fp);
	// Ps(se.e.e_name);
	if ( se.e.e.e_zeroes ) {
	  Ps(se.e.e_name);
	} else {
	  Px(se.e.e.e_zeroes);
	  Px(se.e.e.e_offset);
	}
	Px(se.e_value);
	Px(se.e_scnum);
	Px(se.e_type);
	Px(se.e_sclass[0]);
	Px(se.e_numaux[1]);
      }
    }
  }
  
  fclose(fp);
  return 0;
}