예제 #1
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], output_fname[200], basename[200], basenameout[200];
  int  j, n, type, snapshot_number, output_number,files, Ngas, random, ncount, ncounthalo1, ncount2;
  float x,y,z,x1,y1, z1, delr;
  double delx, dely, delz, boxsize;
  FILE *outfile;

  sprintf(path, "/work/00863/minerva/");
  sprintf(basename, "bin_HR10_map");

output_number = 0;
for(j=0; j<=0; j=j+1)
  {

  snapshot_number=j;
  
  files=1;     

  boxsize = 140.0;

  delx = 512.65800353;  //del's used in making bin_zoom10_cut_??? (bin_zoom10_???)
  dely = 505.21836888;
  delz = 497.39349349;

  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  if(snapshot_number > 999)
    sprintf(input_fname, "%s/%s_%04d", path, basename, snapshot_number);
  if(snapshot_number > 9999)
    sprintf(input_fname, "%s/%s_%05d", path, basename, snapshot_number);
  
  sprintf(basenameout, "ot");
  sprintf(output_fname, "%s/%s_%04d", path, basenameout, output_number);
  if(snapshot_number > 999)
    sprintf(output_fname, "%s/%s_%04d", path, basenameout, output_number);
  if(snapshot_number > 9999)
    sprintf(output_fname, "%s/%s_%05d", path, basenameout, output_number);
  output_number++;

  Ngas = write_snapshot(input_fname, files, output_fname, delx, dely, delz, boxsize);

  unit_conversion();  

  do_what_you_want();
  free(P);
}
}
예제 #2
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], basename[200];
  int type, snapshot_number, files;


  sprintf(path, "/home/tczhang/desktop/C");
  sprintf(basename, "snapshot");
  snapshot_number = 6;		/* number of snapshot */
  files = 1;			/* number of files per snapshot */


  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  load_snapshot(input_fname, files);


  reordering();			/* call this routine only if your ID's are set properly */

  unit_conversion();		/* optional stuff */

  do_what_you_want();
}
예제 #3
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], input_fname_dm[200], output_fname[200], basename[200], basenameout[200];
  int  j, n, type, snapshot_number, files, Ngas, random, ncount, ncounthalo1, ncount2;
  float x,y,z,x1,y1, z1, delr;
  double delx, dely, delz, delx_dm, dely_dm, delz_dm, boxsize;
  FILE *outfile;


  sprintf(path, "/work/00863/minerva");
  sprintf(basename, "ds_ic");
  snapshot_number=000;                   /* number of snapshot */
  files=1;     

  boxsize = 100.0;
  delx = 50.339110402;
  dely = 50.122129376;
  delz = 49.486652655;

  delx_dm = 3.4331373996e-06;
  dely_dm = 3.4336503546e-06;
  delz_dm = 3.432893655e-06;
 
  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  sprintf(input_fname_dm, "/work/00863/minerva/minihalo_128");
  sprintf(output_fname, "/work/00863/minerva/ds_ng_000");
  Ngas = write_snapshot(input_fname, input_fname_dm, files, output_fname, delx, dely, delz, delx_dm, dely_dm, delz_dm, boxsize);

  unit_conversion();  

  ncount = 0;
  ncount2 = 0;

  printf("ncount = %d.\n", ncount);
  printf("ncount2 = %d.\n", ncount2);

  do_what_you_want();
}
예제 #4
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], input_fname_dm[200], output_fname[200], basename[200], basenameout[200];
  int  j, n, type, snapshot_number, files, Ngas, random, ncount, ncounthalo1, ncount2;
  float x,y,z,x1,y1, z1, delr;
  double delx, dely, delz, delx_dm, dely_dm, delz_dm, boxsize, dummy=1.0;
  FILE *outfile;


  sprintf(path, "/nobackupp1/astacy");
  sprintf(basename, "dma");
  snapshot_number=12;                   /* number of snapshot */
  files=1;     

  boxsize = 140.0;
  delx = dely = delz = dummy;

  delx_dm = dely_dm = delz_dm = dummy;
 
  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);

  sprintf(input_fname_dm, "/nobackupp1/astacy/minihalo_256");  //"nfw" denotes an r^-1 profile!
  sprintf(output_fname, "/nobackupp1/astacy/dma_prof1_000");

  Ngas = write_snapshot(input_fname, input_fname_dm, files, output_fname, delx, dely, delz, delx_dm, dely_dm, delz_dm, boxsize);

  unit_conversion();  

  ncount = 0;
  ncount2 = 0;

  printf("ncount = %d.\n", ncount);
  printf("ncount2 = %d.\n", ncount2);

  do_what_you_want();
}
예제 #5
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], output_fname[200], basename[200], basenameout[200];
  int  j, n, type, snapshot_number, files, Ngas, random, ncount, ncounthalo1, ncount2;
  double x,y,z,x1,y1, z1, delr;
  double nh, nhmax, nhmax2, mass, mmax, mmax2, dis, xmax, xmax2, ymax, ymax2, zmax, zmax2, sl, masstot, temp, tmax, h2, h2max, gam, gammin;
  double sinkposx, sinkposy, sinkposz, disAU, vrad, vrotx, vroty, vrotz, vrot;
  double velx, vely, velz;
  double dum_num;
  FILE *outfile;


  sprintf(path, "/work/utexas/ao/minerva");
  sprintf(basename, "hires_am2");
  sprintf(basenameout, "snaphires_am2_chem");

  for(j=2;j<=2;j++){

  snapshot_number= j;                   /* number of snapshot */
  files=1;                               /* number of files per snapshot */

  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  sprintf(output_fname, "%s/%s_%03d", path, basenameout, snapshot_number);
  Ngas = load_snapshot(input_fname, files);

  /*    reordering();*/ /* call this routine only if your ID's are set properly */

  unit_conversion();  

  outfile=fopen(output_fname, "w");

  ncount = 0;
  ncount2 = 0;

  nhmax = nhmax2 = 0;
  mmax= mmax2 = 0;
  xmax= xmax2 = 0;
  ymax= ymax2 = 0;
  zmax= zmax2 = 0;
  sl = 0;
  tmax=0;
  h2max=0;


  for(n = 1; n <= Ngas; n++)
       {
       if(P[n].Id == 3755078)
          {
          sinkposx = P[n].Pos[0];
          sinkposy = P[n].Pos[1];
          sinkposz = P[n].Pos[2];
          }
       }


  for(n=1;n<=Ngas;n++) { 
    x=P[n].Pos[0];
    y=P[n].Pos[1];
    z=P[n].Pos[2];

    x1=x/(0.7e0*(1.e0 + 18.9e0));
    y1=y/(0.7e0*(1.e0 + 18.9e0));
    z1=z/(0.7e0*(1.e0 + 18.9e0));

          nh = P[n].nh;
          mass=P[n].Mass;
          masstot=masstot+mass;
          h2 = P[n].H2I;

          if(nh > nhmax2 && mass < 3.e-12)
            {
              nhmax2 = nh;
              mmax2=mass;
              xmax2=P[n].Pos[0];
              ymax2=P[n].Pos[1];
              zmax2=P[n].Pos[2];

            }


          if(nh > nhmax)
            {
              nhmax = nh;
              mmax=mass;
              xmax=P[n].Pos[0];
              ymax=P[n].Pos[1];
              zmax=P[n].Pos[2];
              h2max=P[n].H2I;
            }
    }


    random = rand();
    dum_num = 5.0;

         sinkposx=xmax;
         sinkposy=ymax;
         sinkposz=zmax; 
         printf("sinkposx = %g, sinkposy = %g, sinkposz = %g\n", sinkposx, sinkposy, sinkposz);

         printf("nhmax2 = %lg, maxmass2 = %lg, xmax2 = %lg, ymax2 = %lg, zmax2 = %lg\n", nhmax2, mmax2, xmax2, ymax2, zmax2);

         for(n = 1; n <= Ngas; n++)
             {


             dis = pow(((P[n].Pos[0]-sinkposx)*(P[n].Pos[0]-sinkposx) + (P[n].Pos[1]-sinkposy)*(P[n].Pos[1]-sinkposy) + (P[n].Pos[2]-sinkposz)*(P[n].Pos[2]-sinkposz)), 0.5);
             dis=dis*1.e3*Time/(0.7);
             disAU=dis*206264.806;


      if (/*(random*(1.e0/RAND_MAX))< 0.1e0*/ /* P[n].nh > 1.e4 || P[n].sink > 0.5*/ P[n].Id % 100 == 0) {
      //fprintf(outfile,"%15.13g %8d %15.13g %15.13g %15.13g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g\n", P[n].sink, Id[n],x,y,z,P[n].Temp,P[n].nh,P[n].HII,P[n].H2I,P[n].HDI, P[n].gam, P[n].Vel[0],P[n].Vel[1],P[n].Vel[2],P[n].hsm, P[n].Mass);
      fprintf(outfile,"%15.13g %8d %15.13g %15.13g %15.13g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g\n", dum_num, P[n].Id,P[n].Pos[0],P[n].Pos[1],P[n].Pos[2],dum_num,P[n].nh,P[n].HII,P[n].H2I,P[n].HDI, dum_num, disAU, vrad, vrot,dum_num, P[n].Mass);
      ncount = ncount + 1;
       }

    delr = sqrt((226.791-x)*(226.791-x) + (230.096-y)*(230.096-y) + (230.16-z)*(230.16-z))/(0.7e0*19.98);
  }
  printf("ncount = %d.\n", ncount);
  printf("ncount2 = %d.\n", ncount2);

   printf("nhmax= %g\n", nhmax);
   printf("mmax= %g\n", mmax);
   printf("xmax= %g\n", xmax);
   printf("ymax= %g\n", ymax);
   printf("zmax= %g\n", zmax);
   printf("sl = %g\n", sl);
   printf("tmax = %g\n", tmax);
   printf("h2max = %g\n", h2max);


  fclose(outfile);
}

  do_what_you_want();
}
예제 #6
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], output_fname[200], basename[200], basenameout[200];
  int  i, j, jnum, n, type, snapshot_number, files, random, ncount, ncounthalo1, ncount2, idmax;
  double x,y,z,x1,y1, z1, delr, vx, vy, vz, vel, typemax, dismax;
  double nh, nhmax, mass, mmax, dis, xmax, ymax, zmax, sl, masstot, temp, tmax, h2, h2max, gam, gammin;
  double sinkposx, sinkposy, sinkposz, disAU, vrad, vrotx, vroty, vrotz, vrot, mh_mass;
  double xCOM, yCOM, zCOM, vxCOM, vyCOM, vzCOM, disCOM, vCOM, ncount_doub;
  double hubble_param;
  FILE *outfile;

  sprintf(path, "/work/00863/minerva/strom");

  sprintf(basename, "strom");
  sprintf(basenameout, "snapstrom");

  jnum = 800;

  for(j=jnum;j<=jnum;j=j+5){

  snapshot_number= j;                   /* number of snapshot */
  files=1;                               /* number of files per snapshot */

  if(j<=999)
  {
  sprintf(input_fname, "%s/%s_%04d", path, basename, snapshot_number);
  sprintf(output_fname, "%s/%s_%04d", path, basenameout, snapshot_number);
  }

  if(j>999)
  {
    sprintf(input_fname, "%s/%s_%04d", path, basename, snapshot_number);
    sprintf(output_fname, "%s/%s_%04d", path, basenameout, snapshot_number);
  }

  Ngas = load_snapshot(input_fname, files);

  //for NON-comoving integrations
  Time = hubble_param = 1.0;

  /*    reordering();*/ /* call this routine only if your ID's are set properly */

  printf("hi 1, Ngas = %d, NumPart = %d\n", Ngas, NumPart);

  unit_conversion();  

  printf("hi 2\n");

  outfile=fopen(output_fname, "w");

  ncount = 0;
  ncount2 = 0;

  printf("hi 3\n");

  nhmax = 0;
  mmax = mh_mass = 0;
  xmax = ymax = zmax = 0;
  sl = tmax = h2max = gammin=0;
  masstot = dismax = 0;
  typemax = 5;
  xCOM = yCOM = zCOM = vxCOM = vyCOM = vzCOM = ncount_doub = 0.0;

  printf("hi 4\n");

  for(n=0;n<Ngas;n++) { 

          nh = P[n].nh;
          mass=P[n].Mass;
          temp = P[n].Temp;
          h2 = P[n].H2I;
          gam=P[n].gam;

          if(nh > nhmax)
          //if(mass > mmax)
            {
              //printf("Found the sink!\n");
              nhmax = nh;
              mmax=mass;
              xmax=P[n].Pos[0];
              ymax=P[n].Pos[1];
              zmax=P[n].Pos[2];
              sl = P[n].hsm;
              tmax=P[n].Temp;
              h2max=P[n].H2I;
              gammin=P[n].gam;
              typemax = P[n].Type;
              idmax = P[n].Id;
              vx = P[n].Vel[0];
              vy = P[n].Vel[1];
              vz = P[n].Vel[2];
            }
    }

         for(n=0;n<=Ngas;n++)
           {
            nh = P[n].nh;
            if(nh > nhmax/1e8)
            {
            vxCOM = vxCOM + P[n].Vel[0]*P[n].Mass;
            vyCOM = vyCOM + P[n].Vel[1]*P[n].Mass;
            vzCOM = vzCOM + P[n].Vel[2]*P[n].Mass;
            xCOM = xCOM + P[n].Pos[0]*P[n].Mass;
            yCOM = yCOM + P[n].Pos[1]*P[n].Mass;
            zCOM = zCOM + P[n].Pos[2]*P[n].Mass;
            ncount_doub = ncount_doub + P[n].Mass;
            }
            //if(nh > 1.e6)
            //if(nh > 1e3 && nh < 1e5)
              //printf("ID = %d, nh = %lg\n", P[n].Id, P[n].nh);
              //printf("%d\n", P[n].Id);
         }


         vx = vxCOM/ncount_doub;
         vy = vyCOM/ncount_doub;
         vz = vzCOM/ncount_doub;


         sinkposx=xmax;
         sinkposy=ymax;
         sinkposz=zmax;
         printf("sinkposx = %15.11g, sinkposy = %15.11g, sinkposz = %15.11g, nhmax = %15.11g, mmax = %15.11g\n", sinkposx, sinkposy, sinkposz, nhmax, mmax);

         vx = vy = vz = 0;
         sinkposx = sinkposy = sinkposz = header1.BoxSize/2.0; 

         if(nhmax < 1.e1)
           {
           sinkposx=header1.BoxSize/2.0;
           sinkposy=header1.BoxSize/2.0;
           sinkposz=header1.BoxSize/2.0; 
           }
         printf("sinkposx = %15.11g, sinkposy = %15.11g, sinkposz = %15.11g\n", sinkposx, sinkposy, sinkposz);
         printf("vx = %lg, vy = %lg, vz = %lg\n", vx, vy, vz);

         for(n = 0; n < NumPart; n++)
         //for(n = 0; n < Ngas; n++)
             {

             P[n].Vel[0] = P[n].Vel[0] - vx;
             P[n].Vel[1] = P[n].Vel[1] - vy;
             P[n].Vel[2] = P[n].Vel[2] - vz;

             x = P[n].Pos[0];
             y = P[n].Pos[1];
             z = P[n].Pos[2];

             dis = pow(((P[n].Pos[0]-sinkposx)*(P[n].Pos[0]-sinkposx) + (P[n].Pos[1]-sinkposy)*(P[n].Pos[1]-sinkposy) + (P[n].Pos[2]-sinkposz)*(P[n].Pos[2]-sinkposz)), 0.5);
             //dis = pow(((P[n].Pos[0]-xmax)*(P[n].Pos[0]-xmax) + (P[n].Pos[1]-ymax)*(P[n].Pos[1]-ymax) + (P[n].Pos[2]-zmax)*(P[n].Pos[2]-zmax)), 0.5);
             if(dis > dismax)
                dismax = dis;
             dis=dis*1.e3*Time/hubble_param;
             disAU=dis*206264.806;

             vel = P[n].Vel[0]*P[n].Vel[0] + P[n].Vel[1]*P[n].Vel[1] + P[n].Vel[2]*P[n].Vel[2];
             vel = pow(vel,0.5)*pow(Time, 0.5); 

             vrad =  (P[n].Vel[0]*(P[n].Pos[0]-sinkposx) + P[n].Vel[1]*(P[n].Pos[1]-sinkposy) + P[n].Vel[2]*(P[n].Pos[2]-sinkposz))/pow(((P[n].Pos[0]-sinkposx)*(P[n].Pos[0]-sinkposx) + (P[n].Pos[1]-sinkposy)*(P[n].Pos[1]-sinkposy) + (P[n].Pos[2]-sinkposz)*(P[n].Pos[2]-sinkposz)), 0.5);
             vrad = vrad*pow(Time, 0.5); 

             vrotx = (P[n].Pos[1]-sinkposy)*P[n].Vel[2]  - (P[n].Pos[2]-sinkposz)*P[n].Vel[1];
             vroty = (P[n].Pos[2]-sinkposz)*P[n].Vel[0] - (P[n].Pos[0]-sinkposx)*P[n].Vel[2];
             vrotz = (P[n].Pos[0]-sinkposx)*P[n].Vel[1]  -  (P[n].Pos[1]-sinkposy)*P[n].Vel[0];


             vrot = pow(vrotx*vrotx + vroty*vroty + vrotz*vrotz, 0.5); 
             vrot = vrot*pow(Time, 0.5)/pow(((P[n].Pos[0]-sinkposx)*(P[n].Pos[0]-sinkposx) + (P[n].Pos[1]-sinkposy)*(P[n].Pos[1]-sinkposy) + (P[n].Pos[2]-sinkposz)*(P[n].Pos[2]-sinkposz)), 0.5);
;  //convert to km/s

             if(n%10000 == 0)
               printf("ID = %d, nh = %lg, temp = %lg, elec %lg, H2 = %lg HeII = %lg mass = %lg\n", P[n].Id, P[n].nh, P[n].Temp, P[n].HII, P[n].H2I, P[n].HeII, P[n].Mass);

             //f(P[n].nh > 1.e10 && P[n].sink > -4)
             if(disAU <= 1.e2 /*&& P[n].sink < -4*/)
               masstot = masstot + P[n].Mass/1.e-10/hubble_param;

             if(P[n].sink > 0 && P[n].nh > 8.0e13)
               printf("Mass = %g sink = %g ID = %d nh = %lg Dens = %lg Temp = %lg dis = %lg, vel = %lg, vrad = %lg, vrot = %lg\n", P[n].Mass, P[n].sink, P[n].Id, P[n].nh, P[n].Rho, P[n].Temp, disAU, vel, vrad, vrot);


    random = rand();

    if((random*(1.e0/RAND_MAX)< 0.2 && P[n].nh > 3.e-2) /*|| P[n].nh > 2.e1*/ /*&& P[n].sink < 0*/ /* ||  P[n].sink > 0.5*/ || P[n].Id < 3 ) 
    //if(P[n].nh > 1.e4 /*&& random*(1.e0/RAND_MAX)< 0.1e0*/ /*|| P[n].sink > 0.5 || (random*(1.e0/RAND_MAX))< 0.02e0*/) 
    //if(dis < 1.e1)
      {
      fprintf(outfile,"%15.13g %12d %15.13g %15.13g %15.13g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g\n", P[n].sink, P[n].Id,x,y,z,P[n].Temp,P[n].nh,P[n].HII,P[n].H2I,P[n].HDI, P[n].gam, disAU, vrad, vrot,P[n].Vel[0], P[n].Mass);
      //fprintf(outfile,"%15.13g %12d %15.13g %15.13g %15.13g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %15.6g %lg %lg %15.6g %15.6g\n", P[n].sink, Id[n],x,y,z,P[n].Temp,P[n].nh,P[n].HII,P[n].H2I,P[n].HDI, P[n].gam, disAU, P[n].Vel[0]*pow(Time, 0.5), P[n].Vel[2]*pow(Time, 0.5), P[n].hsm, P[n].Mass);
      ncount = ncount + 1;
      }
  }
  printf("ncount = %d.\n", ncount);
  printf("ncount2 = %d.\n", ncount2);

   printf("nhmax= %g\n", nhmax);
   printf("mmax= %g\n", mmax);
   printf("xmax= %15.11g\n", xmax);
   printf("ymax= %15.11g\n", ymax);
   printf("zmax= %15.11g\n", zmax);
   printf("sl = %g\n", sl);
   printf("tmax = %g\n", tmax);
   printf("h2max = %g\n", h2max);
   printf("gammin = %g\n", gammin);
   printf("typemax = %lg\n", typemax);
   printf("idmax = %d\n", idmax);
   printf("sink = %g\n", P[n-1].sink);
   printf("masstot = %g\n", masstot);
   printf("dismax = %g\n", dismax);

  fclose(outfile);
  free(P);
}

  do_what_you_want();
}
예제 #7
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], output_fname[200], basename[200], basenameout[200];
  int  i, k=0, j, n, type, snapshot_number, files, Ngas, random, ncount, ncounthalo1, ncount2, halo;
  double x,y,z,x1,y1,z1, delr;
  double nh, nhmax, mass, mmax, dis, disAU, xmax, ymax, zmax, sl, masstot, temp, tmax, h2, h2max, gam, gammin;
  double kB, G;
  double massHIT, diskmass, massin=0.0, massout=0.0;
  double mass_sink1, mass_sink2, mass_sink3, mass_sink4, mass_tot;
  double dis12, dis13, x_com, y_com, z_com, vx_com, vy_com, vz_com, vx1, vy1, vz1, vx2, vy2, vz2, vx3, vy3, vz3, vx4, vy4, vz4;
  double sinkposx1, sinkposy1, sinkposz1, sinkposx2, sinkposy2, sinkposz2, sinkposx3, sinkposy3, sinkposz3, sinkposx4, sinkposy4, sinkposz4;
  double num, numz, tempz, vz, rhoz, amom, amomtot, amomtotx, amomtoty, amomtotz, amomx, amomy, amomz, amomx1, amomx2, amomy1, amomy2, amomz1, amomz2;
  double xfac, vrad, vrot, vrotx, vroty, vrotz, omega, nh_avg, temp_avg, vrad_avg, vrot_avg, omega_avg, num_tot;
  double xtimesm, ytimesm, ztimesm, vxtimesm, vytimesm, vztimesm;
  double xCOM, yCOM, zCOM, vxCOM, vyCOM, vzCOM, jzcent, jnum;
  double m_enc_arr[200], d_arr[200], mass_enc;
  int ID_sink1, ID_sink2, ID_sink3, ID_sink4, sinknum;
  FILE *outfile;
  FILE *outfile2;


  sprintf(path, "/nobackupp1/astacy/hires");
  //sprintf(path, "/nobackupp1/astacy/");
  //sprintf(path, "/nobackupp1/astacy/binHR");

  halo = 0;

    if(halo == 0)
     {
     //sprintf(basename, "hires_test10");
     sprintf(basename, "hires_test10b");
     sprintf(basename, "hires3");
     sprintf(basenameout, "snaphires_test10");
     //jnum = 228;
     jnum = 2;
     }
  if(halo == 1)
     {
     sprintf(basename, "bin_HR1");
     sprintf(basenameout, "snapbin_HR1");
     //jnum = 228;
     jnum = 6;
     }
  if(halo == 2)
     {
     sprintf(basename, "bin_HR2");
     sprintf(basenameout, "snapbin_HR2");
     //jnum = 207;
     jnum = 5;
     }
  if(halo == 3)
     {
     sprintf(basename, "bin_HR3");
     sprintf(basenameout, "snapbin_HR3");
     //jnum = 206;
     jnum = 7;
     }
  if(halo == 4)
     {
     sprintf(basename, "bin_HR4");
     sprintf(basenameout, "snapbin_HR4");
     //jnum = 204;
     jnum = 7;
     }
  if(halo == 5)
     {
     sprintf(basename, "bin_HR5");
     sprintf(basenameout, "snapbin_HR5");
     //jnum = 209;
     jnum = 7;
     }
  if(halo == 6)
     {
     sprintf(basename, "bin_HR6");
     sprintf(basenameout, "snapbin_HR6b");
     //jnum = 224;
     jnum = 7;
     }
  if(halo == 7)
     {
     sprintf(basename, "bin_HR7b");
     sprintf(basenameout, "snapbin_HR7b");
     //jnum = 655;
     jnum = 9;
     //jnum=38;
     }
  if(halo == 8)
     {
     sprintf(basename, "bin_HR8");
     sprintf(basenameout, "snapbin_HR8");
     //jnum = 219;
     jnum = 7;
     }
  if(halo == 9)
     {
     sprintf(basename, "bin_HR9");
     sprintf(basenameout, "snapbin_HR9");
     //jnum = 207;
     jnum = 5;
     }
  if(halo == 10)
     {
     //sprintf(basename, "bin_HR10");
     sprintf(basename, "bin_HR10_alt");
     sprintf(basenameout, "snapbin_HR10");
     //jnum = 241;
     //jnum = 7;
     jnum=8;
     //jnum = 24;
     }


  for(j=2;j<=50;j=j+1){
  //for(j=jnum;j<=jnum;j=j+100){

  snapshot_number= j;                   /* number of snapshot */
  files=1;                               /* number of files per snapshot */

  kB = 1.38e-16;
  G = 6.67e-8;
  diskmass = 0.0;

  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  sprintf(output_fname, "%s_disk.dat",basename);
  Ngas = load_snapshot(input_fname, files);

  ID_sink1 = 4352905;
  ID_sink2 = 4333881;
  sinknum = 0;
          /*    reordering();*/ /* call this routine only if your ID's are set properly */

printf("hello line 187\n");

          unit_conversion();

printf("hello line 191\n");

          nh_avg= vrad_avg = vrot_avg = omega_avg = 0;

printf("hello line 195\n");

          temp_avg=0;
          num_tot=0;
          h2max=0;
          masstot=0;
          mmax=0;
          xtimesm = 0.0;
          ytimesm = 0.0;
          ztimesm = 0.0;
          vxtimesm = 0.0;
          vytimesm = 0.0;
          vztimesm = 0.0;


             for(i = 0; i < Ngas; i++)
                {
                if(Id[i] == ID_sink1)
                  {
                  sinkposx1 = P[i].Pos[0];
                  sinkposy1 = P[i].Pos[1];
                  sinkposz1 = P[i].Pos[2];
                  vx1 = P[i].Vel[0];
                  vy1 = P[i].Vel[1];
                  vz1 = P[i].Vel[2];
                  mass_sink1 = P[i].Mass*1.e10/0.7;
                  printf("Found the sink! mass= %lg, nh = %lg\n", mass_sink1, P[i].nh);
                  }

                 if(P[i].nh > 1e9)
                  {
                  diskmass = diskmass + (P[i].Mass*1.e10/0.7);
                  xtimesm = xtimesm + P[i].Pos[0]*(P[i].Mass*1.e10/0.7);
                  ytimesm = ytimesm + P[i].Pos[1]*(P[i].Mass*1.e10/0.7);
                  ztimesm = ztimesm + P[i].Pos[2]*(P[i].Mass*1.e10/0.7);
                  vxtimesm = vxtimesm + P[i].Vel[0]*(P[i].Mass*1.e10/0.7);
                  vytimesm = vytimesm + P[i].Vel[1]*(P[i].Mass*1.e10/0.7);
                  vztimesm = vztimesm + P[i].Vel[2]*(P[i].Mass*1.e10/0.7);
                  }
                }

             xCOM = xtimesm/diskmass;
             yCOM = ytimesm/diskmass;
             zCOM = ztimesm/diskmass;
             vxCOM = vxtimesm/diskmass;
             vyCOM = vytimesm/diskmass;
             vzCOM = vztimesm/diskmass;
             printf("%15.11g %15.11g %15.11g\n", xCOM, yCOM, zCOM);
             printf("%15.11g %15.11g %15.11g\n", vxCOM, vyCOM, vzCOM);


          //  if(j>=4)
          //  {
            sinkposx1 = xCOM;
            sinkposy1 = yCOM;
            sinkposz1 = zCOM;
            mass_sink1 = diskmass;
            vx1 = vxCOM;
            vy1 = vyCOM;
            vz1 = vzCOM;
         //   }

         diskmass=0.0;
         ncount=0;

        for(n=0; n<200; n++)
               {
               m_enc_arr[n] = 0.0;
               d_arr[n] = (double(n)/199.0)*10000.0;
               printf("d_arr[%d] = %lg\n", n, d_arr[n]);
               }

       for(i = 0; i < Ngas; i++)
               {
                if(P[i].nh > 1.e8)
                  {
                   dis = pow(((P[i].Pos[0]-sinkposx1)*(P[i].Pos[0]-sinkposx1) + (P[i].Pos[1]-sinkposy1)*(P[i].Pos[1]-sinkposy1) + (P[i].Pos[2]-sinkposz1)*(P[i].Pos[2]-sinkposz1)), 0.5);
                   dis=dis*1.e3*Time/(0.7);                   //dis is in pc
                   disAU = dis*206264.8060;
                   for(n=0; n<200; n++)
                     {
                     if(disAU < d_arr[n] /*|| P[i].sink > 0.5*/)
                       m_enc_arr[n] = m_enc_arr[n] + P[i].Mass*1.e10/0.7;
                     }
                    }
                  }

        for(n=0; n<200; n++)
               {
               printf("m_enc_arr[%d] = %lg\n", n, m_enc_arr[n]);
               }


         for(i = 0; i < Ngas; i++)
                {

                 P[i].Vel[0] = P[i].Vel[0] - vx1;
                 P[i].Vel[1] = P[i].Vel[1] - vy1;
                 P[i].Vel[2] = P[i].Vel[2] - vz1;

                 amomx = (P[i].Pos[1]-sinkposy1)*P[i].Vel[2]  - (P[i].Pos[2]-sinkposz1)*P[i].Vel[1];
                 amomy = (P[i].Pos[2]-sinkposz1)*P[i].Vel[0] - (P[i].Pos[0]-sinkposx1)*P[i].Vel[2];
                 amomz = (P[i].Pos[0]-sinkposx1)*P[i].Vel[1]  -  (P[i].Pos[1]-sinkposy1)*P[i].Vel[0];

                 amomx =  amomx*pow(Time, 0.5)*1.e5*3.086e18*1.e3*Time/(0.7);  //convert to cgs units
                 amomy =  amomy*pow(Time, 0.5)*1.e5*3.086e18*1.e3*Time/(0.7);
                 amomz =  amomz*pow(Time, 0.5)*1.e5*3.086e18*1.e3*Time/(0.7);

                 amom = pow(amomx*amomx + amomy*amomy + amomz*amomz, 0.5);

                 dis = pow(((P[i].Pos[0]-sinkposx1)*(P[i].Pos[0]-sinkposx1) + (P[i].Pos[1]-sinkposy1)*(P[i].Pos[1]-sinkposy1) + (P[i].Pos[2]-sinkposz1)*(P[i].Pos[2]-sinkposz1)), 0.5);
                 //dis = pow(((P[i].Pos[0]-sinkposx1)*(P[i].Pos[0]-sinkposx1) + (P[i].Pos[2]-sinkposz1)*(P[i].Pos[2]-sinkposz1)), 0.5);
                 dis=dis*1.e3*Time/(0.7);                   //dis is in pc
                 disAU = dis*206264.8060;
                 dis=dis*3.086e18;   //dis in now in cm                

                 vrad =  (P[n].Vel[0]*(P[n].Pos[0]-sinkposx1) + P[n].Vel[1]*(P[n].Pos[1]-sinkposy1) + P[n].Vel[2]*(P[n].Pos[2]-sinkposz1))/pow(((P[n].Pos[0]-sinkposx1)*(P[n].Pos[0]-sinkposx1) + (P[n].Pos[1]-sinkposy1)*(P[n].Pos[1]-sinkposy1) + (P[n].Pos[2]-sinkposz1)*(P[n].Pos[2]-sinkposz1)), 0.5);
                 vrad = vrad*pow(Time, 0.5);


                 vrotx = (P[n].Pos[1]-sinkposy1)*P[n].Vel[2]  - (P[n].Pos[2]-sinkposz1)*P[n].Vel[1];
                 vroty = (P[n].Pos[2]-sinkposz1)*P[n].Vel[0] - (P[n].Pos[0]-sinkposx1)*P[n].Vel[2];
                 vrotz = (P[n].Pos[0]-sinkposx1)*P[n].Vel[1]  -  (P[n].Pos[1]-sinkposy1)*P[n].Vel[0];

                 vrot = pow(vrotx*vrotx + vroty*vroty + vrotz*vrotz, 0.5);
                 vrot = vrot*pow(Time, 0.5)/pow(((P[n].Pos[0]-sinkposx1)*(P[n].Pos[0]-sinkposx1) + (P[n].Pos[1]-sinkposy1)*(P[n].Pos[1]-sinkposy1) + (P[n].Pos[2]-sinkposz1)*(P[n].Pos[2]-sinkposz1)), 0.5);

                 omega = vrot/(dis/1.e5);  // pi factors CANCEL OUT -- 2 pi r to get circumference CANCELS with the 2 pi radians per circumference

                 if(P[i].nh > 1.e8)
                 {
                   mass_enc = m_enc_arr[0];
                   for(n=0; n<200; n++)
                     {
                     if(disAU > d_arr[n])
                       mass_enc = m_enc_arr[n];
                     }
                 //jzcent = pow(6.67e-8 * mass_sink1 * 1.98892e33*dis, 0.5);
                 jzcent = pow(6.67e-8 * mass_enc * 1.98892e33*dis, 0.5);
                 }

                 //if((fabs(amom - jzcent) <= 0.5*jzcent && P[i].nh > 1.e8) && P[i].sink < 0.5)
                 //if((fabs(amom - jzcent) <= 0.5*jzcent && P[i].nh > 1.e8) || P[i].sink > 0.5)
                 if(P[i].nh > 1.e9 && P[i].H2I > 1.e-3 || P[i].sink > 0.5)
                 //if(P[i].nh > 1.e9 && P[i].H2I > 1.e-3 && P[i].sink < 0.5)
                 //if(P[i].nh > 1.e9 && P[i].H2I <= 1.e-3 &&  P[i].sink < 0.5)
                 //if(amom > jzcent && P[i].nh > 1.e8 && P[i].sink < 0.5)
                  {

                  //diskmass = diskmass + (P[i].Mass*1.e10/0.7);
                  //nh_avg = nh_avg + P[i].nh*(P[i].Mass/1.03395e-12);
                  //temp_avg = temp_avg + P[i].Temp*(P[i].Mass/1.03395e-12);
                  //num_tot = num_tot + (P[i].Mass/1.03395e-12);

                  diskmass = diskmass + (P[i].Mass*1.e10/0.7);
                  //nh_avg = nh_avg + P[i].nh;
                  nh_avg = nh_avg +(1- 2.*P[i].H2I);

                  if(P[i].sink < 0.5)
                   temp_avg = temp_avg + P[i].Temp;
                  
                  //if(P[i].Temp > 6000)
                  //  printf("ID = %d nh = %lg, temp = %lg, elec %lg, H2 = %lg sink = %lg\n", Id[i], P[i].nh, P[i].Temp, P[i].HII, P[i].H2I, P[i].sink);

                  vrad_avg = vrad_avg + fabs(vrad);
                  vrot_avg = vrot_avg + vrot;
                  omega_avg = omega_avg + omega;
                  num_tot = num_tot + 1.0;

                  if(P[i].sink > 0.5)
                   sinknum++;

                    ncount++;
                    //}
                  }
                }
            //fclose(outfile2);  
            printf("temp = %lg, num_tot = %lg, temp_avg = %lg\n", temp_avg, num_tot, temp_avg/num_tot);

             //outfile=fopen("disk_tot_h2_ng9_nr6e_alt", "a");
             //outfile=fopen("disk_nosink_h2_ng9_nr6e_alt", "a");
             //outfile=fopen("disk_hot_ng9_nr6e_alt", "a");
             //outfile=fopen("disk_test", "a");
             outfile=fopen(output_fname, "a");
             fprintf(outfile, "%15.11g %15.11g %15.11g %15.11g %15.11g %15.11g %15.11g %d\n", Time, diskmass, nh_avg/num_tot, temp_avg/num_tot, vrad_avg/num_tot, vrot_avg/num_tot, omega_avg/num_tot, sinknum);
             fclose(outfile);

             outfile=fopen(output_fname2, "a");
             fprintf(outfile, "%15.11g %15.11g \n", Time, fshield);
             fclose(outfile);

  free(P);
}

  do_what_you_want();
}
예제 #8
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], output_fname[200], basename[200], basenameout[200];
  int  j, n, type, snapshot_number, output_number,files, Ngas, random, ncount, ncounthalo1, ncount2;
  float x,y,z,x1,y1, z1, delr;
  double delx, dely, delz, boxsize;
  FILE *outfile;


  sprintf(path, "/work/00863/minerva/");

  //sprintf(basename, "midres_small");
  //sprintf(basename, "midhires/midhires");
  //sprintf(basename, "hires_test10");
  //sprintf(basename, "dmaH101");
  sprintf(basename, "bin_HR10");
  //sprintf(basename, "bin_zoom10_new");
  //sprintf(basename, "bin_zoom10_new_highN");
  //sprintf(basename, "bin_zoom10_new_ref");

  //snapshot_number=300;                   /* number of snapshot */
  //snapshot_number=500;
  //snapshot_number=800;  
  //snapshot_number=910;
  //snapshot_number=2550;
  //snapshot_number=764;
  //snapshot_number=442;

  //sprintf(basename, "midres");
  //snapshot_number=250;                   /* number of snapshot */

