In Situ Python Analysis: Plummer - hyschive/gamer-fork 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
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
, andLIBYT_PATH
in configuration file. -
Compile the code in the
src
folder.make clean make -j 4
Execution results
... ... Compiling GAMER --> Successful!
-
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
-
In
Input__Parameter
, setOPT__OUTPUT_TOTAL
to0
since we don't need to dump data to disk in this demo. (If you want to make GAMER dump data snapshots, enableSUPPORT_HDF5
and setHDF5_PATH
inMakefile
. KeepOPT__OUTPUT_TOTAL
to1
.)# data dump OPT__OUTPUT_TOTAL 0 # output the simulation snapshot: (0=off, 1=HDF5, 2=C-binary) [1]
-
In
Input__TestProb
, setPlummer_Collision
to1
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]
-
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 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 ):
pass
Projection 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 + C
to shut down the process.