SlowDown Algorithmic Regularization (SDAR)
Algorithmic Regularization with slowdown method for integrating few-body motions
|
Go to the documentation of this file.
44 const Float* acc1)
const {
45 const Float s0 = acc0[0] * acc0[0] + acc0[1] * acc0[1] + acc0[2] * acc0[2] +
acc0_offset_sq;
46 const Float s1 = acc1[0] * acc1[0] + acc1[1] * acc1[1] + acc1[2] * acc1[2];
50 return eta_2nd * sqrt( s0 / s1 );
64 const Float* acc3)
const {
65 const Float s0 = acc0[0] * acc0[0] + acc0[1] * acc0[1] + acc0[2] * acc0[2] +
acc0_offset_sq;
66 const Float s1 = acc1[0] * acc1[0] + acc1[1] * acc1[1] + acc1[2] * acc1[2];
67 const Float s2 = acc2[0] * acc2[0] + acc2[1] * acc2[1] + acc2[2] * acc2[2];
68 const Float s3 = acc3[0] * acc3[0] + acc3[1] * acc3[1] + acc3[2] * acc3[2];
72 return eta_4th * sqrt( (sqrt(s0*s2) + s1) / (sqrt(s1*s3) + s2) );
75 void print(std::ostream & _fout)
const{
76 _fout<<
"eta_4th : "<<
eta_4th<<std::endl
77 <<
"eta_2nd : "<<
eta_2nd<<std::endl;
86 _fout<<std::setw(_width)<<
"Eta(4th)"
87 <<std::setw(_width)<<
"Eta(2nd)";
96 _fout<<std::setw(_width)<<
eta_4th
104 fwrite(
this,
sizeof(*
this),1,_fp);
111 size_t rcount = fread(
this,
sizeof(*
this),1,_fin);
113 std::cerr<<
"Error: Data reading fails! requiring data number is 1, only obtain "<<rcount<<
".\n";
136 for (
int i=0; i<_pow_index_min; i++) {
137 dt_min_ *=
Float(0.5);
161 ASSERT(dt_max_>dt_min_);
164 if(_time==0.0)
return dt_max_;
167 unsigned long long int bitmap =
to_double(_time/dt_min_);
175 unsigned long long int c=1;
177 while((bitmap&1)==0) {
178 bitmap = (bitmap>>1);
184 return std::min(c*dt_min_,dt_max_);
197 const Float _dt_limit)
const{
198 ASSERT(dt_max_>dt_min_);
199 ASSERT(_dt_limit<=dt_max_);
200 ASSERT(_dt_limit>=dt_min_);
203 Float dt = _dt_limit;
204 while(dt > dt_ref) dt *= 0.5;
207 std::cerr<<
"Error: time step size too small: ("<<dt<<
") < dt_min ("<<dt_min_<<
")!"<<std::endl;
208 DATADUMP(
"hard_dump");
227 const Float _dt_limit)
const {
228 ASSERT(dt_max_>dt_min_);
229 ASSERT(_dt_limit<=dt_max_);
230 ASSERT(_dt_limit>=dt_min_);
233 Float dt = _dt_limit;
234 while(dt > dt_ref) dt *= 0.5;
237 std::cerr<<
"Error: time step size too small: ("<<dt<<
") < dt_min ("<<dt_min_<<
")!"<<std::endl;
238 DATADUMP(
"hard_dump");
244 void print(std::ostream & _fout)
const{
246 _fout<<
"dt_max: "<<dt_max_<<std::endl
247 <<
"dt_min: "<<dt_min_<<std::endl;
257 _fout<<std::setw(_width)<<
"Dt_max"
258 <<std::setw(_width)<<
"Dt_min";
268 _fout<<std::setw(_width)<<dt_max_
269 <<std::setw(_width)<<dt_min_;
276 fwrite(
this,
sizeof(*
this),1,_fp);
283 size_t rcount = fread(
this,
sizeof(*
this),1,_fin);
285 std::cerr<<
"Error: Data reading fails! requiring data number is 1, only obtain "<<rcount<<
".\n";
void setDtRange(const Float _dt_max, const int _pow_index_min)
set dt limit (max and min)
Definition: block_time_step.h:133
Float calcBlockDt4th(const Float *acc0, const Float *acc1, const Float *acc2, const Float *acc3, const Float _dt_limit) const
Calculate 4th order block time step.
Definition: block_time_step.h:223
Float calcDt4th(const Float *acc0, const Float *acc1, const Float *acc2, const Float *acc3) const
calculate 4th order time step
Definition: block_time_step.h:61
void readBinary(FILE *_fin)
read class data to file with binary format
Definition: block_time_step.h:110
void printColumn(std::ostream &_fout, const int _width=20)
print data of class members using column style
Definition: block_time_step.h:95
const Float NUMERIC_FLOAT_MAX
Definition: Float.h:29
Float eta_4th
Definition: block_time_step.h:9
Float calcBlockDt2nd(const Float *_acc0, const Float *_acc1, const Float _dt_limit) const
Calculate 2nd order block time step.
Definition: block_time_step.h:195
TimeStep4th()
acceleration offset to avoid too small step when weak acceleration exist
Definition: block_time_step.h:13
void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: block_time_step.h:255
BlockTimeStep4th()
contructor
Definition: block_time_step.h:126
void readBinary(FILE *_fin)
read class data to file with binary format
Definition: block_time_step.h:282
Float calcNextDtLimit(const Float _time)
calculate the maximum time step limit for next block step based on the input (current) time
Definition: block_time_step.h:160
void calcAcc0OffsetSq(const Float _mass, const Float _r, const Float _G)
calculate a0_offset_sq
Definition: block_time_step.h:31
void writeBinary(FILE *_fp) const
write class data to file with binary format
Definition: block_time_step.h:103
Float getDtMax() const
get maximum time step
Definition: block_time_step.h:144
void print(std::ostream &_fout) const
Definition: block_time_step.h:244
void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: block_time_step.h:85
double Float
Definition: Float.h:25
Definition: block_time_step.h:7
void print(std::ostream &_fout) const
Definition: block_time_step.h:75
Float getDtMin() const
get minimum time step
Definition: block_time_step.h:151
bool checkParams()
check whether parameters values are correct
Definition: block_time_step.h:18
Float calcDt2nd(const Float *acc0, const Float *acc1) const
calculate 2nd order time step
Definition: block_time_step.h:43
Definition: block_time_step.h:120
Definition: ar_information.h:9
void printColumn(std::ostream &_fout, const int _width=20)
print data of class members using column style
Definition: block_time_step.h:266
Float eta_2nd
time step coefficient (outside sqrt) for forth order
Definition: block_time_step.h:10
Float acc0_offset_sq
time step coefficient (outside sqrt) for second order
Definition: block_time_step.h:11
#define to_double(x)
Definition: Float.h:27
void writeBinary(FILE *_fp) const
write class data to file with binary format
Definition: block_time_step.h:275