This class collects all the Frames of an integration, sampled at a fixed sample_period. More...
#include <orsa_universe.h>
Public Member Functions | |
Evolution () | |
Evolution (const Evolution &) | |
This copy constructor copies the parameters, not the frames! | |
virtual | ~Evolution () |
virtual unsigned int | size () const |
virtual void | push_back (const Frame &f) |
virtual reference | operator[] (size_type n) |
virtual const_reference | operator[] (size_type n) const |
virtual void | clear () |
virtual iterator | begin () |
virtual iterator | end () |
virtual iterator | erase (iterator position) |
virtual const_iterator | begin () const |
virtual const_iterator | end () const |
void | Integrate (const UniverseTypeAwareTime &time_stop, const bool save_last_anyway=false) |
void | Integrate (const Frame &, const UniverseTypeAwareTime &, const UniverseTypeAwareTime &) |
virtual void | step_done (const UniverseTypeAwareTime &, const UniverseTypeAwareTime &, const UniverseTypeAwareTimeStep &, const Frame &, bool &continue_integration) |
virtual void | integration_started () |
virtual void | integration_finished () |
void | SetMaxUnsavedSubSteps (unsigned int m) |
void | SetIntegrator (const IntegratorType) |
void | SetIntegrator (const Integrator *) |
const Integrator * | GetIntegrator () const |
void | SetIntegratorTimeStep (const UniverseTypeAwareTimeStep) |
const UniverseTypeAwareTimeStep & | GetIntegratorTimeStep () const |
void | SetIntegratorAccuracy (const double) |
double | GetIntegratorAccuracy () const |
void | SetInteraction (const InteractionType) |
void | SetInteraction (const Interaction *) |
const Interaction * | GetInteraction () const |
void | SetSamplePeriod (const UniverseTypeAwareTimeStep &) |
const UniverseTypeAwareTimeStep & | GetSamplePeriod () const |
bool | integrating () const |
virtual void | stop_integration () const |
unsigned int | Id () const |
Public Attributes | |
std::vector< BodyWithEpoch > | start_bodies |
std::vector< JPL_planets > | start_JPL_bodies |
std::string | name |
This class collects all the Frames of an integration, sampled at a fixed sample_period.
Definition at line 40 of file orsa_universe.h.
Evolution | ( | ) |
Definition at line 145 of file orsa_universe.cc.
References orsa::FromUnits(), and orsa::YEAR.
00145 : std::vector<Frame>(), id(used_evolution_id++) { 00146 /* 00147 if (universe->GetUniverseType() == Real) { 00148 sample_period = FromUnits(1,DAY); 00149 } else { 00150 sample_period = FromUnits(0.01,YEAR); 00151 } 00152 */ 00153 sample_period = FromUnits(0.01,YEAR); 00154 integrator = 0; 00155 interaction = 0; 00156 max_unsaved_substeps_active = false; 00157 _integrating=false; 00158 }
This copy constructor copies the parameters, not the frames!
Definition at line 161 of file orsa_universe.cc.
References Interaction::clone(), and Integrator::clone().
00161 : std::vector<Frame>(), id(used_evolution_id++) { 00162 sample_period = e.sample_period; 00163 integrator = e.integrator->clone(); 00164 interaction = e.interaction->clone(); 00165 // 00166 max_unsaved_substeps_active = false; 00167 _integrating=false; 00168 }
~Evolution | ( | ) | [virtual] |
Definition at line 170 of file orsa_universe.cc.
virtual const_iterator begin | ( | ) | const [inline, virtual] |
Definition at line 62 of file orsa_universe.h.
References Evolution::begin().
00062 { return std::vector<Frame>::begin(); }
virtual iterator begin | ( | ) | [inline, virtual] |
Definition at line 58 of file orsa_universe.h.
Referenced by Evolution::begin(), and Evolution::Integrate().
00058 { return std::vector<Frame>::begin(); }
virtual void clear | ( | ) | [inline, virtual] |
Definition at line 51 of file orsa_universe.h.
Referenced by Evolution::Integrate(), and orsa::StartFrame().
00051 { std::vector<Frame>::clear(); }
virtual const_iterator end | ( | ) | const [inline, virtual] |
Definition at line 63 of file orsa_universe.h.
References Evolution::end().
00063 { return std::vector<Frame>::end(); }
virtual iterator end | ( | ) | [inline, virtual] |
Definition at line 59 of file orsa_universe.h.
Referenced by Evolution::end(), and Evolution::Integrate().
00059 { return std::vector<Frame>::end(); }
virtual iterator erase | ( | iterator | position | ) | [inline, virtual] |
Definition at line 60 of file orsa_universe.h.
00060 { return std::vector<Frame>::erase(position); }
const Integrator* GetIntegrator | ( | ) | const [inline] |
Definition at line 101 of file orsa_universe.h.
double GetIntegratorAccuracy | ( | ) | const |
Definition at line 198 of file orsa_universe.cc.
References Integrator::accuracy.
const UniverseTypeAwareTimeStep & GetIntegratorTimeStep | ( | ) | const |
Definition at line 190 of file orsa_universe.cc.
References Integrator::timestep.
const Interaction* GetInteraction | ( | ) | const [inline] |
Definition at line 111 of file orsa_universe.h.
const UniverseTypeAwareTimeStep& GetSamplePeriod | ( | ) | const [inline] |
Definition at line 114 of file orsa_universe.h.
unsigned int Id | ( | ) | const [inline] |
Definition at line 137 of file orsa_universe.h.
void Integrate | ( | const Frame & | f, | |
const UniverseTypeAwareTime & | utat_start, | |||
const UniverseTypeAwareTime & | utat_stop | |||
) |
Definition at line 532 of file orsa_universe.cc.
References Evolution::begin(), Evolution::clear(), Evolution::end(), orsa::FromUnits(), Evolution::Integrate(), Evolution::push_back(), Evolution::size(), and orsa::YEAR.
00532 { 00533 00534 // clear Evolution 00535 clear(); 00536 00537 UniverseTypeAwareTime t_start = utat_start; 00538 UniverseTypeAwareTime t_stop = utat_stop; 00539 00540 if (utat_start > utat_stop) { 00541 t_start = utat_stop; 00542 t_stop = utat_start; 00543 } 00544 00545 const UniverseTypeAwareTimeStep saved_sample_period = sample_period; 00546 const UniverseTypeAwareTimeStep huge_sample_period = FromUnits(1e3,YEAR); 00547 00548 Frame running_frame; 00549 00550 if (t_start < f) { 00551 if (t_stop < f) { 00552 push_back(f); 00553 sample_period = huge_sample_period; 00554 Integrate(t_stop,true); 00555 running_frame = (*this)[size()-1]; 00556 clear(); 00557 push_back(running_frame); 00558 sample_period = saved_sample_period; 00559 Integrate(t_start); 00560 } else { 00561 push_back(f); 00562 Integrate(t_start); 00563 // swap 00564 (*this)[0] = (*this)[size()-1]; 00565 (*this)[size()-1] = f; 00566 // 00567 Integrate(t_stop); 00568 } 00569 } else { 00570 push_back(f); 00571 sample_period = huge_sample_period; 00572 Integrate(t_start,true); 00573 running_frame = (*this)[size()-1]; 00574 clear(); 00575 push_back(running_frame); 00576 sample_period = saved_sample_period; 00577 Integrate(t_stop); 00578 } 00579 00580 std::sort(begin(),end()); 00581 }
void Integrate | ( | const UniverseTypeAwareTime & | time_stop, | |
const bool | save_last_anyway = false | |||
) |
Definition at line 215 of file orsa_universe.cc.
References UniverseTypeAwareTimeStep::absolute(), Frame::ForceJPLEphemerisData(), UniverseTypeAwareTime::GetDate(), Date::GetDayFraction(), UniverseTypeAwareTimeStep::GetDouble(), Date::GetGregor(), Universe::GetUniverseType(), Evolution::integration_finished(), Evolution::integration_started(), Interaction::IsSkippingJPLPlanets(), UniverseTypeAwareTimeStep::IsZero(), ORSA_DEBUG, ORSA_ERROR, ORSA_WARNING, Evolution::push_back(), orsa::Real, orsa::Simulated, Evolution::size(), Integrator::Step(), Evolution::step_done(), UniverseTypeAwareTime::Time(), Integrator::timestep, and orsa::universe.
Referenced by Evolution::Integrate(), OptimizedOrbitPositions::PropagatedOrbit(), and orsa::StartFrame().
00215 { 00216 00217 if (integrator==0) { 00218 ORSA_WARNING("Integrator not initialized"); 00219 return; 00220 } 00221 00222 if (interaction==0) { 00223 ORSA_WARNING("Interaction not initialized!"); 00224 return; 00225 } 00226 00227 integration_started(); 00228 00229 // FIXME: if the timestep is not set? 00230 // if (sample_period == 0) sample_period = integrator->timestep; 00231 if (sample_period.IsZero()) sample_period = integrator->timestep; 00232 sample_period = sample_period.absolute(); 00233 00234 if (size() == 0) { 00235 ORSA_ERROR("no starting frame in integration."); 00236 return; 00237 } 00238 00239 Frame f_start = (*this)[size()-1]; 00240 Frame f_stop = f_start; 00241 00242 if (f_start == time_stop) { 00243 // no integration needed... 00244 return; 00245 } 00246 00247 const double time_start = f_start.Time(); 00248 00249 bool save_frame = false; 00250 00251 bool continue_integration = true; 00252 00253 // double sign; 00254 int sign; 00255 00256 // if ((time_stop.Time()-f_stop.Time()) > 0) { 00257 if ((time_stop - f_stop) > 0) { 00258 // integrator->timestep = fabs(integrator->timestep); 00259 integrator->timestep = integrator->timestep.absolute(); 00260 sign = +1; 00261 } else { 00262 // integrator->timestep = -fabs(integrator->timestep); 00263 integrator->timestep = -integrator->timestep.absolute(); 00264 sign = -1; 00265 } 00266 00267 // important init value! 00268 UniverseTypeAwareTimeStep last_genuine_timestep; 00269 if (integrator->timestep.absolute() > 0.0) { 00270 last_genuine_timestep = integrator->timestep; 00271 } else { 00272 last_genuine_timestep = time_stop - f_start; 00273 } 00274 00275 unsigned int unsaved_substeps = 0; 00276 unsigned int total_substeps = 0; 00277 00278 while ( (continue_integration) && (((time_stop.Time()-f_stop.Time())/(time_stop.Time()-time_start)) > 0) ) { 00279 00280 f_start = f_stop; 00281 00282 /* 00283 fprintf(stderr, 00284 "========================== \n" 00285 "f_start.Time() : %20.12e \n" 00286 "integrator->timestep : %20.12e \n" 00287 "(*this)[size()-1].Time() : %20.12e \n" 00288 "sample_period : %20.12e \n" 00289 "frames : %zi \n" 00290 "========================== \n", 00291 f_start.Time(),integrator->timestep,(*this)[size()-1].Time(),sample_period,size() 00292 ); 00293 */ 00294 00295 if (0) { 00296 ORSA_DEBUG( 00297 "\n" 00298 "========================== \n" 00299 "f_start.Time() : %20.12e \n" 00300 "time_stop.Time() : %20.12e \n" 00301 "integrator->timestep : %20.12e \n" 00302 "(*this)[size()-1].Time() : %20.12e \n" 00303 "sample_period : %20.12e \n" 00304 "frames : %zi \n" 00305 "========================== \n", 00306 f_start.Time(),time_stop.Time(),integrator->timestep.GetDouble(), 00307 (*this)[size()-1].Time(),sample_period.GetDouble(),size()); 00308 // 00309 if (universe->GetUniverseType() == Real) { 00310 int y,m,d; 00311 double frac; 00312 // 00313 f_start.GetDate().GetGregor(y,m,d); 00314 frac = f_start.GetDate().GetDayFraction(); 00315 ORSA_ERROR( 00316 "f_start date: %i/%02i/%013.10f", 00317 y,m,d+frac); 00318 // 00319 time_stop.GetDate().GetGregor(y,m,d); 00320 frac = time_stop.GetDate().GetDayFraction(); 00321 ORSA_ERROR( 00322 "time_stop date: %i/%02i/%013.10f", 00323 y,m,d+frac); 00324 } 00325 } 00326 00327 if (integrator->timestep.IsZero()) integrator->timestep = last_genuine_timestep; 00328 00329 // if ( fabs(f_start.Time() + integrator->timestep - (*this)[size()-1].Time()) > sample_period) { 00330 // if ( (f_start + integrator->timestep - (*this)[size()-1]).absolute() > sample_period) { 00331 if ( (f_start - (*this)[size()-1] + integrator->timestep).absolute() > sample_period) { 00332 if (integrator->timestep > 0.0) last_genuine_timestep = integrator->timestep; 00333 // integrator->timestep = (*this)[size()-1].Time() + sign*sample_period - f_start.Time(); 00334 integrator->timestep = (*this)[size()-1] - f_start + sign*sample_period; 00335 /* 00336 fprintf(stderr, 00337 "timestep changed: from %.20e to %.20e val: %.20e sp: %.20e\n", 00338 last_genuine_timestep.GetDouble(), 00339 integrator->timestep.GetDouble(), 00340 (f_start + integrator->timestep - (*this)[size()-1]).absolute().GetDouble(), 00341 sample_period.GetDouble()); 00342 */ 00343 } 00344 00345 // cerr << "timestep (tmp): " << integrator->timestep.GetDouble() << endl; 00346 00347 if (integrator->timestep > 0) { 00348 // cerr << "timestep > 0 !!!" << endl; 00349 // if ( (f_start.Time()+integrator->timestep) > (time_stop.Time()) ) { 00350 if ( (f_start+integrator->timestep) > time_stop) { 00351 // integrator->timestep = time_stop.Time() - f_start.Time(); 00352 if (integrator->timestep > 0.0) last_genuine_timestep = integrator->timestep; 00353 integrator->timestep = time_stop - f_start; 00354 } 00355 } else if (integrator->timestep < 0) { 00356 // cerr << "timestep < 0 !!!" << endl; 00357 // if ( (f_start.Time()+integrator->timestep) < (time_stop.Time()) ) { 00358 if ( (f_start+integrator->timestep) < time_stop) { 00359 // integrator->timestep = time_stop.Time() - f_start.Time(); 00360 if (integrator->timestep > 0.0) last_genuine_timestep = integrator->timestep; 00361 integrator->timestep = time_stop - f_start; 00362 } 00363 } else { 00364 ORSA_WARNING("Timestep equal to zero!"); 00365 // timestep == 0... 00366 } 00367 00368 // cerr << "timestep (tmp-II): " << integrator->timestep.GetDouble() << endl; 00369 00370 /* 00371 if (f_start == time_stop) { 00372 return; 00373 } 00374 */ 00375 00376 // debug 00377 /* 00378 if (integrator->timestep.absolute().GetDouble() < FromUnits(1.0,SECOND)) { 00379 ORSA_ERROR("timestep smaller than 1.0 seconds!"); 00380 // sleep(1.0); 00381 } 00382 */ 00383 00384 // step 00385 if (integrator->timestep.IsZero()) { 00386 ORSA_ERROR("zero timestep, no integrator->Step() call..."); 00387 f_stop = f_start; 00388 } else { 00389 integrator->Step(f_start,f_stop,interaction); 00390 if (f_start.Time() != f_stop.Time()) { 00391 ++total_substeps; 00392 } 00393 } 00394 00395 if (0) { 00396 if (universe->GetUniverseType() == Real) { 00397 int y,m,d; 00398 double frac; 00399 // 00400 f_stop.GetDate().GetGregor(y,m,d); 00401 frac = f_stop.GetDate().GetDayFraction(); 00402 ORSA_ERROR( 00403 "f_stop date: %i/%02i/%013.10f", 00404 y,m,d+frac); 00405 } 00406 } 00407 00408 /* 00409 { 00410 // debug 00411 fprintf(stderr,"..after step: %g\n",((f_stop - (*this)[size()-1]).absolute() - sample_period).absolute().GetDouble()); 00412 fprintf(stderr,"....timestep: %g\n",integrator->timestep.GetDouble()); 00413 fprintf(stderr,"....time....: %g\n",f_stop.Time()); 00414 } 00415 */ 00416 00417 /* 00418 { 00419 // debug 00420 fprintf(stderr, 00421 "save frame test: %.20e\n" 00422 "sign*sample_period: %.20e (*this)[size()-1].GetTime(): %.9f\n", 00423 // ((f_stop-(*this)[size()-1]).absolute()-sample_period).absolute().GetDouble()); 00424 ( (*this)[size()-1] - f_stop + sign*sample_period).GetDouble(), 00425 sign*sample_period.GetDouble(), 00426 (*this)[size()-1].GetTime()); 00427 } 00428 */ 00429 00430 // save frame 00431 switch (universe->GetUniverseType()) { 00432 case Real: 00433 if ( ( (*this)[size()-1] - f_stop + sign*sample_period).IsZero() ) { 00434 save_frame = true; 00435 } 00436 break; 00437 case Simulated: 00438 if ( fabs( fabs(f_stop.Time() - (*this)[size()-1].Time()) - sample_period.GetDouble()) < (fabs(f_stop.Time())+fabs((*this)[size()-1].Time())+fabs(sample_period.GetDouble()))*total_substeps*std::numeric_limits<double>::epsilon()) { 00439 save_frame = true; 00440 } 00441 break; 00442 } 00443 00444 // end of integration 00445 /* if ( fabs(f_stop.Time() - time_stop.Time()) < fabs(time_stop.Time())*std::numeric_limits<double>::epsilon()) { 00446 continue_integration=false; 00447 if (save_last_anyway) save_frame=true; 00448 } 00449 */ 00450 // 00451 // cerr << "end of integration checks..." << endl; 00452 // end of integration 00453 switch (universe->GetUniverseType()) { 00454 case Real: 00455 // if (f_stop == time_stop) { 00456 // if (f_stop.GetDate() == time_stop.GetDate()) { 00457 if ((f_stop - time_stop).IsZero()) { // IMPORTANT! This one works properly, while "(f_stop == time_stop)" or "(f_stop.GetDate() == time_stop.GetDate())" don't... WHY?? 00458 // cerr << "(f_stop == time_stop)" << endl; 00459 continue_integration = false; 00460 if (save_last_anyway) save_frame = true; 00461 } else { 00462 /* 00463 cerr << "(f_stop != time_stop)" << endl; 00464 // 00465 const Date fs_date = f_stop.GetDate(); 00466 const Date ts_date = time_stop.GetDate(); 00467 int y,m,d; 00468 double frac; 00469 // 00470 fs_date.GetGregor(y,m,d); 00471 frac = fs_date.GetDayFraction(); 00472 ORSA_ERROR( 00473 " fs_date: %i/%02i/%013.10f", 00474 y,m,d+frac); 00475 // 00476 ts_date.GetGregor(y,m,d); 00477 frac = ts_date.GetDayFraction(); 00478 ORSA_ERROR( 00479 " ts_date: %i/%02i/%013.10f", 00480 y,m,d+frac); 00481 // 00482 ORSA_ERROR( 00483 " ts-fs: %013.10f seconds", 00484 FromUnits(ts_date.GetTime()-fs_date.GetTime(),SECOND,-1)); 00485 // 00486 UniverseTypeAwareTime fsw = fs_date; 00487 UniverseTypeAwareTime tsw = ts_date; 00488 ORSA_ERROR( 00489 "2- ts-fs: %013.10f seconds", 00490 FromUnits((tsw-fsw).GetDouble(),SECOND,-1)); 00491 */ 00492 } 00493 break; 00494 case Simulated: 00495 if ( fabs(f_stop.Time() - time_stop.Time()) < fabs(time_stop.Time())*total_substeps*std::numeric_limits<double>::epsilon()) { 00496 continue_integration = false; 00497 if (save_last_anyway) save_frame = true; 00498 } 00499 break; 00500 } 00501 00502 if (save_frame) { 00503 step_done(time_start,time_stop,last_genuine_timestep,f_stop,continue_integration); 00504 if (interaction->IsSkippingJPLPlanets()) { 00505 f_stop.ForceJPLEphemerisData(); 00506 } 00507 push_back(f_stop); 00508 save_frame = false; 00509 integrator->timestep = last_genuine_timestep; 00510 unsaved_substeps = 0; 00511 } else { 00512 ++unsaved_substeps; 00513 if (max_unsaved_substeps_active) { 00514 if (unsaved_substeps > max_unsaved_substeps) { 00515 continue_integration=false; 00516 ORSA_WARNING("max unsaved substeps hit!!! stopping integration!"); 00517 } 00518 } 00519 } 00520 00521 // test 00522 /* 00523 if (integrator->timestep.IsZero()) { 00524 continue_integration=false; 00525 } 00526 */ 00527 } 00528 00529 integration_finished(); 00530 }
bool integrating | ( | ) | const [inline] |
Definition at line 117 of file orsa_universe.h.
virtual void integration_finished | ( | ) | [inline, virtual] |
Definition at line 80 of file orsa_universe.h.
Referenced by Evolution::Integrate().
virtual void integration_started | ( | ) | [inline, virtual] |
Definition at line 79 of file orsa_universe.h.
Referenced by Evolution::Integrate().
virtual const_reference operator[] | ( | size_type | n | ) | const [inline, virtual] |
Definition at line 50 of file orsa_universe.h.
References Evolution::operator[]().
00050 { return std::vector<Frame>::operator[](n); }
virtual reference operator[] | ( | size_type | n | ) | [inline, virtual] |
Definition at line 49 of file orsa_universe.h.
Referenced by Evolution::operator[]().
00049 { return std::vector<Frame>::operator[](n); }
virtual void push_back | ( | const Frame & | f | ) | [inline, virtual] |
Definition at line 48 of file orsa_universe.h.
Referenced by Evolution::Integrate(), OptimizedOrbitPositions::PropagatedOrbit(), and orsa::StartFrame().
00048 { std::vector<Frame>::push_back(f); }
void SetIntegrator | ( | const Integrator * | itg | ) |
Definition at line 181 of file orsa_universe.cc.
References Integrator::clone().
void SetIntegrator | ( | const IntegratorType | type | ) |
Definition at line 177 of file orsa_universe.cc.
References orsa::make_new_integrator().
Referenced by OptimizedOrbitPositions::PropagatedOrbit(), and orsa::StartFrame().
00177 { 00178 make_new_integrator(&integrator,type); 00179 }
void SetIntegratorAccuracy | ( | const double | a | ) |
Definition at line 194 of file orsa_universe.cc.
References Integrator::accuracy.
void SetIntegratorTimeStep | ( | const UniverseTypeAwareTimeStep | ts | ) |
Definition at line 186 of file orsa_universe.cc.
References Integrator::timestep.
Referenced by orsa::StartFrame().
void SetInteraction | ( | const Interaction * | itr | ) |
Definition at line 206 of file orsa_universe.cc.
References Interaction::clone().
void SetInteraction | ( | const InteractionType | type | ) |
Definition at line 202 of file orsa_universe.cc.
References orsa::make_new_interaction().
Referenced by OptimizedOrbitPositions::PropagatedOrbit(), and orsa::StartFrame().
00202 { 00203 make_new_interaction(&interaction,type); 00204 }
void SetMaxUnsavedSubSteps | ( | unsigned int | m | ) | [inline] |
Definition at line 83 of file orsa_universe.h.
Referenced by OptimizedOrbitPositions::PropagatedOrbit().
void SetSamplePeriod | ( | const UniverseTypeAwareTimeStep & | sp | ) |
Definition at line 211 of file orsa_universe.cc.
Referenced by OptimizedOrbitPositions::PropagatedOrbit(), and orsa::StartFrame().
virtual unsigned int size | ( | ) | const [inline, virtual] |
Definition at line 47 of file orsa_universe.h.
Referenced by Evolution::Integrate(), OptimizedOrbitPositions::PropagatedOrbit(), and orsa::StartFrame().
00047 { return std::vector<Frame>::size(); }
virtual void step_done | ( | const UniverseTypeAwareTime & | , | |
const UniverseTypeAwareTime & | , | |||
const UniverseTypeAwareTimeStep & | , | |||
const Frame & | , | |||
bool & | continue_integration | |||
) | [inline, virtual] |
Definition at line 71 of file orsa_universe.h.
Referenced by Evolution::Integrate().
virtual void stop_integration | ( | ) | const [inline, virtual] |
Definition at line 118 of file orsa_universe.h.
std::string name |
Definition at line 131 of file orsa_universe.h.
std::vector<BodyWithEpoch> start_bodies |
Definition at line 89 of file orsa_universe.h.
std::vector<JPL_planets> start_JPL_bodies |
Definition at line 90 of file orsa_universe.h.