Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
		
}
Ejemplo n.º 3
0
void run_integration(){
	if(!validate_configuration(cfg) ) ERROR( "Invalid configuration" );

	load_generate_ensemble();

	DEBUG_OUTPUT(2, "Make a copy of ensemble for energy conservation test" );
	current_ens = initial_ens.clone();

	prepare_integrator();

	double integration_time = watch_time ( cfg.valid("interval") ? stability_test : generic_integrate );

	save_ensemble();

	INFO_OUTPUT( 1, "Integration time: " << integration_time << " ms " << std::endl);
}
Ejemplo n.º 4
0
void output_test() {
	if(!validate_configuration(cfg) ) ERROR( "Invalid configuration" );

	if(!read_input_file(initial_ens, cfg) ) {
		ERROR("you should have a tested input file");
	}

	DEBUG_OUTPUT(2, "Make a copy of ensemble for energy conservation test" );
	current_ens = initial_ens.clone();

	prepare_integrator();

	double integration_time = watch_time ( cfg.valid("interval") ? stability_test : generic_integrate );

	if(read_output_file(reference_ens,cfg)){

		// 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 );

		INFO_OUTPUT(1,"\tPosition difference: " << pos_diff  << endl
			 << "\tVelocity difference: " << vel_diff  << endl
			 << "\tTime     difference: " << time_diff << endl );

		if( !comparison || pos_diff > pos_threshold || vel_diff > vel_threshold || time_diff > time_threshold ){
			INFO_OUTPUT(0, "Test failed" << endl);
			exit(1);
		}else {
			INFO_OUTPUT(0, "Test success" << endl);
		}


	}else{
		ERROR("You should provide a test output file");
	}

	INFO_OUTPUT( 1, "Integration time: " << integration_time << " ms " << std::endl);
}