The SKIRT project
advanced radiative transfer for astrophysics
DiscreteWavelengthDistribution Class Reference

#include <DiscreteWavelengthDistribution.hpp>

Inheritance diagram for DiscreteWavelengthDistribution:

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 levels=-999999, bool setup=true) 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

 DiscreteWavelengthDistribution ()
void setupSelfAfter () override
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

DiscreteWavelengthDistribution is a specialty class for representing discrete wavelength probability distributions derived from a wavelength grid that can be configured by the user. This class is useful for mimicking codes that emit photon packets at discrete wavelengths rather than across a continuous range, perhaps to compare results in the context of a benchmark. One has to take great care when using this class in a simulation configuration, as indicated in more detail below.

When a DiscreteWavelengthDistribution instance is used as the wavelength bias distribution for a source with a composite bias factor of one, the source will emit photon packets only at the characteristic wavelengths of the configured grid, and the photon packets will be distributed with equal probability among those wavelengths. More precisely, the DiscreteWavelengthDistribution instance uses only the characteristic wavelengths of the configured grid that fall inside the wavelength range of the associated source (obtained through the SourceWavelengthRangeInterface). If none of the characteristic wavelengths fall inside the source range, a fatal error is issued.

When sending photon packets at a particular grid of discrete wavelengths, it makes little sense to configure wavelength grids with different bins for detecting photon packets in other areas of the simulation. Doing so might cause unexpected results. For example, some bins might receive no photon packets at all and thus incorrectly report zero influx. It is therefore best to configure the same wavelength grid throughout the simulation.

To configure a simulation that uses discrete wavelengths, follow these guidelines:

  • Choose a wavelength grid with adjacent bins (i.e. representing a continuous range), such as a LogWavelengthGrid or a FileWavelengthGrid with relativeHalfWidth set to zero.
  • Configure all primary and secondary sources (including, e.g. dust emission) with a wavelength bias factor of one, and a wavelength bias distribution of type DiscreteWavelengthDistribution using the chosen wavelength grid.
  • Explicitly configure all wavelength grids in the simulation to be the same chosen wavelength grid. This includes the radiation field wavelength grid, the dust emission wavelength grid, and the wavelength grids for all instruments and probes.
  • Avoid using kinematics in the simulation. Small Doppler shifts from the emitted discrete wavelengths will stay within the same wavelength bin anyway. Larger shifts will cause photon packets to move between wavelength bins in a discontinuous way.

Constructor & Destructor Documentation

◆ DiscreteWavelengthDistribution()

DiscreteWavelengthDistribution::DiscreteWavelengthDistribution ( )
inlineprotected

Default constructor for concrete Item subclass DiscreteWavelengthDistribution: "a discrete wavelength probability distribution derived from a wavelength grid".

Member Function Documentation

◆ generateWavelength()

double DiscreteWavelengthDistribution::generateWavelength ( ) const
overridevirtual

This function draws a random wavelength from the wavelength distribution. For this class, it generates one of the (in-range) characteristic wavelengths of the configured grid, with equal probability. In other words, it implements a Dirac-delta function within each of the (in-range) bins of the configured wavelength grid.

Implements WavelengthDistribution.

◆ probability()

double DiscreteWavelengthDistribution::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, reflecting the equal distribution of generated wavelengths over the bins, and satisfies the normalization condition \(\sum_\ell p_\ell = 1\).

Implements WavelengthDistribution.

◆ setupSelfAfter()

void DiscreteWavelengthDistribution::setupSelfAfter ( )
overrideprotectedvirtual

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

Reimplemented from SimulationItem.

◆ wavelengthGrid()

DisjointWavelengthGrid * DiscreteWavelengthDistribution::wavelengthGrid ( ) const
inline

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

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


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