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

#include <FilePolarizedPointSource.hpp>

Inheritance diagram for FilePolarizedPointSource:
Inheritance graph
[legend]

Classes

struct  Tables
 

Public Member Functions

int dimension () const override
 
string filename () const
 
bool hasVelocity () const override
 
void launch (PhotonPacket *pp, size_t historyIndex, double L) const override
 
double luminosity () const override
 
LuminosityNormalizationnormalization () const
 
double positionX () const
 
double positionY () const
 
double positionZ () const
 
double specificLuminosity (double wavelength) const override
 
double symmetryX () const
 
double symmetryY () const
 
double symmetryZ () const
 
Vec velocity () const override
 
double velocityX () const
 
double velocityY () const
 
double velocityZ () const
 
Range wavelengthRange () const override
 
- Public Member Functions inherited from Source
virtual int dimension () const =0
 
virtual bool hasVelocity () const =0
 
virtual void launch (PhotonPacket *pp, size_t historyIndex, double L) const =0
 
virtual double luminosity () const =0
 
virtual void prepareForLaunch (double sourceBias, size_t firstIndex, size_t numIndices)
 
double sourceWeight () const
 
virtual double specificLuminosity (double wavelength) const =0
 
double wavelengthBias () const
 
WavelengthDistributionwavelengthBiasDistribution () 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
 
- Public Member Functions inherited from WavelengthRangeInterface
virtual ~WavelengthRangeInterface ()
 
virtual Range wavelengthRange () const =0
 
- Public Member Functions inherited from VelocityInterface
virtual ~VelocityInterface ()
 
virtual Vec velocity () const =0
 

Protected Member Functions

 FilePolarizedPointSource ()
 
void setupSelfAfter () override
 
void setupSelfBefore () override
 
- Protected Member Functions inherited from Source
 Source ()
 
void informAvailableWavelengthRange (Range available, string itemType)
 
Randomrandom () const
 
void setupSelfBefore () 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 ()
 
- Protected Member Functions inherited from SourceWavelengthRangeInterface
 SourceWavelengthRangeInterface ()
 
- Protected Member Functions inherited from WavelengthRangeInterface
 WavelengthRangeInterface ()
 
- Protected Member Functions inherited from VelocityInterface
 VelocityInterface ()
 

Private Types

using BaseType = Source
 
using ItemType = FilePolarizedPointSource
 

Private Attributes

WavelengthDistribution_biasDistribution
 
VelocityInterface_bvi
 
string _filename
 
LuminosityNormalization_normalization
 
double _positionX
 
double _positionY
 
double _positionZ
 
ContSED_sed
 
Direction _sym
 
double _symmetryX
 
double _symmetryY
 
double _symmetryZ
 
Tables _tables
 
double _velocityX
 
double _velocityY
 
double _velocityZ
 
double _xi
 

Friends

class ItemRegistry
 

Detailed Description

FilePolarizedPointSource represents a primary source limited to a single point in space and emitting polarized radiation with an axisymmetric angular dependence. The Stokes vector components of the emitted radiation, as a function of wavelength and inclination angle cosine, are loaded from a user-provided file. The bolometric output is characterized by a LuminosityNormalization object configured in the ski file. The class furthermore offers user-configured properties to specify the position of the point source, the orientation of the symmetry axis of the angular dependence, and a "bulk" velocity.

Inclination angle

For the purposes of this class, the inclination angle \(\theta\) is defined as the angle between the user-configured symmetry axis \(\bf{s}\) and the propagation direction \(\bf{k}\) of the emitted photon packet. The inclination cosine values given in the input file must conform to this convention.

In formula form, assuming that both directions \(\bf{s}\) and \(\bf{k}\) are given as unit vectors, the inclination angle cosine simply is \(\cos\theta=\bf{s}\cdot\bf{k}\).

Reference direction

The components of a Stokes vector (and hence the polarization angle derived from it) are specified relative to some reference direction \(\bf{d}\) which must be perpendicular to the propagation direction \(\bf{k}\) of the emitted photon packet. For the purposes of this class, the reference direction is taken to be the orthogonal projection of the user-configured symmetry axis \(\bf{s}\) on the plane perpendicular to the propagation direction \(\bf{k}\). The Stokes vector values given in the input file must conform to this convention.

In formula form, assuming that the propagation direction \(\bf{k}\) is given as a unit vector, the (unnormalized) orthogonal projection of \(\bf{s}\) on the plane with normal \(\bf{k}\) is given by \(\bf{d} = \bf{s} - (\bf{k}\cdot\bf{s})\bf{k}\). Rather than the reference direction itself, the implementation instead uses the normal \(\bf{n}\) to the reference plane, which is defined as the plane through both the reference direction and the propagation direction. The normalized normal vector \(\bf{n}\) is obtained from

