2 #include "Common/binary_tree.h"
8 typedef COMM::BinaryTree<Tptcl,COMM::Binary>
BinTree;
9 typedef COMM::Binary
Bin;
33 const bool is_cm_in_first) {
35 PS::F64 fac = 1.0 - 2.0*_bin_in.ecc/3.0 * (1.0 - 0.5*_bin_in.ecc*_bin_in.ecc)
36 - 0.3*std::cos(_incline)*(1.0 - 0.5*_bin_in.ecc + 2.0*std::cos(_incline)*(1.0 - 2.5*std::pow(_bin_in.ecc,1.5) - std::cos(_incline)));
50 PS::F64 q = 1.52*std::pow(std::sqrt(_t_crit/_bin_out.period)/(1.0 - _bin_out.ecc),1.0/6.0)*std::pow(fac*g,1.0/3.0);
52 PS::F64 peri_out = _bin_out.semi * (_bin_out.ecc + 1.0);
53 PS::F64 rp = peri_out/_bin_in.semi;
72 #ifdef STABLE_CHECK_DEBUG_PRINT
73 std::cerr<<
"STAB2: semi="<<_bin.semi
77 <<
" period="<<_bin.period
78 <<
" apo="<<_bin.semi*(1.0+_bin.ecc)
79 <<
" pec="<<_bin.semi*(1.0-_bin.ecc)
85 #ifdef STABLE_CHECK_DEBUG_PRINT
86 std::cerr<<
"STAB2 reject: Hyperbolic"<<std::endl;
92 PS::F64 apo = _bin.semi*(1.0+_bin.ecc);
94 if (apo<_r_crit&&_bin.period<_t_crit) {
95 #ifdef STABLE_CHECK_DEBUG_PRINT
96 std::cerr<<
"STAB2 accept: Stable"<<std::endl;
101 #ifdef STABLE_CHECK_DEBUG_PRINT
102 std::cerr<<
"STAB2 reject: Stable but too large orbit, apo: "<<apo<<
" ecc: "<<_bin.ecc<<
" r_crit: "<<_r_crit
103 <<
" period: "<<_bin.period<<
" t_crit: "<<_t_crit<<std::endl;
125 const PS::F64 _is_cm_in_first) {
126 #ifdef STABLE_CHECK_DEBUG_PRINT
127 std::cerr<<
"STAB3 bout semi="<<_bout.semi
131 <<
" period="<<_bout.period
132 <<
" apo="<<_bout.semi*(1.0+_bout.ecc)
133 <<
" pec="<<_bout.semi*(1.0-_bout.ecc)
134 <<
" bin semi="<<_bin.semi
138 <<
" period="<<_bin.period
139 <<
" apo="<<_bin.semi*(1.0+_bin.ecc)
140 <<
" pec="<<_bin.semi*(1.0-_bin.ecc)
145 #ifdef STABLE_CHECK_DEBUG_PRINT
146 std::cerr<<
"STAB3 reject: Unstable, Outer body hyperbolic, semi_out: "<<_bout.semi<<std::endl;
150 PS::F64 apo_out=_bout.semi*(1.0+_bout.ecc);
153 if(apo_out>_r_crit) {
154 #ifdef STABLE_CHECK_DEBUG_PRINT
155 std::cerr<<
"STAB3 reject: Too large outer orbit, apo_out: "<<apo_out<<
" r_crit: "<<_r_crit<<std::endl;
161 if(_bout.period>_t_crit) {
162 #ifdef STABLE_CHECK_DEBUG_PRINT
163 std::cerr<<
"STAB3 reject: Too large outer period, period_out: "<<_bout.period<<
" t_crit: "<<_t_crit<<std::endl;
170 PS::F64 incline=std::acos(
std::min(1.0, _bout.am*_bin.am/std::sqrt((_bout.am*_bout.am)*(_bin.am*_bin.am))));
174 #ifdef STABLE_CHECK_DEBUG_PRINT
175 std::cerr<<
"STAB3 reject: Unstable, stab3: "<<stab3<<std::endl;
181 #ifdef STABLE_CHECK_DEBUG_PRINT
182 std::cerr<<
"STAB3 accept: Stable, stab3: "<<stab3<<
" period_in: "<<_bin.period<<
" period_out: "<<_bout.period<<std::endl;
209 #ifdef STABLE_CHECK_DEBUG_PRINT
210 std::cerr<<
"STAB4 bout semi="<<_bout.semi
214 <<
" period="<<_bout.period
215 <<
" apo="<<_bout.semi*(1.0+_bout.ecc)
216 <<
" pec="<<_bout.semi*(1.0-_bout.ecc)
217 <<
" bin1 semi="<<_bin1.semi
221 <<
" period="<<_bin1.period
222 <<
" apo="<<_bin1.semi*(1.0+_bin1.ecc)
223 <<
" pec="<<_bin1.semi*(1.0-_bin1.ecc)
224 <<
" bin2 semi="<<_bin2.semi
228 <<
" period="<<_bin2.period
229 <<
" apo="<<_bin2.semi*(1.0+_bin2.ecc)
230 <<
" pec="<<_bin2.semi*(1.0-_bin2.ecc)
235 #ifdef STABLE_CHECK_DEBUG_PRINT
236 std::cerr<<
"STAB4 reject: Unstable, Outer body hyperbolic, semi_out: "<<_bout.semi<<std::endl;
241 PS::F64 apo_out=_bout.semi*(1.0+_bout.ecc);
248 if(apo_out>_r_crit) {
249 #ifdef STABLE_CHECK_DEBUG_PRINT
250 std::cerr<<
"STAB4 reject: Unstable, Too large outer orbit, apo_out: "<<apo_out<<
" r_crit: "<<_r_crit<<std::endl;
256 if(_bout.period>_t_crit) {
257 #ifdef STABLE_CHECK_DEBUG_PRINT
258 std::cerr<<
"STAB4 reject: Too large outer period, period_out: "<<_bout.period<<
" t_crit: "<<_t_crit<<std::endl;
265 PS::F64 incl1=std::acos(
std::min(1.0, _bout.am*_bin1.am/std::sqrt((_bout.am*_bout.am)*(_bin1.am*_bin1.am))));
266 PS::F64 incl2=std::acos(
std::min(1.0, _bout.am*_bin2.am/std::sqrt((_bout.am*_bout.am)*(_bin2.am*_bin2.am))));
269 if(stab3_1>0.8||stab3_2>0.8) {
271 #ifdef STABLE_CHECK_DEBUG_PRINT
272 std::cerr<<
"STAB4 reject: Unstable, stab3_1: "<<stab3_1<<
" stab3_2: "<<stab3_2<<std::endl;
278 #ifdef STABLE_CHECK_DEBUG_PRINT
279 std::cerr<<
"STAB4 accept: Stable, stab3_1: "<<stab3_1<<
" stab3_2: "<<stab3_2<<std::endl;
293 if (_stab_res1==0||_stab_res2==0) {
300 PS::F64 apo = _bin.semi*(1+_bin.ecc);
301 bool stab_flag = (apo>0.0 && apo<=_bin.getRGroup());
303 if (_stab_res1==1&&_stab_res2==1) {
304 if (stab_flag)
return 1;
312 if (_stab_res1==-1&&_stab_res2==1) {
313 if (stab_flag)
return 1;
319 if (_stab_res2==-1&&_stab_res1==1) {
320 if (stab_flag)
return 1;
327 #ifdef STABLE_CHECK_DEBUG
328 assert(_stab_res1==-1&&_stab_res2==-1);
330 if (stab_flag)
return 1;
353 if (_stab_res1==1&&_stab_res2==1) {
363 if (_stab_res1==0||_stab_res2==0) {
370 if (_stab_res1==-1&&_stab_res2==1) {
378 if (_stab_res2==-1&&_stab_res1==1) {
387 #ifdef STABLE_CHECK_DEBUG
388 assert(_stab_res1==-1&&_stab_res2==-1);