Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
MESAIO.h
Go to the documentation of this file.
1 
9 #ifndef __MESAIO_H
10 #define __MESAIO_H
11 
12 #include "../Core/SharedLibraryExportMacros.h"
13 #include "Interpolator.h"
14 #include "../IO/IOUtil.h"
15 #include "../Core/Common.h"
16 #include "../Core/AstronomicalConstants.h"
17 #include "../Core/Error.h"
18 #include "dirent_hacked.h"
19 #include <iostream>
20 #include <iomanip>
21 #include <fstream>
22 #include <string>
23 #include <cassert>
24 #include <vector>
25 #include <boost/archive/text_oarchive.hpp>
26 #include <boost/archive/text_iarchive.hpp>
27 #include <boost/serialization/base_object.hpp>
28 
29 namespace StellarEvolution {
30 
37  namespace MESA {
38 
40  const double Yprimordial = 0.249;
41 
43  const double Yprotosun = 0.2612;
44 
46  const double Zprotosun = 0.0150;
47 
49  const double Xprotosun = 1.0 - Yprotosun - Zprotosun;
50 
53  LIB_LOCAL double metallicity_from_feh(double feh);
54 
56  //interpolation parameter.
57  LIB_LOCAL double feh_from_metallicity(double metallicity);
58 
60  enum Column {
63 
65  AGE,
66 
69 
72 
75 
78 
81 
84 
88 
92 
93 
96  };
97 
101  class LIB_LOCAL Header {
102  private:
105  std::vector<std::string> __column_names;
106 
109  std::vector<int> __column_numbers;
110 
116  void read_column_numbers(std::istream &track,
117  const std::string &filename, unsigned &line_number);
118 
120  void set_column_names();
121  public:
123  Header(std::ifstream &track, const std::string &filename);
124 
126  int get_column(MESA::Column quantity) const
127  {return __column_numbers[quantity];}
128 
130  const std::vector<int> &get_all_columns() const
131  {return __column_numbers;}
132  };
133 
134 
135 
139  class LIB_LOCAL EvolutionIterator {
140  public:
143  EvolutionIterator() : quantity_iter(NUM_QUANTITIES) {}
144 
146  std::list<double>::iterator mass_iter;
147 
149  std::list<double>::iterator feh_iter;
150 
152  std::list< std::valarray<double> >::iterator age_iter;
153 
155  std::vector< std::list< std::valarray<double> >::iterator >
157 
160  mass_iter(orig.mass_iter),
161  feh_iter(orig.feh_iter),
162  age_iter(orig.age_iter),
163  quantity_iter(orig.quantity_iter)
164  {}
165 
167  EvolutionIterator &operator=(const EvolutionIterator &rhs);
168 
170  EvolutionIterator &operator++();
171 
174  {EvolutionIterator result(*this); ++(*this); return result;}
175 
179  bool operator==(const EvolutionIterator &rhs)
180  {return mass_iter == rhs.mass_iter;}
181 
185  bool operator!=(const EvolutionIterator &rhs)
186  {return !((*this) == rhs);}
187  };
188 
192  class LIB_PUBLIC Interpolator : public StellarEvolution::Interpolator {
193  private:
194 
201  static const std::vector<QuantityID> __column_to_quantity;
202 
205  static const std::vector<double> __default_smoothing;
206 
209  static const std::vector<int> __default_nodes;
210 
214  static const std::vector<bool> __default_vs_log_age;
215 
219  static const std::vector<bool> __default_log_quantity;
220 
222  std::list<double> __mass_list;
223 
225  std::list<double> __feh_list;
226 
228  std::list< std::valarray<double> > __track_ages;
229 
241  std::vector< std::list< std::valarray<double> > >
243 
252  bool parse_model_file_name(const std::string &filename);
253 
255  void sort_last_track_by_age();
256 
258  void read_model_file(const std::string &filename);
259 
260 #ifndef NDEBUG
261  void log_current_age_ranges() const;
263 #endif
264 
267  void get_mass_feh_grid(
270  std::valarray<double> &masses,
271 
274  std::valarray<double> &feh
275  );
276 
279  EvolutionIterator begin();
280 
283  EvolutionIterator end();
284 
286  void move(EvolutionIterator &dest, EvolutionIterator &source);
287 
289  void sort_tracks();
290  public:
294 
297  Interpolator(
299  const std::string &model_directory,
300 
302  unsigned num_threads,
303 
308  const std::vector<double> &smoothing = __default_smoothing,
309 
316  const std::vector<int> &nodes = __default_nodes,
317 
320  const std::vector<bool> &vs_log_age = __default_vs_log_age,
321 
324  const std::vector<bool> &log_quantity =__default_log_quantity
325  );
326 
328  static double default_smoothing(
331  )
332  {return __default_smoothing[quantity];}
333 
335  static const std::vector<double> &default_smoothing()
336  {return __default_smoothing;}
337 
339  static int default_nodes(
342  )
343  {return __default_nodes[quantity];}
344 
346  static const std::vector<int> &default_nodes()
347  {return __default_nodes;}
348 
350  static bool default_vs_log_age(
353  )
354  {return __default_vs_log_age[quantity];}
355 
357  static const std::vector<bool> &default_vs_log_age()
358  {return __default_vs_log_age;}
359 
361  static bool default_log_quantity(
364  )
365  {return __default_log_quantity[quantity];}
366 
369  static const std::vector<bool> &default_log_quantity()
370  {return __default_log_quantity;}
371  };
372 
373  } //End MESA namespace.
374 
375 } //End StellarEvolution namespace.
376 
378 std::ostream &operator<<(std::ostream &os,
380 
381 #endif
The total number of interesting columns.
Definition: MESAIO.h:95
static bool default_vs_log_age(StellarEvolution::QuantityID quantity)
By default is the given quantity interpolated vs log(age)?
Definition: MESAIO.h:350
double metallicity_from_feh(double feh)
Return the metallicity interpolation parameter corresponding to the given [Fe/H] value.
Definition: MESAIO.cpp:28
const double Yprotosun
The Helium fraction with which the Sun formed.
Definition: MESAIO.h:43
std::list< std::valarray< double > >::iterator age_iter
Iterator over the array of ages of the tracks.
Definition: MESAIO.h:152
std::vector< int > __column_numbers
The column numbers of the interesting quantities, indexed by MESA::Column.
Definition: MESAIO.h:109
static const std::vector< bool > & default_vs_log_age()
Return the default vs_log_age argument to pass to constructor.
Definition: MESAIO.h:357
Mass of the radiative core in .
Definition: MESAIO.h:80
static const std::vector< bool > __default_log_quantity
The default selection of interpolation function (quantity vs log(quantity) for each quantity...
Definition: MESAIO.h:219
std::ostream & operator<<(std::ostream &os, StellarEvolution::MESA::Column col)
Civilized output of mesa column names.
Definition: MESAIO.cpp:4
const double Yprimordial
The primordial Helium fraction of the universe.
Definition: MESAIO.h:40
Log10 of the luminosity of the star in .
Definition: MESAIO.h:74
const double Zprotosun
The metal fraction with which the Sun formed.
Definition: MESAIO.h:46
Log10 of the radius of the star in .
Definition: MESAIO.h:68
static const std::vector< bool > & default_log_quantity()
Return the default log_quantity argument to pass to constructor.
Definition: MESAIO.h:369
static const std::vector< bool > __default_vs_log_age
The default selection of interpolation argument (age vs log(age) for each quantity. See StellarEvolution::Interpolator::create_from.
Definition: MESAIO.h:214
const double Xprotosun
The hydrogen fraction with which the Sun formed.
Definition: MESAIO.h:49
The total mass of the star in .
Definition: MESAIO.h:62
static const std::vector< double > & default_smoothing()
Return the default smoothing argument to pass to constructor.
Definition: MESAIO.h:335
EvolutionIterator()
Create an iterator, which must have all its *_iter members set before it can be used.
Definition: MESAIO.h:143
Stellar age in years.
Definition: MESAIO.h:65
A class that interpolates among stellar evolution tracks.
Definition: Interpolator.h:42
Column
Names for the interesting columns in a MESA track.
Definition: MESAIO.h:60
std::list< double > __feh_list
The [Fe/H] values of the available tracks in the order read.
Definition: MESAIO.h:225
std::list< double > __mass_list
The masses of the available tracks in the order read.
Definition: MESAIO.h:222
A stellar evolution interpolator based on the MESA tracks.
Definition: MESAIO.h:192
std::list< std::valarray< double > > __track_ages
The ages at which each track is tabulated.
Definition: MESAIO.h:228
const std::vector< int > & get_all_columns() const
Returns all column numbers at once.
Definition: MESAIO.h:130
EvolutionIterator operator++(int)
Advance all iterators to the next track.
Definition: MESAIO.h:173
A class which parses the header of a MESA evolution track.
Definition: MESAIO.h:101
Moment of inertia of the convective envelope in .
Definition: MESAIO.h:87
static double default_smoothing(StellarEvolution::QuantityID quantity)
The default smoothing argument used for a given quantity.
Definition: MESAIO.h:328
The luminosity of the star in .
Definition: MESAIO.h:77
double feh_from_metallicity(double metallicity)
Return the [Fe/H] value corresponding to the given metallicity.
Definition: MESAIO.cpp:41
static const std::vector< int > & default_nodes()
Return the default nodes argument to pass to constructor.
Definition: MESAIO.h:346
std::list< double >::iterator feh_iter
Iterator over the masses of the tracks.
Definition: MESAIO.h:149
EvolutionIterator(const EvolutionIterator &orig)
Copy orig to *this.
Definition: MESAIO.h:159
std::vector< std::list< std::valarray< double > > > __track_quantities
A structure holding all interesting quantities from the MESA tracks except age.
Definition: MESAIO.h:242
static const std::vector< QuantityID > __column_to_quantity
The value at the indexed from Column is the StellarEvolution::QuantityID to which this column is conv...
Definition: MESAIO.h:201
const int NUM_QUANTITIES
The number of interpolation quantities currentyl supported.
Definition: CInterface.cpp:17
An iterator over the list of extracted tracks.
Definition: MESAIO.h:139
Radius of the radiative core in .
Definition: MESAIO.h:83
The radius of the star in .
Definition: MESAIO.h:71
std::list< double >::iterator mass_iter
Iterator over the masses of the tracks.
Definition: MESAIO.h:146
QuantityID
Defines the quantities tracked by stellar evolution and their order.
bool operator==(const EvolutionIterator &rhs)
Is RHS at the same position as this?
Definition: MESAIO.h:179
std::vector< std::string > __column_names
The names of the columns in the track, indexed by MESA::Column.
Definition: MESAIO.h:105
int get_column(MESA::Column quantity) const
The column number corresponding to the given quantity.
Definition: MESAIO.h:126
std::vector< std::list< std::valarray< double > >::iterator > quantity_iter
Iterators over the arrays of the track quantities.
Definition: MESAIO.h:156
static int default_nodes(StellarEvolution::QuantityID quantity)
The default interpolation nodes used for a given quantity.
Definition: MESAIO.h:339
Moment of inertia of the radiative core in .
Definition: MESAIO.h:91
bool operator!=(const EvolutionIterator &rhs)
Is RHS at a different position than this?
Definition: MESAIO.h:185
static const std::vector< int > __default_nodes
The default number of node to use for each quantity. See StellarEvolution::Interpolator::create_from...
Definition: MESAIO.h:209
static const std::vector< double > __default_smoothing
The default amount of smoothing to use for each quantity. See StellarEvolution::Interpolator::create_...
Definition: MESAIO.h:205
static bool default_log_quantity(StellarEvolution::QuantityID quantity)
By default is the log(given quantity) interpolated?
Definition: MESAIO.h:361
Defines the StellarEvolution class needed for interpolating among stellar evolution tracks...