\[ \bf{n} = \frac{\bf{d} \times \bf{k}}{||\bf{d} \times \bf{k}||} = \frac{\bf{s} \times \bf{k}}{||\bf{s} \times \bf{k}||} \]

after substitution of the above expression for \(\bf{d}\). If the symmetry axis and the propogation direction are (anti)parallel, the normal vector \(\bf{n}\) is undefined and the emitted radiation is taken to be unpolarized.

Input file format

As indicated in the introduction above, the user-provided input file tabulates the Stokes vector components \(I,Q,U,V\) of the emitted radiation as a function of wavelength and inclination angle cosine. In other words, the input file represents a two-dimensional table with four values in each entry. All information is bundled in a single binary file using the SKIRT stored table format (see StoredTable).

All quantities are specified in internal SKIRT units:

Example python script

Below is an excerpt from a python script used to create an appropiate input file for this class from the information in a set of text files. In particular, the script shows how to create the file in SKIRT stored table format using the PTS function pts.storedtable.io.writeStoredTable. It also illustrates some of the conversions that may need to be performed.

import numpy as np
from pts.storedtable.io import writeStoredTable
# read the inclination grid (in deg); range is 0..90 deg
theta = ...
numTheta = len(theta)
# read the energy grid (in keV)
E = ...
numE = len(E)
# read the Stokes vector components (in ph/s/keV) for each inclination bin
Ie = np.zeros((numTheta, numE))
Qe = np.zeros((numTheta, numE))
Ue = np.zeros((numTheta, numE))
for i in range(numTheta):
Ie[i], Qe[i], Ue[i] = ...
# add symmetrical inclination range and reverse the order so that range becomes 180..0 deg
theta = np.concatenate((180 - theta, theta[::-1]))
Ie = np.concatenate((Ie, Ie[::-1]))
Qe = np.concatenate((Qe, Qe[::-1]))
Ue = np.concatenate((Ue, Ue[::-1]))
# convert inclination from deg to cosine in range -1..1
costheta = np.cos(theta * np.pi/180)
# convert energy in keV to wavelength in m
h = 6.62606957e-34
c = 2.99792458e8
q = 1.602176634e-19
lam = 1e-3 * h * c / q / E
# convert flux from per-energy flavor to per-wavelength flavor,
# with arbitrary normalization so that values are on the order of 1
Ilam = Ie / lam**3 / 1e35
Qlam = Qe / lam**3 / 1e35
Ulam = Ue / lam**3 / 1e35
# reverse spectral range so that wavelengths are in increasing order
lam = np.flip(lam)
Ilam = np.flip(Ilam, axis=1)
Qlam = np.flip(Qlam, axis=1)
Ulam = np.flip(Ulam, axis=1)
# create zero V component
Vlam = np.zeros_like(Ilam)
# write stored table
writeStoredTable(inputname + ".stab",
['costheta','lambda'], ['1','m'], ['lin','log'], [costheta,lam],
['I','Q','U','V'], ['W/m','W/m','W/m','W/m'], ['log','lin','lin','lin'], [Ilam,Qlam,Ulam,Vlam])

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

When an item of this type is used, the names provided by the conditional value expression "Dimension2,ContSED" are inserted into the name sets used for evaluating Boolean expressions.

Constructor & Destructor Documentation

◆ FilePolarizedPointSource()

FilePolarizedPointSource::FilePolarizedPointSource ( )
inlineprotected

Default constructor for concrete Item subclass FilePolarizedPointSource : "a primary point source with a polarized spectrum read from file" .

Member Function Documentation

◆ dimension()

int FilePolarizedPointSource::dimension ( ) const
overridevirtual

This function returns the dimension of the point source, which depends on the (lack of) symmetry of its geometry.

Implements Source.

◆ filename()

string FilePolarizedPointSource::filename ( ) const
inline

This function returns the value of the discoverable string property filename : "the name of the stored table file listing the Stokes vector components" .

◆ hasVelocity()

bool FilePolarizedPointSource::hasVelocity ( ) const
overridevirtual

This function returns true if the velocity of the source is nonzero.

Implements Source.

◆ launch()

void FilePolarizedPointSource::launch ( PhotonPacket pp,
size_t  historyIndex,
double  L 
) const
overridevirtual

This function causes the photon packet pp to be launched from the source using the given history index and luminosity contribution. The function samples a wavelength and a propagation direction from the spectral and angular dependencies derived from the input file, constructs proper objects for angular distribution, polarization profile and bulk velocity, and finally emits the photon packet with these properties.

Implements Source.

◆ luminosity()

double FilePolarizedPointSource::luminosity ( ) const
overridevirtual

This function returns the luminosity \(L\) (i.e. radiative power) of the source integrated over the wavelength range of primary sources (configured for the source system as a whole).

