In Situ Python Analysis: Plummer - hyschive/gamer-fork GitHub Wiki

This test problem Plummer demonstrates the in situ Python analysis feature in GAMER.


  1. Install the required packages for this demo.

Important

This example assumes it is using libyt interactive mode. Please compile libyt in interactive mode.

  • yt: the core analysis tool.
  • FFTW: needed in this test problem.
  • HDF5: this is optional since we are not going to output any data.
  1. Generate Makefile with the following options:

    --gravity=true --particle=true --passive=2 --mpi=true --fftw=FFTW2 --libyt=true --libyt_interactive=true

    Also please set the paths FFTW_PATH, MPI_PATH, and LIBYT_PATH in configuration file.

  2. Compile the code in the src folder.

    make clean
    make -j 4
Execution results
   ...
   ...
Compiling GAMER --> Successful!
  1. Create a working directory in the bin folder and copy the GAMER executable and Plummer test problem files.

    mkdir Plummer                                       # create a folder for this test
    cd Plummer
    cp -r ../../example/test_problem/Hydro/Plummer/* .  # copy test problem settings
    cp ../../src/gamer .                                # copy GAMER executable
  2. In Input__Parameter, set OPT__OUTPUT_TOTAL to 0 since we don't need to dump data to disk in this demo. (If you want to make GAMER dump data snapshots, enable SUPPORT_HDF5 and set HDF5_PATH in Makefile. Keep OPT__OUTPUT_TOTAL to 1.)

    # data dump
    OPT__OUTPUT_TOTAL       0     # output the simulation snapshot: (0=off, 1=HDF5, 2=C-binary) [1]
    
  3. In Input__TestProb, set Plummer_Collision to 1 for simulating colliding Plummer clouds.

    Plummer_Collision       1     # (0/1)--> single Plummer cloud/two colliding Plummer clouds
    Plummer_AddColor        1     # assign different colors to different clouds (must turn on Plummer_Collision
                                  # and set NCOMP_PASSIVE_USER to 2 in the Makefile) [0]
    
  4. Create a LIBYT_STOP file. This demo assumes libyt is in interactive mode. It will only enter interactive Python prompt if errors occur while running Python codes or it detects the file LIBYT_STOP.

    touch LIBYT_STOP
  5. Run GAMER.

    OMPI_MCA_osc=sm,pt2pt mpirun -np 4 ./gamer
  6. Results from the inline script.

Inline script inline_script.py:

import yt_libyt
import yt

yt.enable_parallelism()

def yt_inline():
    # Get data
    ds = yt_libyt.libytDataset()

    # Do ProjectionPlot to field Cloud0.
    sz = yt.ProjectionPlot(ds, 'z', ('gamer', 'Cloud0'), center='c')

    # Do ParticlePlot
    par = yt.ParticlePlot(ds, 'particle_position_x', 'particle_position_y', 'particle_mass', center='c')

    if yt.is_root():
        sz.save()
        par.save()

def yt_inline_inputArg( fields ):
    pass

Projection of field Cloud01 along the z-axis:

insitu_projection

Particle plot using particle position x and y as axes with particle mass mapped to a colorbar:

insitu_particle

  1. Since we have run libyt in interactive mode, the program should now pause and wait for user input.
=====================================================================
  Inline Function                              Status         Run
---------------------------------------------------------------------
  * yt_inline                                  success         V
  * yt_inline_inputArg                         success         V
=====================================================================
>>>
  1. You can explore interactive prompt or simply press Ctrl + C to shut down the process.
⚠️ **GitHub.com Fallback** ⚠️