The SKIRT project
advanced radiative transfer for astrophysics
Units Class Reference

#include <Units.hpp>

Inheritance diagram for Units:

Public Types

enum class  FluxOutputStyle : int { Neutral , Wavelength , Frequency , Energy }
enum class  WavelengthOutputStyle : int { Wavelength , Frequency , Energy }

Public Member Functions

std::tuple< double, double, double > def (string qty, string unit) const
FluxOutputStyle fluxOutputStyle () const
bool has (string qty, string unit) const
double in (string qty, string unit, double value) const
double oangle (double theta) const
double obolluminosity (double L) const
double obolluminositysurfacedensity (double L) const
double obolluminosityvolumedensity (double L) const
double obulkmass (double mu) const
double obulkmassdensity (double rho) const
double odistance (double d) const
double oenergy (double E) const
double ofluxdensity (double lambda, double Flambda) const
double ograinsize (double a) const
double olength (double x) const
double omagneticfield (double B) const
double omass (double M) const
double omasscoefficient (double kappa) const
double omasssurfacedensity (double Sigma) const
double omassvolumedensity (double rho) const
double omeanintensity (double lambda, double Jlambda) const
double omonluminosity (double lambda, double Llambda) const
double omonluminosityvolumedensity (double lambda, double Llambda) const
double onumbersurfacedensity (double N) const
double onumbervolumedensity (double n) const
double oopacity (double k) const
double opergrainsize (double a) const
double oposangle (double theta) const
double opressure (double p) const
double osection (double C) const
double osolidangle (double Omega) const
double ospectraltimefluxdensity (double lambda, double flambdatime) const
double osurfacebrightness (double lambda, double flambda) const
double otemperature (double T) const
double otimefluxdensity (double Ftime, double lambdaFtime) const
double otimelag (double t) const
double out (string qty, double value) const
double ovelocity (double v) const
double ovolume (double V) const
double owavelength (double lambda) const
bool rwavelength () const
string sfluxdensity () const
string smeanintensity () const
string smonluminosity () const
string smonluminosityvolumedensity () const
string sspectraltimefluxdensity () const
string ssurfacebrightness () const
string stimefluxdensity () const
string swavelength () const
string uangle () const
string ubolluminosity () const
string ubolluminositysurfacedensity () const
string ubolluminosityvolumedensity () const
string ubulkmass () const
string ubulkmassdensity () const
string udistance () const
string uenergy () const
string ufluxdensity () const
string ugrainsize () const
string ulength () const
string umagneticfield () const
string umass () const
string umasscoefficient () const
string umasssurfacedensity () const
string umassvolumedensity () const
string umeanintensity () const
string umonluminosity () const
string umonluminosityvolumedensity () const
string unit (string qty) const
string unumbersurfacedensity () const
string unumbervolumedensity () const
string uopacity () const
string upergrainsize () const
string uposangle () const
string upressure () const
string usection () const
string usolidangle () const
string uspectraltimefluxdensity () const
string usurfacebrightness () const
string utemperature () const
string utimefluxdensity () const
string utimelag () const
string uvelocity () const
string uvolume () const
string uwavelength () const
WavelengthOutputStyle wavelengthOutputStyle () 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

Static Public Member Functions

template<class Style>
static FluxOutputStyle fluxStyle (Style style)
static Array fromFluxStyle (const Array &lambdav, const Array &Lv, FluxOutputStyle style)
static double fromFluxStyle (double lambda, double L, FluxOutputStyle style)

Protected Member Functions

 Units ()
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
using ItemType

Private Attributes

FluxOutputStyle _fluxOutputStyle
SkirtUnitDef _unitDef
WavelengthOutputStyle _wavelengthOutputStyle

Friends

class ItemRegistry

Detailed Description

Units is the abstract base class of the classes that represent the unit systems supported by SKIRT for input/output purposes (internally in SKIRT, everything is in SI units). The Units class serves several purposes.

Firstly, the Units base class and its derived classes enable the SMILE units mechanism in SKIRT parameter files, as described in the documentation of the UnitDef class.

Secondly, the Units class allows the user to configure the wavelength and flux output styles as attributes in the SKIRT parameter file.

Finally, the Units class offers functionality for use by other classes in the simulation item hierarchy. It provides functions for converting physical quantities from internal SI units to external output units depending on the unit system (determined by the name of the subclass being called) and, where applicable, on the selected wavelength and flux output styles.

Member Enumeration Documentation

◆ FluxOutputStyle

enum class Units::FluxOutputStyle : int
strong

