1 #define BUILDING_LIBRARY 7 void LagSpinBreakCondition::set_num_subconditions()
13 __powerlaw_index == __zone.__spin_frequency_breaks.size()
15 __num_subconditions = 1;
17 __num_subconditions = 2;
20 double LagSpinBreakCondition::derivative(
double surf_angmom_deriv,
21 double wcritical)
const 25 (__zone.spin_frequency() < 0 ? -1.0 : 1.0)
29 __zone.moment_of_inertia(1)
31 __zone.spin_frequency()
34 (__zone.moment_of_inertia() * wcritical)
38 void LagSpinBreakCondition::fill_locked_derivs(
44 const std::valarray<double> &orbit,
45 const std::valarray<double> &derivatives,
46 std::valarray<double> &stop_deriv
49 assert(evol_mode == Core::BINARY);
50 double deriv_factor = (-1.5 * __zone.spin_frequency()
52 derivatives[0] / orbit[0]);
54 if(__powerlaw_index > 0)
55 stop_deriv[subcond++] = (
58 __zone.__spin_frequency_breaks[__powerlaw_index - 1]
60 if(__powerlaw_index < __zone.__spin_frequency_breaks.size())
61 stop_deriv[subcond] = (
64 __zone.__spin_frequency_breaks[__powerlaw_index]
68 void LagSpinBreakCondition::fill_unlocked_derivs(
70 const std::valarray<double> &,
71 const std::valarray<double> &derivatives,
72 std::valarray<double> &stop_deriv
75 unsigned angmom_index = 1 + __zone_index + 2 * __body.number_zones();
76 if(evol_mode == Core::BINARY)
78 2 * __other_body.number_zones()
82 : (__other_body.number_zones()
84 __other_body.number_locked_zones()))
86 else angmom_index -= 3;
87 assert(angmom_index <= derivatives.size());
89 double surf_angmom_deriv = derivatives[angmom_index];
91 if(__powerlaw_index > 0)
92 stop_deriv[0] = derivative(
94 __zone.__spin_frequency_breaks[__powerlaw_index - 1]
96 if(__powerlaw_index < __zone.__spin_frequency_breaks.size())
97 stop_deriv[1] = derivative(
99 __zone.__spin_frequency_breaks[__powerlaw_index]
103 LagSpinBreakCondition::LagSpinBreakCondition(
105 const DissipatingBody &body,
106 const DissipatingBody &other_body,
112 __other_body(other_body),
114 __zone_index(zone_index),
115 __powerlaw_index(__zone.__spin_index)
120 std::valarray<double> LagSpinBreakCondition::operator()(
122 const std::valarray<double> &orbit,
123 const std::valarray<double> &derivatives,
124 std::valarray<double> &stop_deriv
127 assert(evol_mode != Core::LOCKED_SURFACE_SPIN);
128 assert(__primary || evol_mode == Core::BINARY);
134 fill_locked_derivs(evol_mode, orbit, derivatives, stop_deriv);
136 fill_unlocked_derivs(evol_mode, orbit, derivatives, stop_deriv);
140 unsigned subcond = 0;
142 double critical_frequency =
144 result[subcond++] = (
150 double critical_frequency =
161 void LagSpinBreakCondition::reached(
172 assert(deriv_sign == -1);
176 assert(deriv_sign == 1);
186 short LagSpinBreakCondition::expected_crossing_deriv_sign(
200 std::string LagSpinBreakCondition::describe(
int index)
const 202 std::ostringstream description;
203 description << (__primary ?
"Primary" :
"Secondary")
206 <<
" spin frequency leaving the interval ";
211 description <<
" |Wspin| ";
223 description << std::endl;
224 return description.str();
std::vector< double >::size_type __spin_index
The index within __spin_frequency_powers of the powerlaw now in effect.
struct LIB_PUBLIC BrokenPowerlawPhaseLagZone
Opaque struct to cant to/from Evolve::BrokenPowerlawPhasLagZone.
Orientations of zones of bodies in a binary system.
Declares a stopping condition monitoring for critical spin frequencies.
unsigned __num_subconditions
See num_subcondition().
virtual bool locked(int orbital_frequency_multiplier, int spin_frequency_multiplier) const
Should return true iff the given term is presently locked.
std::vector< double > __spin_frequency_breaks
The locations of the breaks in spin frequency in rad/day.
EvolModeType
The various evolution modes.
Declares the class that provides the phase lag function to DissipatingZone objects.
BrokenPowerlawPhaseLagZone & __zone
The zone being monitored (for more convenient access).
void set_num_subconditions()
Set the appropriate value of __num_subcondition.
std::vector< double >::size_type __powerlaw_index
The index of the currently active powerlaw within __zone.__tidal_frequency_powers.
double spin_frequency() const
The spin frequency of the given zone.