Skip to content

Commit

Permalink
Write results on file also for single_run
Browse files Browse the repository at this point in the history
in addition to printing a summary on standard output
Modified the settings.json template adding the output_file flag
Added an example of csv results file for single run
  • Loading branch information
Enry99 committed Sep 14, 2023
1 parent 72f79ea commit 955ba75
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/result_single_run.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
beta,initial_s0,H,GAMMA,measured_sigmax,measured_sigmaz,N_measures,N_attempted_flips,N_accepted_flips,N_attempted_addsegment,N_accepted_addsegment,N_attempted_removesegment,N_accepted_removesegment,max_diagram_order,avg_diagram_order,run_time,N_total_steps,N_thermalization_steps,update_choice_seed,diagram_seed
1,1,1,1,-0.627866,-0.628183,50000000,16671384,5471745,16661864,4236089,16666752,4236089,10,0,2216023100,50000000,0,1694693316578956500,1694693316578957400
3 changes: 3 additions & 0 deletions examples/settings_singlerun.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"CALC_TYPE" : "single",

"output_file" : "result_single_run.csv",


"beta" : 1,
"H" : 1,
"GAMMA" : 1,
Expand Down
15 changes: 13 additions & 2 deletions src/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ void single_run(const json & settings)
"H",
"GAMMA",
"N_total_steps",
"output_file"
}
);

Expand All @@ -195,11 +196,16 @@ void single_run(const json & settings)
//############################################################################


//open file stream to write results in output file, write the header row containing the titles of the columns
std::ofstream output_file_stream(static_cast<std::string>(settings["output_file"]));
output_file_stream << SingleRunResults::ostream_output_header();


//SIMULATION#################################################################
std::cout<<"Running single run simulation...\n";

//execute single run simulation, and print results to terminal standard output
run_simulation(
SingleRunResults results = run_simulation(
settings["beta"],
initial_s0,
settings["H"],
Expand All @@ -208,7 +214,12 @@ void single_run(const json & settings)
N_thermalization_steps,
update_choice_seed,
diagram_seed
).print_results();
);
output_file_stream << results;
output_file_stream.close();

//for single run, also print summary on console standard output
results.print_results();
//############################################################################

}
Expand Down

0 comments on commit 955ba75

Please sign in to comment.