diskpy.disk package

Module contents

init for diskpy.disk

Created on Thu Jul 16 15:42:44 2015

@author: ibackus

diskpy.disk.centerdisk(snapshot)[source]

Centers a disk on the center of mass puts it into rest frame

diskpy.disk.snapshot_defaults(snapshot)[source]

Applies various defaults to tipsy snapshots of protoplanetary disk simulations. These include:

-Sets nice units
-Calculates particle smoothing lengths using mass and rho
(if available)
-Centers on snapshot center-of-mass
-Puts in rest frame

Changes the snapshot in place

diskpy.disk.Q(snapshot, molecular_mass=2.0, bins=100, use_velocity=False, use_omega=True)[source]

Calculates the Toomre Q as a function of r, assuming radial temperature profile and kappa ~= omega

Parameters:

snapshot : tipsy snapshot

molecular_mass : float

Mean molecular mass (for sound speed). Default = 2.0

bins : int or array

Either the number of bins or the bin edges

use_velocity : Bool

Determines whether to use the particles’ velocities to calculate orbital velocity. Useful if the circular orbital velocities are set in the snapshot.

use_omega : Bool

Default=True. Use omega as a proxy for kappa to reduce noise

Returns:

Q : array

Toomre Q as a function of r

r_edges : array

Radial bin edges

diskpy.disk.Qeff(snapshot, molecular_mass=2.0, bins=100, use_velocity=False, use_omega=True, alpha=0.1766, beta=2.121)[source]

Estimates the effective Toomre Q as a function of r, defined as:

\[Q_{eff} = \beta Q (h/R)^{\alpha}\]

See Q and h for the estimates of Q and h.

The values for alpha and beta are from Backus & Quinn, 2016 and are appropriate for an isothermal disk.

Parameters:

snapshot : tipsy snapshot

molecular_mass : float

Mean molecular mass (for sound speed). Default = 2.0

bins : int or array

Either the number of bins or the bin edges

use_velocity : Bool

Determines whether to use the particles’ velocities to calculate orbital velocity. Useful if the circular orbital velocities are set in the snapshot.

use_omega : Bool

Default=True. Use omega as a proxy for kappa to reduce noise

alpha : float

Powerlaw for height dependence

beta : float

Normalization such that disks fragment for Qeff = 1

Returns:

Qeff : array

Effective Toomre Q as a function of r

r_edges : array

Radial bin edges

diskpy.disk.kappa(f, bins=100)[source]

Estimate the epicyclic frequency from velocity

Parameters:

f : TipsySnap

f is a Simulation snapshot

bins : int or array-like

Either the number of bins to use or the bin edges

Returns:

kappa : SimArray

epicyclic frequency

r_edges : SimArray

binedges used

diskpy.disk.height(snapshot, bins=100, center_on_star=True)[source]

Calculates the characteristic height (h) of a flared disk as a function of cylindrical radius (r).

Parameters:

snapshot : TipsySnap

Simulation snapshot for a flared disk

bins : int or array_like

Specifies the bins to use. If int, specifies the number of bins. If array_like, specifies the bin edges

center_on_star : bool

If true (DEFAULT), cylindrical r is calculated relative to the star

Returns:

r_edges : SimArray

Radial bin edges used for calculating h. Length N+1

h : SimArray

Height as a function of r, calculated as the RMS of z over a bin. Length N

diskpy.disk.sigma(snapshot, bins=100, cmFlag=True)[source]

Calculates surface density vs r (relative to the center of mass)

Parameters:

snapshot : tipsy snapshot

bins : int, list, array…

(optional) Either the number of bins to use or the binedges to use

cmFlag : bool

(optional) Calculate relative to the center of mass

Returns:

sigma : SimArray

Surface density as a function of r

r_bins : SimArray

Radial bin edges

diskpy.disk.rho0_est(h, sigma)[source]

Estimates the midplane density vs r as

\[\rho(z=0) = \frac{\Sigma}{h \sqrt{2 \pi}}\]
Parameters:

h, sigma : array(s)/SimArrays (same shape)

Disk height and surface density (estimated)

diskpy.disk.h_est(r, M, m, T, gamma=1)[source]

Estimates disk height \(h=c_{s}/\Omega\)

Parameters:

r : SimArray, array, float

Disk radii to calculate h at

M : SimArray, float

Central star mass

m : SimArray, float

Mean molecular mass (with units of mass)

T : SimArray, array, float

Temperature as a function of r

gamma : float

(optional) Adiabatic index to be used. If temperature is not a functino of z, gamma should equal 1 (isothermal)

Returns:

h : SimArray, float, array

Disk height vs. r (1st order estimate)

diskpy.disk.powerspectrum(f, mMax=30, rbins=50, paramname=None)[source]

The density power spectrum along the angular direction, summed along the radial direction.

Parameters:

f : SimSnap or str

Snapshot of a disk OR filename for snapshot

mMax : int

Maximum fourier mode to calculate

rbins : int or array

Number of radial bins or the binedges to use

Returns:

m : array

Array of the fourier modes from 0 to mMax (integers)

power : array

Power in the fourier modes, summed along radial direction. Power is take to be the square of the surface density fourier transform

diskpy.disk.powerspectrum_t(flist, mMax=30, rbins=50, paramname=None, parallel=True, spacing=’linear’)[source]

Calculates the power spectrum along the angular direction for a whole simulation (see powerspectrum).

