bool save_ensemble(){ // Save the ensemble if(cfg.valid("output")) { INFO_OUTPUT(1, "Saving as binary " << cfg["output"]); INFO_OUTPUT(1, ", time = " << current_ens.time_ranges() << endl); swarm::snapshot::save(current_ens,cfg["output"]); return true; }else if(cfg.valid("text_output")) { INFO_OUTPUT(1, "Saving as text " << cfg["text_output"]); INFO_OUTPUT(1, ", time = " << current_ens.time_ranges() << endl); swarm::snapshot::save_text(current_ens,cfg["text_output"]); return true; }else return false; }
bool read_output_file(defaultEnsemble& ens, config& cfg){ if(cfg.valid("output") ) { INFO_OUTPUT(1, "Loading from binary file " << cfg["output"]); ens = swarm::snapshot::load(cfg["output"]); INFO_OUTPUT(1,", time = " << ens.time_ranges() << endl); return true; }else if(cfg.valid("text_output")) { INFO_OUTPUT(1, "Loading from text file " << cfg["text_output"]); ens = swarm::snapshot::load_text(cfg["text_output"]); INFO_OUTPUT(1,", time = " << ens.time_ranges() << endl); return true; }else return false; }
void prepare_integrator () { // Initialize Integrator DEBUG_OUTPUT(2, "Initializing integrator" ); double begin_time = initial_ens.time_ranges().average; double destination_time = cfg.optional("destination_time", begin_time + 10 * M_PI ); integ = integrator::create(cfg); integ->set_ensemble(current_ens); integ->set_destination_time ( destination_time ); SYNC; }
void benchmark_item(const string& param, const string& value) { //outputConfigSummary(std::cout,cfg); if(!validate_configuration(cfg) ) ERROR( "Invalid configuration" ); if(param == "input" || param == "nsys" || param == "nbod" || cfg.count("reinitialize")) load_generate_ensemble(); DEBUG_OUTPUT(2, "Make a copy of ensemble for energy conservation test" ); current_ens = initial_ens.clone(); double init_time = watch_time( prepare_integrator ); double integration_time = watch_time( generic_integrate ); double max_deltaE = find_max_energy_conservation_error(current_ens, initial_ens ); // Compare with reneference ensemble for integrator verification double pos_diff = 0, vel_diff = 0, time_diff = 0; bool comparison = compare_ensembles( current_ens, reference_ens , pos_diff, vel_diff, time_diff ); /// CSV output for use in spreadsheet software std::cout << param << ", " << value << ", " << current_ens.time_ranges() << ", " << max_deltaE << ", " << pos_diff << ", " << vel_diff << ", " << time_diff << ", " << integration_time << ", " << init_time << std::endl; if( !comparison || pos_diff > pos_threshold || vel_diff > vel_threshold || time_diff > time_threshold ){ fail_verify(); } }