The enumeration type indicating the output style for flux density and surface brightness. Neutral indicates \(\lambda F_\lambda = \nu F_\nu\); Wavelength indicates \(F_\lambda\); Frequency indicates \(F_\nu\); and Energy indicates \(F_E\).

Neutral : "neutral: λ F_λ = ν F_ν".

Wavelength : "per unit of wavelength: F_λ".

Frequency : "per unit of frequency: F_ν".

Energy : "counts per unit of energy: F_E".

◆ WavelengthOutputStyle

enum class Units::WavelengthOutputStyle : int
strong

The enumeration type indicating the output style for spectral values, i.e. as photon wavelength (the internal representation), as photon frequency, or as photon energy.

Wavelength : "as photon wavelength: λ".

Frequency : "as photon frequency: ν".

Energy : "as photon energy: E".

Constructor & Destructor Documentation

◆ Units()

Units::Units ( )
inlineprotected

Default constructor for abstract Item subclass Units: "a units system".

Member Function Documentation

◆ def()

std::tuple< double, double, double > Units::def ( string qty,
string unit ) const

This function returns the definition of the specified units in the form of a tuple providing the front factor, power exponent and offset for conversion from input to internal quantities.

◆ fluxOutputStyle()

FluxOutputStyle Units::fluxOutputStyle ( ) const
inline

This function returns the value of the discoverable FluxOutputStyle enumeration property fluxOutputStyle: "the output style for flux density and surface brightness".

The default value for this property is given by the conditional value expression "wavelengthOutputStyleEnergy:Energy;Frequency".

◆ fluxStyle()

template<class Style>
FluxOutputStyle Units::fluxStyle ( Style style)
inlinestatic

This template function translates a flux style given as an enumeration with elements corresponding to the specific luminosity quantity strings defined by the SkirtUnitDef class to a FluxOutputStyle flux style.

◆ fromFluxStyle() [1/2]

Array Units::fromFluxStyle ( const Array & lambdav,
const Array & Lv,
FluxOutputStyle style )
static

This function converts a list of specific luminosities from a given input style to the internal per-wavelength style, assuming the given corresponding wavelengths. Both the input values and the returned value are in SI units.

◆ fromFluxStyle() [2/2]

double Units::fromFluxStyle ( double lambda,
double L,
FluxOutputStyle style )
static

This function converts a specific luminosity from a given input style to the internal per-wavelength style, assuming a given wavelength. Both the input values and the returned value are in SI units.

◆ has()

bool Units::has ( string qty,
string unit ) const

This function returns true if the specified combination of physical quantity and unit or unit system is present in the unit definition, and false if not.

◆ in()

double Units::in ( string qty,
string unit,
double value ) const

This function converts a physical value from the specified units to internal program units. If the specified combination is not present in the unit definition, the function throws an exception.

◆ oangle()

double Units::oangle ( double theta) const

This function converts the angular size \(\theta\) from the internally used SI units (rad) to the program's output units.

◆ obolluminosity()

double Units::obolluminosity ( double L) const

This function converts the bolometric luminosity \(L\) from the internally used SI units (W) to the program's output units.

◆ obolluminositysurfacedensity()

double Units::obolluminositysurfacedensity ( double L) const

This function converts the bolometric luminosity surface density \(L\) from the internally used SI units (W/m2) to the program's output units.

◆ obolluminosityvolumedensity()

double Units::obolluminosityvolumedensity ( double L) const

This function converts the bolometric luminosity volume density \(L\) from the internally used SI units (W/m3) to the program's output units.

◆ obulkmass()

double Units::obulkmass ( double mu) const

This function converts the bulk mass \(\mu\) from the internally used SI units (kg) to the program's output units.

◆ obulkmassdensity()

double Units::obulkmassdensity ( double rho) const

This function converts the bulk mass density \(\rho\) from the internally used SI units ( \({\text{kg}}\, {\text{m}}^{-3}\)) to the program's output units.

◆ odistance()

double Units::odistance ( double d) const

This function converts the distance \(d\) from the internally used SI units (m) to the program's output units.

◆ oenergy()

double Units::oenergy ( double E) const

This function converts the energy \(E\) from the internally used SI units (J) to the program's output units.

◆ ofluxdensity()

double Units::ofluxdensity ( double lambda,
double Flambda ) const

This function converts the per-wavelength flux density \(F_\lambda\) for wavelength \(\lambda\) from the internally used SI units ( \({\text{W}}\, {\text{m}}^{-3}\)) to the program's flux output style and units.

◆ ograinsize()

double Units::ograinsize ( double a) const

