Re: ICs with ZA+2LPT

From: Volker Springel <volker_at_MPA-Garching.MPG.DE>
Date: Thu, 30 Sep 2010 10:41:16 +0200

One possibility is also to modify the read-in routine of gadget such
that gas particles are automatically created for DM-only initial
conditions. This duplicates the set of dm particles, and shifts the
particle pairs such that the center-of-mass stays invariant, but at the
same time the two particle species form two interleaved grids/glasses.
This technique assumes that the displacement fields for gas and dark
matter are the same, which is ok unless you probe quite small scales.
Such an option already exists in gadget3. To do this in gadget2, one
would have to insert code modications in two places

before allocate_memory() is called, and before All.MaxPart ist set, one
would have to add something like

#ifdef GENERATE_GAS_IN_ICS
      if(RestartFlag == 0)
        {
          All.TotN_gas += header.npartTotal[1];
          All.TotNumPart += header.npartTotal[1];
        }
#endif


And towards the end of read_ic(), before the temperatures/entropies are
initialized, one could add something like


#ifdef GENERATE_GAS_IN_ICS
  int count;
  double fac, d, a, b, rho;

  if(RestartFlag == 0)
    {
      for(i = 0, count = 0; i < NumPart; i++)
        if(P[i].Type == 1)
          count++;

      memmove(P + count, P, sizeof(struct particle_data) * NumPart);

      NumPart += count;
      N_gas += count;
 

      fac = All.OmegaBaryon / All.Omega0;
      rho = All.Omega0 * 3 * All.Hubble * All.Hubble / (8 * M_PI *
All.G);

      int j;

      for(i = count, j = 0; i < NumPart; i++)
        if(P[i].Type == 1)
          {
            d = pow(P[i].Mass / rho, 1.0 / 3);
            a = 0.5 * All.OmegaBaryon / All.Omega0 * d;
            b = 0.5 * (All.Omega0 - All.OmegaBaryon) / All.Omega0 * d;
            P[j] = P[i];

            P[j].Mass *= fac;
            P[i].Mass *= (1 - fac);
            P[j].Type = 0;
            P[j].ID += 1000000000;

            P[i].Pos[0] += a;
            P[i].Pos[1] += a;
            P[i].Pos[2] += a;
            P[j].Pos[0] -= b;
            P[j].Pos[1] -= b;
            P[j].Pos[2] -= b;

            j++;
          }

      All.MassTable[0] = 0;
      All.MassTable[1] *= (1 - fac);
    }
#endif



Your milage with these changes may vary - debug yourself please.


Volker



On Thursday, September 30, 2010 09:47:28 am Scott Wales wrote:
> Hi Shankar,
>
> You'll probably want to generate the gas particles separately, using
> the baryon transfer function, so that you get two IC files, one for
> CDM and one for gas. You can then combine them into one manually.
>
> It looks like 2lpt takes a cmbfast transfer function file, which will
> probably have a column for each cosmological component (baryon, cdm,
> neutrino etc.). You should only have to change which column is used
> in 2lpt's source code. You'll probably get better results if you use
> the same random generator seed for both cdm and baryon particles.
>
> Combining the cdm and gas files should be fairly straightforward,
> you'll have to set the correct number of particles and masses in the
> header, then in each block put the gas particles before the cdm
> particles. Blocks consist of a size (32 bit unsigned integer), that
> many bytes and then the size again (check the gadget user's guide).
> Fill the SPH specific blocks with zeros and you should be good.
>
> You should be able to work out the particle mass from rho, the box
> size and the particle count, edit the initial conditions file header
> to correct it.
>
> Cheers,
> Scott Wales
>
> On 29/09/2010, at 11:37 PM, Agarwal, Shankar wrote:
> > Hi all,
> >
> > I intend to run large-scale CDM+gas cosmological simulations using
> > Gadget. I have generated the ICs using ZA+2LPT
> > (http://cosmo.nyu.edu/roman/2LPT/).
> >
> > I found that the way 2LPT is set up, it generated only CDM
> > realization and it sets the gas mass [Massarr(0)] and gas particles
> > [Npart(0)] equal to zero. Also, the mass_per_cdm_particle is not
> > correct (it is correct if Ngas=0).
> >
> >
> > Please let me know if I need to modify 2LPT to include gas. If yes,
> > I have identified the following modifications :
> >
> > 1. Npart(0)
> > 2. Massarr(0)
> > 3. temperature field - i can initialize it to zero.
> >
> >
> > I will appreciate any feedback. I have so far been using Enzo1.5
> > N-body code but have found that it does not resolve low mass halos
> > well.
> >
> >
> > Regards
> > Shankar Agarwal
> > Cosmology group
> > University of Kansas
> > USA
> >
> >
> > -----------------------------------------------------------
> >
> > If you wish to unsubscribe from this mailing, send mail to
> > minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe
> > gadget-list A web-archive of this mailing list is available here:
> > http://www.mpa-garching.mpg.de/gadget/gadget-list
>
Received on 2010-09-30 10:42:31

This archive was generated by hypermail 2.3.0 : 2023-01-10 10:01:31 CET