Example #1
0
char *parse_conf_line(char *line,char *field)
{
    line += strlen(field);
    for (; *line!='='&&*line!=0; line++)
        break;
    if ( *line == 0 )
        return(0);
    if ( *line == '=' )
        line++;
    stripstr(line,strlen(line));
    if ( Debuglevel > 0 )
        printf("[%s]\n",line);
    return(clonestr(line));
}
int FMDSread(FILE* fp, Para* q)
{
  char buf[BUFSIZE];
  int i;
  FMDSInternals* qint;

  qint = q->internals = (FMDSInternals*) malloc(sizeof(FMDSInternals));
					

  do
    fgets(buf, BUFSIZE, fp);
  while (strncmp(buf, "<Para ", 5) && !feof(fp));
  if (feof(fp)) {
    fprintf(stderr, "did't find <Para ...>\n");
    return -1;
  }
  
  char Pname[80], qname[80];

  sscanf(buf, "<Para %s %s>", Pname, qname);
  if (strcmp(Pname, "FMDS")) {
    fprintf(stderr, "not a FMDS parameter set\n");
    return -1;
  }
  strcpy(q->name, stripstr(qname, ">"));

  fgets(buf, BUFSIZE, fp);
  if (sscanf(buf, "%d %d %d", &q->A, &q->Z, &q->N) != 3) {
    fprintf(stderr, "malformed line\n>>%s<<\n", stripstr(buf, "\n"));
    return -1;
  }
  if (q->A != q->Z+q->N) {
    fprintf(stderr, "proton and neutron number don't sum up in line\n>>%s<<\n",
	    stripstr(buf, "\n"));
    return -1;
  }
  fgets(buf, BUFSIZE, fp);
  if (sscanf(buf, "%d", &q->ngauss) != 1) {
    fprintf(stderr, "malformed line\n>>%s<<\n", stripstr(buf, "\n"));
    return -1;
  }

  qint->idx = (int*) malloc(q->A*sizeof(int));
  qint->ng = (int*) malloc(q->A*sizeof(int));
  qint->xi = (int*) malloc(q->A*sizeof(int));
  qint->chi = (int*) malloc(q->ngauss*sizeof(int));
  for (i=0; i<q->A; i++) {
    qint->idx[i] = 0;
    qint->ng[i] = 0;
    qint->xi[i] = 0;
  }
  for (i=0; i<q->ngauss; i++)
    qint->chi[i] = 0;

  q->n = q->ngauss*NGAUSS;

  q->x = (double*) malloc(q->n*sizeof(double));

  int k, xi, chi;
  double are, aim, b0re, b0im, b1re, b1im, b2re, b2im; 
  for (i=0; i<q->ngauss; i++) {
    fgets(buf, BUFSIZE, fp);
    if (sscanf(buf, "%d %d %d "
	       "(%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf)", 
	       &k, &xi, &chi,
	       &are, &aim, &b0re, &b0im, &b1re, &b1im, &b2re, &b2im) != 11) {
      fprintf(stderr, "malformed line\n>>%s<<\n", 
	      stripstr(buf,"\n"));
      return -1;
    }
    qint->ng[k]++;
    qint->xi[k] = xi;
    qint->chi[i] = chi;
    q->x[i*NGAUSS+ 0] = are;    q->x[i*NGAUSS+ 1] = aim;
    q->x[i*NGAUSS+ 2] = b0re;   q->x[i*NGAUSS+ 3] = b0im;
    q->x[i*NGAUSS+ 4] = b1re;   q->x[i*NGAUSS+ 5] = b1im;
    q->x[i*NGAUSS+ 6] = b2re;   q->x[i*NGAUSS+ 7] = b2im;
  }     
  for (k=1; k<q->A; k++) 
    qint->idx[k] = qint->idx[k-1]+qint->ng[k-1];

  fgets(buf, BUFSIZE, fp);
  if (strncmp(buf, "</Para>", 7)) {
    fprintf(stderr, "didn't find </Para>\n");
    return -1;
  }	

  return 0;
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  // enough arguments ?

  if (argc < 2) {
    fprintf(stderr, "\nusage: %s [OPTIONS] mcstate"
	    "\n     -j J            2j of state"
	    "\n     -p +1|-1        parity of state"
	    "\n     -l MULTIPOLE    multipole density"
	    "\n     -a INDEX        index of state"
	    "\n     -q QMAX         calculate to max momentum"
	    "\n     -n NPOINTS      number of points"
	    "\n     -P NALPHA-NBETA number of angles"
	    "\n     -r              with recoil\n",
	    argv[0]);
    exit(-1);
  }

  int hermit = 0;

  // formfactor parameters

  int npoints = 51;
  double qmax = 5.0;
  int nalpha = 5;
  int ncosb = 4;
  int recoil = 0;
  int l=0;

  // grid in coordinate space

  double rmax = 15.0;
  double deltar = 0.05;
  int npointsr = (int) (rmax/deltar) + 1;

  // project to this state
  int j=-1, pi=-1, alpha=0;

  /* manage command-line options */

  char c; char* projparas;
  while ((c = getopt(argc, argv, "j:p:a:l:q:n:P:r")) != -1)
    switch (c) {
    case 'j':
      j = atoi(optarg);
      break;
    case 'p':
      pi = (atoi(optarg) == -1 ? 1 : 0);
      break;
    case 'a':
      alpha = atoi(optarg);
      break;
    case 'l':
      l = atoi(optarg);
      break;
    case 'q':
      qmax = atof(optarg);
      break;
    case 'n':
      npoints = atoi(optarg);
      break;
    case 'P':
      projparas = optarg;
      char* ang = strtok(projparas, "-");
      nalpha = atoi(ang);
      ang = strtok(NULL, "-");
      ncosb = atoi(ang);
      break;
    case 'r':
      recoil = 1;
      break;
    }

  char* mcstatefile = argv[optind];
  char** mbfile;

  // open multiconfigfile
  Projection P;
  SlaterDet* Q;
  Symmetry* S;
  Eigenstates E;
  int n;

  if (readMulticonfigfile(mcstatefile, &mbfile, &P, &Q, &S, &E, &n)) {
    fprintf(stderr, "couldn't read %s\n", mcstatefile);
    exit(-1);
  }

  FormfactorPara FfP = {
    qmax : qmax,
    npoints : npoints,
    nalpha : nalpha,
    ncosb : ncosb,
    recoil : recoil
  };

  int i;
  int a,b;

  // J or Pi unset
  if (j == -1) j = (Q[0].A % 2 ? 1 : 0);
  if (pi == -1) pi = (Q[0].A % 2 ? 1 : 0); 

  fprintf(stderr, "J: %d, Pi: %c1, alpha: %d\n", j, pi ? '-' : '+', alpha);

  // calculate certain multipole

  int nmulti = 1;
  int multi[NMULTIPOLES] = {0, 0, 0, 0};
  multi[l] = 1;
  
  // Project formfactor on angular momentum

  initOpFormfactors(&FfP);

  void* ffactorme[NMULTIPOLES][n*n];

  // read or calculate matrix elements

  for (b=0; b<n; b++)
    for (a=0; a<n; a++) {
      for (i=0; i<NMULTIPOLES; i++)   
	if (multi[i]) {
	  ffactorme[i][a+b*n] = initprojectedMBME(&P, &OpMultipoleFormfactor[i]);

	  if (readprojectedMBMEfromFile(mbfile[a], mbfile[b], &P,
					&OpMultipoleFormfactor[i], S[a], S[b],
					ffactorme[i][a+b*n])) {
	    calcprojectedMBME(&P, &OpMultipoleFormfactor[i], &Q[a], &Q[b],
			      S[a], S[b], ffactorme[i][a+b*n]);
	    writeprojectedMBMEtoFile(mbfile[a], mbfile[b], &P, 
				     &OpMultipoleFormfactor[i], S[a], S[b], 
				     ffactorme[i][a+b*n]);
	  }
	}
    }

  if (hermit) {
    for (i=0; i<NMULTIPOLES; i++)
      if (multi[i])
	hermitizeprojectedMBME(&P, &OpMultipoleFormfactor[i], ffactorme[i], n);
  }

  fprintf(stderr, "calculate expectation values\n");

  // calculate static formfactors

  void* ffactorexp[NMULTIPOLES];

  for (i=0; i<NMULTIPOLES; i++)   
    if (multi[i]) {
      ffactorexp[i] = initprojectedVectornull(&P, &OpMultipoleFormfactor[i], n);
      calcexpectprojectedMBMEipj(&P, &OpMultipoleFormfactor[i], ffactorme[i], 
				 S, &E, j, pi, alpha, 
				 ffactorexp[i]);
    }

  // output

  char outfile[255];

  snprintf(outfile, 255, "%s-%s.%d.matterdens", 
	   stripstr(mcstatefile, ".states"), AngmomtoStr(j, pi), alpha);

  // write densities to data files

  char datafile[255];
  FILE *datafp;

  snprintf(datafile, 255, "%s-%d--%05.2f-%d-%d-%d%s.data", 
	   outfile, l,
	   qmax, npoints, nalpha, ncosb, recoil ? "-recoil" : "");

  if (!(datafp = fopen(datafile, "w"))) {
    fprintf(stderr, "couldn't open %s for writing\n", datafile);
    exit(-1);
  }

  for (i=0; i<NMULTIPOLES; i++)
    if (multi[i]) {
      writeMatterDensities(datafp, &P, &FfP, 
                           rmax, npointsr, 
                           Q[0].A, i,
                           j, pi, alpha, ffactorexp[i], &E);
    }

  fclose(datafp);


  return 0;
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  // enough arguments ?

  if (argc < 2) {
    fprintf(stderr, "\nusage: %s [OPTIONS] mcstate"
	    "\n     -j J            2j of state"
	    "\n     -p +1|-1        parity of state"
	    "\n     -a INDEX        index of state"
	    "\n     -q QMAX         calculate to max separation"
	    "\n     -n NPOINTS      number of points\n",
	    argv[0]);
    exit(-1);
  }

  int hermit = 0;

  // grid in coordinate space

  int npoints = 51;
  double qmax = 10.0;

  // project to this state
  int j=-1, pi=-1, alpha=0;

  /* manage command-line options */

  char c;
  while ((c = getopt(argc, argv, "j:p:a:q:n:")) != -1)
    switch (c) {
    case 'j':
      j = atoi(optarg);
      break;
    case 'p':
      pi = (atoi(optarg) == -1 ? 1 : 0);
      break;
    case 'a':
      alpha = atoi(optarg);
      break;
    case 'q':
      qmax = atof(optarg);
      break;
    case 'n':
      npoints = atoi(optarg);
      break;
    }

  char* mcstatefile = argv[optind];
  char** mbfile;

  // open multiconfigfile
  Projection P;
  SlaterDet* Q;
  Symmetry* S;
  Eigenstates E;
  int n;

  if (readMulticonfigfile(mcstatefile, &mbfile, &P, &Q, &S, &E, &n)) {
    fprintf(stderr, "couldn't read %s\n", mcstatefile);
    exit(-1);
  }

  TBDensQPara TBDP = {
    qmax : qmax,
    npoints : npoints
  };

  int a,b;

  // J or Pi unset
  if (j == -1) j = (Q[0].A % 2 ? 1 : 0);
  if (pi == -1) pi = (Q[0].A % 2 ? 1 : 0); 

  fprintf(stderr, "J: %d, Pi: %c1, alpha: %d\n", j, pi ? '-' : '+', alpha);

  // initialize operator

  initOpTwoBodyDensityQ(&TBDP);

  void* tbdensme[n*n];

  // read or calculate matrix elements

  for (b=0; b<n; b++)
    for (a=0; a<n; a++) {
      tbdensme[a+b*n] = initprojectedMBME(&P, &OpTwoBodyDensityQ);

      if (readprojectedMBMEfromFile(mbfile[a], mbfile[b], &P,
				    &OpTwoBodyDensityQ, S[a], S[b],
				    tbdensme[a+b*n])) {
	calcprojectedMBME(&P, &OpTwoBodyDensityQ, &Q[a], &Q[b],
			  S[a], S[b], tbdensme[a+b*n]);
	writeprojectedMBMEtoFile(mbfile[a], mbfile[b], &P, 
				 &OpTwoBodyDensityQ, S[a], S[b], 
				 tbdensme[a+b*n]);
      }
    }

  if (hermit) {
    hermitizeprojectedMBME(&P, &OpTwoBodyDensityQ, tbdensme, n);
  }

  fprintf(stderr, "calculate expectation values\n");

  // expectation values

  void* tbdensexp;

  tbdensexp = initprojectedVectornull(&P, &OpTwoBodyDensityQ, n);
  calcexpectprojectedMBMEipj(&P, &OpTwoBodyDensityQ, tbdensme, 
				 S, &E, j, pi, alpha, 
				 tbdensexp);
  // output

  char outfile[255];

  snprintf(outfile, 255, "%s-%s.%d.tbdensmom", 
	   stripstr(mcstatefile, ".states"), AngmomtoStr(j, pi), alpha);

  // write densities to file

  char datafile[255];
  FILE *datafp;

  snprintf(datafile, 255, "%s--%05.2f-%d.data", 
	   outfile,
	   qmax, npoints);

  if (!(datafp = fopen(datafile, "w"))) {
    fprintf(stderr, "couldn't open %s for writing\n", datafile);
    exit(-1);
  }

  writeTBDensQ(datafp, &P, &TBDP, 
               j, pi, alpha, tbdensexp, &E);

  fclose(datafp);


  return 0;
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 2) {
    fprintf(stderr, "\nusage: %s [OPTIONS] mcstate"
	    "\n   -A             show all eigenstates\n", argv[0]);
    exit(-1);
  }

  int all=0;
  int hermit=0;

  char c;

  /* manage command-line options */

  while ((c = getopt(argc, argv, "A")) != -1)
    switch (c) {
    case 'A':
      all=1;
      break;
    }

  char* mcstatefile = argv[optind];
  char** mbfile;

  // open multiconfigfile
  Projection P;
  SlaterDet* Q;
  Symmetry* S;
  Eigenstates E;
  int n;

  readMulticonfigfile(mcstatefile, &mbfile, &P, &Q, &S, &E, &n);

  void* radiime[n*n]; 

  int a,b;
  for (b=0; b<n; b++)	
    for (a=0; a<n; a++) {
      radiime[a+b*n] = initprojectedMBME(&P, &OpSDRadii);
    }

  // read or calculate matrix elements
  for (b=0; b<n; b++)
    for (a=0; a<n; a++) {
      if (readprojectedMBMEfromFile(mbfile[a], mbfile[b], &P, 
				    &OpSDRadii, S[a], S[b], 
				    radiime[a+b*n])) {
	calcprojectedMBME(&P, &OpSDRadii, &Q[a], &Q[b], 
			  S[a], S[b], radiime[a+b*n]);
	writeprojectedMBMEtoFile(mbfile[a], mbfile[b], &P, 
				 &OpSDRadii, S[a], S[b], 
				 radiime[a+b*n]);
      }
    }


  if (hermit) {
    hermitizeprojectedMBME(&P, &OpSDRadii, radiime, n);
  }

  fprintf(stderr, "calculate expectation values\n");

  // calculate expectation values
  void* radiiexp = initprojectedVector(&P, &OpSDRadii, n);
  calcexpectprojectedMBME(&P, &OpSDRadii, radiime, S, &E, radiiexp);


  // output

  char outfile[255];
  char tostrip[255];
  FILE* outfp;

  snprintf(tostrip, 255, ".states");
  snprintf(outfile, 255, "%s.radii", stripstr(mcstatefile, tostrip));
  if (!(outfp = fopen(outfile, "w"))) {
    fprintf(stderr, "couldn't open %s for writing\n", outfile);
    goto cleanup;
  }

  fprintinfo(outfp);
  fprintProjectinfo(outfp, &P);

  writeprojectedSDRadii(outfp, Q, &P, radiiexp, &E);

  fclose(outfp);

 cleanup:

  return 0;
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 2) {
    fprintf(stderr, "\nusage: %s [OPTIONS] mcstatefin mcstateini"
	    "\n   -a             show all eigenstates\n", argv[0]);
    exit(-1);
  }

  int all=0;
  int hermit=0;

  char c;

  /* manage command-line options */

  while ((c = getopt(argc, argv, "a")) != -1)
    switch (c) {
    case 'a':
      all=1;
      break;
    }

  char* mcstatefilefin = argv[optind];
  char* mcstatefileini = argv[optind+1];
  char** mbfilefin; char** mbfileini;

  // open multiconfigfile
  Projection P;
  SlaterDet *Qfin, *Qini;
  Symmetry *Sfin, *Sini;
  Eigenstates Efin, Eini;
  int nfin, nini;

  readMulticonfigfile(mcstatefileini, &mbfileini, &P, &Qini, &Sini, &Eini, &nini);
  readMulticonfigfile(mcstatefilefin, &mbfilefin, &P, &Qfin, &Sfin, &Efin, &nfin);

  int direction;
  if (Qfin[0].Z - Qini[0].Z == 1) {
    fprintf(stderr, "GT+ transitions");
    direction = +1;
  }
  if (Qfin[0].Z - Qini[0].Z == -1) {
    fprintf(stderr, "GT- transitions");
    direction = -1;
  }

 
  ManyBodyOperator OpGT;

  if (direction == +1)
    OpGT = OpGTplus;
  if (direction == -1)
    OpGT = OpGTminus;


  int a,b; 

  void** gtme[nfin*nini];

  for (b=0; b<nini; b++)	
    for (a=0; a<nfin; a++)
      gtme[a+b*nfin] = initprojectedMBME(&P, &OpGT);


  // read or calculate matrix elements
  for (b=0; b<nini; b++)
    for (a=0; a<nfin; a++)
      if (readprojectedMBMEfromFile(mbfilefin[a], mbfileini[b], &P,
                                    &OpGT, Sfin[a], Sini[b], gtme[a+b*nfin])) {
	calcprojectedMBME(&P, &OpGT, &Qfin[a], &Qini[b], Sfin[a], Sini[b],
                          gtme[a+b*nfin]);
        writeprojectedMBMEtoFile(mbfilefin[a], mbfileini[b], &P,
                                 &OpGT, Sfin[a], Sini[b], gtme[a+b*nfin]);
      } 
  
  fprintf(stderr, "calculate transition strengths\n");

  void**** gttrans = initprojectedtransitionVector(&P, &OpGT, nfin, nini);
  calctransitionprojectedMBME(&P, &OpGT, gtme, Sfin, Sini, &Efin, &Eini, gttrans);

  // output

  char outfile[511];
  char tostrip[255];
  FILE* outfp;

  snprintf(tostrip, 255, ".states");
  snprintf(outfile, 255, "%s--%s.transgt", 
           stripstr(mcstatefilefin, tostrip), stripstr(mcstatefileini, tostrip));
  if (!(outfp = fopen(outfile, "w"))) {
    fprintf(stderr, "couldn't open %s for writing\n", outfile);
    goto cleanup;
  }

  fprintinfo(outfp);
  fprintProjectinfo(outfp, &P);

  if (direction == +1)
    writeprojectedtransitionGTplus(outfp, &P, gttrans, &Efin, &Eini);
  else
    writeprojectedtransitionGTminus(outfp, &P, gttrans, &Efin, &Eini);

  fclose(outfp);

 cleanup:

  return 0;
}