This function converts the dust grain size \(a\) from the internally used SI units (m) to the program's output units.

◆ olength()

double Units::olength ( double x) const

This function converts the length \(x\) from the internally used SI units (m) to the program's output units.

◆ omagneticfield()

double Units::omagneticfield ( double B) const

This function converts the magnetic field strength \(B\) from the internally used SI units (T) to the program's output units.

◆ omass()

double Units::omass ( double M) const

This function converts the mass \(M\) from the internally used SI units (kg) to the program's output units.

◆ omasscoefficient()

double Units::omasscoefficient ( double kappa) const

This function converts the mass coefficient \(\kappa\) from the internally used SI units ( \({\text{m}}^{-2}\, {\text{kg}}^{-1}\)) to the program's output units.

◆ omasssurfacedensity()

double Units::omasssurfacedensity ( double Sigma) const

This function converts the mass surface density \(\Sigma\) from the internally used SI units ( \({\text{kg}}\, {\text{m}}^{-2}\)) to the program's output units.

◆ omassvolumedensity()

double Units::omassvolumedensity ( double rho) const

This function converts the mass volume density \(\rho\) from the internally used SI units ( \({\text{kg}}\, {\text{m}}^{-3}\)) to the program's output units.

◆ omeanintensity()

double Units::omeanintensity ( double lambda,
double Jlambda ) const

This function converts the per-wavelength mean intensity \(J_\lambda\) for wavelength \(\lambda\) from the internally used SI units ( \({\text{W}}\, {\text{m}}^{-3}\, {\text{sr}}^{-1}\)) to the program's flux output style and units.

◆ omonluminosity()

double Units::omonluminosity ( double lambda,
double Llambda ) const

This function converts the monochromatic per-wavelength luminosity \(L_\lambda\) from the internally used SI units ( \({\text{W}}\, {\text{m}}^{-1}\)) to the program's flux output style and units.

◆ omonluminosityvolumedensity()

double Units::omonluminosityvolumedensity ( double lambda,
double Llambda ) const

This function converts the monochromatic per-wavelength luminosity volume density \(L_\lambda/V\) from the internally used SI units ( \({\text{W}}\, {\text{m}}^{-4}\)) to the program's flux output style and units.

◆ onumbersurfacedensity()

double Units::onumbersurfacedensity ( double N) const

This function converts the number surface density \(\mathcal{N}\) from the internally used SI units ( \({\text{m}}^{-2}\)) to the program's output units.

◆ onumbervolumedensity()

double Units::onumbervolumedensity ( double n) const

This function converts the number volume density \(n\) from the internally used SI units ( \({\text{m}}^{-3}\)) to the program's output units.

◆ oopacity()

double Units::oopacity ( double k) const

This function converts the opacity \(k\) from the internally used SI units (1/m) to the program's output units.

◆ opergrainsize()

double Units::opergrainsize ( double a) const

This function converts a quantity with units of inverse dust grain size from the internally used SI units (1/m) to the program's output units.

◆ oposangle()

double Units::oposangle ( double theta) const

This function converts the positioning angle \(\theta\) from the internally used SI units (rad) to the program's output units.

◆ opressure()

double Units::opressure ( double p) const

This function converts the pressure \(p\) from the internally used SI units (Pa) to the program's output units.

◆ osection()

double Units::osection ( double C) const

This function converts the volume \(C\) from the internally used SI units ( \({\text{m}}^2\)) to the program's output units.

◆ osolidangle()

double Units::osolidangle ( double Omega) const

This function converts the solid angle \(\Omega\) from the internally used SI units (sr) to the program's output units.

◆ ospectraltimefluxdensity()

double Units::ospectraltimefluxdensity ( double lambda,
double flambdatime ) const

This function converts a spectral flux density per timelag interval given in internal SI units ( \({\text{W}}\, {\text{m}}^{-3}\, {\text{s}}^{-1}\)) to the program's adopted output style and units.

◆ osurfacebrightness()

double Units::osurfacebrightness ( double lambda,
double flambda ) const

This function converts the per-wavelength surface brightness \(f_\lambda\) for wavelength \(\lambda\) from the internally used SI units ( \({\text{W}}\, {\text{m}}^{-3}\, {\text{sr}}^{-1}\)) to the program's flux output style and units.

◆ otemperature()

double Units::otemperature ( double T) const

This function converts the temperature \(T\) from the internally used SI units (K) to the program's output units.

◆ otimefluxdensity()

double Units::otimefluxdensity ( double Ftime,
double lambdaFtime ) const