output_number = 6;
for(j=6; j<=6; j=j+1)
  {

  snapshot_number=j;
  
  files=1;     

  boxsize = 140.0;

/*
  delx = 70.309788381;  /del's used in making hires_nf (?) (midhires_920)
  dely = 70.290775273;
  delz = 69.663477541;
*/
/*
  delx = 70.285815369;  //del's used in making hires_nf2 (midhires_500)
  dely = 70.267684537;
  delz = 69.645294964;
*/
/*
  delx = 70.285954951;  //del's used in making hires_nf3 (midhires_800)
  dely = 70.267065424;
  delz = 69.645294964;
*/
/*
  delx = 70.285976724;  //del's used in making hires_nf2 (midhires_910)
  dely = 70.266799478;
  delz = 69.644071682;
*/
/*
  delx = 70.286688899;  //del's used in making dma_ (midhires_300)
  dely = 70.271233273;
  delz = 69.65345084;
*/
/*
  delx = 70.285951357;  //del's used in making hires_test10_4202 (hires_test10_4201)
  dely = 70.2668302;
  delz = 69.644059893;
*/
/*
  delx = 70.285964359;  //del's used in making hires_test10b_2550 (hires_test10_2550)
  dely = 70.266825688;
  delz = 69.644095683;
*/
/*
  delx = 70.285900597;  //del's used in making dmaH101_765 (dmaH101_764)
  dely = 70.267312791;
  delz = 69.645754876;
*/
/*
  delx = 512.65800353;  //del's used in making bin_HRE10_442 (bin_HRE10_443)
  dely = 505.21836888;
  delz = 497.39349349;
*/

  delx = 512.65800353;  //del's used in making bin_zoom10_cut_??? (bin_zoom10_???)
  dely = 505.21836888;
  delz = 497.39349349;

  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);

  if(snapshot_number > 999)
    sprintf(input_fname, "%s/%s_%04d", path, basename, snapshot_number);

  //sprintf(output_fname, "/nobackupp1/astacy/dma_001");
  //sprintf(output_fname, "/nobackupp1/astacy/hires_test10_4202");
  //sprintf(output_fname, "/nobackupp1/astacy/hires_test10b_2550");
  //sprintf(output_fname, "/nobackupp1/astacy/dmaH101_765");
  //sprintf(output_fname, "/nobackupp1/astacy/bin_HRE10_443");
  
  sprintf(basenameout, "bin_HR10_cut");
  sprintf(output_fname, "%s/%s_%03d", path, basenameout, output_number);
  if(snapshot_number > 999)
    sprintf(output_fname, "%s/%s_%04d", path, basenameout, output_number);
  output_number++;

  Ngas = write_snapshot(input_fname, files, output_fname, delx, dely, delz, boxsize);

  unit_conversion();  

  ncount = 0;
  ncount2 = 0;

  printf("ncount = %d.\n", ncount);
  printf("ncount2 = %d.\n", ncount2);

  do_what_you_want();
  free(P);
}
}
예제 #9
0
/* Here we load a snapshot file. It can be distributed
 * onto several files (for files>1).
 * The particles are brought back into the order
 * implied by their ID's.
 * A unit conversion routine is called to do unit
 * conversion, and to evaluate the gas temperature.
 */
