DensityGradient
This class represents an exponential density gradient, for example, for modelling the density of the atmosphere. The density varies continuously with location \(\vec{r}\) as
where \(\rho_0\), \(\vec{r}_0\), \(\vec{n}\) and \(\lambda\) are configurable model parameters (see the constructor below).
Constructor
- class DensityGradient(density, scale, direction=None, origin=None)
Creates a density gradient along a given direction (\(\vec{n}\)). The density argument (\(\rho_0\), in \(\text{g}/\text{cm}^3\)) specifies the density value at the origin (\(\vec{r}_0\), in \(\text{cm}\)). The scale argument (\(\lambda\), in \(\text{cm}\)) controls the density variation, as detailed above. The optional direction and origin arguments should be 3d-cartesian coordinates (e.g. a
tuple), refering to the simulation frame. If no direction is provided, then(0,0,-1)is assumed. By default, the gradient origin is at(0,0,0).
Attributes
- DensityGradient.density: float
The density value (\(\rho_0\)) at the gradient
origin, in \(\text{g}/\text{cm}^3\).
- DensityGradient.direction: numpy.ndarray
The direction (\(\vec{n}\)) of the density gradient, in Cartesian coordinates.
- DensityGradient.origin: numpy.ndarray
The origin (\(\vec{r}_0\)) of the density gradient model, in Cartesian coordinates (in \(\text{cm}\)).
Methods
- DensityGradient.__call__(position)
Returns the density value(s) at the requested position(s). The position argument can be a length 3 sequence or a shape \([\cdots, 3]\)
numpy.ndarray.