pencil.ism_dyn
Diagnostics for interstellar-medium dynamo simulations.
Submodules
Attributes
Classes
SedovTaylor -- holds blast wave parameters and radial profiles. |
Functions
|
|
|
compute from src data and existing dst data derived data |
|
Check if the variable denoted by the label key is a vector. |
|
|
|
|
|
|
|
This function opens hdf5 file in serial or parallel. |
|
This function adds/removes hdf5 group objects. |
|
This function adds/removes hdf5 dataset objects. |
|
call signature: |
|
|
|
dot(a, b) |
|
dot2(a) |
|
natural_sort(string_list, reverse=False) |
|
helmholz_fft(field, grid, params) |
|
|
|
curl(f, dx=None, dy=None, dz=None, x=None, y=None, run2D=False, coordinate_system="cartesian", grid=None) |
|
div(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None) |
|
curl2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None) |
|
grad(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None) |
|
Computes the fluid Reynolds number from the advective and effective |
|
Computes the magnetic Reynolds number from the advective and effective |
|
This function opens hdf5 file in serial or parallel. |
|
This function adds/removes hdf5 group objects. |
|
This function adds/removes hdf5 dataset objects. |
|
|
|
xvar: array 1D.ravel() format of variable |
|
Compute analytic radial time evolution of SN blast waves for |
Package Contents
- pencil.ism_dyn.derive_data(sim_path, src, dst, magic=['pp', 'tt'], par=[], comm=None, gd=[], grp_overwrite=False, overwrite=False, rank=0, size=1, nghost=3, status='a', chunksize=1000.0, dtype=np.float64, quiet=True, nmin=32, Reynolds_shock=False, lmix=False)
- pencil.ism_dyn.calc_derived_data(src, dst, key, par, gd, l1=3, l2=-3, m1=3, m2=-3, n1=3, n2=-3, nghost=3, Reynolds_shock=False, lmix=False)
compute from src data and existing dst data derived data
- pencil.ism_dyn.is_vector(key)
Check if the variable denoted by the label key is a vector.
- pencil.ism_dyn.der_limits(n1, n2, m1, m2, l1, l2, nghost)
- pencil.ism_dyn.under_limits(n1, m1, l1, n1shift, m1shift, l1shift, nghost)
- pencil.ism_dyn.cpu_optimal(nx, ny, nz, mvar=8, maux=0, par=dict(), nmin=32, MBmin=5.0, minghosts=7, quiet=True, size=1, remesh=False, nsize=None)
- pencil.ism_dyn.open_h5(filename, status, driver=None, comm=None, overwrite=False, size=1, rank=0, lfs=False, MB=1, count=1)
This function opens hdf5 file in serial or parallel.
- Keyword Arguments:
filename – relative or absolute path string for name of hdf5 file.
status – open state of file ‘w’: write, ‘r’: read or ‘a’/’r+’: append.
driver – ‘mpio’ required for parallel: version but absent for serial.
comm – only present for parallel version of h5py.
overwrite – flag to replace existing file.
rank – processor rank with root = 0.
- pencil.ism_dyn.group_h5(h5obj, groupname, status='r', delete=False, overwrite=False, rank=0, size=1, comm=None)
This function adds/removes hdf5 group objects.
- Keyword Arguments:
h5obj – h5 object, may be the file or a sub group within the file
groupname – string for name of the group.
status – open state of file ‘w’: write, ‘r’: read or ‘a’/’r+’: append.
delete – flag to remove existing group from h5 object.
overwrite – flag to replace existing group from h5 object.
rank – processor rank with root = 0.
comm – only present for parallel version of h5py.
- pencil.ism_dyn.dataset_h5(h5obj, dataname, status='r', data=None, shape=None, dtype=None, overwrite=False, delete=False, rank=0, size=1, comm=None)
This function adds/removes hdf5 dataset objects.
- Keyword Arguments:
h5obj – h5 object, may be the file or a sub group within the file
dataname – string for name of the dataset.
status – open state of file ‘w’: write, ‘r’: read or ‘a’/’r+’: append.
data – h5 compatible data object; float, integer, string, array
shape – data shape tuple of length > 0
dtype – h5 compatible data type, eg. np.float64
delete – flag to remove existing group from h5 object.
overwrite – flag to replace existing group from h5 object.
rank – processor rank with root = 0.
comm – only present for parallel version of h5py.
- pencil.ism_dyn.thermal_decomposition(ss, pars, unit_key='unit_entropy', ent_cut=[2320000000.0])
call signature:
thermal_decomposition(ss, pars, unit=’unit_entropy’, ent_cut=[2.32e9,])
- Keyword Arguments:
ss – dataset used for masks, default ‘ss’, alternate e.g.’tt’
pars – Param() object required for units rescaling
unit_key – label of physical units in pars to apply to code values
ent_cut – list of boundary mask values, default see thesis http://hdl.handle.net/10443/1755 Figure 5.10 may have multiple boundaries
- pencil.ism_dyn.derive_masks(sim_path, src, dst, data_key='data/ss', par=[], comm=None, overwrite=False, rank=0, size=1, nghost=3, status='a', chunksize=1000.0, quiet=True, nmin=32, ent_cuts=[2320000000.0], mask_keys=['hot'], unit_key='unit_entropy')
- pencil.ism_dyn.dot(a, b)
dot(a, b)
Take dot product of two pencil-code vectors a and b.
- Parameters:
a (ndarrays) – Pencil-code vectors with shape [3, mz, my, mx].
b (ndarrays) – Pencil-code vectors with shape [3, mz, my, mx].
- pencil.ism_dyn.dot2(a)
dot2(a)
Take dot product of a pencil-code vector with itself.
- Parameters:
a (ndarray) – Pencil-code vector with shape [3, mz, my, mx].
- pencil.ism_dyn.natural_sort(string_list, reverse=False)
natural_sort(string_list, reverse=False)
Sort a list of float numbers in strings in a natural way.
- pencil.ism_dyn.helmholtz_fft(tot_field, grid, params, nghost=3, pot=True, rot=True, lno_mean=False, nonperi_bc=None, field_scalar=[], s=None, quiet=True)
helmholz_fft(field, grid, params)
Creates the decomposition vector pair for the supplied vector field.
- Parameters:
tot_field (ndarray) – Vector field of dimension [3, mz, my, mx], which is decomposed.
grid (obj) – Grid object with grid spacing dx, dy, dz.
params (obj) – Simulation Params object with domain dimensions Lx, Ly and Lz.
nghost (int) – Number of ghost zones to exclude from the fft.
lno_mean (float) – Exclude any mean flow from the decomposition - should drop anyway.
nonperi_bc (string) – String if not None with boundary condition label. How to apply the bc needs to be implemented as required.
field_scalar (ndarray) – Scalar field (density) as debug tool for energy comparison.
s (list of int) – List of three integers if not None for fft dimension. If none the dimension of the field [nz,ny,nx] is used.
- Return type:
ndarray with decomposed field.
- pencil.ism_dyn.cpu_optimal(nx, ny, nz, mvar=8, maux=0, par=dict(), nmin=32, MBmin=5.0, minghosts=7, quiet=True, size=1, remesh=False, nsize=None)
- pencil.ism_dyn.curl(f, dx=None, dy=None, dz=None, x=None, y=None, run2D=False, coordinate_system='cartesian', grid=None)
curl(f, dx=None, dy=None, dz=None, x=None, y=None, run2D=False, coordinate_system=”cartesian”, grid=None)
Take the curl of a pencil code vector array f in various coordinate systems.
- Parameters:
f (ndarray) – Pencil code scalar array f.
grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().
run2D (bool) – Deals with pure 2-D snapshots. !Only for Cartesian grids at the moment! Requires grid!=None.
coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’. !Does not work for 2d runs yet!
compatibility) (Deprecated parameters (only for backwards)
--------------------------------------------------------
dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
- pencil.ism_dyn.div(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)
div(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)
Take divergence of pencil code vector array f in various coordinate systems.
- Parameters:
f (ndarray) – Pencil code vector array f.
grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().
coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.
compatibility) (Deprecated parameters (only for backwards)
--------------------------------------------------------
dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
- pencil.ism_dyn.curl2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)
curl2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)
Take the double curl of a pencil code vector array f.
- Parameters:
f (ndarray) – Pencil code vector array f.
grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().
coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.
compatibility) (Deprecated parameters (only for backwards)
--------------------------------------------------------
dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
- pencil.ism_dyn.grad(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)
grad(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)
Take the gradient of a pencil code scalar array f in various coordinate systems.
- Parameters:
f (ndarray) – Pencil code scalar array f.
grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().
coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.
compatibility) (Deprecated parameters (only for backwards)
--------------------------------------------------------
dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None
x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None
- pencil.ism_dyn.fluid_reynolds(uu, param, grid, lnrho=list(), shock=list(), nghost=3, lmix=True, quiet=True)
Computes the fluid Reynolds number from the advective and effective viscous expressions in the momentum equation.
call signature:
fluid_reynolds(uu, ivisc, grid, rho=None, shock=None, nghost=3)
- Keyword Arguments:
*uu* – The velocity field [3,mz,my,mx] from the simulation data
*param* – The Param simulation object with viscosity data information
*grid* – The Grid simulation object
*lnrho* – The log density field if it is non-uniform
*shock* – The shock variable if shock viscosity is applied
*nghost* – The number of ghost zones appropriate to the order of accuracy
*lmix* – Option not to include hyper values when Laplacian values present
- pencil.ism_dyn.magnetic_reynolds(uu, param, grid, aa=list(), bb=list(), jj=list(), nghost=3, lmix=True, quiet=True)
Computes the magnetic Reynolds number from the advective and effective resistive expressions in the induction equation.
call signature:
magnetic_reynolds(uu, param, grid, aa=None, bb=None, jj=None, nghost=3):
- Keyword Arguments:
*uu* – The velocity field [3,mz,my,mx] from the simulation data
*param* – The Param simulation object with resistivity data information
*grid* – The Grid simulation object
*aa* – The vector potential if bb is not present or hyper diffusion
*bb* – The magnetic field
*jj* – The current density field
*nghost* – The number of ghost zones appropriate to the order of accuracy
*lmix* – Option not to include hyper values when Laplacian values present
- pencil.ism_dyn.open_h5(filename, status, driver=None, comm=None, overwrite=False, size=1, rank=0, lfs=False, MB=1, count=1)
This function opens hdf5 file in serial or parallel.
- Keyword Arguments:
filename – relative or absolute path string for name of hdf5 file.
status – open state of file ‘w’: write, ‘r’: read or ‘a’/’r+’: append.
driver – ‘mpio’ required for parallel: version but absent for serial.
comm – only present for parallel version of h5py.
overwrite – flag to replace existing file.
rank – processor rank with root = 0.
- pencil.ism_dyn.group_h5(h5obj, groupname, status='r', delete=False, overwrite=False, rank=0, size=1, comm=None)
This function adds/removes hdf5 group objects.
- Keyword Arguments:
h5obj – h5 object, may be the file or a sub group within the file
groupname – string for name of the group.
status – open state of file ‘w’: write, ‘r’: read or ‘a’/’r+’: append.
delete – flag to remove existing group from h5 object.
overwrite – flag to replace existing group from h5 object.
rank – processor rank with root = 0.
comm – only present for parallel version of h5py.
- pencil.ism_dyn.dataset_h5(h5obj, dataname, status='r', data=None, shape=None, dtype=None, overwrite=False, delete=False, rank=0, size=1, comm=None)
This function adds/removes hdf5 dataset objects.
- Keyword Arguments:
h5obj – h5 object, may be the file or a sub group within the file
dataname – string for name of the dataset.
status – open state of file ‘w’: write, ‘r’: read or ‘a’/’r+’: append.
data – h5 compatible data object; float, integer, string, array
shape – data shape tuple of length > 0
dtype – h5 compatible data type, eg. np.float64
delete – flag to remove existing group from h5 object.
overwrite – flag to replace existing group from h5 object.
rank – processor rank with root = 0.
comm – only present for parallel version of h5py.
- pencil.ism_dyn.derive_stats(sim_path, src, dst, stat_keys=['Rm', 'uu', 'Ms'], par=[], comm=None, overwrite=False, rank=0, size=1, nghost=3, status='a', chunksize=1000.0, quiet=True, nmin=32, lmask=False, mask_key='hot')
- pencil.ism_dyn.plot_hist2d(xvar, yvar, par=[], xlim=None, ylim=None, xbins=100, ybins=100, figsize=[3.5 * 1.61803, 3.5], xlabel='$x$', ylabel='$y$', clabel='${\\cal P}\\,(\\log\\,x,\\log\\,y)$', norm=None, cmap=None, density=True, pad=0.02, fontsize=14)
xvar: array 1D.ravel() format of variable yvar: array length and format matching xvar of complementary variable par: Param object containing simulation parameters xlim: tuple with min & max bin values for xvar ylim: tuple with min & max bin values for yvar xbins: number of bins for xvar histogram ybins: number of bins for yvar histogram figsize: list of length 2 floats with width and height of figure ylabel: plot y-axis label string xlabel: plot x-axis label string clabel: plot colorbar label string norm: color table normalization from colors cmap: color table density: normalize histogram integral to 1 for PDF fontsize: size of plot fonts
- pencil.ism_dyn.wsw_cooling
- pencil.ism_dyn.sedov_taylor(*args, **kwargs)
Compute analytic radial time evolution of SN blast waves for comparison with numerical results
- t_sedov:
Time_series object read from the simulation sn_series.dat
- par:
Param object containing the simulation parameters
- time:
list of time in code units
- nt:
Integer size of analytic arrays
- endt
Real end time in code units for the time series
- dims:
Dimension of the simulation default 3D
- rho0:
Ambient ISM density
- class pencil.ism_dyn.SedovTaylor
Bases:
objectSedovTaylor – holds blast wave parameters and radial profiles.
Fill members with default values.
- t = []
- keys = []
- get_st(t_sedov=None, par=list(), time=list(), nt=5000, startt=0.0, endt=0.005, dims=3, quiet=True, rho0=None, M0=10, lsnowplough=True, lcioffi=True)
Compute analytic radial time evolution of SN blast waves for comparison with numerical results
- t_sedov:
Time_series object read from the simulation sn_series.dat
- par:
Param object containing the simulation parameters
- time:
list of time in code units
- nt:
Integer size of analytic arrays
- endt
Real end time in code units for the time series
- dims:
Dimension of the simulation default 3D
- rho0:
Ambient ISM density
- *lsnowplough:
Include original snowplough profile
- *lcioffi:
Include Cioffi et al profile