int main(int argc, char **argv)
{
  char path[200], input_fname[200], output_fname[200], basename[200], basenameout[200];
  int  j, n, type, snapshot_number, files, Ngas, random, ncount, ncounthalo1, ncount2;
  float x,y,z,x1,y1, z1, delr;
  double delx, dely, delz, boxsize;
  FILE *outfile;


  sprintf(path, "/nobackupp1/astacy/bin_zoom");
  //sprintf(basename, "midres_small");
  //sprintf(basename, "midhires");
  sprintf(basename, "bin_zoom10");
  //snapshot_number=90;                   /* number of snapshot */
  //snapshot_number=77;
  //snapshot_number=86;
  //snapshot_number=127;
  //snapshot_number=112; 
  //snapshot_number=139;
  //snapshot_number=101;
  //snapshot_number=94;
  //snapshot_number=113;
  snapshot_number=91;
  //snapshot_number=89;           //using bin_zoom10 for dma study
  files=1;     

  boxsize = 140.0;

  //delx = 70.309788381;
  //dely = 70.290775273;
  //delz = 69.663477541;

  //delx = 50.339110402;
  //dely = 50.122129376;
  //delz = 49.486652655;

  //delx = 501.10837429;   //bin_HR1
  //dely = 502.63795002;
  //delz = 500.57881331;

  //delx = 504.74822278;   //bin_HR2
  //dely = 502.54674042;
  //delz = 498.35964366;

  //delx = 497.97549715;   //bin_HR3
  //dely = 478.97623119;
  //delz = 533.38658886;

  //delx = 492.79124064;   //bin_HR4
  //dely = 481.69180059;
  //delz = 488.42188726;

  //delx = 500.7922779;   //bin_HR5
  //dely = 499.63885791;
  //delz = 498.79440875;

  //delx = 491.44365517;   //bin_HR6
  //dely = 524.86976032;
  //delz = 504.56886557;

  //delx = 500.88344323;   //bin_HR7
  //dely = 499.58683015;
  //delz = 504.99209358;

  //delx = 506.01124135;   //bin_HR8
  //dely = 501.56161969;
  //delz = 503.11090611;

  //delx = 496.9606639;   //bin_HR9
  //dely = 497.98016741;
  //delz = 514.16669622;

  delx = 512.66315335;   //bin_HR10
  dely = 505.21955922;
  delz = 497.39292251;

  //delx = 512.70283548;   //bin_HR10 (for dma study)
  //dely = 505.23514735;
  //delz = 497.3872807;

  sprintf(input_fname, "%s/%s_%03d", path, basename, snapshot_number);
  //sprintf(output_fname, "/nobackupp1/astacy/hires_001a");
  //sprintf(output_fname, "/nobackupp1/astacy/bin_HR10_001");
  sprintf(output_fname, "/nobackupp1/astacy/bin_HRL10_001");
  //sprintf(output_fname, "/nobackupp1/astacy/dma2_001");
  Ngas = write_snapshot(input_fname, files, output_fname, delx, dely, delz, boxsize);

  unit_conversion();  

  ncount = 0;
  ncount2 = 0;

  printf("ncount = %d.\n", ncount);
  printf("ncount2 = %d.\n", ncount2);

  do_what_you_want();
}