This function converts a flux density per timelag interval given in internal units to the program's adopted output style and units. Because the quantity is spectrally integrated, it is not possible to convert the aggregated quantity between an amount of energy and a number of photons. Therefore, the caller must provide both the flux density \(F_\text{time}\) in regular internal SI units \({\text{W}}\, {\text{m}}^{-2}\, {\text{s}}^{-1}\) and the same quantity multiplied by wavelength for every photon packet contribution separately, resulting in internal SI units \({\text{W}}\, {\text{m}}^{-1}\, {\text{s}}^{-1}\).

◆ otimelag()

double Units::otimelag ( double t) const

This function converts the time lag \(t\) from the internally used SI units (s) to the program's adopted output units.

◆ out()

double Units::out ( string qty,
double value ) const

This function converts a physical value from internal SI units to the output units adopted by the program. The name of the physical quantity must be specified in all lowercase and without any spaces. If the specified combination of physical quantity and unit is unknown, the function throws a fatal error.

◆ ovelocity()

double Units::ovelocity ( double v) const

This function converts the velocity \(v\) from the internally used SI units ( \({\text{m}}\, {\text{s}}^{-1}\)) to the program's output units.

◆ ovolume()

double Units::ovolume ( double V) const

This function converts the volume \(V\) from the internally used SI units ( \({\text{m}}^3\)) to the program's output units.

◆ owavelength()

double Units::owavelength ( double lambda) const

This function converts the wavelength \(\lambda\) from the internal style (wavelength) and the internally used SI units (m) to the program's adopted output style and units.

◆ rwavelength()

bool Units::rwavelength ( ) const

This function returns true if wavelength values are ordered in reverse in the wavelength output style adopted by the program, and false otherwise. Specifically, it returns false for the output style 'wavelength' and true for the output styles 'frequency' and 'energy'.

◆ sfluxdensity()

string Units::sfluxdensity ( ) const

This function returns a string describing the flux density output style adopted by the program.

◆ smeanintensity()

string Units::smeanintensity ( ) const

This function returns a string describing the mean intensity output style adopted by the program.

◆ smonluminosity()

string Units::smonluminosity ( ) const

This function returns a string describing the monochromatic luminosity output style adopted by the program.

◆ smonluminosityvolumedensity()

string Units::smonluminosityvolumedensity ( ) const

This function returns a string describing the monochromatic luminosity volume density output style adopted by the program.

◆ sspectraltimefluxdensity()

string Units::sspectraltimefluxdensity ( ) const

This function returns a string describing the output style adopted by the program for a spectral flux density per timelag interval (the quantity used by a spectral-time map).

◆ ssurfacebrightness()

string Units::ssurfacebrightness ( ) const

This function returns a string describing the surface brightness output style adopted by the program.

◆ stimefluxdensity()

string Units::stimefluxdensity ( ) const

This function returns a string describing the output style adopted by the program for a flux density per timelag interval (the quantity used by a light curve).

◆ swavelength()

string Units::swavelength ( ) const

This function returns a string describing the wavelength output style adopted by the program.

◆ uangle()

string Units::uangle ( ) const

This function returns a string containing the name of the unit of angular size adopted by the program for output.

◆ ubolluminosity()

string Units::ubolluminosity ( ) const

This function returns a string containing the name of the unit of bolometric luminosity adopted by the program for output.

◆ ubolluminositysurfacedensity()

string Units::ubolluminositysurfacedensity ( ) const

This function returns a string containing the name of the unit of bolometric luminosity surface density adopted by the program for output.

◆ ubolluminosityvolumedensity()

string Units::ubolluminosityvolumedensity ( ) const

This function returns a string containing the name of the unit of bolometric luminosity volume density adopted by the program for output.

◆ ubulkmass()

string Units::ubulkmass ( ) const

This function returns a string containing the name of the unit of bulk mass adopted by the program for output.

◆ ubulkmassdensity()

string Units::ubulkmassdensity ( ) const

This function returns a string containing the name of the unit of bulk mass density adopted by the program for output.

◆ udistance()

string Units::udistance ( ) const

This function returns a string containing the name of the unit of distance adopted by the program for output. Apart from this unit of distance, the program uses an independent unit of length, because usually the distance to an astronomical object and the typical length scale within an astronomical object are quite different.

◆ uenergy()

string Units::uenergy ( ) const

This function returns a string containing the name of the unit of energy adopted by the program for output.

◆ ufluxdensity()

string Units::ufluxdensity ( ) const

This function returns a string containing the name of the unit of flux density adopted by the program for output, depending on the selected flux output style.