Loops through snapshots in a simulation, in parallel. Uses the same radial and angular bins for every timestep

Parameters:

flist : list

A list of filenames OR of SimSnaps for a simulation

mMax : int

Maximum fourier mode to calculate

rbins : int or array

Number of radial bins or the binedges to use

paramname : str

Filename of .param file. Used for loading if flist is a list of filenames

parallel : bool

Flag to perform this in parallel or not

spacing : str

If rbins is an int, this defines whether to use ‘log’ or ‘linear’ binspacing

Returns:

m : array

Number of the fourier modes

power : SimArray

Power spectrum vs time along the angular direction

diskpy.disk.sigmafft(f, rbins=50, thetabins=50)[source]

Calculates the fourier transform of the surface density along the angular direction. Works by binning sigma in r, theta (using sigmacylindrical) and doing a fourier transform along the theta axis.

Parameters:

f : SimSnap

Simulation snapshot of a disk

rbins, thetabins : int or array like

Number of bins or binedges to use

Returns:

rmesh : SimArray

2D Meshgrid of radial binedges

mmesh : Array

2D meshgrid of m binedges, where m is an integer (the mth fourier mode)

sigfft : SimArray

2D meshgrid of surface density fourier transformed along the angular direction.

Notes

The returned arrays are indexed such that array[i,j] gives the value of array at radial bin i and theta bin j.

diskpy.disk.sigmacylindrical(f, rbins=50, thetabins=50)[source]

Estimates the surface density, binned in cylindrical coordinates

Parameters:

f : SimSnap (see pynbody)

Snapshot of a disk

rbins, thetabins : int or arraylike

Number of bins or binedges. Theta is calculated between 0 and 2 pi

Returns:

rmesh : SimArray

2D Meshgrid of radial binedges

thetamesh : Array

2D meshgrid of angle binedges

sigma : SimArray

2D meshgrid of surface density.

Notes

The returned arrays are indexed such that array[i,j] gives the value of array at radial bin i and theta bin j.

diskpy.disk.spiralpower(f, rbins=50, thetabins=50)[source]

Estimates the spiral power (non-axisymmetric power) as a function of radius Power is calculated as the standard deviation of the surface density along the angular direction.

Parameters:

f : SimSnap

Simulation snapshot

rbins, thetabins : int or arraylike

Number of bins OR the bins

Returns:

power : SimArray

Non-axisymmetric power as a function of r

r : SimArray

Radial binedges used

diskpy.disk.spiralpower_t(flist, rbins=100, thetabins=100, binspacing=’log’, rlim=None, paramname=None, center=True)[source]

Estimates the spiral power as a function of r and t for a whole simulation. Calculated using spiralpower

Parameters:

flist : list

List of SimSnaps or a filelist

rbins, thetabins : int or arraylike

Number of bins OR bins to use

binspacing : str

‘log’ or ‘linear’. Spacing of radial bins to use

rlim : list or array

If rbins is an int, sets the min and max to consider

paramname : str

Optional filename of the param file, used for pynbody.load

center : bool

Shift snapshot center of mass to origin and place it in rest frame

Returns:

power : SimArray

power as a function of t and r. power[i] gives power vs r at time i

t : SimArray

Time of each snapshot in years

redges : SimArray

Radial binedges used

diskpy.disk.pSpiralpower_t(simdirs, fprefix, rbins=100, thetabins=100, binspacing=’log’, rlim=None, paramnames=None, center=True)[source]

Parallel implementation of spiralpower_t for looping over simulation diretories. Assumes simulation outputs are standard ChaNGa format. Only simdirs and paramnames can change from simulation to simulation. See spiralpower_t for other parameters

Parameters:

simdirs : list or arraylike

list of simulation directories (strings)

fprefix : str or list

prefix or prefixes of simulation snapshots (see pychanga.get_fnames)

**kwargs

See spiralpower_t for other parameters

Returns:

output : dict

Output for every simulation (see spiralpower_t)

diskpy.disk.setDustfrac(f, dustFrac=0.01, scale_mass=False)[source]

Set the dust fraction to a SimSnap or sub-snap, and optionally scale the mass to keep the original mass (e.g. star mass or gas mass) constant.

Parameters:

f : SimSnap

Snapshot or sub-snap

dustFrac : number or array-like

Dust fraction to apply

scale_mass : bool

If true, the mass will be scaled to keep the non-dust mass constant.

diskpy.disk.add_dust_sim(f, param, gasDustFrac=0.01, starDustFrac=0.0, scaleGasMass=True, scaleStarMass=True, grainSize=‘1 mm’, grainDensity=‘3 g cm**-3’)[source]

Add a single size of dust to a simulation. Changes are applied in-place to the snapshot and the param dict.

Parameters:

f : SimSnap

Simulation snapshot

param : dict

Param dictionary (see diskpy.utils.configparser).

gasDustFrac, starDustFrac : number or array-like

Sets the gas fraction for the gas, star. If None, no dust fraction is set.

scaleGasMass, scaleStarMass : bool

Scale the gas, star mass to keep it constant after adding dust. For example, this can be useful to keep the gas pressure constant.

grainSize : number, SimArray, str

The grain size (i.e. radius). Assumed units (if none are supplied) are ‘mm’

grainDensity : number, SimArray, str

Intrinsic grain density (e.g. for silica). Assumed units if non are supplied are g/cm^3