PeTar
N-body code for collisional gravitational systems
ar_perturber.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Common/list.h"
4 #include "Hermite/hermite_particle.h"
5 #include "hard_ptcl.hpp"
6 #include "Common/binary_tree.h"
7 #include "tidal_tensor.hpp"
8 
9 
11 class ARPerturber: public H4::Neighbor<PtclHard>{
12 public:
13  typedef H4::Neighbor<PtclHard> NB;
15  Float soft_pert_min;
16 
17  ARPerturber(): NB(), soft_pert(NULL), soft_pert_min(Float(0.0)) {}
18 
20  void clear() {
21  NB::clear();
22  if (soft_pert!=NULL) {
25  soft_pert = NULL;
26  }
27  }
28 
30  bool checkParams() {
31  ASSERT(NB::checkParams());
32  //ASSERT(soft_pert_min>=0.0);
33  //ASSERT(soft_pert!=NULL);
34  return true;
35  }
36 
38 
46  PS::S32 findCloseSoftPert(TidalTensor* _tt, int& _n_tt, const int _n_max, const H4::ParticleH4<PtclHard>& _cm, const PS::F64 _gid) {
47  ASSERT(_gid>0.0);
48  const PS::F64vec& pos = _cm.pos;
49  PS::F64 r_min2=PS::LARGE_FLOAT;
50  PS::S32 r_min_index=-1;
51  for (int i=0; i<_n_tt; i++) {
52  PS::F64vec dr = pos - _tt[i].pos;
53  PS::F64 r2 = dr*dr;
54  if (r_min2>r2) {
55  r_min_index = i;
56  r_min2 = r2;
57  }
58  }
59  // if the close tt is already used, copy a new one
60  //if (_tt[r_min_index].group_id>=0) {
61  //ASSERT(_n_tt<_n_max);
62 
63  //_tt[_n_tt] = _tt[r_min_index];
64  //soft_pert = &_tt[_n_tt];
65  //_n_tt++;
66  //}
67  if (-_tt[r_min_index].group_id==_gid) {
68  soft_pert = &_tt[r_min_index];
69  soft_pert->group_id = _gid;
70  // update c.m.
71  soft_pert->shiftCM(pos);
72  return r_min_index;
73  }
74  else
75  return -1;
76  }
77 
79 
84  template <class Tptcl>
85  void calcSoftPertMin(const AR::BinaryTree<Tptcl>& _bin, const Float _G) {
86  soft_pert_min = 0.0;
87 #ifdef SOFT_PERT
88  if(soft_pert!=NULL&&_bin.semi>0.0) {
89  ParticleBase p[2];
90  _bin.calcParticlesEcca(p[0], p[1], COMM::PI, _G);
91  Float dacc_soft = 0.0;
92  Float acc_p1[3] = {0.0, 0.0, 0.0};
93  Float acc_p2[3] = {0.0, 0.0, 0.0};
94  soft_pert->eval(acc_p1, p[0].pos);
95  soft_pert->eval(acc_p2, p[1].pos);
96  Float dacc[3] = {acc_p1[0]-acc_p2[0],
97  acc_p1[1]-acc_p2[1],
98  acc_p1[2]-acc_p2[2]};
99  dacc_soft = std::sqrt(dacc[0]*dacc[0] + dacc[1]*dacc[1] + dacc[2]*dacc[2]);
100  Float apo = _bin.semi*(1.0+_bin.ecc);
101  soft_pert_min = _bin.mass*dacc_soft/(_G*apo);
102  }
103 #endif
104  }
105 };
ARPerturber::checkParams
bool checkParams()
check parameters status
Definition: ar_perturber.hpp:30
PIKG::S32
int32_t S32
Definition: pikg_vector.hpp:24
ARPerturber::soft_pert_min
Float soft_pert_min
soft perturbation
Definition: ar_perturber.hpp:15
ParticleBase
Basic particle class.
Definition: particle_base.hpp:20
PIKG::F64vec
Vector3< F64 > F64vec
Definition: pikg_vector.hpp:167
ARPerturber::soft_pert
TidalTensor * soft_pert
Definition: ar_perturber.hpp:14
TidalTensor::group_id
PS::F64 group_id
Definition: tidal_tensor.hpp:14
PIKG::F64
double F64
Definition: pikg_vector.hpp:17
ARPerturber::NB
H4::Neighbor< PtclHard > NB
Definition: ar_perturber.hpp:13
TidalTensor::shiftCM
void shiftCM(const PS::F64vec &_pos)
Shift c.m. to new reference position.
Definition: tidal_tensor.hpp:247
ARPerturber::clear
void clear()
clear function
Definition: ar_perturber.hpp:20
ARPerturber::findCloseSoftPert
PS::S32 findCloseSoftPert(TidalTensor *_tt, int &_n_tt, const int _n_max, const H4::ParticleH4< PtclHard > &_cm, const PS::F64 _gid)
find close tidal tensor and if (-) tensor group id is the same as input, initial tidal tensor c....
Definition: ar_perturber.hpp:46
ARPerturber::calcSoftPertMin
void calcSoftPertMin(const AR::BinaryTree< Tptcl > &_bin, const Float _G)
calculate soft_pert_min for slowdown pert_out
Definition: ar_perturber.hpp:85
ARPerturber::ARPerturber
ARPerturber()
minimum soft perturbation
Definition: ar_perturber.hpp:17
TidalTensor
Tidal tensor perterbation for AR.
Definition: tidal_tensor.hpp:4
TidalTensor::eval
void eval(PS::F64 *acc, const PS::F64vec &pos) const
Definition: tidal_tensor.hpp:289
ARPerturber
Perturber class for AR integration.
Definition: ar_perturber.hpp:11
ASSERT
#define ASSERT(expr)
Definition: hard_assert.hpp:238
hard_ptcl.hpp
tidal_tensor.hpp
TidalTensor::pos
PS::F64vec pos
Definition: tidal_tensor.hpp:13