Skip to content

Paraview: Black Holes

Maria Okounkova edited this page Jul 18, 2022 · 3 revisions

Guide: Black Hole Binary Visualization

A common visualization task is to display surface data of a black hole binary. This involves converting dumped "Run" data into Paraview-readable formats (.vtk, .pvd), using python scripts to generate jpeg images, and using movie-making scripts to combine those jpegs. Fortunately, the undergraduates have thoroughly fleshed out much of this process.

Converting Your Data Into the VTK Format

First, you need to get your data into the correct format.

Turning H5 Files into Vtk Files

Generating Your Stills

You should now have a directory with a .pvd file and the actual vtk data for your black holes.

There is one main binary black hole data visualization script:

  • ParaviewPythonScript.py

Setting Up The Script

  1. Copy SpEC/Support/Visualization/ParaviewPythonScripting/ParaviewPythonScript.py to the directory where you wish to dump the images
  2. Set the initial variables (listed in the order in which they appear at the top of ParaviewPythonScript.py)
    1. Set debugmode = 1 initially before you are ready to make jpegs and while you are tweaking/debugging movie parameters
    2. Set the 'data' Booleans to let the script know what data you are visualizing (eg 'RData', 'GWData', 'SpinProA', ...)
    3. Set the 'Time' variables (eg 'StartTime', 'EndTime', ...)
    4. Set the 'DataName' variable to the name of the scalar to color the apparent horizons. Example: <code> DataName = 'WeylB_NN'</code>
    5. Set the 'AhADirectory' and 'AhBDirectory' variables to the full paths to their respective .pvd files. Example: <code> AhADirectory = '/home/astrosun/robertm/UltBBHRun/AhA/Data1.pvd' # Hole A's surface .pvd file

... AhBDirectory = '/home/astrosun/robertm/UltBBHRun/AhB/Data1.pvd' # Hole B's surface .pvd file </code>

  - Set the 'OutputLocation' to tell the script where to write the jpegs once you are done debugging
  - Set any of the other 'Direc' variables depending on what you want to visualize (eg if you set ''TData = 1'', then you should specify both 'AhATrajDirec' and 'AhBTrajDirec')
- Set other variables as needed 

Running the Script

At this point, you should be ready to start debugging the script and changing the parameters to optimally visualize your binary. When running the script in debugmode (debugmode = 1), use: <code> pvpython ParaviewPythonScript.py </code>

This should render the images in 'live time,' without actually saving them to the 'OutputLocation'. Use the debugmode to tweak the various parameters at the top of the script. Options include:

  • when to start the movie ('StartTime')
  • when to end the movie ('EndTime')
  • when to zoom in ('ZoomInTime')
  • when to 'speed up' by rendering fewer timesteps ('SpeedUpTime')
  • whether to display the time, legends ('ShowTime', 'ShowLeg')

There are several other options that have been built into the script in an attempt to make it robust and versatile for many different binaries. The best way to make a good movie is to play around with these parameters. Since surface data is no where near as large as volume data, the live rendering in debugmode works quickly enough to allow this trial and error.

Making the Images

Once you have the parameters properly adjusted, you can write the images to the 'OutputLocation' to be combined into a movie.

  1. First, set debugmode = 0 at the top of the script
  2. Then to generate the images, use <code> pvbatch --use-offscreen-rendering ParaviewPythonScript.py </code>

If pvbatch throws any errors, you should try running the script using <code> pvpython --use-offscreen-rendering < ParaviewPythonScript.py </code> Be warned that running the script without the --use-offscreen-rendering option results in each rendered frame appearing onscreen for a split second.

Past experience has shown that it does not usually pay to parallelize this script; surface data is just not large enough. How long rendering the images takes depends mainly on how many timesteps there are, but usually takes around an hour.

Plotting trajectories for inspiraling binaries

Note: Please ask Harald for anything unclear here. This can be easily scripted, so if you would like to volunteer (or know a volunteer), please just script this and let Harald know (or just let Harald know).

For inspirals with many orbits and/or for precessing binaries, showing the entire past trajectory often results in quite messy images. In such cases, it is useful to only plot a constant duration part of the past trajectory. For example, if one only shows the last 200M of the trajectory, then this is about a quarter of an orbit ~50 orbits before merger, but is more than a full orbit near merger; this gives the viewer an extra indication that the orbit is speeding up.

These images were generated from Horizons.h5 and HorizonsDump.h5 as follows:

STEP=200 # this controls the frequency of the output frames.  
ConvertH5TrajectoryToVtk -s ${STEP} Horizons.h5 AhA.dir/CoordCenterInertial.dat TrajAhA
ConvertH5TrajectoryToVtk -s ${STEP} Horizons.h5 AhB.dir/CoordCenterInertial.dat TrajAhB
ConvertH5SurfaceToVtk -s ${STEP} -v HorizonsDump.h5

ConvertH5TrajectoryToVtk inserts a dataset 'age' into the VTK-output. For each frame, this gives the age relative to the current time of each point of the trajectory. The idea is now to use this 'age' dataset to set color and opacity of the trajectory:

Load TrajAhA and TrajAhB into Paraview, apply ExtractSurface to both, respectively, and set ColorBy to age. At the first time-step, the Trajectories are empty, so you may generate a Paraview error. If so, move off the first time-step.

At this point, you should see the entire previous trajectory in Paraview's default (and awful) color-scheme. To continue, set custom-range [-200, 0] on the colormap. Now open the color-map editor

Make the following changes:

  • Check Enable Opacity
  • Adjust the opacity profile to be fully opaque for the right half of the 'Mapping Data', then falling to zero on left edge.
  • Adjust colors to be either entirely uniform, or shift the color-changes to the very left (where the low opacity renders them invisible anyway)
  • S Line Width on both trajectories as desired. It has to be set based on the desired output rendering, and the exact choice requires trial and error. For output rendering at width 2000pixels, 10 and 3 are reasonable starting points, for AhA and AhB, respectively.

Finally, add black hole horizons or neutron stars as desired.

Clone this wiki locally