PeTar
N-body code for collisional gravitational systems
|
Go to the documentation of this file.
7 #define NAN_CHECK(val) assert((val) == (val));
12 enum class BinaryInterruptState:int {
none = 0,
form = 1, type_change = 2, start_roche = 3, end_roche = 4, contact = 5, start_symbiotic = 6, end_symbiotic = 7, common_envelope = 8 , giant = 9,
collision = 10, blue_straggler = 11, no_remain = 12, disrupt = 13, tide = 14};
16 #define BINARY_STATE_ID_SHIFT 4
17 #define BINARY_INTERRUPT_STATE_MASKER 0xF
27 #ifdef STELLAR_EVOLUTION
63 #ifdef STELLAR_EVOLUTION
79 #ifdef STELLAR_EVOLUTION
90 #ifdef STELLAR_EVOLUTION
97 time_record(_time_record), time_interrupt(_time_interrupt), star(_star) {}
104 time_record(_time_record), time_interrupt(_time_interrupt) {}
112 #ifdef STELLAR_EVOLUTION
117 fprintf(
fp,
"%26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %lld %26.17e %26.17e %26.17e %26.17e ",
119 this->pos.x, this->pos.y, this->pos.z,
120 this->vel.x, this->vel.y, this->vel.z,
121 this->binary_state, this->radius, this->dm, this->time_record, this->time_interrupt);
131 PS::S64 rcount=fscanf(
fp,
"%lf %lf %lf %lf %lf %lf %lf %lld %lf %lf %lf %lf",
133 &this->pos.x, &this->pos.y, &this->pos.z,
134 &this->vel.x, &this->vel.y, &this->vel.z,
136 &this->radius, &this->dm, &this->time_record, &this->time_interrupt);
138 std::cerr<<
"Error: Data reading fails! requiring data number is 12, only obtain "<<rcount<<
".\n";
139 std::cerr<<
"Check your input data, whether the consistent features (interrupt mode and external mode) are used in configuring petar and the data generation\n";
151 fprintf(
fp,
"%26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %lld",
153 this->pos.x, this->pos.y, this->pos.z,
154 this->vel.x, this->vel.y, this->vel.z,
162 PS::S64 rcount=fscanf(
fp,
"%lf %lf %lf %lf %lf %lf %lf %lld",
164 &this->pos.x, &this->pos.y, &this->pos.z,
165 &this->vel.x, &this->vel.y, &this->vel.z,
166 &this->binary_state);
168 std::cerr<<
"Error: Data reading fails! requiring data number is 7, only obtain "<<rcount<<
".\n";
169 std::cerr<<
"Check your input data, whether the consistent features (interrupt mode and external mode) are used in configuring petar and the data generation\n";
189 std::cerr<<
"Error: Data reading fails! requiring data number is 1, only obtain "<<rcount<<
".\n";
190 std::cerr<<
"Check your input data, whether the consistent features (interrupt mode and external mode) are used in configuring petar and the data generation\n";
196 void print(std::ostream & fout)
const{
201 #ifdef STELLAR_EVOLUTION
202 fout<<
" radius="<<radius
204 <<
" time_record="<<time_record
205 <<
" time_interrupt="<<time_interrupt;
218 _fout<<std::setw(_width)<<
"mass"
219 <<std::setw(_width)<<
"pos.x"
220 <<std::setw(_width)<<
"pos.y"
221 <<std::setw(_width)<<
"pos.z"
222 <<std::setw(_width)<<
"vel.x"
223 <<std::setw(_width)<<
"vel.y"
224 <<std::setw(_width)<<
"vel.z"
225 <<std::setw(_width)<<
"bin_stat";
226 #ifdef STELLAR_EVOLUTION
227 _fout<<std::setw(_width)<<
"radius"
228 <<std::setw(_width)<<
"dm"
229 <<std::setw(_width)<<
"t_record"
230 <<std::setw(_width)<<
"t_interrupt";
244 int counter = _counter;
246 _fout<<std::setw(_offset)<<
" "<<counter<<
". mass: mass of particle\n";
248 _fout<<std::setw(_offset)<<
" "<<counter<<
"-"<<counter+2<<
". pos.[x/y/z]: 3D position of particle\n";
250 _fout<<std::setw(_offset)<<
" "<<counter<<
"-"<<counter+2<<
". vel.[x/y/z]: 3D velocity of particle\n";
252 _fout<<std::setw(_offset)<<
" "<<counter<<
". bin_stat: binary status storing pair id and status [formatted] (0.0)\n";
253 #ifdef STELLAR_EVOLUTION
255 _fout<<std::setw(_offset)<<
" "<<counter<<
". radius: stellar radius for merger checker (0.0)\n";
257 _fout<<std::setw(_offset)<<
" "<<counter<<
". dm: mass change (0.0)\n";
259 _fout<<std::setw(_offset)<<
" "<<counter<<
". t_record: time record of last check (0.0)\n";
261 _fout<<std::setw(_offset)<<
" "<<counter<<
". t_interrupt: time for next evolution check (0.0)\n";
274 void printColumn(std::ostream & _fout,
const int _width=20)
const{
275 _fout<<std::setw(_width)<<
mass
276 <<std::setw(_width)<<
pos.x
277 <<std::setw(_width)<<
pos.y
278 <<std::setw(_width)<<
pos.z
279 <<std::setw(_width)<<
vel.x
280 <<std::setw(_width)<<
vel.y
281 <<std::setw(_width)<<
vel.z
283 #ifdef STELLAR_EVOLUTION
284 _fout<<std::setw(_width)<<radius
285 <<std::setw(_width)<<dm
286 <<std::setw(_width)<<time_record
287 <<std::setw(_width)<<time_interrupt;
300 template <
class Tpcm>
302 _fout<<std::setw(_width)<<
mass
303 <<std::setw(_width)<<
pos.x + _pcm.pos.x
304 <<std::setw(_width)<<
pos.y + _pcm.pos.y
305 <<std::setw(_width)<<
pos.z + _pcm.pos.z
306 <<std::setw(_width)<<
vel.x + _pcm.vel.x
307 <<std::setw(_width)<<
vel.y + _pcm.vel.y
308 <<std::setw(_width)<<
vel.z + _pcm.vel.z
310 #ifdef STELLAR_EVOLUTION
311 _fout<<std::setw(_width)<<radius
312 <<std::setw(_width)<<dm
313 <<std::setw(_width)<<time_record
314 <<std::setw(_width)<<time_interrupt;
332 #ifdef STELLAR_EVOLUTION
335 time_record = din.time_record;
336 time_interrupt = din.time_interrupt;
371 #ifdef NAN_CHECK_DEBUG
391 #ifdef NAN_CHECK_DEBUG
410 #ifdef NAN_CHECK_DEBUG
void writeBinary(FILE *fp) const
write class data with BINARY format
Definition: particle_base.hpp:178
fp
Definition: galpy_pot_movie.py:131
Basic particle class.
Definition: particle_base.hpp:20
static void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: particle_base.hpp:217
Vector3< F64 > F64vec
Definition: pikg_vector.hpp:167
#define BINARY_STATE_ID_SHIFT
Definition: particle_base.hpp:16
void readBinary(FILE *fp)
read class data with BINARY format
Definition: particle_base.hpp:186
PS::S64 binary_state
Definition: particle_base.hpp:26
BinaryInterruptState
Definition: particle_base.hpp:14
void printColumn(std::ostream &_fout, const int _width=20) const
print data of class members using column style
Definition: bse_interface.h:345
void readAscii(FILE *fp)
read class data with ASCII format
Definition: bse_interface.h:299
ParticleBase()
defaulted constructor
Definition: particle_base.hpp:61
double F64
Definition: pikg_vector.hpp:17
void printColumn(std::ostream &_fout, const int _width=20) const
print data of class members using column style
Definition: particle_base.hpp:274
PS::F64vec pos
Definition: particle_base.hpp:24
int64_t S64
Definition: pikg_vector.hpp:23
void printColumnWithOffset(Tpcm &_pcm, std::ostream &_fout, const int _width=20) const
print data of class members with pos and vel offset using column style
Definition: particle_base.hpp:301
PS::F64vec vel
Definition: particle_base.hpp:25
#define NAN_CHECK(val)
Definition: hard_test.cxx:18
#define BINARY_INTERRUPT_STATE_MASKER
Definition: particle_base.hpp:17
PS::F64 getMass()
Get mass (required for ARC::chain)
Definition: particle_base.hpp:346
void setPos(const PS::F64 x, const PS::F64 y, const PS::F64 z)
Set position (required for ARC::chain)
Definition: particle_base.hpp:370
void setPos(const PS::F64vec &_pos)
Set position (used in soft part)
Definition: particle_base.hpp:382
ParticleBase(const Tp &p)
Definition: particle_base.hpp:72
void setBinaryInterruptState(const BinaryInterruptState _state)
save binary interrupt state in the first BINARY_STATE_ID_SHIFT bit in binary_state
Definition: particle_base.hpp:44
void DataCopy(const Tp &din)
Copy from another ParticleBase.
Definition: particle_base.hpp:327
void initial(double _mass, int _kw=1, double _ospin=0.0, double _epoch=0.0)
Landmark luminosities
Definition: bse_interface.h:276
void setMass(const PS::F64 m)
Set mass (required for ARC::chain)
Definition: particle_base.hpp:409
static void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: bse_interface.h:327
PS::F64 * getPos()
Get position (required for ARC::chain)
Definition: particle_base.hpp:353
BinaryInterruptState getBinaryInterruptState() const
get binary interrupt state from binary_state
Definition: particle_base.hpp:49
PS::F64 mass
Definition: particle_base.hpp:23
void print(std::ostream &fout) const
for print debugging
Definition: particle_base.hpp:196
ParticleBase(const PS::F64 _mass, const PS::F64vec &_pos, const PS::F64vec &_vel)
constructor
Definition: particle_base.hpp:75
void writeAscii(FILE *fp) const
write class data with ASCII format
Definition: bse_interface.h:291
PS::S64 getBinaryPairID() const
get pair ID from binary_state
Definition: particle_base.hpp:54
void writeAscii(FILE *fp) const
write class data with ASCII format
Definition: particle_base.hpp:150
static int printTitleWithMeaning(std::ostream &_fout, const int _counter=0, const int _offset=0)
print column title with meaning (each line for one column)
Definition: particle_base.hpp:243
PS::F64 * getVel()
Get velocity (required for ARC::chain)
Definition: particle_base.hpp:360
void print(std::ostream &fout) const
for print in one line
Definition: bse_interface.h:309
void setBinaryPairID(const PS::S64 _id)
save pair id in binary_state with shift bit size of BINARY_STATE_ID_SHIFT
Definition: particle_base.hpp:39
void readAscii(FILE *fp)
read class data with ASCII format
Definition: particle_base.hpp:161
static int printTitleWithMeaning(std::ostream &_fout, const int _counter=0, const int _offset=0)
print column title with meaning (each line for one column)
Definition: bse_interface.h:364
void setVel(const PS::F64 vx, const PS::F64 vy, const PS::F64 vz)
Set velocity (required for ARC::chain)
Definition: particle_base.hpp:390
void setVel(const PS::F64vec &_vel)
Set velocity.
Definition: particle_base.hpp:403
SSE/BSE based code star parameter for saving.
Definition: bse_interface.h:257