25 #ifndef __GyotoWorldline_H_ 26 #define __GyotoWorldline_H_ 35 #ifdef GYOTO_HAVE_BOOST_INTEGRATORS 36 # include <functional> 38 # include <boost/numeric/odeint/stepper/controlled_step_result.hpp> 43 class FactoryMessenger;
58 #define GYOTO_WORLDLINE_PROPERTIES(c) \ 59 Gyoto::Property("Gyoto::Worldline", "Time-like or null geodesic."), \ 60 GYOTO_PROPERTY_BOOL(c, Integ31, Integ4D, _integ31, \ 61 "Whether to integrate the 3+1 or 4D equation of geodesics.") \ 62 GYOTO_PROPERTY_BOOL(c, HighOrderImages, PrimaryOnly, _secondary, \ 63 "Whether to stop Photon integration at 180° deflection.") \ 64 GYOTO_PROPERTY_BOOL(c, ParallelTransport, NoParallelTransport, _parallelTransport, \ 65 "Whether to perform parallel transport of a local triad (used for polarization).") \ 66 GYOTO_PROPERTY_DOUBLE(c, MaxCrossEqplane, _maxCrossEqplane, \ 67 "Maximum number of crossings of the equatorial plane allowed for this worldline") \ 68 GYOTO_PROPERTY_DOUBLE(c, RelTol, _relTol, \ 69 "Relative tolerance for the adaptive step integrators.") \ 70 GYOTO_PROPERTY_DOUBLE(c, AbsTol, _absTol, \ 71 "Absolute tolerance for the adaptive step integrators.") \ 72 GYOTO_PROPERTY_DOUBLE(c, DeltaMaxOverR, _deltaMaxOverR, \ 73 "Maximum value of step/distance from center of mass.") \ 74 GYOTO_PROPERTY_DOUBLE(c, DeltaMax, _deltaMax, "Maximum step (geometrical units).") \ 75 GYOTO_PROPERTY_DOUBLE(c, DeltaMin, _deltaMin, "Minimum step (geometrical units).") \ 76 GYOTO_PROPERTY_STRING(c, Integrator, _integrator, \ 77 "Name of integrator (\"runge_kutta_fehlberg78\").") \ 78 GYOTO_PROPERTY_SIZE_T(c, MaxIter, _maxiter, \ 79 "Maximum number of integration steps.") \ 80 GYOTO_PROPERTY_BOOL(c, Adaptive, NonAdaptive, _adaptive, \ 81 "Whether to use an adaptive step.") \ 82 GYOTO_PROPERTY_DOUBLE_UNIT(c, MinimumTime, _tMin, \ 83 "Do not integrate earlier than this date (geometrical_time).") \ 84 GYOTO_PROPERTY_DOUBLE_UNIT(c, Delta, _delta, \ 85 "Initial integration step (geometrical units).") \ 86 GYOTO_PROPERTY_VECTOR_DOUBLE(c, InitCoord, _initCoord, \ 87 "Initial 8-coordinate.") \ 88 GYOTO_PROPERTY_METRIC(c, Metric, _metric, \ 89 "The geometry of space-time at this end of the Universe.") 106 #define GYOTO_WORLDLINE_ACCESSORS(c) \ 107 void c::_integ31(bool s) {integ31(s);} \ 108 bool c::_integ31() const {return integ31();} \ 109 void c::_secondary(bool s) {secondary(s);} \ 110 bool c::_secondary() const {return secondary();} \ 111 void c::_parallelTransport(bool s) {parallelTransport(s);} \ 112 bool c::_parallelTransport() const {return parallelTransport();} \ 113 void c::_adaptive(bool s) {adaptive(s);} \ 114 bool c::_adaptive() const {return adaptive();} \ 115 void c::_maxCrossEqplane(double max){maxCrossEqplane(max);} \ 116 double c::_maxCrossEqplane()const{return maxCrossEqplane();} \ 117 void c::_relTol(double f){relTol(f);} \ 118 double c::_relTol()const{return relTol();} \ 119 void c::_absTol(double f){absTol(f);} \ 120 double c::_absTol()const{return absTol();} \ 121 void c::_deltaMin(double f){deltaMin(f);} \ 122 double c::_deltaMin()const{return deltaMin();} \ 123 void c::_deltaMax(double f){deltaMax(f);} \ 124 double c::_deltaMax()const{return deltaMax();} \ 125 void c::_deltaMaxOverR(double f){deltaMaxOverR(f);} \ 126 double c::_deltaMaxOverR()const{return deltaMaxOverR();} \ 127 void c::_delta(double f){delta(f);} \ 128 double c::_delta()const{return delta();} \ 129 void c::_delta(double f, std::string const &u){delta(f, u);} \ 130 double c::_delta(std::string const &u)const{return delta(u);} \ 131 void c::_tMin(double f){tMin(f);} \ 132 double c::_tMin()const{return tMin();} \ 133 void c::_tMin(double f, std::string const &u){tMin(f, u);} \ 134 double c::_tMin(std::string const &u)const{return tMin(u);} \ 135 void c::_maxiter(size_t f){maxiter(f);} \ 136 size_t c::_maxiter()const{return maxiter();} \ 137 void c::_integrator(std::string const &f){integrator(f);} \ 138 std::string c::_integrator() const {return integrator();} \ 139 std::vector<double> c::_initCoord()const{return initCoord();} \ 140 void c::_initCoord(std::vector<double> const &f){initCoord(f);} \ 141 void c::_metric(SmartPointer<Metric::Generic>f){metric(f);} \ 142 SmartPointer<Metric::Generic> c::_metric() const{return metric();} 151 #define GYOTO_WORLDLINE_PROPERTY_END(c, a) \ 152 GYOTO_WORLDLINE_PROPERTIES(c) \ 153 GYOTO_PROPERTY_END(c, a) \ 154 GYOTO_WORLDLINE_ACCESSORS(c) 164 #define GYOTO_WORLDLINE \ 165 void _delta(const double delta); \ 166 void _delta(double, const std::string &unit); \ 167 double _delta() const ; \ 168 double _delta(const std::string &unit) const ; \ 169 void _tMin(const double tmin); \ 170 void _tMin(double, const std::string &unit); \ 171 double _tMin() const ; \ 172 double _tMin(const std::string &unit) const ; \ 173 void _adaptive (bool mode) ; \ 174 bool _adaptive () const ; \ 175 void _secondary (bool sec) ; \ 176 bool _secondary () const ; \ 177 void _integ31 (bool sec) ; \ 178 bool _integ31 () const ; \ 179 void _parallelTransport (bool sec) ; \ 180 bool _parallelTransport () const ; \ 181 void _maxiter (size_t miter) ; \ 182 size_t _maxiter () const ; \ 183 void _integrator(std::string const & type); \ 184 std::string _integrator() const ; \ 185 double _deltaMin() const; \ 186 void _deltaMin(double h1); \ 187 void _absTol(double); \ 188 double _absTol()const; \ 189 void _maxCrossEqplane(double); \ 190 double _maxCrossEqplane()const; \ 191 void _relTol(double); \ 192 double _relTol()const; \ 193 void _deltaMax(double h1); \ 194 double _deltaMax()const; \ 195 double _deltaMaxOverR() const; \ 196 void _deltaMaxOverR(double t); \ 197 std::vector<double> _initCoord()const; \ 198 void _initCoord(std::vector<double> const&f); \ 199 void _metric(SmartPointer<Metric::Generic>); \ 200 SmartPointer<Metric::Generic> _metric() const; 396 size_t getI0()
const;
398 virtual double getMass()
const = 0;
402 void initCoord(std::vector<double>
const&);
403 std::vector<double> initCoord()
const;
427 virtual void setInitCoord(
const double coord[8],
int dir,
428 double const Ephi[4],
429 double const Etheta[4]);
450 virtual void setInitCoord(
const double coord[8],
int dir = 0);
459 virtual void setInitCoord(
double const pos[4],
double const vel[3],
int dir=0);
534 virtual double deltaMax(
double const pos[8],
double delta_max_external)
const;
568 virtual size_t xExpand(
int dir);
577 virtual void xExpand(
double * &x,
int dir);
599 void delta(
double,
const std::string &unit);
600 double delta()
const ;
601 double delta(
const std::string &unit)
const ;
602 double tMin()
const ;
603 double tMin(
const std::string &unit)
const ;
604 void tMin(
double tlim);
605 void tMin(
double,
const std::string &unit);
624 double const *
getCst()
const ;
635 void setCst(
double const * cst,
size_t const ncsts) ;
667 const double coord[8],
669 double const Ephi[4],
double const Etheta[4]) ;
680 const double coord[8],
695 void getCoord(
size_t index, Gyoto::state_t &dest)
const;
701 void getCoord(
size_t index, Gyoto::state_t &dest) ;
708 void getCoord(
double date, Gyoto::state_t &dest,
bool proper=
false);
713 virtual void xStore(
size_t ind, state_t
const &coord,
double tau) ;
714 virtual void xStore(
size_t ind, state_t
const &coord) =
delete;
715 virtual void xStore(
size_t ind,
double const coord[8]) =
delete;
716 virtual void xFill(
double tlim,
bool proper=
false) ;
731 void get_t(
double *dest)
const;
736 void get_tau(
double *dest)
const;
755 void getCartesian(
double const *
const dates,
size_t const n_dates,
756 double *
const x,
double *
const y,
757 double *
const z,
double *
const xprime=NULL,
758 double *
const yprime=NULL,
double *
const zprime=NULL) ;
763 void get_xyz(
double* x,
double *y,
double *z)
const;
796 void getCoord(
double const *
const dates,
size_t const n_dates,
797 double *
const x1dest,
798 double *
const x2dest,
double *
const x3dest,
799 double *
const x0dot=NULL,
double *
const x1dot=NULL,
800 double *
const x2dot=NULL,
double *
const x3dot=NULL,
801 double * ep0=NULL,
double * ep1=NULL,
double * ep2=NULL,
double * ep3=NULL,
802 double * et0=NULL,
double * et1=NULL,
double * et2=NULL,
double * et3=NULL,
803 double * otime=NULL,
bool proper=
false) ;
811 void getCoord(
double *x0,
double *x1,
double *x2,
double *x3)
const ;
831 void get_dot(
double *x0dot,
double *x1dot,
double *x2dot,
double *x3dot)
const ;
836 void get_prime(
double *x1prime,
double *x2prime,
double *x3prime)
const ;
842 void save_txyz(
char * fichierxyz)
const ;
843 void save_txyz(
char*
const filename,
double const t1,
double const mass_sun,
853 #ifdef GYOTO_HAVE_BOOST_INTEGRATORS 865 #ifndef GYOTO_SWIGIMPORTED 919 virtual void
init(Worldline * line, const state_t &coord, const double delta);
921 virtual void
init(Worldline * line, const double *coord, const double delta) = delete;
944 virtual std::string
kind()=0;
958 virtual int
nextStep(state_t &coord, double &tau, double h1max=GYOTO_DEFAULT_DELTA_MAX)=0;
960 virtual int
nextStep(double *coord, double h1max=GYOTO_DEFAULT_DELTA_MAX) = delete;
972 virtual void
doStep(state_t const &coordin,
974 state_t &coordout)=0;
976 virtual void
doStep(double const coordin[8],
978 double coordout[8]) = delete;
1004 Legacy(Worldline *parent);
1007 void
init(Worldline * line, const state_t &coord, const double delta);
1008 virtual std::string
kind();
1010 virtual int
nextStep(state_t &coord, double &tau, double h1max=1e6);
1012 virtual void
doStep(state_t const &coordin,
1019 #ifdef GYOTO_HAVE_BOOST_INTEGRATORS 1036 enum
Kind {runge_kutta_cash_karp54,
1037 runge_kutta_fehlberg78,
1039 runge_kutta_cash_karp54_classic };
1044 typedef std::function<boost::numeric::odeint::controlled_step_result
1045 (state_t&,
double&,
double&)> try_step_t;
1046 typedef std::function<void(state_t&, double)> do_step_t;
1047 typedef std::function<void(
const state_t &,
1049 const double )> system_t;
1075 virtual void init();
1077 virtual int nextStep(state_t &coord,
double &tau,
double h1max=1e6);
1078 virtual void doStep(state_t
const &coordin,
1081 virtual std::string
kind();
double delta_max_over_r_
Numerical tuning parameter.
Definition: GyotoWorldline.h:341
double maxCrossEqplane() const
Get maxCrossEqplane_.
double * init_vel_
Hack in setParameters()
Definition: GyotoWorldline.h:309
void getSkyPos(SmartPointer< Screen > screen, double *dalpha, double *ddellta, double *dD) const
Get computed positions in sky coordinates.
size_t get_nelements() const
Get number of computed dates.
void reset()
Forget integration, keeping initial contition.
void integ31(bool integ)
Defines the kind of geodesic equation to integrate (3+1, 4D)
virtual void setPosition(double const pos[4])
Set initial 4-position.
double deltaMax() const
Get delta_max_.
double maxCrossEqplane_
Maximum number of crossings of equatorial plane.
Definition: GyotoWorldline.h:367
Timelike or null geodesics.
Definition: GyotoWorldline.h:238
SmartPointer< Gyoto::Metric::Generic > metric_
The Gyoto::Metric in this part of the universe.
Definition: GyotoWorldline.h:248
double delta_
Initial integrating step.
Definition: GyotoWorldline.h:292
void get_tau(double *dest) const
Get computed proper times or values of the affine parameter.
virtual void xFill(double tlim, bool proper=false)
Fill x0, x1... by integrating the Worldline from previously set inittial condition to time tlim...
void save_txyz(char *fichierxyz) const
Save in a file.
Tellers tell Listeners when they mutate.
virtual void xStore(size_t ind, state_t const &coord, double tau)
Store coord at index ind.
bool parallel_transport_
Whether to parallel-transport base vectors.
Definition: GyotoWorldline.h:884
Reference-counting pointers.
virtual std::string className_l() const
"worldline"
Boost integrator.
Definition: GyotoWorldline.h:1030
do_step_t do_step_
Stepper used by the non-adaptive-step integrator.
Definition: GyotoWorldline.h:1055
void setInitialCondition(SmartPointer< Metric::Generic > gg, const double coord[8], const int dir, double const Ephi[4], double const Etheta[4])
Set or re-set the initial condition prior to integration.
void reInit()
Reset and recompute particle properties.
double tmin_
Time limit for the integration (geometrical units)
Definition: GyotoWorldline.h:304
Kind
Enum to represent the integrator flavour.
Definition: GyotoWorldline.h:1036
double delta_min_
Minimum integration step for the adaptive integrator.
Definition: GyotoWorldline.h:319
double * tau_
proper time or affine parameter
Definition: GyotoWorldline.h:249
size_t getImax() const
Get imax_.
virtual void eExpand(int dir)
virtual void checkNorm(double coord[8])
Check norm.
double * cst_
Worldline's csts of motion (if any)
Definition: GyotoWorldline.h:306
double * et1_
Coordinate of Second base vector to parallel transport.
Definition: GyotoWorldline.h:263
double relTol() const
Get reltol_.
double delta() const
Get delta_.
void getInitialCoord(std::vector< double > &dest) const
Get initial coordinates + base vectors.
void getCartesian(double const *const dates, size_t const n_dates, double *const x, double *const y, double *const z, double *const xprime=NULL, double *const yprime=NULL, double *const zprime=NULL)
Get the 6 Cartesian coordinates for specific dates.
virtual int nextStep(state_t &coord, double &tau, double h1max=GYOTO_DEFAULT_DELTA_MAX)=0
Make one step.
bool adaptive_
Whether to use an adaptive step.
Definition: GyotoWorldline.h:883
virtual void tell(Gyoto::Hook::Teller *)
This is how a Teller tells.
bool secondary() const
Get secondary_.
Gyoto::SmartPointer< Gyoto::Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoWorldline.h:891
double * et2_
Coordinate of Second base vector to parallel transport.
Definition: GyotoWorldline.h:264
void get_xyz(double *x, double *y, double *z) const
Get 3-position in cartesian coordinates for computed dates.
size_t i0_
Index of initial condition in array.
Definition: GyotoWorldline.h:268
void getCartesianPos(size_t index, double dest[4]) const
Get Cartesian expression of 4-position at index.
Obsolete: Home-brewed integrator.
Definition: GyotoWorldline.h:995
double tMin() const
Get tmin_.
double const * getCst() const
Returns the worldline's cst of motion (if any)
Gyoto ubiquitous macros and typedefs.
Base class for metric description.
SmartPointer< Worldline::IntegState::Generic > state_
An object to hold the integration state.
Definition: GyotoWorldline.h:862
size_t x_size_
Coordinate of Second base vector to parallel transport.
Definition: GyotoWorldline.h:266
double * x0_
t or T
Definition: GyotoWorldline.h:250
bool adaptive_
Whether integration should use adaptive delta.
Definition: GyotoWorldline.h:270
bool integ31() const
Get the kind of geodesic equation integrated by state_.
double * ep3_
Coordinate of first base vector to parallel transport.
Definition: GyotoWorldline.h:261
size_t getImin() const
Get imin_.
size_t maxiter() const
Get maxiter_.
double * x2_
θ or y
Definition: GyotoWorldline.h:252
double * x3dot_
φdot or zdot
Definition: GyotoWorldline.h:257
double * x0dot_
tdot or Tdot
Definition: GyotoWorldline.h:254
bool parallel_transport_
Whether to parallel transport a local triad.
Definition: GyotoWorldline.h:285
Definition: GyotoWorldline.h:849
double norm_
Current norm of the 4-velocity.
Definition: GyotoWorldline.h:885
double reltol_
Absolute tolerance of the integrator.
Definition: GyotoWorldline.h:359
double normref_
Definition: GyotoWorldline.h:886
double deltaMaxOverR() const
Get delta_max_over_r_.
double * et3_
Coordinate of Second base vector to parallel transport.
Definition: GyotoWorldline.h:265
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
virtual double getMass() const =0
Get mass of particule.
virtual Generic * clone(Worldline *newparent) const =0
Deep copy.
virtual void init()
Cache whatever needs to be cached.
virtual void doStep(state_t const &coordin, double step, state_t &coordout)=0
Make one step of exactly this size.
virtual void eAllocate()
Allocate ep0_ ... et3_.
void get_t(double *dest) const
Get computed dates.
double * ep1_
Coordinate of first base vector to parallel transport.
Definition: GyotoWorldline.h:259
bool adaptive() const
Get adaptive_.
void checkPhiTheta(double coord[8]) const
Bring θ in [0,Π] and φ in [0,2Π].
double deltaMin() const
Get delta_min_.
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:80
bool secondary_
Experimental: choose 0 to compute only primary image.
Definition: GyotoWorldline.h:277
try_step_t try_step_
Stepper used by the adaptive-step integrator.
Definition: GyotoWorldline.h:1052
I might listen to a Teller.
Definition: GyotoHooks.h:64
void get_prime(double *x1prime, double *x2prime, double *x3prime) const
Get computed 3-velocities.
bool parallelTransport() const
Get parallel_transport_.
std::vector< double > constantsOfMotion() const
Return a copy of the Metric-specific constants of motion.
virtual std::string kind()=0
Return the integrator kind.
bool integ_31_
Whether to integrate the 3+1 equation of geodesics instead of the 4D one.
Definition: GyotoWorldline.h:881
virtual ~Worldline()
Destructor.
double delta_
Integration step (current in case of adaptive_).
Definition: GyotoWorldline.h:882
double * x3_
φ or z
Definition: GyotoWorldline.h:253
void getCoord(size_t index, Gyoto::state_t &dest) const
Get coordinates+base vectors corresponding to index.
double * ep2_
Coordinate of first base vector to parallel transport.
Definition: GyotoWorldline.h:260
virtual std::string className() const
"Worldline"
size_t cst_n_
Number of constants of motion.
Definition: GyotoWorldline.h:307
size_t imin_
Minimum index for which x0_, x1_... have been computed.
Definition: GyotoWorldline.h:267
double * x1dot_
rdot or xdot
Definition: GyotoWorldline.h:255
double abstol_
Absolute tolerance of the integrator.
Definition: GyotoWorldline.h:350
size_t getI0() const
Get i0_.
virtual size_t xExpand(int dir)
Expand x0, x1 etc... to hold more elements.
Current state of a geodesic integration.
Definition: GyotoWorldline.h:870
virtual void setVelocity(double const vel[3])
Set initial 3-velocity.
Kind kind_
Integrator flavour.
Definition: GyotoWorldline.h:1042
Description of the observer screen.
virtual void setInitCoord(const double coord[8], int dir, double const Ephi[4], double const Etheta[4])
Set Initial coordinate.
SmartPointer< Metric::Generic > metric() const
Get metric.
virtual void eDeallocate()
Deallocate ep0_ ... et3_.
Worldline * line_
Worldline that we are integrating.
Definition: GyotoWorldline.h:879
double delta_max_
Maximum integration step for the adaptive integrator.
Definition: GyotoWorldline.h:328
double * et0_
Coordinate of first base vector to parallel transport.
Definition: GyotoWorldline.h:262
int wait_pos_
Hack in setParameters()
Definition: GyotoWorldline.h:308
std::string integrator() const
Describe the integrator used by state_.
virtual void xAllocate()
Allocate x0, x1 etc. with default size.
double * x2dot_
θdot or ydot
Definition: GyotoWorldline.h:256
Listen to me and I'll warn you when I change.
Definition: GyotoHooks.h:82
void get_dot(double *x0dot, double *x1dot, double *x2dot, double *x3dot) const
Get computed 4-velocities.
double * x1_
r or x
Definition: GyotoWorldline.h:251
int stopcond
Whether and why integration is finished.
Definition: GyotoWorldline.h:245
void setCst(double const *cst, size_t const ncsts)
Set Metric-specific constants of motion.
size_t maxiter_
Maximum number of iterations when integrating.
Definition: GyotoWorldline.h:310
Worldline()
Default constructor.
double absTol() const
Get abstol_.
size_t imax_
Maximum index for which x0_, x1_... have been computed.
Definition: GyotoWorldline.h:269