Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
poet.h
Go to the documentation of this file.
1 #ifndef __POET_H
2 #define __POET_H
3 
12 #include "Core/Common.h"
14 #include "StellarEvoltion/MESAIO.h"
16 #include "BinarySystem/OrbitSolver.h"
17 #include "BinarySystem/EvolvingStar.h"
18 #include "BinarySystem/LockedPlanet.h"
19 #include "BinarySystem/DiskPlanetSystem.h"
20 #include "BinarySystem/ConstSolutionIterator.h"
21 #include "IO/IOColumns.h"
22 #include <argtable2.h>
23 #include <iostream>
24 #include <fstream>
25 #include <sstream>
26 
27 std::vector<std::string>
29 
30 std::string data_directory()
31 {
32  std::string datadir=DATADIR;
33  if(datadir[datadir.size()-1]!='/') datadir+='/';
34  return datadir;
35 }
36 
39 private:
40 
45  std::vector<std::string> __input_column_names,
46 
51 
58 
62 
65  std::vector<double> __defaults;
66 
71  std::vector<double> __default_track_smoothing;
72 
78  std::vector<int> __default_track_nodes;
79 
81  static const std::string __default_outfname,
82 
86 
89 
92 
93  __default_eccentricity_expansion;
94 
96  std::vector<arg_dbl*> __direct_value_options;
97 
100  std::vector<arg_dbl*> __custom_track_smoothing;
101 
104  std::vector<arg_int*> __custom_track_nodes;
105 
108 
111 
115 
116  *__custom_stellar_evolution_format;
117 
120  arg_lit *__start_locked;
121 
123  arg_lit *__use_YREC;
124 
126  arg_file *__input_fname,
127 
130 
134 
137 
141 
142  void *__argtable[InCol::NUM_INPUT_QUANTITIES
143  +
145  +
146  10];
147 
149  std::vector<InCol::InputColumns> __input_file_format;
150 
152  std::vector<OutCol::OutputColumns> __output_file_format;
153 
155  std::vector<CustomStellarEvolution::Columns> __track_format;
156 
158  std::ifstream __input_stream;
159 
161  std::list<char*> __option_help_copies;
162 
165  std::list<double> __required_ages;
166 
169 
172 
175  __need_orbit;
176 
178  char *cstr_copy(const std::ostringstream &stream)
179  {return cstr_copy(stream.str());}
180 
182  char *cstr_copy(const std::string &str);
183 
185  void define_options();
186 
188  void set_defaults();
189 
191  template<typename COL_ID_TYPE>
192  void parse_column_list(
194  const char *columns_str,
195 
197  const std::vector<std::string> column_names,
198 
200  int num_column_names,
201 
204  std::vector<COL_ID_TYPE> &columns,
205 
207  bool allow_noname=false);
208 
219  void postprocess();
220 
222  void cleanup();
223 
226 
230 
234 
237  void init_defaults();
238 
240  void setup();
241 
246 public:
248  CommandLineOptions(int argc, char **argv);
249 
252  double get_real_value(InCol::InputColumns quantity) const;
253 
256  std::istream &input()
257  {if(__input_fname->count) return __input_stream; else return std::cin;}
258 
260  std::string input_filename() const {return __input_fname->filename[0];}
261 
263  std::string output_filename() const {return __output_fname->filename[0];}
264 
267  const char *serialized_stellar_evolution() const
268  {return __serialized_stellar_evolution->filename[0];}
269 
272  const char *eccentricity_expansion() const
273  {return __eccentricity_expansion->filename[0];}
274 
278  bool start_locked() const {return __start_locked->count>0;}
279 
281  bool use_YREC() const {return __use_YREC->count>0;}
282 
284  bool input_from_list() const {return __input_file_format.size();}
285 
287  const std::vector<InCol::InputColumns> &input_file_format() const
288  {return __input_file_format;}
289 
291  const std::vector<OutCol::OutputColumns> &output_file_format() const
292  {return __output_file_format;}
293 
295  const std::list<double> &required_ages() const
296  {return __required_ages;}
297 
301  const std::string custom_stellar_evolution() const
302  {return __custom_stellar_evolution->filename[0];}
303 
305  const std::vector<CustomStellarEvolution::Columns>&
307 
311  const;
312 
316  const;
317 
320  bool need_orbit() const {return __need_orbit;}
321 
323  operator bool() {return __parsed_ok;}
324 
327 };
328 
333 void parse_real_list(
335  const char *values_str,
336 
338  std::list<double> &values);
339 
341 void output_solution(
344  const OrbitSolver &solver,
345 
347  const BinarySystem &system,
348 
350  const std::string &filename,
351 
353  const std::vector<OutCol::OutputColumns> &output_file_format,
354 
357  double start_age,
358 
361  double end_age,
362 
365  double timestep,
366 
369  const std::list<double> &required_ages=std::list<double>());
370 
375  const std::vector<double> &real_parameters,
376 
379  bool start_locked,
380 
382  const std::list<double> &required_ages,
383 
385  const StellarEvolution &stellar_evolution,
386 
388  const std::string &outfname,
389 
391  const std::vector<OutCol::OutputColumns> &output_file_format,
392 
394  bool need_orbit);
395 
398 std::string update_run_parameters(
401  std::vector<double> &real_parameters,
402 
405  bool &start_locked,
406 
408  std::list<double> &required_ages,
409 
411  const std::vector<InCol::InputColumns> &input_format,
412 
414  std::istringstream &line,
415 
417  size_t input_lineno);
418 
420 void run(
422  const CommandLineOptions &options,
423 
425  const StellarEvolution &stellar_evolution);
426 
427 
428 #endif
std::vector< std::string > __track_column_descr
Description of the columns in the input stellar evolution track.
Definition: poet.h:45
void output_solution(const OrbitSolver &solver, const BinarySystem &system, const std::string &filename, const std::vector< OutCol::OutputColumns > &output_file_format, double start_age, double end_age, double timestep, const std::list< double > &required_ages=std::list< double >())
Outputs the solution calculated by the given solver.
void parse_column_list(const char *columns_str, const std::vector< std::string > column_names, int num_column_names, std::vector< COL_ID_TYPE > &columns, bool allow_noname=false)
Parses a comma separated list of column names.
arg_file * __eccentricity_expansion
The name of the file to read eccentricity expansion coefficients from.
Definition: poet.h:126
Defines various astronomical constants.
std::vector< double > __default_track_smoothing
Default smoothing to apply to custom stellar evolution track quantities.
Definition: poet.h:71
void postprocess()
Updates some command line options after parsing and parses column lists.
const char * serialized_stellar_evolution() const
The name of the file to read/write a serialized stellar evolution from/to.
Definition: poet.h:267
arg_str * __input_file_columns
The columns in the input file.
Definition: poet.h:107
std::vector< double > __defaults
The default values for the quantities defining the evolution to calculate.
Definition: poet.h:65
std::ifstream __input_stream
The stream to the input filename if stdin is not being used.
Definition: poet.h:158
std::string update_run_parameters(std::vector< double > &real_parameters, bool &start_locked, std::list< double > &required_ages, const std::vector< InCol::InputColumns > &input_format, std::istringstream &line, size_t input_lineno)
Updates the evolution parameters as indicated on the next line of the input stream and returns filena...
void setup()
Fills in all the static members.
arg_str * __required_ages_option
The comma separated list of ages to include in the tabulated evolution.
Definition: poet.h:107
const std::vector< CustomStellarEvolution::Columns > & custom_track_format() const
A list of the columns in the custom stellar evolution track.
Definition: poet.h:306
void cleanup()
Free all manually allocated memory and close open streams.
std::vector< arg_dbl * > __direct_value_options
The command line options which directly specify a value.
Definition: poet.h:96
double custom_track_smoothing(CustomStellarEvolution::Columns column) const
The smoothing to apply to the given column from the custom stellar evolution track.
Defines the class which implements a custom single track stellar evolution.
void run(const CommandLineOptions &options, const StellarEvolution &stellar_evolution)
Actually calculates the orbital evolutions.
std::vector< CustomStellarEvolution::Columns > __track_format
A list of the columns in the custom stellar evolution track.
Definition: poet.h:155
arg_file * __custom_stellar_evolution
The filename of the custom stellar evolution track.
Definition: poet.h:126
const std::list< double > & required_ages() const
Ages at which the evolution should definitely step.
Definition: poet.h:295
arg_file * __input_fname
The name of the file to read the evolution scenarios from.
Definition: poet.h:126
void set_defaults()
Sets default values to the appropriate options.
std::list< double > __required_ages
The sorted list of ages to make sure are included in the tabulated evolution.
Definition: poet.h:165
const char * eccentricity_expansion() const
The name of the file to read eccentricity expansion coefficients from.
Definition: poet.h:272
static const std::string __default_output_columns
The default output columns.
Definition: poet.h:81
struct LIB_PUBLIC OrbitSolver
Opaque struct to cast to/from Evolve::OrbitSolver.
Definition: CInterface.h:38
std::istream & input()
The stream to read the parameters of the planet-star systems for which to calculate evolution...
Definition: poet.h:256
std::list< char * > __option_help_copies
The copies of the option help strings made when creating the options.
Definition: poet.h:161
double get_real_value(InCol::InputColumns quantity) const
Returns the value of the quantity, if it is not overwritten by the input list.
The number of different input quantities supported.
std::vector< std::string > __input_column_names
The names to use for the input columns in the –input-columns option.
Definition: poet.h:45
void verify_custom_stellar_evolution()
Declares enumerations that define the possible input/outut quantities.
std::vector< InCol::InputColumns > __input_file_format
A list of the columns in the input file.
Definition: poet.h:149
bool input_from_list() const
Are any quantities to be read from a list file?
Definition: poet.h:284
bool __parsed_ok
Did parsing the command line succeed.
Definition: poet.h:168
std::string output_filename() const
The name of the file to output the solution to.
Definition: poet.h:263
static const std::string __default_outfname
The default output filename.
Definition: poet.h:81
InputColumns
Tags for the quantities required to fully specify the system to evolve.
Definition: IOColumns.h:17
bool start_locked() const
Whether the planet should start locked to the star.
Definition: poet.h:278
arg_file * __serialized_stellar_evolution
The name of the file to read pre-serialized stellar evolution from.
Definition: poet.h:126
int custom_track_nodes(CustomStellarEvolution::Columns column) const
The nodes to use for the given column from the custom stellar evolution track.
const std::vector< InCol::InputColumns > & input_file_format() const
List of the columns expected in the input file.
Definition: poet.h:287
const std::string custom_stellar_evolution() const
Definition: poet.h:301
static const std::string __default_track_columns
The default columns in a custom stellar evolution track.
Definition: poet.h:81
arg_file * __output_fname
The name of the file to output the solution to.
Definition: poet.h:126
arg_lit * __start_locked
Definition: poet.h:120
AGE
The derivative w.r.t. age, excluding the dependence through the body&#39;s radius and the moments of iner...
arg_str * __output_file_columns
The columns to write to the output file.
Definition: poet.h:107
std::vector< int > __default_track_nodes
Default numbef or spline nodes for custom stellar evolution track quantities.
Definition: poet.h:78
void parse_real_list(const char *values_str, std::list< double > &values)
Parses a comma separated list of real values.
std::vector< arg_dbl * > __custom_track_smoothing
The command line options which specify the smoothing for custom stellar evolution tracks...
Definition: poet.h:100
Declaration of some general purpose utilities.
void init_defaults()
Fills in default values for all possible real valued input quantities and the smoothing parameters fo...
The number of different input quantities supported.
Definition: IOColumns.h:98
void init_track_column_descriptions_and_units()
Fills is the descriptions of the columns in a custom stellar evolution track in __track_column_descr...
CommandLineOptions(int argc, char **argv)
Parse the command line.
bool __need_orbit
Definition: poet.h:168
std::string input_filename() const
The name of the file to read in the various evolution scenarios.
Definition: poet.h:260
static const std::string __default_serialized_evol
The default filename to read the serialized stellar evoliton from.
Definition: poet.h:81
arg_lit * __use_YREC
Wether we should use the YREC tracks instead of the MESA.
Definition: poet.h:123
std::vector< std::string > __track_column_units
Descriptions of the units expected of the stellar evolution track quantities.
Definition: poet.h:45
char * cstr_copy(const std::ostringstream &stream)
Returns a copy of the c-string content of the stream.
Definition: poet.h:178
void init_output_column_descriptions()
Fills is the descriptions of the output columns in __output_column_descr.
void calculate_evolution(const std::vector< double > &real_parameters, bool start_locked, const std::list< double > &required_ages, const StellarEvolution &stellar_evolution, const std::string &outfname, const std::vector< OutCol::OutputColumns > &output_file_format, bool need_orbit)
Calculates the evolution for a set of parameters.
std::vector< std::string > __output_column_descr
Description of the output columns.
Definition: poet.h:45
const std::vector< OutCol::OutputColumns > & output_file_format() const
The columns to output.
Definition: poet.h:291
std::vector< OutCol::OutputColumns > __output_file_format
A list of the columns in the output file.
Definition: poet.h:152
~CommandLineOptions()
Closes the input filename if it was opened.
Definition: poet.h:326
void init_input_column_names()
Fills in the names of the input columns in __input_column_names.
void define_options()
Defines the command line options.
All command line options can be accessed through members.
Definition: poet.h:38
bool use_YREC() const
Whether to used the YREC tracks instead of the MESA ones.
Definition: poet.h:281
bool __opened_stream
Set to true only if and when the __input_stream is opened.
Definition: poet.h:168
bool need_orbit() const
Definition: poet.h:320
std::vector< arg_int * > __custom_track_nodes
The command line options which specify the number of nodes to use if a custom track quantity is to be...
Definition: poet.h:104