In Situ Python Analysis: Plummer - vivi235711/gamer GitHub Wiki
This test problem Plummer demonstrates the in situ Python analysis feature in GAMER.
- Install the required packages for this demo.
- libyt and yt_libyt: the in situ analysis library and its yt frontend.
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.
-
Generate
Makefilewith 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, andLIBYT_PATHin configuration file. -
Compile the code in the
srcfolder.make clean make -j 4
Execution results
... ... Compiling GAMER --> Successful!
-
Create a working directory in the
binfolder 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
-
In
Input__Parameter, setOPT__OUTPUT_TOTALto0since we don't need to dump data to disk in this demo. (If you want to make GAMER dump data snapshots, enableSUPPORT_HDF5and setHDF5_PATHinMakefile. KeepOPT__OUTPUT_TOTALto1.)# data dump OPT__OUTPUT_TOTAL 0 # output the simulation snapshot: (0=off, 1=HDF5, 2=C-binary) [1] -
In
Input__TestProb, setPlummer_Collisionto1for 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] -
Create a
LIBYT_STOPfile. 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 fileLIBYT_STOP.touch LIBYT_STOP
-
Run GAMER.
OMPI_MCA_osc=sm,pt2pt mpirun -np 4 ./gamer
-
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 ):
passProjection of field Cloud01 along the z-axis:

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

- 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 ===================================================================== >>>
- You can explore interactive prompt
or simply press
Ctrl + Cto shut down the process.