The SKIRT project
advanced radiative transfer for astrophysics
GridWavelengthDistribution Class Referenceabstract

#include <GridWavelengthDistribution.hpp>

Inheritance diagram for GridWavelengthDistribution:

Public Member Functions

double generateWavelength () const override
double probability (double wavelength) const override
DisjointWavelengthGridwavelengthGrid () const
Public Member Functions inherited from SimulationItem
template<class T>
T * find (bool setup=true) const
template<class T>
T * interface (int upLevels, int downLevels, bool setup) const
virtual string itemName () const
void setup ()
string typeAndName () const
Public Member Functions inherited from Item
 Item (const Item &)=delete
virtual ~Item ()
void addChild (Item *child)
const vector< Item * > & children () const
virtual void clearItemListProperty (const PropertyDef *property)
void destroyChild (Item *child)
virtual bool getBoolProperty (const PropertyDef *property) const
virtual vector< double > getDoubleListProperty (const PropertyDef *property) const
virtual double getDoubleProperty (const PropertyDef *property) const
virtual string getEnumProperty (const PropertyDef *property) const
virtual int getIntProperty (const PropertyDef *property) const
virtual vector< Item * > getItemListProperty (const PropertyDef *property) const
virtual ItemgetItemProperty (const PropertyDef *property) const
virtual string getStringProperty (const PropertyDef *property) const
int getUtilityProperty (string name) const
virtual void insertIntoItemListProperty (const PropertyDef *property, int index, Item *item)
Itemoperator= (const Item &)=delete
Itemparent () const
virtual void removeFromItemListProperty (const PropertyDef *property, int index)
virtual void setBoolProperty (const PropertyDef *property, bool value)
virtual void setDoubleListProperty (const PropertyDef *property, vector< double > value)
virtual void setDoubleProperty (const PropertyDef *property, double value)
virtual void setEnumProperty (const PropertyDef *property, string value)
virtual void setIntProperty (const PropertyDef *property, int value)
virtual void setItemProperty (const PropertyDef *property, Item *item)
virtual void setStringProperty (const PropertyDef *property, string value)
void setUtilityProperty (string name, int value)
virtual string type () const

Protected Member Functions

 GridWavelengthDistribution ()
void setupSelfAfter () override
virtual double wavelengthInBin (int ell) const =0
Protected Member Functions inherited from WavelengthDistribution
 WavelengthDistribution ()
Randomrandom () const
void setupSelfBefore () override
Protected Member Functions inherited from SimulationItem
 SimulationItem ()
virtual bool offersInterface (const std::type_info &interfaceTypeInfo) const
Protected Member Functions inherited from Item
 Item ()

Private Types

using BaseType
using ItemType

Private Attributes

int _beginWavelengthIndex
int _endWavelengthIndex
int _numWavelengths
DisjointWavelengthGrid_wavelengthGrid

Friends

class ItemRegistry

Detailed Description

GridWavelengthDistribution is an abstract class for representing wavelength probability distributions derived from a wavelength grid that can be configured by the user. The distribution uses only the bins of the configured grid for which the characteristic wavelength falls inside the wavelength range of the associated source (obtained through the SourceWavelengthRangeInterface), and those bins are selected with equal probability. If none of the characteristic wavelengths fall inside the source range, a fatal error is issued.

Each subclass determines how an actual wavelength is drawn from within a selected bin (see the wavelengthInBin() function); this abstract class handles everything else, including a probability() function that treats the generated wavelengths as if they were spread out evenly over each selected bin, regardless of the precise recipe used by the subclass to place a wavelength inside the bin.

Constructor & Destructor Documentation

◆ GridWavelengthDistribution()

GridWavelengthDistribution::GridWavelengthDistribution ( )
inlineprotected

Default constructor for abstract Item subclass GridWavelengthDistribution: "a wavelength probability distribution derived from a wavelength grid".

Member Function Documentation

◆ generateWavelength()

double GridWavelengthDistribution::generateWavelength ( ) const
overridevirtual

This function draws a random wavelength from the wavelength distribution. It first selects one of the (in-range) bins of the configured grid with equal probability, and then calls wavelengthInBin() to obtain the actual wavelength within that bin.

Implements WavelengthDistribution.

◆ probability()

double GridWavelengthDistribution::probability ( double wavelength) const
overridevirtual

This function returns the probability of the distribution at the given wavelength. It acts as if the wavelengths generated by the generateWavelength() function were spread out over each bin (rather than being concentrated into a single wavelength). The returned probability is zero for wavelengths outside of the (in-range) bins of the configured wavelength grid. For a wavelength that falls inside bin \(\ell\), the returned probability is given by \( p_\ell = 1 / (\Delta\lambda_\ell \, N_\text{bins}) \), where \(\Delta\lambda_\ell\) is the width of the bin and \(N_\text{bins}\) is the number of (in-range) bins. This value is inversely proportional to the bin width, and satisfies the normalization condition \(\sum_\ell p_\ell = 1\).

Implements WavelengthDistribution.

◆ setupSelfAfter()

void GridWavelengthDistribution::setupSelfAfter ( )
overrideprotectedvirtual

This function determines the grid bins that fall inside the source range.

Reimplemented from SimulationItem.

◆ wavelengthGrid()

DisjointWavelengthGrid * GridWavelengthDistribution::wavelengthGrid ( ) const
inline

This function returns the value of the discoverable item property wavelengthGrid: "the wavelength grid defining the distribution".

The default value for this property is given by the conditional value expression "FileWavelengthGrid".

◆ wavelengthInBin()

virtual double GridWavelengthDistribution::wavelengthInBin ( int ell) const
protectedpure virtual

This function must be implemented in each subclass to return a wavelength inside the bin with index ell of the configured wavelength grid.

Implemented in BinnedWavelengthDistribution, and DiscreteWavelengthDistribution.


The documentation for this class was generated from the following file: