1. Loading file and basic information


In [ ]:
import yt

In [ ]:
ds = yt.load('/home/ychen/d9/2018_production_runs/20180802_L438_rc10_beta07/data/Group_L438_hdf5_plt_cnt_0100')

In [ ]:
print(ds.parameters['run_comment'])

In [ ]:
ds.print_stats()

List all fields in this plot file


In [ ]:
ds.field_list

List all derived fields in the plot file


In [ ]:
ds.derived_field_list

What is the size of the domain?


In [ ]:
print(ds.domain_width)

In [ ]:
# in different units
print(ds.domain_width.in_units('Mpc'))
print(ds.domain_width.in_units('ly'))
print(ds.domain_width.in_units('cm'))

Where is the center of the domain?

This is the coordinate of the central point


In [ ]:
print(ds.domain_center)

Excersice

  • What is the coordinate of the left edge of the domain? (hint: use tab to auto-complete and list possible options)

In [ ]:

2. Let's do some visualizations

Slice through the center of the simulation box and show the density


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='density')
slc.show()

The box is probably too big. We should zoom in to the center.


In [ ]:
slc.zoom(32)
slc.show()

That's much better. We can see a bubble is being drilled by the jets.

We can also slice through a different axis.


In [ ]:
slc = yt.SlicePlot(ds, normal='z', fields='density')
slc.zoom(32)
slc.show()

We can also slice at a different location.


In [ ]:
slc = yt.SlicePlot(ds, normal='z', fields='density', center=([0,0,10], 'kpc'))
slc.zoom(32)
slc.show()

Excersice

  • What do the slices of temperature and pressure look like?

In [ ]:


In [ ]:


In [ ]:


In [ ]:

How to visualize the velocity (which is a vector)

(Refer to ds.derived_field_list for all available properties)

We can show the magnitude of the velocity


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='velocity_magnitude')
slc.zoom(32)
slc.show()

Or just one component of the velocity

(velocity_z in this example)


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='velocity_z')
slc.zoom(32)
slc.show()

Maybe we can change the color map for a better representation of the positive and negative values

See yt colormap or matplotlib colormap reference for all available colormpas.


In [ ]:
slc.set_cmap('velocity_z', 'seismic')
slc.show()

We see positive velocity_z (going toward right in this case) in red and negative (going toward left) in blue

We can put some arrow to indicate the direction of the flow


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='velocity_z')
slc.zoom(32)
slc.set_cmap('velocity_z', 'seismic')
slc.annotate_velocity()
slc.show()

The velocity in the jet is too large compared to other region. Let's focus at some other region away from the center.


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='velocity_z', center=([0,0,10], 'kpc'), width=(10, 'kpc'))
slc.set_cmap('velocity_z', 'seismic')
slc.annotate_velocity()
slc.show()

We need to specify the range of the velocity so that the 0 velocity will be in the middle. (The velocity of the jet is 0.2c = 0.2*3E10 cm = 6E9 cm.)


In [ ]:
slc.set_zlim('velocity_z', -6E9, 6E9)

3. Inspect Grid Structure

We can show the grid boundary in a slice plot


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='density', width=(40, 'kpc'))

slc.annotate_grids()
slc.show()

In this simulation, each box (which is called grid) represents 8x8x8 cells that are the most basic resolution elements.

We can zoom in to see the cells inside a grid.


In [ ]:
slc = yt.SlicePlot(ds, normal='y', fields='density', width=(1, 'kpc'), center=([0,0,10], 'kpc'))
slc.annotate_grids()
slc.show()

Exercises

  • What is the structure of the magnetic fields in the jets?

In [ ]:

  • Make a cross-section (normal='z') visualization of the magnetic fields and annotate the directions of the fields using arrows.

In [ ]: