Changes between Version 2 and Version 3 of Tutorials/RunCosmologySimulation

Show
Ignore:
Timestamp:
08/26/08 12:44:23 (5 years ago)
Author:
sskory
Comment:

Updated, still a few more changes need to be made.

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials/RunCosmologySimulation

    v2 v3  
    11= How to run a cosmology simulation =  
    22 
    3 In order to run an example cosmology simulation you will need to recompile the code with MPI ON. Refer to the section above on compiling Enzo to see how to do that. After recompiling with MPI on, you should create a directory to run the simulation in. This is because Enzo cosmology simulations create quite a few output files, so it's best to store them in their own directory. For the purposes of this example I'm going to assume that you have created a directory called EnzoTestSim in your home directory. You should then download these two files: Example_Cosmology_Sim.inits and Example_Cosmology_Sim.param which are the initial conditions parameter file and the simulation parameter file, respectively. Put these two files in that directory, along with the enzo binary, the ring binary, and the initial conditions generator binary (the binaries are named enzo, ring and inits, respectively). 
    4 Creating initial conditions 
     3In order to run a cosmology simulation, you'll need to [wiki:BuildingEnzo build enzo.exe, inits.exe and ring.exe]. inits creates the initial conditions for your simulation, and ring splits up the root grid which is necessary if you're using parallel IO. Once you have built the three executables, put them in a common directory where you will run your test simulation. You will also save the inits and param files (shown and discussed below) in this directory. 
    54 
    6 The first step in preparing the simulation is to create the initial conditions. The file Example_Cosmology_Sim.inits is a text file which contains a list of parameter file names with their associated values. These values tell the initial conditions generator useful information like the simulation box size, the cosmological parameters and the size of the root grid. The code then takes that information and creates a set of initial conditions. inits is run by typing this command: 
     5== Creating initial conditions == 
    76 
    8 user02:~/EnzoTestSim150% ./inits -d Example_Cosmology_Sim.inits 
     7The first step in preparing the simulation is to create the initial conditions. The file inits uses is a text file which contains a list of parameter file names with their associated values. These values tell the initial conditions generator useful information like the simulation box size, the cosmological parameters and the size of the root grid. The code then takes that information and creates a set of initial conditions. Here is an example inits file: 
     8 
     9 
     10{{{ 
     11# 
     12#  Generates initial grid and particle fields for a multi-grid 
     13#    CDM simulation  (top grid) 
     14# 
     15#  Cosmology Parameters 
     16# 
     17CosmologyOmegaBaryonNow      = 0.044 
     18CosmologyOmegaMatterNow      = 0.27  
     19CosmologyOmegaLambdaNow      = 0.73   
     20CosmologyComovingBoxSize     = 10.0    // in Mpc/h 
     21CosmologyHubbleConstantNow   = 0.71      // in units of 100 km/s/Mpc 
     22CosmologyInitialRedshift     = 60 
     23# 
     24#  Power spectrum Parameters 
     25# 
     26 
     27PowerSpectrumType            = 11 
     28PowerSpectrumSigma8          = 0.9 
     29PowerSpectrumPrimordialIndex = 1.0 
     30PowerSpectrumRandomSeed      = -584783758 
     31# 
     32#  Grid info 
     33# 
     34Rank                = 3 
     35GridDims            = 32 32 32 
     36InitializeGrids     = 1 
     37GridRefinement      = 1 
     38# 
     39#  Particle info 
     40# 
     41ParticleDims        = 32 32 32 
     42InitializeParticles = 1 
     43ParticleRefinement  = 1 
     44# 
     45#  Overall field parameters 
     46# 
     47# 
     48#  Names 
     49# 
     50ParticlePositionName = ParticlePositions 
     51ParticleVelocityName = ParticleVelocities 
     52GridDensityName      = GridDensity 
     53GridVelocityName     = GridVelocities 
     54}}} 
     55 
     56inits is run by typing this command: 
     57 
     58{{{% ./inits.exe -d Example_Cosmology_Sim.inits}}} 
    959 
    1060inits will produce some output to the screen to tell you what it is doing, and will write five files: GridDensity, GridVelocities, ParticlePositions, ParticleVelocities and PowerSpectrum.out. The first four files contain information on initial conditions for the baryon and dark matter componenets of the simulation, and are HDF 5 files. The last file is an ascii file which contains information on the power spectrum used to generate the initial conditions. 
    11 Parallel IO - the ring tool 
    1261 
    13 This simulation is quite small. The root grid is only 32 cells on a side and we allow a maximum of three levels of mesh refinement. Still, we will use the ring tool, since it is important for larger simulations of sizes typically used for doing science. 
     62It is also possible to run cosmology simulations using initial nested subgrids. 
    1463 
    15 The ring tool is part of the Enzo parallel IO (input-output) scheme. Examine the last section of the parameter file for this example simulation and you will see: 
     64== Parallel IO - the ring tool == 
    1665 
     66This simulation is quite small. The root grid is only 32 cells on a side and we allow a maximum of three levels of mesh refinement. Still, we will use the ring tool, since it is important for larger simulations of sizes typically used for doing science. Additionally, if you wish to run with 64 or more processors, you are required to use [wiki:HowDoesParallelRootGridIOwork parallel root grid IO], so it is beneficial to learn. 
     67 
     68The ring tool is part of the Enzo parallel IO (input-output) scheme. Examine the last section of the parameter file (see below) for this example simulation and you will see: 
     69 
     70{{{ 
    1771# 
    1872# IO parameters 
     
    2074ParallelRootGridIO = 1 
    2175ParallelParticleIO = 1 
     76}}} 
    2277 
    2378These two parameters turn on parallel IO for both grids and particles. In a serial IO simulation where multiple processors are being used, the master processor reads in all of the grid and particle initial condition information and parcels out portions of the data to the other processors. Similarly, all simulation output goes through the master processor as well. This is fine for relatively small simulations using only a few processors, but slows down the code considerably when a huge simulation is being run on hundreds of processors. Turning on the parallel IO options allows each processor to perform its own IO, which greatly decreases the amount of time the code spends performing IO. 
     
    2580The process for parallelizing grid and particle information is quite different. Since we know exactly where every grid cell in a structured Eulerian grid is in space, and these cells are stored in a regular and predictable order in the initial conditions files, turning on ParallelRootGridIO simply tells each processor to figure out which portions of the arrays in the GridDensity and GridVelocities belong to it, and then read in only that part of the file. The particle files (ParticlePositions and ParticleVelocities) store the particle information in no particular order, so in order to efficiently parallelize the particle IO the ring tool is used. ring is run on the same number of processors as the simulation that you intend to run, and can be used right before the simulation itself is run. In ring, each processor reads in an equal fraction of the particle position and velocity information into a list, flags the particles that belong in its simulation spatial domain, and then passes its portion of the total list on to another processor. After each portion of the list has made its way to every processor, each processor then collects all of the particle and velocity information that belongs to it and writes them out into files called PPos.nnnn and PVel.nnnn, where nnnn is the processor number. Turning on the ParallelParticleIO flag in the Enzo parameter file instructs Enzo to look for these files. 
    2681 
    27 For the purpose of this example, I'm going to run ring and Enzo on 4 processors, but as an interactive job on Titan. One enters interactive parallel mode by typing: 
     82There are lots more details on [wiki:HowDoesParallelRootGridIOwork this page]. 
    2883 
    29 user02:~/EnzoTestSim151% qsub -I -V -l walltime=00:30:00,nodes=2:ppn=2:prod 
     84For the purpose of this example, I'm going to run ring and Enzo on 4 processors. The number of processors used in an MPI job is set differently on each machine, so you'll have to figure out how that works for you. To start an interactive run, it might look something like this: 
    3085 
    31 This tells the machine that I want two compute nodes with two processors on each node (for a total of 4 processors) for a half hour of wall clock time. See this web page for more information on running interactive jobs on Titan. You may have to wait a bit until nodes become available, and then you will probably be left in your home directory, so you will have to change back to the EnzoTestSim subdirectory. You then run ring on the particle files by typing: 
     86{{{% qsub -I -V -l walltime=00:30:00,size=4}}} 
    3287 
    33 user02:~/EnzoTestSim154% vmirun ./ring ParticlePositions ParticleVelocities 
     88This tells the machine that I want four processors total for a half hour of wall clock time. You may have to wait a bit until nodes become available, and then you will probably start out back in your home directory. You then run ring on the particle files by typing something like this: 
    3489 
    35 This will then produce some output to your screen, and will generate 8 files: PPos.0000 through PPos.0003 and PVel.0000 through PVel.0003. Note that if you are using a different machine or platform, you may use something other than vmirun for MPI-parallel applications. Consult your system administrator or system documentation for more information. 
     90{{{% aprun -n 4 ./ring.exe pv ParticlePositions ParticleVelocities}}} 
     91 
     92This will then produce some output to your screen, and will generate 8 files: PPos.0000 through PPos.0003 and PVel.0000 through PVel.0003. 
    3693 
    3794Congratulations, you're now ready to run your cosmology simulation! 
    38 Running an Enzo cosmology simulation 
    3995 
    40 After all of this preparation, running the simulation itself should be straightforward. You start enzo by typing: 
     96== Running an Enzo cosmology simulation == 
    4197 
    42 user02:~/EnzoTestSim155% vmirun ./enzo -d Example_Cosmology_Sim.param > output.log 
     98After all of this preparation, running the simulation itself should be straightforward. First, you need to have an enzo parameter file. Here is an example compatible with the inits file above: 
    4399 
    44 The simulation will now run. The -d flag ensures a great deal of output, so we redirect it into a log file called output.log for later examination. This particular simulation should take approximately ten minutes to run on 4 processors on Titan. When the simulation is done, enzo will display the message "Successful run, exiting." 
     100{{{ 
     101# 
     102# AMR PROBLEM DEFINITION FILE: Cosmology Simulation (amr version) 
     103# 
     104#  define problem 
     105# 
     106ProblemType                = 30      // cosmology simulation 
     107TopGridRank                = 3 
     108TopGridDimensions          = 32 32 32 
     109SelfGravity                = 1       // gravity on 
     110TopGridGravityBoundary     = 0       // Periodic BC for gravity 
     111LeftFaceBoundaryCondition  = 3 3 3   // same for fluid 
     112RightFaceBoundaryCondition = 3 3 3 
     113# 
     114#  problem parameters 
     115# 
     116CosmologySimulationOmegaBaryonNow       = 0.044 
     117CosmologySimulationOmegaCDMNow          = 0.226  
     118CosmologyOmegaMatterNow                 = 0.27  
     119CosmologyOmegaLambdaNow                 = 0.73   
     120CosmologySimulationDensityName          = GridDensity 
     121CosmologySimulationVelocity1Name        = GridVelocities 
     122CosmologySimulationVelocity2Name        = GridVelocities 
     123CosmologySimulationVelocity3Name        = GridVelocities 
     124CosmologySimulationParticlePositionName = ParticlePositions 
     125CosmologySimulationParticleVelocityName = ParticleVelocities 
     126CosmologySimulationNumberOfInitialGrids = 1 
     127# 
     128#  define cosmology parameters 
     129# 
     130ComovingCoordinates        = 1       // Expansion ON 
     131CosmologyHubbleConstantNow = 0.71    // in km/s/Mpc 
     132CosmologyComovingBoxSize   = 10.0  // in Mpc/h 
     133CosmologyMaxExpansionRate  = 0.015   // maximum allowed delta(a)/a 
     134CosmologyInitialRedshift   = 60.0      //  
     135CosmologyFinalRedshift     = 3.0     // 
     136GravitationalConstant      = 1       // this must be true for cosmology 
     137# 
     138#  set I/O and stop/start parameters 
     139# 
     140CosmologyOutputRedshift[0] = 25.0  
     141CosmologyOutputRedshift[1] = 10.0 
     142CosmologyOutputRedshift[2] = 5.0   
     143CosmologyOutputRedshift[3] = 3.0 
     144# 
     145#  set hydro parameters 
     146# 
     147Gamma                  = 1.6667 
     148PPMDiffusionParameter  = 0       // diffusion off 
     149DualEnergyFormalism    = 1       // use total & internal energy 
     150InterpolationMethod    = 1     // SecondOrderA 
     151CourantSafetyNumber    = 0.5 
     152ParticleCourantSafetyNumber = 0.8 
     153FluxCorrection         = 1 
     154ConservativeInterpolation = 0 
     155HydroMethod            = 0 
     156# 
     157#  set cooling parameters 
     158# 
     159RadiativeCooling       = 0 
     160MultiSpecies           = 0 
     161RadiationFieldType     = 0 
     162StarParticleCreation   = 0 
     163StarParticleFeedback   = 0 
     164# 
     165#  set grid refinement parameters 
     166# 
     167StaticHierarchy           = 0    // AMR turned on! 
     168MaximumRefinementLevel    = 3 
     169MaximumGravityRefinementLevel = 3 
     170RefineBy                  = 2 
     171CellFlaggingMethod        = 2 4 
     172MinimumEfficiency         = 0.35 
     173MinimumOverDensityForRefinement = 4.0 4.0 
     174MinimumMassForRefinementLevelExponent = -0.1 
     175MinimumEnergyRatioForRefinement = 0.4  
    45176 
    46 Enzo is a complicated code, with a similarly complicated output format. See the Enzo User Guide page on the Enzo output format for more information on the data outputs. 
     177# 
     178#  set some global parameters 
     179# 
     180GreensFunctionMaxNumber   = 100   // # of greens function at any one time 
     181 
     182 
     183# 
     184# IO parameters 
     185# 
     186 
     187ParallelRootGridIO = 1 
     188ParallelParticleIO = 1 
     189}}} 
     190 
     191Once you've saved this, you start enzo by typing: 
     192 
     193{{{% aprun -n 4 ./enzo.exe -d Example_Cosmology_Sim.param > output.log}}} 
     194 
     195The simulation will now run. The -d flag ensures a great deal of output, so we redirect it into a log file called output.log for later examination. This particular simulation shouldn't take too long, so you can run this in the same 30 minute interactive job you started when you ran inits. When the simulation is done, enzo will display the message "Successful run, exiting." 
    47196 
    48197Congratulations! If you've made it this far, you have now successfully run a simulation using Enzo!