forked from gamer-project/gamer
-
Notifications
You must be signed in to change notification settings - Fork 0
In Situ Python Analysis: Plummer
Hsi-Yu Schive edited this page Jul 8, 2023
·
3 revisions
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.
- 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.
- Edit the
Makefile
to validate the following settings and set the pathsFFTW_PATH
,MPI_PATH
, andLIBYT_PATH
. You can also use the Python script configure.py to tailor theMakefile
(an example can be found atexample/test_problem/Hydro/Plummer/generate_make.sh
).
SIMU_OPTION += -DGRAVITY
SIMU_OPTION += -DPARTICLE
# number of user-defined passively advected scalars
# --> set it to 0 or comment it out if none is required
# --> useless for RTVD
SIMU_OPTION += -DNCOMP_PASSIVE_USER=2
#SIMU_OPTION += -DSERIAL
SIMU_OPTION += -DLOAD_BALANCE=HILBERT
# support FFTW library
# --> SUPPORT_FFTW must be defined when GRAVITY is enabled
# --> use FFTW3 for fftw3 support
# use FFTW2 for fftw2 support
SIMU_OPTION += -DSUPPORT_FFTW=FFTW2
# support yt inline analysis
SIMU_OPTION += -DSUPPORT_LIBYT
# support libyt interactive mode
# --> this activates python prompt and does not shut down a simulation when there are
# errors in an inline python script
# --> must compile libyt with INTERACTIVE_MODE
# --> must enable SUPPORT_LIBYT
SIMU_OPTION += -DLIBYT_INTERACTIVE
# switch to MPI compiler
#CXX = g++ # serial compiler
CXX = $(MPI_PATH)/bin/mpicxx # MPI compiler
# set library paths
CUDA_PATH :=
FFTW_PATH := ${YOUR_FFTW_PATH}
MPI_PATH := ${YOUR_MPI_PATH}
HDF5_PATH :=
GRACKLE_PATH :=
GSL_PATH :=
LIBYT_PATH := ${YOUR_LIBYT_PATH}
- Compile the code in the
src
folder.
> make clean
> make -j 4
...
...
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
Crtl + C
to shut down the process.
Getting Started
User Guide
- Installation
- Running the Code
- Adding New Simulations
- Runtime Parameters
- MPI and OpenMP
- GPU
- Physics Modules
- Outputs
- Simulation Logs
- Data Analysis
- In Situ Python Analysis
- Test Problems
- Troubleshooting
Advanced Topics
Developer Guide