8 #ifndef __BINARY_SYSTEM_H 9 #define __BINARY_SYSTEM_H 11 #include "../Core/SharedLibraryExportMacros.h" 15 #include "../Core/AstronomicalConstants.h" 16 #include "../Core/Common.h" 17 #include "../Core/OrbitalExpressions.h" 18 #include "../Core/Error.h" 19 #include <gsl/gsl_errno.h> 20 #include <gsl/gsl_odeiv2.h> 21 #include <gsl/gsl_siman.h> 64 __semimajor_evolution,
68 __eccentricity_evolution,
76 __eccentricity_rate_evolution;
99 __orbit_power_expansion_error,
107 __orbit_angmom_gain_expansion_error;
136 std::valarray<Eigen::VectorXd> __above_lock_fractions,
140 __above_lock_fractions_inclination_deriv,
148 __above_lock_fractions_inertia_deriv,
152 __above_lock_fractions_angmom_deriv;
165 Eigen::ColPivHouseholderQR<Eigen::MatrixXd>
183 void find_locked_zones();
190 int locked_surface_differential_equations(
192 double *evolution_rates,
205 void locked_surface_jacobian(
207 double *param_derivs,
218 int single_body_differential_equations(
221 double *evolution_rates,
230 void fill_single_body_jacobian(
233 double *inclination_param_derivs,
236 double *periapsis_param_derivs,
240 double *angmom_param_derivs,
244 double *inclination_age_derivs,
248 double *periapsis_age_derivs,
252 double *angmom_age_derivs
260 void single_body_jacobian(
262 double *param_derivs,
279 double semimajor_evolution(
288 double orbit_power_deriv=Core::NaN
295 {
return semimajor_evolution(__orbit_power_expansion_error);}
307 double eccentricity_evolution(
314 double orbit_angmom_gain,
321 double orbit_power_deriv=Core::NaN,
326 double orbit_angmom_gain_deriv=Core::NaN,
330 bool semimajor_deriv=
true 336 double eccentricity_evolution_expansion_error()
const;
340 void above_lock_problem_deriv_correction(
342 Dissipation::QuantityEntry entry,
349 Eigen::MatrixXd &matrix,
362 void calculate_above_lock_fractions(
364 Eigen::VectorXd &fractions,
374 bool body1_deriv=
true 379 Eigen::VectorXd above_lock_fractions_deriv(
382 Dissipation::QuantityEntry entry,
394 void fill_above_lock_fractions_deriv();
402 void update_above_lock_fractions();
408 void fill_orbit_torque_and_power();
415 int binary_differential_equations(
418 double *differential_equations,
433 template<
typename VALUE_TYPE>
434 void add_body_rate_deriv(
442 const Eigen::VectorXd &)
const,
446 std::valarray<VALUE_TYPE> &orbit_rate_deriv,
455 void fill_orbit_power_deriv(
457 std::valarray<double> &orbit_power_deriv
462 void fill_orbit_angmom_gain_deriv(
464 std::valarray<double> &orbit_angmom_gain_deriv
468 void semimajor_jacobian(
471 const std::valarray<double> &orbit_power_deriv,
478 double *param_derivs,
486 void eccentricity_jacobian(
489 const std::valarray<double> &orbit_power_deriv,
493 const std::valarray<double> &orbit_angmom_gain_deriv,
500 double *param_derivs,
509 void angle_evolution_age_deriv(
525 unsigned locked_zone_ind,
538 void angle_evolution_orbit_deriv(
541 Dissipation::QuantityEntry entry,
560 unsigned locked_zone_ind,
570 void fill_orbit_torque_deriv(
574 Dissipation::QuantityEntry entry,
588 std::valarray<Eigen::Vector3d> &orbit_torque_deriv
593 void fill_zone_torque_deriv(
597 Dissipation::QuantityEntry entry,
612 std::valarray<Eigen::Vector3d> &zone_torque_deriv
617 void inclination_evolution_zone_derivs(
621 Dissipation::QuantityEntry entry,
631 double zone_x_torque_above,
635 double zone_x_torque_below,
638 const std::valarray<Eigen::Vector3d> &zone_torque_deriv,
642 const Eigen::Vector3d &orbit_torque,
645 const std::valarray<Eigen::Vector3d> &orbit_torque_deriv,
648 const std::valarray<Eigen::VectorXd> &above_frac_deriv,
658 unsigned locked_zone_ind,
666 void periapsis_evolution_zone_derivs(
668 Dissipation::QuantityEntry entry,
678 double zone_y_torque_above,
682 double zone_y_torque_below,
685 const std::valarray<Eigen::Vector3d> &zone_torque_deriv,
688 double orbit_y_torque,
691 const std::valarray<Eigen::Vector3d> &orbit_torque_deriv,
694 const std::valarray<Eigen::VectorXd> &above_frac_deriv,
704 unsigned locked_zone_ind,
710 void spin_angmom_evolution_zone_derivs(
712 Dissipation::QuantityEntry entry,
722 double zone_z_torque_above,
726 double zone_z_torque_below,
729 const std::valarray<Eigen::Vector3d> &zone_torque_deriv,
732 const std::valarray<Eigen::VectorXd> &above_frac_deriv,
736 unsigned locked_zone_ind,
743 void binary_jacobian(
745 double *param_derivs,
753 void fill_locked_surface_orbit(std::valarray<double> &orbit)
const;
756 void fill_binary_orbit(std::valarray<double> &orbit)
const;
759 void fill_single_orbit(std::valarray<double> &orbit)
const;
773 const std::string &system_name=
"" 782 const std::string
get_name()
const {
return __name;}
785 virtual int configure(
800 const double *spin_angmom,
805 const double *inclination,
810 const double *periapsis,
826 const double *parameters,
833 double age()
const {
return __age;}
843 {
return (__evolution_mode == Core::BINARY
844 ? __body1.number_zones() + __body2.number_zones()
845 : __body1.number_zones());}
849 {
return __body1.number_locked_zones() + __body2.number_locked_zones();}
863 std::valarray<double> &orbit
869 double above_lock_fraction(
871 unsigned locked_zone_index,
881 unsigned deriv_zone_index=0,
885 bool secondary_radius=
false 895 int differential_equations(
925 const double *parameters,
933 double *differential_equations,
938 bool expansion_error=
false 949 const double *parameters,
956 double *param_derivs,
967 int orbital_freq_mult,
974 unsigned short body_index,
990 virtual double minimum_separation(
1002 virtual void secondary_died();
1005 virtual void release_lock(
1008 unsigned locked_zone_index,
1016 virtual void add_to_evolution();
1019 virtual void reset_evolution();
1022 virtual void rewind_evolution(
1037 virtual void reached_critical_age(
double age);
1041 virtual double next_stop_age()
const;
1045 {
return __semimajor_evolution;}
1049 {
return __semimajor_rate_evolution;}
1053 {
return __eccentricity_evolution;}
1057 {
return __eccentricity_rate_evolution;}
1062 unsigned new_e_order
1065 __body1.change_e_order(new_e_order, *
this,
true);
1066 __body2.change_e_order(new_e_order, *
this,
false);
1071 virtual unsigned eccentricity_order()
const;
Eigen::VectorXd __above_lock_fractions_body2_radius_deriv
The derivative of the above lock fractions w.r.t. to the radius of the secondardy.
const std::list< double > & eccentricity_evolution() const
The tabulated evolution of the eccentricity so far.
const std::string get_name() const
Returns the name of the system.
double __semimajor_rate
The current rate at which the semiamjor axis is changing.
const DissipatingBody & primary() const
Returns the primary body in the system (const).
A base class for any body contributing to tidal dissipation.
std::string __name
The name of the binary system (e.g. "HAT-P-20")
double __semimajor
The current semimajor axis.
const std::list< double > & eccentricity_evolution_rate() const
The tabulated evolution of the eccentricity so far.
Orientations of zones of bodies in a binary system.
const std::list< double > & semimajor_evolution() const
The tabulated evolution of the semimajor axis so far.
NUM_DERIVATIVES
The total number of derivatives supported.
double age() const
Returns the present age of the system in Gyr.
unsigned number_locked_zones() const
How many zones on either body are currently locked.
const DissipatingBody & secondary() const
Returns the secondary body in the system (const).
std::list< double > __semimajor_rate_evolution
The rate at which the semimajor axis evolved at each.
DissipatingBody & __body2
The second body in the system.
BinarySystem(DissipatingBody &body1, DissipatingBody &body2, const std::string &system_name="")
Construct a binary system.
std::list< unsigned > __locked_zones
A list of indices of locked zones.
Core::EvolModeType __evolution_mode
The evolution mode from the last call to configure();.
Eigen::ColPivHouseholderQR< Eigen::MatrixXd > __above_lock_fractions_decomp
The matrix that defines the problem to solve for __above_lock_fractions.
Declares a stopping condition class monitoring for the death of the secondary object.
Core::EvolModeType evolution_mode()
The evolution mode of last call to configure().
NO_DERIV
The quantity itself, undifferentiated.
Eigen::Vector3d __orbit_torque_expansion_error
An estiamte of the error in ::__orbit_torque due to truncating the eccentricity series of the tidal p...
Declares the DissipatingBody class.
EvolModeType
The various evolution modes.
double semimajor() const
The current semimajor axis of the system.
const std::list< double > & semimajor_evolution_rate() const
The tabulated evolution of the semimajor axis so far.
virtual void change_e_order(unsigned new_e_order)
Change the eccentricity expansion order for all dissipative zones.
Declares a class for a stopping condition that combines other stopping conditions.
std::valarray< Eigen::VectorXd > __above_lock_fractions_periapsis_deriv
The derivatives of the above lock fractions w.r.t. the periapses of the zones.
A class combining the the outputs of multiple stopping conditions.
unsigned number_zones() const
The total number of zones in both system bodies.
double semimajor_evolution_expansion_error() const
Estimate of the error in the value returned by semimajor_evolution() due to truncating the tidal pote...
double eccentricity() const
The current eccentricity of the system.
Describes a system of two bodies orbiting each other.