Commits

Matthew Turk committed 5e42072

Initial import of repository

  • Participants

Comments (0)

Files changed (5)

AMRCosmologySimulation.enzo

+#
+# AMR PROBLEM DEFINITION FILE: Cosmology Simulation (amr version)
+#
+#  define problem
+#
+ProblemType                = 30      // cosmology simulation
+TopGridRank                = 3
+TopGridDimensions          = 32 32 32
+SelfGravity                = 1       // gravity on
+TopGridGravityBoundary     = 0       // Periodic BC for gravity
+LeftFaceBoundaryCondition  = 3 3 3   // same for fluid
+RightFaceBoundaryCondition = 3 3 3
+#
+#  problem parameters
+#
+CosmologySimulationOmegaBaryonNow       = 0.04
+CosmologySimulationOmegaCDMNow          = 0.26
+CosmologySimulationDensityName          = GridDensity
+CosmologySimulationVelocity1Name        = GridVelocities
+CosmologySimulationVelocity2Name        = GridVelocities
+CosmologySimulationVelocity3Name        = GridVelocities
+CosmologySimulationParticlePositionName = ParticlePositions
+CosmologySimulationParticleVelocityName = ParticleVelocities
+#
+#  define cosmology parameters
+#
+ComovingCoordinates        = 1       // Expansion ON
+CosmologyOmegaMatterNow    = 0.3
+CosmologyOmegaLambdaNow    = 0.7
+CosmologyHubbleConstantNow = 0.5     // in 100 km/s/Mpc
+CosmologyComovingBoxSize   = 0.30    // in Mpc/h
+CosmologyMaxExpansionRate  = 0.015   // maximum allowed delta(a)/a
+CosmologyInitialRedshift   = 99      // 
+CosmologyFinalRedshift     = 0       //
+GravitationalConstant      = 1       // this must be true for cosmology
+#
+#  set I/O and stop/start parameters
+#
+StopCycle              = 1000          // stop after this many cycles
+dtDataDump             = 0.25        // dump at beginning and end
+#CycleSkipDataDump      = 20
+DataDumpName           = DD
+ParallelRootGridIO     = 1
+CosmologyOutputRedshift[0] = 10
+CosmologyOutputRedshift[1] = 8
+CosmologyOutputRedshift[2] = 6
+CosmologyOutputRedshift[3] = 4
+CosmologyOutputRedshift[4] = 3
+CosmologyOutputRedshift[5] = 2
+CosmologyOutputRedshift[6] = 1
+CosmologyOutputRedshift[7] = 0
+#
+#  set hydro parameters
+#
+Gamma                  = 1.6667
+PPMDiffusionParameter  = 0       // diffusion off
+DualEnergyFormalism    = 1       // use total & internal energy
+InterpolationMethod    = 1     // SecondOrderA
+CourantSafetyNumber    = 0.5
+ParticleCourantSafetyNumber = 0.8
+RadiativeCooling            = 0
+MultiSpecies                = 0
+HydroMethod = 0
+#
+#  set grid refinement parameters
+#
+StaticHierarchy           = 0    // dynamic hierarchy
+MaximumRefinementLevel    = 2    // use up to 2 levels
+RefineBy                  = 2    // refinement factor
+CellFlaggingMethod        = 2 4    // use baryon mass for refinement 
+MinimumEfficiency         = 0.4  // fraction efficiency
+MinimumOverDensityForRefinement = 4.0 // times the initial density
+MinimumMassForRefinementLevelExponent = -0.3
+MinimumEnergyRatioForRefinement = 0.4 // min Egas/Etot for shock refinement
+#RefineRegionLeftEdge            = 0.15 0.20 0.41
+#RefineRegionRightEdge           = 0.35 0.45 0.79
+#
+#  set some global parameters
+#
+GreensFunctionMaxNumber   = 30   // # of greens function at any one time
+

AMRCosmologySimulation.inits

