Solves the system of ODEs describing the evolution of a single planet around a single star. More...
#include <OrbitSolver.h>
Public Member Functions | |
OrbitSolver (double max_age, double required_precision, bool print_progress=false) | |
Prepare to solve for the orbital evolution. More... | |
void | operator() (BinarySystem &system, double max_step=Core::Inf, const std::list< double > &required_ages=std::list< double >(), double max_runtime=0) |
Actually solves the given differential equation with the given boundary conditions. More... | |
const std::list< double > & | evolution_ages () const |
The ages at which evolution has been tabulated so far. More... | |
const std::list< Core::EvolModeType > & | mode_evolution () const |
The tabulated evolution modes so far. More... | |
~OrbitSolver () | |
Clean up. More... | |
Private Member Functions | |
void | output_history_and_discarded (std::ostream &os) |
Generates a nicely formatted table of the contents of the discarded and history stopping condition information. More... | |
void | clear_discarded () |
Removes all stored discarded stop condition information. More... | |
void | insert_discarded (double age, const std::valarray< double > ¤t_stop_cond, const std::valarray< double > ¤t_stop_deriv) |
Adds an entry in the discarded ages, stop conditions and derivatives. More... | |
void | add_to_evolution (double age, Core::EvolModeType evolution_mode, BinarySystem &system) |
Adds the last step to the evolution. More... | |
double | go_back (double max_age, BinarySystem &system, std::valarray< double > &orbit) |
Rewinds the evlution to the last step before the given age and returns the age of that step. More... | |
void | clear_history () |
Clears the current stopping condition history. More... | |
StopHistoryInterval | select_stop_condition_interval (bool crossing, size_t cond_ind, size_t max_points) const |
Selects a history interval for interpolating to a reason to stop the evolution. More... | |
ExtremumInformation | extremum_from_history_no_deriv (size_t condition_index) const |
Estimates the value and age of an extremum of a stopping condition for which no derivative information is available. More... | |
ExtremumInformation | extremum_from_history (size_t condition_index) const |
Estimates the value and age of an extremum of a stopping condition for which derivative information is available. More... | |
double | crossing_from_history_no_deriv (size_t condition_index) const |
Estimates the age at which a stopping condition with no derivative information crossed zero. More... | |
double | crossing_from_history (size_t condition_index) const |
Estimates the age at which a stopping condition with derivative information crossed zero. More... | |
void | initialize_skip_history (const StoppingCondition &stop_cond, StoppingConditionType stop_reason) |
Initializes the skip_history_zerocrossing and skip_history_extremum arrays appropriately after a mode change. More... | |
bool | at_exact_condition (double previous_age, const StopInformation &stop_info) |
Is the condition causing a stop match to within the required precision? More... | |
bool | acceptable_step (double current_age, double previous_age, const StopInformation &stop_info) |
Updates the skip_history_zerocrossing and skip_history_extremum arrays appropriately after an acceptable step. More... | |
int | check_expansion_error (const std::valarray< double > &derivatives, const std::valarray< double > &expansion_errors) |
Return -1 if the expansion error is too small (e-order can safely be decreased, 0 if it is within range, 1 if it is too big. More... | |
StopInformation | update_stop_condition_history (double age, const std::valarray< double > &orbit, const std::valarray< double > &derivatives, const std::valarray< double > &expansion_errors, Core::EvolModeType evolution_mode, StoppingConditionType stop_reason=NO_STOP, bool ignore_e_order_decrease=false) |
Updates stop_cond_history and stop_deriv_history after a GSL step, returning if/where the evolution needs to stop. More... | |
void | reject_step (double &age, StopInformation &stop, BinarySystem &system, std::valarray< double > &orbit, double &max_next_t, double &step_size, std::string reason) |
Handle the situation when the last step has to be rejected. More... | |
StopInformation | evolve_until (BinarySystem &system, double &max_age, std::valarray< double > &orbit, StoppingConditionType &stop_reason, double max_step, Core::EvolModeType evolution_mode) |
Evolves a system until either some age cut-off is reached or some stopping condition crosses zero. More... | |
CombinedStoppingCondition * | get_stopping_condition (BinarySystem &system) |
Returns the stopping conditions which end the given evolution mode and update __stop_info. More... | |
double | stopping_age (double age, const BinarySystem &system, const std::list< double > &required_ages) |
The age at which the evolution should stop next if no other stopping condition occurs. More... | |
void | reached_stopping_condition (double stop_age, StoppingConditionType stop_reason) |
Handle a stop in the evolution due to at least one condition reaching a critical value. More... | |
void | adjust_eccentricity_order (BinarySystem &system, const std::valarray< double > &orbit, Core::EvolModeType evolution_mode, bool must_increase=false) |
Increase/decrease the eccentricity expansion order until error is acceptable and return the new order. More... | |
void | reset (BinarySystem &system) |
Clears any previously calculated evolution. More... | |
Private Attributes | |
double | __end_age |
The last age for which evolution is required. More... | |
double | __precision |
The precision required of the solution. More... | |
double | __e_order_downgrade_threshold |
If the fractional error due to truncating the eccentricity series falls below this value times the maximum acceptable error, the eccentricity order is downgraded. More... | |
double | __last_e_order_upgrade_age |
The last age at which the eccentricity order was increased. More... | |
std::list< double > | __tabulated_ages |
The ages at which solution is tabulated. More... | |
std::list< Core::EvolModeType > | __tabulated_evolution_modes |
The evolution mode corresponding to the matching tabulated age. More... | |
std::valarray< size_t > | __skip_history_zerocrossing |
The number of points at the start of the history to skip when lookng for a zero crossing for each condition. More... | |
std::valarray< double > | __skip_history_extremum |
The age after which to look for extrema for each condition. More... | |
std::list< double > | __stop_history_ages |
The ages at which the stop condition history is kept. More... | |
std::list< double > | __discarded_stop_ages |
The ages of steps which were discarded becauset they are past a zero or an extremum of a stopping condition . More... | |
std::list< std::valarray< double > > | __orbit_history |
Past orbits. More... | |
std::list< std::valarray< double > > | __orbit_deriv_history |
Past orbital derivatives. More... | |
std::list< std::valarray< double > > | __stop_cond_history |
Past values of the stop conditions. More... | |
std::list< std::valarray< double > > | __stop_deriv_history |
Past values of the stop condition derivatives. More... | |
std::list< std::valarray< double > > | __stop_cond_discarded |
Discarded values of the stop conditions. More... | |
std::list< std::valarray< double > > | __stop_deriv_discarded |
Discarded derivatives of the stop conditions. More... | |
StoppingCondition * | __stopping_conditions |
The current set of stopping conditions. More... | |
std::vector< StopInformation > | __stop_info |
bool | __print_progress |
See print_progress argument of constructor. More... | |
time_t | __evolution_start_time |
When did the currently running evolution start. More... | |
double | __runtime_limit |
Max number of seconds current evolution is allowed to run. More... | |
Solves the system of ODEs describing the evolution of a single planet around a single star.
Definition at line 115 of file OrbitSolver.h.
Evolve::OrbitSolver::OrbitSolver | ( | double | max_age, |
double | required_precision, | ||
bool | print_progress = false |
||
) |
Prepare to solve for the orbital evolution.
max_age | The end age for the evolution. |
required_precision | The precision which to require of the solution. |
print_progress | Should output be created to track the progress in calculating the evolution? |
Definition at line 1387 of file OrbitSolver.cpp.
|
inline |
Clean up.
Definition at line 502 of file OrbitSolver.h.
|
private |
Updates the skip_history_zerocrossing and skip_history_extremum arrays appropriately after an acceptable step.
Return true iff the step with the given stop information is acceptable.
Definition at line 650 of file OrbitSolver.cpp.
|
private |
Adds the last step to the evolution.
age | The age of the evolving stellar system. |
evolution_mode | The evolution mode represented in orbit. |
system | The binary system being evolved. |
Definition at line 158 of file OrbitSolver.cpp.
|
private |
Increase/decrease the eccentricity expansion order until error is acceptable and return the new order.
system | The system being evolved. |
orbit | The current orbital elements. |
evolution_mode | The evolution mode for this part of the evolution. |
must_increase | If true the eccentircity order is increased by at least 1. |
Definition at line 1282 of file OrbitSolver.cpp.
|
private |
Is the condition causing a stop match to within the required precision?
Definition at line 632 of file OrbitSolver.cpp.
|
private |
Return -1 if the expansion error is too small (e-order can safely be decreased, 0 if it is within range, 1 if it is too big.
derivatives | The rates of change of the evolution variables per Gyr. |
expansion_errors | The errors in derivatives, due to the truncated eccentricity series. |
Definition at line 681 of file OrbitSolver.cpp.
|
private |
Removes all stored discarded stop condition information.
Definition at line 135 of file OrbitSolver.cpp.
|
private |
Clears the current stopping condition history.
Definition at line 206 of file OrbitSolver.cpp.
|
private |
Estimates the age at which a stopping condition with derivative information crossed zero.
If no zero-crossing is indicated, Inf is returned.
condition_index | The index of the condition to search. |
Definition at line 532 of file OrbitSolver.cpp.
|
private |
Estimates the age at which a stopping condition with no derivative information crossed zero.
If no zero-crossing is indicated, Inf is returned.
condition_index | The index of the condition to search. |
Definition at line 483 of file OrbitSolver.cpp.
|
inline |
The ages at which evolution has been tabulated so far.
Definition at line 494 of file OrbitSolver.h.
|
private |
Evolves a system until either some age cut-off is reached or some stopping condition crosses zero.
Appends each accepted step to tabulated_ages, tabulated_evolution_mode, tabulated_orbit and tabulated_deriv.
The return value is true if the last step finished after the stopping condition crossed zero and false if it ended before that.
system | The planet-star system to evolve. |
max_age | The age at which to stop this part of the evolution. On exit, it is overwritten with the age of the last accepted step. |
orbit | The initial conditions. The contents depends on the value of evolution_mode. See #BinarySystem.differential equations for details. |
On exit, it is overwritten with the orbit of the last accepted step.
stop_reason | On input should be the reason why the last evolution stopped. It should be NO_STOP if this is the first piece of evolution being calculated. On exit it is overwritten with the value appropriate for the next run. |
max_step | The maximum step that GSL is allowed to take. |
evolution_mode | The evolution mode for this part of the evolution. |
Definition at line 945 of file OrbitSolver.cpp.
|
private |
Estimates the value and age of an extremum of a stopping condition for which derivative information is available.
If no extremum is indicated by the points, or if it is in the wrong direction to cause a zero-crossing, returns the result of the default constructor of ExtremumInformation.
Definition at line 445 of file OrbitSolver.cpp.
|
private |
Estimates the value and age of an extremum of a stopping condition for which no derivative information is available.
If no extremum is indicated by the points, or if it is in the wrong direction to cause a zero-crossing, returns the result of the default constructor of ExtremumInformation.
Definition at line 313 of file OrbitSolver.cpp.
|
private |
Returns the stopping conditions which end the given evolution mode and update __stop_info.
system | The system being evolved. |
Definition at line 1185 of file OrbitSolver.cpp.
|
private |
Rewinds the evlution to the last step before the given age and returns the age of that step.
Sets the orbit to what it was at that step and removes any items from the histories and tabulations that are later than max_age.
Definition at line 168 of file OrbitSolver.cpp.
|
private |
Initializes the skip_history_zerocrossing and skip_history_extremum arrays appropriately after a mode change.
Definition at line 587 of file OrbitSolver.cpp.
|
private |
Adds an entry in the discarded ages, stop conditions and derivatives.
Makes sure the ages remain ordered.
Definition at line 142 of file OrbitSolver.cpp.
|
inline |
The tabulated evolution modes so far.
Definition at line 498 of file OrbitSolver.h.
void Evolve::OrbitSolver::operator() | ( | BinarySystem & | system, |
double | max_step = Core::Inf , |
||
const std::list< double > & | required_ages = std::list<double>() , |
||
double | max_runtime = 0 |
||
) |
Actually solves the given differential equation with the given boundary conditions.
system | The stellar system to calculate the evolution for |
max_step | The maximum size of the time steps allowed (useful if finer sampling of the output than default is necessary). |
required_ages | A sorted list of ages to include in the tabulated evolution. |
max_runtime | The maximum amount of wall-clock time in seconds to allow for calculating the evolution. If it runs out, whatever portion is calculated is preserved. |
Definition at line 1401 of file OrbitSolver.cpp.
|
private |
Generates a nicely formatted table of the contents of the discarded and history stopping condition information.
Only exists if NDEBUG is not #defined.
Definition at line 55 of file OrbitSolver.cpp.
|
private |
Handle a stop in the evolution due to at least one condition reaching a critical value.
Assumes that __stop_info was updated per the last accepted step.
stop_age | The age of the last accepted evolution step. |
stop_reason | The type of condition which caused the stoppage. |
Definition at line 1238 of file OrbitSolver.cpp.
|
private |
Handle the situation when the last step has to be rejected.
age | The age up to which the rejected step reached, on exit gets updated with the last acceptable age found. |
stop | The reason we stopped. If a zero-crossing, the precision is updated. |
system | The binary system being evolved. |
orbit | The current orbit of the system, gets updated with the last acceptable orbit found. |
max_next_t | Gets updated with the maximum age up to which evolution is allowed to proceed. |
step_size | Gets updated with the step size to use for the next step.The reason for rejecting the step. |
Definition at line 893 of file OrbitSolver.cpp.
|
private |
Clears any previously calculated evolution.
Definition at line 1380 of file OrbitSolver.cpp.
|
private |
Selects a history interval for interpolating to a reason to stop the evolution.
Finds the smallest possible interval that contains a zero crossing/or an extremum straddling the history and discarded stop conditions, containing at most the specified number of points (could be less if there are not enough points). The interval is also guaranteed to contain at least one point in the history and one point in the discarded list.
Definition at line 216 of file OrbitSolver.cpp.
|
private |
The age at which the evolution should stop next if no other stopping condition occurs.
age | The age from which the next part of the evolution starts. |
system | The stellar system being evolved. |
required_ages | A sorted list of ages which must be stopped at. |
Definition at line 1203 of file OrbitSolver.cpp.
|
private |
Updates stop_cond_history and stop_deriv_history after a GSL step, returning if/where the evolution needs to stop.
Returns the index of the condition with the closest estimated age for zero crossing or an extremum exists which might have crossed zero.
age | System age in Gyr. |
orbit | The values of the current evolution variables. |
derivatives | The rates of change of the evolution variables per Gyr. |
expansion_errors | The errors in derivatives, due to the truncated eccentricity series. |
evolution_mode | The current evolution mode. |
stop_reason | For the first call of this function for an evolution stretch, this should indicate the reason why the previous stretch was stopped. For subsequent calls during the same evolution stretch it should be NO_STOP. |
ignore_e_order_decrease | If true, ignore indication that eccentricity order should be decreased. |
Definition at line 735 of file OrbitSolver.cpp.
|
private |
The ages of steps which were discarded becauset they are past a zero or an extremum of a stopping condition .
Definition at line 146 of file OrbitSolver.h.
|
private |
If the fractional error due to truncating the eccentricity series falls below this value times the maximum acceptable error, the eccentricity order is downgraded.
Definition at line 119 of file OrbitSolver.h.
|
private |
The last age for which evolution is required.
Definition at line 119 of file OrbitSolver.h.
|
private |
When did the currently running evolution start.
Definition at line 181 of file OrbitSolver.h.
|
private |
The last age at which the eccentricity order was increased.
Definition at line 119 of file OrbitSolver.h.
|
private |
Past orbital derivatives.
Definition at line 153 of file OrbitSolver.h.
|
private |
Past orbits.
Definition at line 153 of file OrbitSolver.h.
|
private |
The precision required of the solution.
Definition at line 119 of file OrbitSolver.h.
|
private |
See print_progress argument of constructor.
Definition at line 178 of file OrbitSolver.h.
|
private |
Max number of seconds current evolution is allowed to run.
Definition at line 184 of file OrbitSolver.h.
|
private |
The age after which to look for extrema for each condition.
Definition at line 143 of file OrbitSolver.h.
|
private |
The number of points at the start of the history to skip when lookng for a zero crossing for each condition.
Definition at line 140 of file OrbitSolver.h.
|
private |
Discarded values of the stop conditions.
Useful for interpolating to zeroes and extrema.
Definition at line 153 of file OrbitSolver.h.
|
private |
Past values of the stop conditions.
Definition at line 153 of file OrbitSolver.h.
|
private |
Discarded derivatives of the stop conditions.
Useful for interpolating to zeroes and extrema.
Definition at line 153 of file OrbitSolver.h.
|
private |
Past values of the stop condition derivatives.
Definition at line 153 of file OrbitSolver.h.
|
private |
The ages at which the stop condition history is kept.
Definition at line 146 of file OrbitSolver.h.
|
private |
The full information about the next age where each stopping condition indicates evolution should be stopped and why.
Definition at line 175 of file OrbitSolver.h.
|
private |
The current set of stopping conditions.
Definition at line 171 of file OrbitSolver.h.
|
private |
The ages at which solution is tabulated.
Definition at line 133 of file OrbitSolver.h.
|
private |
The evolution mode corresponding to the matching tabulated age.
Definition at line 136 of file OrbitSolver.h.