The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | Friends | List of all members
SourceSystem Class Reference

#include <SourceSystem.hpp>

Inheritance diagram for SourceSystem:
Inheritance graph
[legend]

Public Member Functions

int dimension () const
 
void installLaunchCallBack (ProbePhotonPacketInterface *callback)
 
void launch (PhotonPacket *pp, size_t historyIndex) const
 
double luminosity () const
 
double maxWavelength () const
 
double minWavelength () const
 
int numSources () const
 
void prepareForLaunch (size_t numPackets)
 
double sourceBias () const
 
const vector< Source * > & sources () const
 
const vector< double > & wavelengths () 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

 SourceSystem ()
 
void setupSelfAfter () override
 
- Protected Member Functions inherited from SimulationItem
 SimulationItem ()
 
virtual bool offersInterface (const std::type_info &interfaceTypeInfo) const
 
virtual void setupSelfAfter ()
 
virtual void setupSelfBefore ()
 
- Protected Member Functions inherited from Item
 Item ()
 

Private Types

using BaseType = SimulationItem
 
using ItemType = SourceSystem
 

Private Attributes

vector< ProbePhotonPacketInterface * > _callbackv
 
vector< size_t > _Iv
 
double _L
 
double _Lpp
 
Array _Lv
 
double _maxWavelength
 
double _minWavelength
 
double _sourceBias
 
vector< Source * > _sources
 
vector< double > _wavelengths
 
Array _Wv
 

Friends

class ItemRegistry
 

Detailed Description

An instance of the SourceSystem class represents a complete primary source system, which is the superposition of one or more sources. Each source provides a complete description of its radiation, including the spatial and spectral distribution and characteristics such as anisotropy and polarization.

One key task of the SourceSystem object is to distribute photon packet launches across the sources. In principle, this should/could be achieved by randomly selecting a source for each launch through sampling from an appropriate probability distribution. However, for some sources, a deterministic approach allows significant performance optimizations. Because the number of photon packets should be and usually is (much) larger than the number of (sub)sources, a deterministic approach can be considered to be equivalent to the randomized procedure.

The idea is to iterate through the sources and launch consecutive photon packets from each. A source consisting of many subsources (such as particles or cells) can then use a similar approach, iterating over these components. The implementation can now construct and cache relevant data structures (such as a cumulative spectral distribution) for each subsource, and release the information as soon as the iteration moves on to the next subsource. Because photon packets can (and often are) launched in parallel, these data structures must be allocated in thread-local storage, but that is only a minor complication.

For each primary emission segment (i.e. a sequence of photon packet launches) in the simulation, the MonteCarloSimulation object uses the following procedure. It first determines the number of photon packets to be launched from the simulation configuration. This number \(N\) is passed to the SourceSystem::prepareForLaunch() function in serial mode. Subsequently, the MonteCarloSimulation object launches \(N\) photon packets in (potentially) parallel mode, labeling each of the packets with a history index in the range \(0,...,N-1\). While parallel execution threads are working on photon packets in various chunks of this range, each thread handles photon packets with consecutive history indices within a given chunk.

To achieve the goals described above, the SourceSystem::prepareForLaunch() function maps consecutive history index ranges to each of the sources being held. This mapping is also passed on to each source, so that it can (but doesn't have to) implement a similar approach for its subsources. The number of photon packets allocated to each source is determined as follows:

\[ N_s = \left[ (1-\xi) \frac{w_s L_s}{\sum w_s L_s} + \xi \frac{w_s}{\sum w_s} \right] N \]

where \(N\) is the total number of photon packets to be launched, \(N_s\) is the number of photon packets to be launched by source \(s\), \(L_s\) is the bolometric luminosity of source \(s\), \(w_s\) is the sourceWeight property value for source \(s\), \(\xi\) is the sourceBias property value of the source system, and the sums range over all sources in the source system.

Constructor & Destructor Documentation

◆ SourceSystem()

SourceSystem::SourceSystem ( )
inlineprotected

Default constructor for concrete Item subclass SourceSystem : "a primary source system" .

Member Function Documentation

◆ dimension()

int SourceSystem::dimension ( ) const

This function returns the dimension of the source system, which depends on the (lack of) symmetry in the geometries of its components. A value of 1 means spherical symmetry, 2 means axial symmetry and 3 means none of these symmetries. The source with the least symmetry (i.e. the highest dimension) determines the result for the whole system.

◆ installLaunchCallBack()

void SourceSystem::installLaunchCallBack ( ProbePhotonPacketInterface callback)

This function installs the specified interface as photon packet launch call-back. The function probePhotonPacket() provided by the interface will be called for each photon packet that is ready to be launched.

◆ launch()

void SourceSystem::launch ( PhotonPacket pp,
size_t  historyIndex 
) const

This function causes the photon packet pp to be launched from one of the sources in the source system using the given history index. The photon packet's contents is fully (re-)initialized so that it is ready to start its lifecycle.

◆ luminosity()

double SourceSystem::luminosity ( ) const

This function returns the bolometric luminosity \(L\) of the source system across its spatial and spectral domain, which is the sum of the luminosities of the sources in the system.

◆ maxWavelength()

SourceSystem::maxWavelength ( ) const
inline

This function returns the value of the discoverable double property maxWavelength : "the longest wavelength of photon packets launched from primary sources" .

This property represents a physical quantity of type "wavelength" .

The minimum value for this property is "1 pm" .

The maximum value for this property is "1 m" .

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

This property is relevant only if the Boolean expression "Panchromatic" evaluates to true after replacing the names by true or false depending on their presence.

◆ minWavelength()

SourceSystem::minWavelength ( ) const
inline

This function returns the value of the discoverable double property minWavelength : "the shortest wavelength of photon packets launched from primary sources" .

This property represents a physical quantity of type "wavelength" .

The minimum value for this property is "1 pm" .

The maximum value for this property is "1 m" .

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

This property is relevant only if the Boolean expression "Panchromatic" evaluates to true after replacing the names by true or false depending on their presence.

◆ numSources()

int SourceSystem::numSources ( ) const

This function returns the number of sources in the source system.

◆ prepareForLaunch()

void SourceSystem::prepareForLaunch ( size_t  numPackets)

This function prepares the mapping of history indices to sources; see the description in the class header for more information.

◆ setupSelfAfter()

void SourceSystem::setupSelfAfter ( )
overrideprotectedvirtual

This function obtains the bolometric luminosity of each source for later use.

Reimplemented from SimulationItem.

◆ sourceBias()

SourceSystem::sourceBias ( ) const
inline

This function returns the value of the discoverable double property sourceBias : "the fraction of photon packets distributed uniformly across primary sources" .

The minimum value for this property is "[0" .

The maximum value for this property is "1]" .

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

This property is displayed only if the Boolean expression "Level3" evaluates to true after replacing the names by true or false depending on their presence.

◆ sources()

SourceSystem::sources ( ) const
inline

This function returns the value of the discoverable item list property sources : "the primary sources" .

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

This property is required only if the Boolean expression "false" evaluates to true after replacing the names by true or false depending on their presence.

◆ wavelengths()

SourceSystem::wavelengths ( ) const
inline

This function returns the value of the discoverable double list property wavelengths : "the discrete wavelengths of photon packets launched from primary sources" .

This property represents a physical quantity of type "wavelength" .

The minimum value for this property is "1 pm" .

The maximum value for this property is "1 m" .

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

This property is relevant only if the Boolean expression "Oligochromatic" evaluates to true after replacing the names by true or false depending on their presence.


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