Implements Source.

◆ normalization()

FilePolarizedPointSource::normalization ( ) const
inline

This function returns the value of the discoverable item property normalization : "the type of luminosity normalization for the source" .

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

◆ positionX()

FilePolarizedPointSource::positionX ( ) const
inline

This function returns the value of the discoverable double property positionX : "the position of the point source, x component" .

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

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

When a value is entered for this property, the names provided by the conditional value expression "positionX:Dimension3" are inserted into the name sets used for evaluating Boolean expressions.

◆ positionY()

FilePolarizedPointSource::positionY ( ) const
inline

This function returns the value of the discoverable double property positionY : "the position of the point source, y component" .

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

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

When a value is entered for this property, the names provided by the conditional value expression "positionY:Dimension3" are inserted into the name sets used for evaluating Boolean expressions.

◆ positionZ()

FilePolarizedPointSource::positionZ ( ) const
inline

This function returns the value of the discoverable double property positionZ : "the position of the point source, z component" .

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

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

◆ setupSelfAfter()

void FilePolarizedPointSource::setupSelfAfter ( )
overrideprotectedvirtual

This function warns the user if this source's intrinsic wavelength range does not fully cover the configured wavelength range.

Reimplemented from SimulationItem.

◆ setupSelfBefore()

void FilePolarizedPointSource::setupSelfBefore ( )
overrideprotectedvirtual

This function reads the user-provided input file and caches the relevant information.

Reimplemented from SimulationItem.

◆ specificLuminosity()

double FilePolarizedPointSource::specificLuminosity ( double  wavelength) const
overridevirtual

This function returns the specific luminosity \(L_\lambda\) (i.e. radiative power per unit of wavelength) of the source at the specified wavelength, or zero if the wavelength is outside the wavelength range of primary sources (configured for the source system as a whole) or if the source simply does not emit at the wavelength.

Implements Source.

◆ symmetryX()

FilePolarizedPointSource::symmetryX ( ) const
inline

This function returns the value of the discoverable double property symmetryX : "the direction of the positive symmetry axis, x component" .

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

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

When a value is entered for this property, the names provided by the conditional value expression "symmetryX:Dimension3" are inserted into the name sets used for evaluating Boolean expressions.

◆ symmetryY()

FilePolarizedPointSource::symmetryY ( ) const
inline

This function returns the value of the discoverable double property symmetryY : "the direction of the positive symmetry axis, y component" .

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

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

When a value is entered for this property, the names provided by the conditional value expression "symmetryY:Dimension3" are inserted into the name sets used for evaluating Boolean expressions.

◆ symmetryZ()

FilePolarizedPointSource::symmetryZ ( ) const
inline

This function returns the value of the discoverable double property symmetryZ : "the direction of the positive symmetry axis, z component" .

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

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

◆ velocity()

Vec FilePolarizedPointSource::velocity ( ) const
overridevirtual

This function implements the VelocityInterface interface. It returns the bulk velocity of this source, as configured by the user.

Implements VelocityInterface.

◆ velocityX()

FilePolarizedPointSource::velocityX ( ) const
inline

This function returns the value of the discoverable double property velocityX : "the bulk velocity of the point source, x component" .

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

The minimum value for this property is "[-100000 km/s" .

The maximum value for this property is "100000 km/s]" .

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

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.

When a value is entered for this property, the names provided by the conditional value expression "Panchromatic&velocityX:Dimension3" are inserted into the name sets used for evaluating Boolean expressions.

◆ velocityY()

FilePolarizedPointSource::velocityY ( ) const
inline

This function returns the value of the discoverable double property velocityY : "the bulk velocity of the point source, y component" .

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

The minimum value for this property is "[-100000 km/s" .

The maximum value for this property is "100000 km/s]" .

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

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.

When a value is entered for this property, the names provided by the conditional value expression "Panchromatic&velocityY:Dimension3" are inserted into the name sets used for evaluating Boolean expressions.

◆ velocityZ()

FilePolarizedPointSource::velocityZ ( ) const
inline

This function returns the value of the discoverable double property velocityZ : "the bulk velocity of the point source, z component" .

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

The minimum value for this property is "[-100000 km/s" .

The maximum value for this property is "100000 km/s]" .

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

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.

◆ wavelengthRange()

Range FilePolarizedPointSource::wavelengthRange ( ) const
overridevirtual

This function returns the wavelength range for this source. Outside this range, all luminosities are zero. This source's wavelength range is determined as the intersection of the simulation's source wavelength range (obtained from the simulation configuration) and the intrinsic wavelength range of the spectrum read from the input file.

This function implements the SourceWavelengthRangeInterface interface.

Implements WavelengthRangeInterface.


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