◆ ugrainsize()

string Units::ugrainsize ( ) const

This function returns a string containing the name of the unit of dust grain size adopted by the program for output.

◆ ulength()

string Units::ulength ( ) const

This function returns a string containing the name of the unit of length adopted by the program for output. Apart from this unit of length, the program uses an independent unit of distance, because usually the distance to an astronomical object and the typical length scale within an astronomical object are quite different.

◆ umagneticfield()

string Units::umagneticfield ( ) const

This function returns a string containing the name of the unit of magnetic field adopted by the program for output.

◆ umass()

string Units::umass ( ) const

This function returns a string containing the name of the unit of mass adopted by the program for output.

◆ umasscoefficient()

string Units::umasscoefficient ( ) const

This function returns a string containing the name of the unit of mass coefficient adopted by the program for output.

◆ umasssurfacedensity()

string Units::umasssurfacedensity ( ) const

This function returns a string containing the name of the unit of mass surface density adopted by the program for output.

◆ umassvolumedensity()

string Units::umassvolumedensity ( ) const

This function returns a string containing the name of the unit of mass volume density adopted by the program for output.

◆ umeanintensity()

string Units::umeanintensity ( ) const

This function returns a string containing the name of the unit of mean intensity adopted by the program for output, depending on the selected flux output style.

◆ umonluminosity()

string Units::umonluminosity ( ) const

This function returns a string containing the name of the unit of monochromatic luminosity adopted by the program for output, depending on the selected flux output style.

◆ umonluminosityvolumedensity()

string Units::umonluminosityvolumedensity ( ) const

This function returns a string containing the name of the unit of monochromatic luminosity volume density adopted by the program for output, depending on the selected flux output style.

◆ unit()

string Units::unit ( string qty) const

This function returns a string containing the name of the output unit adopted by the program for the specified physical quantity. The name of the physical quantity must be specified in all lowercase and without any spaces. The function throws a fatal error if the specified physical quantity is unknown.

◆ unumbersurfacedensity()

string Units::unumbersurfacedensity ( ) const

This function returns a string containing the name of the unit of number surface density adopted by the program for output.

◆ unumbervolumedensity()

string Units::unumbervolumedensity ( ) const

This function returns a string containing the name of the unit of number volume density adopted by the program for output.

◆ uopacity()

string Units::uopacity ( ) const

This function returns a string containing the name of the unit of opacity adopted by the program for output.

◆ upergrainsize()

string Units::upergrainsize ( ) const

This function returns a string containing the name of the unit of inverse dust grain size adopted by the program for output.

◆ uposangle()

string Units::uposangle ( ) const

This function returns a string containing the name of the unit of positioning angle adopted by the program for output.

◆ upressure()

string Units::upressure ( ) const

This function returns a string containing the name of the unit of pressure adopted by the program for output.

◆ usection()

string Units::usection ( ) const

This function returns a string containing the name of the unit of cross section adopted by the program for output.

◆ usolidangle()

string Units::usolidangle ( ) const

This function returns a string containing the name of the unit of solid angle adopted by the program for output.

◆ uspectraltimefluxdensity()

string Units::uspectraltimefluxdensity ( ) const

This function returns a string containing the name of the output unit adopted by the program for a spectral flux density per timelag interval.

◆ usurfacebrightness()

string Units::usurfacebrightness ( ) const

This function returns a string containing the name of the unit of surface brightness adopted by the program for output, depending on the selected flux output style.

◆ utemperature()

string Units::utemperature ( ) const

This function returns a string containing the name of the unit of temperature adopted by the program for output.

◆ utimefluxdensity()

string Units::utimefluxdensity ( ) const

This function returns a string containing the name of the output unit adopted by the program for a flux density per timelag interval.

◆ utimelag()

string Units::utimelag ( ) const

This function returns a string containing the name of the unit of time lag adopted by the program for output.

◆ uvelocity()

string Units::uvelocity ( ) const

This function returns a string containing the name of the unit of velocity adopted by the program for output.

◆ uvolume()

string Units::uvolume ( ) const

This function returns a string containing the name of the unit of volume adopted by the program for output.

◆ uwavelength()

string Units::uwavelength ( ) const

This function returns a string containing the name of the style and unit of wavelength adopted by the program for output.

◆ wavelengthOutputStyle()

WavelengthOutputStyle Units::wavelengthOutputStyle ( ) const
inline

This function returns the value of the discoverable WavelengthOutputStyle enumeration property wavelengthOutputStyle: "the output style for wavelengths".

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


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