+#  Generates initial grid and particle fields for a single-grid
+#    CDM simulation
+#
+#  Cosmology Parameters
+#
+
+# PREVIOUS (1998)
+
+# CosmologyOmegaMatterNow      = 1
+# CosmologyOmegaLambdaNow      = 0
+# CosmologyOmegaBaryonNow      = 0.06
+
+# CURRENT (WMAP)
+
+CosmologyOmegaMatterNow      = 0.3
+CosmologyOmegaLambdaNow      = 0.7
+CosmologyOmegaBaryonNow      = 0.04
+
+CosmologyComovingBoxSize     = 0.3      // in Mpc/h
+CosmologyHubbleConstantNow   = 0.5      // in units of 100 km/s/Mpc
+CosmologyInitialRedshift     = 30
+#
+#  Power spectrum Parameters
+#
+PowerSpectrumType            = 1             // BBKS
+PowerSpectrumSigma8          = 0.9
+PowerSpectrumPrimordialIndex = 1.0
+PowerSpectrumRandomSeed      = -223456789
+#
+#  Grid info
+#
+Rank                = 3
+GridDims            = 32 32 32
+InitializeGrids     = 1
+GridRefinement      = 1
+#
+#  Particle info
+#
+ParticleDims        = 32 32 32
+InitializeParticles = 1
+ParticleRefinement  = 1
+#
+#  Overall field parameters
+#
+MaxDims             = 32 32 32
+#NewCenter           = 0.5 0.5 0.5
+#StartIndex          = 0 0 0
+#
+#  Names
+#
+ParticlePositionName = ParticlePositions
+ParticleVelocityName = ParticleVelocities
+GridDensityName      = GridDensity
+GridVelocityName     = GridVelocities
+What this does and how to do it
+===============================
+
+This sets up an inter-communicator to pass data back and forth between a
+running enzo process and a running yt process.
+
+** Right now it only works on a single processor on both ends! **
+
+To start it, you have to have the MPI lookup server running.  For OpenMPI, this
+looks like:
+
+    $ ompi-server --no-daemonize -d -r ompi_server.txt
+
+Now, you can start Enzo (compiled with python-yes) with this:
+
+    $ mpirun -np 1 --ompi-server file:ompi_server.txt ./enzo.exe -d AMRCosmologySimulation.enzo
+
+In another window, once it's up and running (and you have seen yt import) run
+this:
+
+    $ mpirun -np 1 --ompi-server file:ompi_server.txt python2.7 yt_recv.py --parallel
+
+Now your yt window will update a pylab output, while your Enzo window continues
+running Enzo.
+
+Why is this cool?
+=================
+
+Soon we will be able to dynamically connect, disconnect and reconnect processes
+to running Enzo jobs.  Enzo will be able to fire-and-forget some data products,
+which are then dealt with by separate communicators and yt itself.
+
+Ultimately, this will be used for much more flexible in situ visualization.
+Most interestingly, this model will also allow Enzo to run in the background
+while visualization and interactive exploration occur in another window.
+from yt.mods import *
+from mpi4py import MPI
+
+if 1:
+    my_info = MPI.Info()
+    port = MPI.Open_port(my_info)
+    MPI.Publish_name("enzo_server", my_info, port)
+    comm = MPI.COMM_WORLD.Accept(port, my_info, 0)
+
+def main():
+    pf = EnzoStaticOutputInMemory()
+    proj = pf.h.proj(0, "Density")
+    frb = FixedResolutionBuffer(proj, (0.0, 1.0, 0.0, 1.0), (1024, 1024))
+    print "SENDING PIXEL BUFFER", frb["Density"].min(), frb["Density"].max()
+    write_image(na.log10(frb["Density"]), "temp.png")
+    #return
+    st = MPI.Status()
+    waiting = comm.Iprobe(MPI.ANY_SOURCE, 104, status=st)
+    if not waiting: 
+        print "NO FOUND WAITING"
+        return
+    print "GETTING NEW OUTPUT"
+    comm.send(na.log10(frb["Density"]), dest = 0)
+from yt.mods import *
+from mpi4py import MPI
+import pylab
+pylab.ion()
+
+my_info = MPI.Info()
+
+port = MPI.Lookup_name("enzo_server", my_info)
+comm = MPI.COMM_WORLD.Connect(port, my_info, 0)
+
+while 1:
+    print "NOTIFYING ENZO"
+    comm.send(None, dest = 0, tag = 104)
+    print "RECEIVING"
+    image = comm.recv(source = 0)
+    print "UPDATING", image.min(), image.max()
+    pylab.clf()
+    pylab.imshow(image)
+    pylab.clim(image.min(), image.max())
+    pylab.draw()