Welcome to Python3 PLUTO’s documentation!

This package was written as part of the authors Master’s thesis project, focusing on data analysis of the HDF5 files that are exported during simulation from PLUTO (http://plutocode.ph.unito.it/code-overview.html)

The code was written as part of the author’s (M.I.Czentye) MPhys researh project to extend the methods used to analyse .h5 file output from PLUTO.

Current capability of the code is to analyse 2.5D and 3D datasets produced by solving the ideal MHD equations. The code consist of a Superclass and a subclass, that is focusing on the MHD attributes that the jets can have. Furthermore, current MHD properties are based on Ideal equation of state and ideal MHD interpritation of the problem thus working only within the boundaries of the ideal case, to be further expanded later on into more complex scenarios.

Background

The package was designed and initial versions developped during the author’s MPhys research project, to analyse and visualise the output of PLUTO h5 output files.

Modules

pluto.py

This module contains the super class for the package:
  • all data is stored here

  • all subsidary data is calculated here

class pluto_python.pluto.py3Pluto(data_path: str, time_step: int = 0, dpi: int = 300, image_size: tuple = (10, 5), ylim: Optional[tuple] = None, xlim: Optional[tuple] = None, cmap: str = 'bwr', global_limits: bool = False, mirrored: bool = False, gamma: float = 1.6666666666666667, cooling: bool = False, x2_slice_index=0)

This class makes an object from reading in the file at the selected timestep with all its simulated and calculated subsidary data ready formated for plotting using the subclasses like mhd_jet.

_flip_multiply(array, sign_change=False)

This method makes a single quadrant mirrored along the axial direction

_get_limits(log=False)

This method runs through all available data to set the colour limits up for each variable globally, across all time steps.

_read_data_out()

Reads in the h5.out file to determin number of variables

_read_ini()

Method reads in data from the .ini file currently works for cylindrical polar coords

_reader()
calculate_data(time)

This method is to calculate all subsidary data sets from the simulation data. sets global variables that are accessible by sub classes to use

classifier(delta_time)

delta_time: is the time step of which is number of the file by pluto

set_levels(variable)

This sets the global limits for the colourbars

mhd_jet.py

The module contains the subclass of the package that deals with all the magnetohydrodynamic visualisation. It selects the variable to use for each visualisation method when they are called.

class pluto_python.mhd_jet.mhd_jet(data_path: str, time_step: int = 0, dpi: int = 300, image_size: Tuple[int, int] = (10, 5), ylim: Optional[float] = None, xlim: Optional[float] = None, cmap: str = 'bwr', global_limits: bool = False, mirrored: bool = False, gamma: float = 1.6666666666666667, title: str = '')

This is a sub-class of py3Pluto, designed to visualise all MHD specific data sets calculated in the superclass.

data_path: str - path to .h5 files output by PLUTO time_step: int - the number which is in the name of the file representing time-step

Defaults to 0

dpi: int - sets the matplotlib.pyplot artist’s DPI parameter

Defaults to 300,

image_size: Tuple[int, int] - sets the matplotlib.pyplot artist’s figsize argument

Defaults to (10,5),

ylim: float - sets the x-axis limit using matplotlib.pyplot xlim method

Default to None,

xlim: float - sets the y-axis limit using matplotlib.pyplot ylim method

Default to None,

cmap: str - colourmap used by matplotlib, takes a string and will give error if incorrect.

Default to ‘bwr’,

global_limits: bool - if set True, all data file in directory will be looped through, and all the maximum and minimum values of all calculated variables are selected.

Default to False,

mirrored:bool = False, gamma: float = 5/3, title: str = ‘’

_data(data2plot=None, log=False, close=False, save=False)

Method plots individual data sets that are given as an argument.

hist(data2plot=None, data2log=False, close=False, save=False, bins=None, log=False)

Method to plot histogram of the data which is passed in as the argument

Arguments:
data2plot: string variable matching the available data in the data_dict class attribute

default is None

data2log: Boolean if y-axis should be log or not

default is False

close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

bins: Set the number of bins - same as matplotlib histogram method bins argument

default is None

log: Boolean if values should be log or not

default is False

oblique_shocks(min=0, max=10000)

Use the Ranking-Hugoniot relation for ideal MHD to find oblique shocks

Arguments:

min: minimum value of the Mach number max: maximum value of the Mach number

plot(data2plot=None, log=False, close=False, save=False, title='')

This method plots the simulated data sets output by PLUTO, contained within the h5 file while additionally also plots the wave velocities, machnumbers and other calculated values. Focuses on spatial distributon of the data.

Arguments:
data2plot: string variable matching the available data in the data_dict class attribute

default is None

log: Boolean if values should be log or not

default is False

close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

title: This will place additional string into the file name when saving

default is ‘’

plot_azimuthal_energy()

Plots the Kinetic and Magnetic energies as a function of axial distance to compare for stability analysis

plot_energy(save=False, close=False)

Plots the energy curves for the jet

Arguments:
close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

plot_energy_density(save=False, close=False)

Plots the energy density curves for the jet

Arguments:
close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

plot_fieldlines(save=False, close=False, levels=128, min_bxs=None, max_bxs=None, min_bx2=None, max_bx2=None)

Plots a vector plot of the magnetic field lines in the axial-radial plane, while plots the true magnitude of the magnetic field accounted in all 3 directions.

Arguments:
save: Argument if the plot should be saved or not

default is False

close: will not plot the graph

default is False

levels: the resolution of the contour plot (as per matplotlib.pyplot.contour method) min_bxs: minimum value of magnetic field magnitude max_bxs: maximum value of magnetic field magnitude min_bx2: minimum value of magnetic field in x2 direction max_bx2: maximum value of magnetic field in x2 direction

plot_power(save=False, close=False)

Plots the power curves for the jet

Arguments:
close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

plot_spacetime(data2plot=None, begin=0, end=-1, radial_step=0, log=False, close=False, save=False)

Space-time diagram plotting method

Arguments:
data2plot: string variable matching the available data in the data_dict class attribute

default is None

begin: the first time step as indicated in the PLUTO output file

defaults is 0

end: last time step to be loaded in as indicated in the PLUTO output file

defaults is -1

radial_step: choses the radial step in stencil index to plot

default is 0 for axial symmetry axis

log: Boolean if values should be log or not

default is False

close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

shocks(plot_shock='12, 13, 14, 23, 24, 34', save=False, close=False)

method to plot MHD shocks

Arguments:

plot_shocks: string that refers to the shock category i.e.: 12, 34, slow, inter close: will not plot the graph

default is False

save: Argument if the plot should be saved or not

default is False

caculator.py

Contains physics relevant functions that are called in one or more of the classes within the package.

  • Module specific functions get defined here like magnetic pressure, or plasma beta

  • Current version contains all used physics equations, may break it into classes to categorise them later.

pluto_python.calculator.RH_MHD(gamma, beta, mach, prs1, prs2)

This calculates the Ranking-Huginoit relation (both values of the quadratic) as a function of Mach number squared

pluto_python.calculator.alfven_velocity(B, density)

Returns the alvén wave velocity from the magnetic field and the density in each stencil.

pluto_python.calculator.effective_kappa(therma_prs, magnetic_prs, ambient_prs)

Calculates an effective over pressure, due to the thermal, magnetic and ambient contributions.

pluto_python.calculator.energy_density(pressure, density, velocity, gamma, magnetic_field=None)

Calculates the Energy density of each stencil and returns a list of thermal/potential, kinetic and magnetic energy density respectively [pot, kin, mag].

pluto_python.calculator.mach_number(fluid_velocity, wave_velocity)

Returns the wave specific Mach number, in each stencil

pluto_python.calculator.magnetic_field(sigma_z, sigma_phi, kappa=2)

Calculates the magnetic field strength from the magnetisation of the jet, as defined in the init.c in the PLUTO directory and used to compile the simulator with the right physics relations.

pluto_python.calculator.magnetic_pressure(mag_field)

Calculates magnetic pressure from ideal conditions given the magnetic field strength.

pluto_python.calculator.magneto_acoustic_velocity(b, prs, rho, gamma)

Magneto aucustoc velocity from computational stencil values of pressure, density, adiabatic constant and magnetic fields.

pluto_python.calculator.magnetosonic_speed(eta, kappa, b)

Returns the magneto-sonic speed from the environmental variables like jet overpressure, and density ratio

pluto_python.calculator.sound_speed(gamma, prs, rho)

Returns the sound speed of each stencil from pressure, density and adiabatic constant

tools.py

pluto_python.tools.rearrange_axial_grid(initial_list, reference_list)

Indices and tables

Table Of Contents