Package ComboCode :: Package cc :: Package modeling :: Package profilers :: Module Density :: Class Density
[hide private]
[frames] | no frames]

Class Density

source code


An interface for the density profile as a function of radius.

Instance Methods [hide private]
 
__init__(self, r, func=<function dens_mdot at 0x10ef18a28>, dfunc=None, order=3, dust=0, *args, **kwargs)
Create an instance of the Density() class.
source code
float
getMeanMolecularWeight(self)
Return the mean molecular weight for this Density profile.
source code
 
calcNumberDensity(self, fH=0.0, fHe=0.0, sd=None, a=None, gsd=None)
In case of gas, calculate the H_2, H, He and total number density profiles.
source code
array/float
eval(self, r=None, dtype='dens', warn=1)
Evaluate the density function at a coordinate point.
source code

Inherited from cc.modeling.profilers.Profiler.Profiler: __call__, diff

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, r, func=<function dens_mdot at 0x10ef18a28>, dfunc=None, order=3, dust=0, *args, **kwargs)
(Constructor)

source code 

Create an instance of the Density() class. Requires a radial grid, a function for calculating the density profile, and its arguments.

The default is the mass-loss rate density profile. Requires mdot and v to be given either as constants or Profile()s.

Parameters:
  • r (array) - The radial points (cm)
  • func (func) - The function for calculating the density profile.

    (default: dens_mdot)

  • dfunc (function/interp1d object) - The function that describes the derivative of the profile with respect to r. Can be given as an interp1d object. If None, a generic central difference is taken and interpolated.

    (default: None)

  • order (int) - Order of the spline interpolation. Only relevant if spline is requested instead of linear. Default is cubic interpolation.

    (default: 3)

  • dust (bool) - This is a dust density profile rather than a gas density

    (default: 0)

  • args (tuple) - Additional parameters passed to the functions when eval or diff are called.

    (default: [])

  • kwargs (dict) - Additional keywords passed to the functions when eval or diff are called.

    (default: {})

Overrides: object.__init__

getMeanMolecularWeight(self)

source code 

Return the mean molecular weight for this Density profile.

Requires calcNumberDensity to have been called before.

Returns: float
The mean molecular weight in units of m_H

calcNumberDensity(self, fH=0.0, fHe=0.0, sd=None, a=None, gsd=None)

source code 

In case of gas, calculate the H_2, H, He and total number density profiles. In case of dust, calculate the dust number density.

Takes into account fractional abundances of atomic hydrogen and helium, and the specific density/average grain size, respectively.

Note the specific definitions of fH and fHe. These are implemented this way to work well with the energy balance calculation and the definition of dT/dR as well as H_dg.

Parameters:
  • fH (float/array) - The fractional abundance of atomic hydrogen with respect to molecular hydrogen. fH = n(H)/n(H2). Can be a constant or a radially dependent value.

    (default: 0)

  • fHe (float/array) - The fractional abundance of helium with respect to total hydrogen number density. fHe = n(He)/(n(H)+2*n(H2)). Can be a constant or a radially dependent value.

    (default: 0)

  • sd (float) - The average specific density of the dust grains in g/cm3. Only relevant if this is a dust density profile.

    (default: None)

  • a (float) - The average grain size (cm)

    (default: None)

eval(self, r=None, dtype='dens', warn=1)

source code 

Evaluate the density function at a coordinate point.

r can be any value or array. If func is an interp1d object, it is in principle limited by the r-range of the interpolator. However, linear extrapolation is enabled, but it is advised not to extend much beyond the given r-range.

Parameters:
  • r (array/float) - The coordinate point(s). If None, the default coordinate grid is used.

    (default: None)

  • dtype (str) - The type of density requested. Default is the mass density. Alternatives: nh2, nh, nhtot, nhe, ngas.

    (default: dens)

  • warn (bool) - Warn when extrapolation occurs.

    (default: 1)

Returns: array/float
The profile evaluated at x
Overrides: cc.modeling.profilers.Profiler.Profiler.eval