GyotoAstrobj.h
Go to the documentation of this file.
/*
Copyright 2011-2020 Thibaut Paumard, Frederic Vincent
This file is part of Gyoto.
Gyoto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gyoto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GyotoAstrobj_H_
#define __GyotoAstrobj_H_
#include "GyotoConfig.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <GyotoDefs.h>
#include <GyotoSmartPointer.h>
#include <GyotoConverters.h>
#include <GyotoObject.h>
#include <eigen3/Eigen/Dense>
namespace Gyoto{
class Photon;
namespace Register { class Entry; }
namespace Metric { class Generic; }
class FactoryMessenger;
namespace Astrobj {
class Generic;
class Properties;
typedef SmartPointer<Gyoto::Astrobj::Generic>
Subcontractor_t(Gyoto::FactoryMessenger*, std::vector<std::string> const &);
template<typename T> SmartPointer<Astrobj::Generic> Subcontractor
(FactoryMessenger* fmp, std::vector<std::string> const &plugin) {
SmartPointer<T> ao = new T();
ao -> plugins(plugin) ;
#ifdef GYOTO_USE_XERCES
if (fmp) ao -> setParameters(fmp);
#endif
return ao;
}
Gyoto::Astrobj::Subcontractor_t* getSubcontractor(std::string name,
std::vector<std::string> &plugin,
int errmode = 0);
extern Gyoto::Register::Entry * Register_;
void initRegister();
void Register(std::string name, Gyoto::Astrobj::Subcontractor_t* scp);
}
}
class Gyoto::Astrobj::Generic
: public Gyoto::SmartPointee,
public Gyoto::Object
{
friend class Gyoto::SmartPointer<Gyoto::Astrobj::Generic>;
// Data :
// -----
private:
int __defaultfeatures;
protected:
SmartPointer<Gyoto::Metric::Generic> gg_;
double rmax_;
double deltamaxinsidermax_;
bool flag_radtransf_;
int shadow_;
int noredshift_;
// Constructors - Destructor
// -------------------------
public:
GYOTO_OBJECT;
Generic();
Generic(double radmax);
Generic(std::string kind);
Generic(const Generic& ) ;
virtual Generic* clone() const = 0 ;
virtual ~Generic() ;
// Accessors
// ---------
public:
virtual SmartPointer<Metric::Generic> metric() const;
virtual void metric(SmartPointer<Metric::Generic>) ;
virtual double rMax();
virtual double rMax() const;
virtual double rMax(std::string const &unit);
virtual double rMax(std::string const &unit) const;
virtual double deltaMax(double coord[8]);
virtual void rMax(double val);
virtual void rMax(double val, std::string const &unit);
GYOTO_OBJECT_ACCESSORS_UNIT(deltaMaxInsideRMax);
void opticallyThin(bool flag);
bool opticallyThin() const ;
void showshadow(bool flag);
bool showshadow() const ;
void redshift(bool flag);
bool redshift() const ;
virtual Gyoto::Quantity_t getDefaultQuantities();
//XML I/O
public:
#ifdef GYOTO_USE_XERCES
virtual void setParameters(FactoryMessenger *fmp);
#endif
// Outputs
// -------
public:
virtual int Impact(Gyoto::Photon* ph, size_t index,
Astrobj::Properties *data=NULL) = 0 ;
virtual void processHitQuantities(Photon * ph, state_t const &coord_ph_hit,
double const * coord_obj_hit, double dt,
Astrobj::Properties* data) const;
virtual void processHitQuantities(Photon* ph, double* coord_ph_hit,
double* coord_obj_hit, double dt,
Astrobj::Properties* data) const = delete ;
virtual double emission(double nu_em, double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL)
const ;
virtual double emission(double nu_em, double dsem, double coord_ph[8],
double coord_obj[8]=NULL)
const = delete;
virtual void emission(double Inu[], double const nu_em[], size_t nbnu,
double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL) const ;
virtual void emission(double Inu[], double nu_em[], size_t nbnu,
double dsem, double coord_ph[8],
double coord_obj[8]=NULL) const = delete ;
virtual void radiativeQ(double Inu[], double Taunu[],
double const nu_em[], size_t nbnu,
double dsem, state_t const &coord_ph,
double const coord_obj[8]=NULL) const ;
virtual void radiativeQ(double Inu[], double Taunu[],
double nu_em[], size_t nbnu,
double dsem, double coord_ph[8],
double coord_obj[8]=NULL) const = delete ;
virtual void radiativeQ(double *Inu, double *Qnu, double *Unu, double *Vnu,
Eigen::Matrix4d *Onu, double const *nuem , size_t nbnu, double dsem,
state_t const &cph, double const *co) const ;
virtual double integrateEmission(double nu1, double nu2, double dsem,
state_t const &c_ph, double const c_obj[8]=NULL) const;
virtual double integrateEmission(double nu1, double nu2, double dsem,
double c_ph[8], double c_obj[8]=NULL) const=delete;
virtual void integrateEmission(double * I, double const * boundaries,
size_t const * chaninds, size_t nbnu,
double dsem, state_t const &cph, double const *co) const;
virtual void integrateEmission(double * I, double const * boundaries,
size_t const * chaninds, size_t nbnu,
double dsem, double *cph, double *co) const = delete;
virtual double transmission(double nuem, double dsem, state_t const &coord_ph, double const coord_obj[8]) const ;
virtual double transmission(double nuem, double dsem, state_t const &coord) const = delete;
virtual double transmission(double nuem, double dsem, double coord[8]) const = delete;
Eigen::Matrix4d Omatrix(double alphanu[4], double rnu[3], double Chi, double dsem) const;
Eigen::Matrix4d Omatrix(double alphaInu, double alphaQnu, double alphaUnu, double alphaVnu,
double rQnu, double rUnu, double rVnu, double Chi, double dsem) const;
Eigen::Matrix4d Omatrix(double alphanu[4], double rnu[3], double sin2Chi, double cos2Chi, double dsem) const;
Eigen::Matrix4d Omatrix(double alphaInu, double alphaQnu, double alphaUnu, double alphaVnu,
double rQnu, double rUnu, double rVnu, double sin2Chi, double cos2Chi, double dsem) const;
Eigen::Matrix4d Pmatrix(double alphaInu, double alphaQnu, double alphaUnu, double alphaVnu,
double rQnu, double rUnu, double rVnu, double sin2Chi, double cos2Chi, double dsem) const;
Eigen::Vector4d rotateJs(double jInu, double jQnu, double jUnu, double jVnu, double sin2Chi, double cos2Chi) const;
Eigen::Vector4d rotateJs(double jInu, double jQnu, double jUnu, double jVnu, double Chi) const;
double getChi(double const fourvect[4], state_t const &cph, double const vel[4], bool elec=false) const;
void getSinCos2Chi(double const fourvect[4], state_t const &cph, double const vel[4], double* sin2Chi, double* cos2Chi, bool elec=false) const;
void computeB4vect(double B4vect[4], std::string const magneticConfig, double const co[8], state_t const &cph) const;
void computeB4vect_ipole(double B4vect[4], std::string const magneticConfig, double const co[8], state_t const &cph, double spin) const;
double interpolate(int const N, double* const array, double* const Xq, double** const X, int* const X_params, std::string const *cond_limits) const;
double interpolate(int const N, double* const array, double* const Xq, double** const X_params, std::string const *cond_limits) const;
private :
double interp1d(double const x, double const y0, double const y1) const;
double interpNd(int const N, double* const Xq, double** const X, double* const Y, std::string const *cond_limit) const;
int getIndice(double &xq, std::string const cond_limit, double const X_params[3], double* const X=NULL) const;
};
class Gyoto::Astrobj::Properties : public Gyoto::SmartPointee {
friend class Gyoto::SmartPointer<Gyoto::Astrobj::Properties>;
public:
double *intensity;
double *time;
double *distance;
double * first_dmin;
int first_dmin_found;
double *redshift;
double *nbcrosseqplane;
double *spectrum;
double *stokesQ;
double *stokesU;
double *stokesV;
double *binspectrum;
ptrdiff_t offset;
double * impactcoords;
double *user1;
double *user2;
double *user3;
double *user4;
double *user5;
# ifdef HAVE_UDUNITS
Gyoto::SmartPointer<Gyoto::Units::Converter> intensity_converter_ ;
Gyoto::SmartPointer<Gyoto::Units::Converter> spectrum_converter_ ;
Gyoto::SmartPointer<Gyoto::Units::Converter> binspectrum_converter_ ;
# endif
bool alloc;
public:
Properties();
Properties (double*, double*);
void init(size_t nbnuobs=0);
Properties& operator++();
Properties& operator+=(ptrdiff_t offset);
operator Gyoto::Quantity_t () const;
# ifdef HAVE_UDUNITS
void intensityConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
void intensityConverter(std::string);
void spectrumConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
void spectrumConverter(std::string);
void binSpectrumConverter(Gyoto::SmartPointer<Gyoto::Units::Converter>);
void binSpectrumConverter(std::string);
# endif
};
#endif
GyotoConfig.h
Compile-time configuration.
GyotoConverters.h
GYOTO converters.
GyotoDefs.h
Gyoto ubiquitous macros and typedefs.
GyotoObject.h
Introspectable objects.
GYOTO_OBJECT
#define GYOTO_OBJECT
Declare class::properties and class::getProperties().
Definition GyotoObject.h:84
GyotoSmartPointer.h
Reference-counting pointers.
Gyoto::Astrobj::Generic
Base class for astronomical object.
Definition GyotoAstrobj.h:200
Gyoto::Astrobj::Generic::interpNd
double interpNd(int const N, double *const Xq, double **const X, double *const Y, std::string const *cond_limit) const
Gyoto::Astrobj::Generic::__defaultfeatures
int __defaultfeatures
Whether some virtual methods are implemented.
Definition GyotoAstrobj.h:215
Gyoto::Astrobj::Generic::transmission
virtual double transmission(double nuem, double dsem, state_t const &coord_ph, double const coord_obj[8]) const
Transmission: exp( αν * dsem ).
Gyoto::Astrobj::Generic::setParameters
virtual void setParameters(FactoryMessenger *fmp)
Main loop in Subcontractor_t function.
Gyoto::Astrobj::Generic::interp1d
double interp1d(double const x, double const y0, double const y1) const
Gyoto::Astrobj::Generic::deltamaxinsidermax_
double deltamaxinsidermax_
Maximum Photon integration step inside rmax_ [geometrical units].
Definition GyotoAstrobj.h:242
Gyoto::Astrobj::Generic::Omatrix
Eigen::Matrix4d Omatrix(double alphanu[4], double rnu[3], double Chi, double dsem) const
Gyoto::Astrobj::Generic::integrateEmission
virtual double integrateEmission(double nu1, double nu2, double dsem, state_t const &c_ph, double const c_obj[8]=NULL) const
∫ν1ν2 Iν dν (or jν)
Gyoto::Astrobj::Generic::getSinCos2Chi
void getSinCos2Chi(double const fourvect[4], state_t const &cph, double const vel[4], double *sin2Chi, double *cos2Chi, bool elec=false) const
Gyoto::Astrobj::Generic::metric
virtual SmartPointer< Metric::Generic > metric() const
Get the Metric gg_.
Gyoto::Astrobj::Generic::flag_radtransf_
bool flag_radtransf_
1 if radiative transfer inside Astrobj, else 0
Definition GyotoAstrobj.h:244
Gyoto::Astrobj::Generic::shadow_
int shadow_
1 to highlight the shadow region in the image
Definition GyotoAstrobj.h:246
Gyoto::Astrobj::Generic::rmax_
double rmax_
Maximum distance to the center of the coordinate system [geometrical units].
Definition GyotoAstrobj.h:234
Gyoto::Astrobj::Generic::computeB4vect
void computeB4vect(double B4vect[4], std::string const magneticConfig, double const co[8], state_t const &cph) const
Gyoto::Astrobj::Generic::Impact
virtual int Impact(Gyoto::Photon *ph, size_t index, Astrobj::Properties *data=NULL)=0
Does a photon at these coordinates impact the object?
Gyoto::Astrobj::Generic::radiativeQ
virtual void radiativeQ(double Inu[], double Taunu[], double const nu_em[], size_t nbnu, double dsem, state_t const &coord_ph, double const coord_obj[8]=NULL) const
emission and transmission together
Gyoto::Astrobj::Generic::interpolate
double interpolate(int const N, double *const array, double *const Xq, double **const X, int *const X_params, std::string const *cond_limits) const
Gyoto::Astrobj::Generic::clone
virtual Generic * clone() const =0
Cloner.
Gyoto::Astrobj::Generic::emission
virtual double emission(double nu_em, double dsem, state_t const &coord_ph, double const coord_obj[8]=NULL) const
Specific intensity Iν.
Gyoto::Astrobj::Generic::Generic
Generic()
Default constructor.
Gyoto::Astrobj::Generic::opticallyThin
void opticallyThin(bool flag)
Set whether the object is optically thin.
Gyoto::Astrobj::Generic::processHitQuantities
virtual void processHitQuantities(Photon *ph, state_t const &coord_ph_hit, double const *coord_obj_hit, double dt, Astrobj::Properties *data) const
Fills Astrobj::Properties.
Gyoto::Astrobj::Generic::deltaMax
virtual double deltaMax(double coord[8])
Get max step constraint for adaptive integration.
Gyoto::Astrobj::Generic::rMax
virtual double rMax()
Get maximal distance from center of coordinate system.
Gyoto::Astrobj::Generic::getIndice
int getIndice(double &xq, std::string const cond_limit, double const X_params[3], double *const X=NULL) const
Gyoto::Astrobj::Generic::getDefaultQuantities
virtual Gyoto::Quantity_t getDefaultQuantities()
Which quantities to compute if know was requested.
Gyoto::Astrobj::Generic::noredshift_
int noredshift_
1 to impose redshift factor g = 1
Definition GyotoAstrobj.h:247
Gyoto::Astrobj::Generic::getChi
double getChi(double const fourvect[4], state_t const &cph, double const vel[4], bool elec=false) const
Gyoto::Astrobj::Generic::rotateJs
Eigen::Vector4d rotateJs(double jInu, double jQnu, double jUnu, double jVnu, double sin2Chi, double cos2Chi) const
Gyoto::Astrobj::Generic::gg_
SmartPointer< Gyoto::Metric::Generic > gg_
The Metric in this end of the Universe.
Definition GyotoAstrobj.h:222
Gyoto::Astrobj::Properties
Observable properties of an Astronomical object.
Definition GyotoAstrobj.h:792
Gyoto::Astrobj::Properties::first_dmin_found
int first_dmin_found
Whether Properties::first_dmin was found.
Definition GyotoAstrobj.h:815
Gyoto::Astrobj::Properties::redshift
double * redshift
GYOTO_QUANTITY_REDSHIFT : RedShift.
Definition GyotoAstrobj.h:821
Gyoto::Astrobj::Properties::binSpectrumConverter
void binSpectrumConverter(Gyoto::SmartPointer< Gyoto::Units::Converter >)
Set Properties::binspectrum_converter_.
Gyoto::Astrobj::Properties::impactcoords
double * impactcoords
GYOTO_QUANTITY_IMPACTCOORDS: ImpactCoords.
Definition GyotoAstrobj.h:853
Gyoto::Astrobj::Properties::binspectrum_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > binspectrum_converter_
Converter between SI (J.m -2.s-1.sr-1) and requested BinSpectrum unit.
Definition GyotoAstrobj.h:896
Gyoto::Astrobj::Properties::intensityConverter
void intensityConverter(Gyoto::SmartPointer< Gyoto::Units::Converter >)
Set Properties::intentity_converter_.
Gyoto::Astrobj::Properties::user5
double * user5
GYOTO_QUANTITY_USER5 : User5 Astrobj-specific quantity.
Definition GyotoAstrobj.h:883
Gyoto::Astrobj::Properties::time
double * time
GYOTO_QUANTITY_EMISSIONTIME: EmissionTime.
Definition GyotoAstrobj.h:796
Gyoto::Astrobj::Properties::alloc
bool alloc
True if buffers are allocated for entire field (npix*npix).
Definition GyotoAstrobj.h:900
Gyoto::Astrobj::Properties::spectrum
double * spectrum
GYOTO_QUANTITY_SPECTRUM : Spectrum.
Definition GyotoAstrobj.h:831
Gyoto::Astrobj::Properties::offset
ptrdiff_t offset
How to jump from one spectral element to the next.
Definition GyotoAstrobj.h:848
Gyoto::Astrobj::Properties::user2
double * user2
GYOTO_QUANTITY_USER2 : User2 Astrobj-specific quantity.
Definition GyotoAstrobj.h:865
Gyoto::Astrobj::Properties::binspectrum
double * binspectrum
GYOTO_QUANTITY_BINSPECTRUM : BinSpectrum.
Definition GyotoAstrobj.h:842
Gyoto::Astrobj::Properties::distance
double * distance
GYOTO_QUANTITY_MIN_DISTANCE: MinDistance.
Definition GyotoAstrobj.h:803
Gyoto::Astrobj::Properties::user4
double * user4
GYOTO_QUANTITY_USER4 : User4 Astrobj-specific quantity.
Definition GyotoAstrobj.h:877
Gyoto::Astrobj::Properties::intensity
double * intensity
GYOTO_QUANTITY_INTENSITY : Intensity.
Definition GyotoAstrobj.h:795
Gyoto::Astrobj::Properties::nbcrosseqplane
double * nbcrosseqplane
GYOTO_QUANTITY_NBCROSSEQPLANE : nuùber of equatorial plane crossings.
Definition GyotoAstrobj.h:826
Gyoto::Astrobj::Properties::init
void init(size_t nbnuobs=0)
Initialize observable quantities.
Gyoto::Astrobj::Properties::user3
double * user3
GYOTO_QUANTITY_USER3 : User3 Astrobj-specific quantity.
Definition GyotoAstrobj.h:871
Gyoto::Astrobj::Properties::spectrumConverter
void spectrumConverter(Gyoto::SmartPointer< Gyoto::Units::Converter >)
Set Properties::spectrum_converter_.
Gyoto::Astrobj::Properties::Properties
Properties()
Default constructor (everything is set to NULL);.
Gyoto::Astrobj::Properties::intensity_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > intensity_converter_
Converter between SI (J.m -2.s-1.sr-1.Hz-1) and requested Intensity unit.
Definition GyotoAstrobj.h:888
Gyoto::Astrobj::Properties::first_dmin
double * first_dmin
GYOTO_QUANTITY_FIRST_DMIN : FirstDmin.
Definition GyotoAstrobj.h:808
Gyoto::Astrobj::Properties::spectrum_converter_
Gyoto::SmartPointer< Gyoto::Units::Converter > spectrum_converter_
Converter between SI (J.m -2.s-1.sr-1.Hz-1) and requested Spectrum unit.
Definition GyotoAstrobj.h:892
Gyoto::Astrobj::Properties::user1
double * user1
GYOTO_QUANTITY_USER1 : User1 Astrobj-specific quantity.
Definition GyotoAstrobj.h:859
Gyoto::FactoryMessenger
Factory / SmartPointee::Subcontractor_t interface.
Definition GyotoFactoryMessenger.h:92
Gyoto::Metric::Generic
Base class for metrics.
Definition GyotoMetric.h:162
Gyoto::Object
Object with properties.
Definition GyotoObject.h:152
Gyoto::Photon
A null geodesic transporting light.
Definition GyotoPhoton.h:57
Gyoto::Register::Entry
Entry in a register (or a full register).
Definition GyotoRegister.h:117
Gyoto::SmartPointee
Can be pointed to by a SmartPointer.
Definition GyotoSmartPointer.h:81
Gyoto::SmartPointer
Pointers performing reference counting.
Definition GyotoSmartPointer.h:135
Gyoto::Astrobj
Access to astronomical objects.
Definition GyotoAstrobj.h:49
Gyoto::Astrobj::Subcontractor_t
SmartPointer< Gyoto::Astrobj::Generic > Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &)
A function to build instances of a specific Astrobj::Generic sub-class.
Definition GyotoAstrobj.h:63
Gyoto::Astrobj::getSubcontractor
Gyoto::Astrobj::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugin, int errmode=0)
Query the Astrobj register.
Gyoto::Astrobj::initRegister
void initRegister()
Empty the Astrobj register.
Gyoto::Astrobj::Subcontractor
SmartPointer< Astrobj::Generic > Subcontractor(FactoryMessenger *fmp, std::vector< std::string > const &plugin)
A template for Subcontractor_t functions.
Definition GyotoAstrobj.h:77
Gyoto::Astrobj::Register
void Register(std::string name, Gyoto::Astrobj::Subcontractor_t *scp)
Make an Astrobj kind known to the Factory.
Gyoto::Astrobj::Register_
Gyoto::Register::Entry * Register_
The Astrobj register.
Gyoto::Metric
Access to metrics.
Definition GyotoAstrobj.h:47
Gyoto::Register
Gyoto registers.
Definition GyotoAstrobj.h:46
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44
Gyoto::Quantity_t
unsigned int Quantity_t
Type for observabke quantities.
Definition GyotoDefs.h:76