Skip to content

Commit

Permalink
Add time elapsed per tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcarbone committed Jun 28, 2024
1 parent c4a4c14 commit 1baa415
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void combine_json_(json* base_json_ptr, json* json_ptr)
}


json get_final_json(OnePointObservables& obs1, PsiConfig& psiConfig, PsiBasin& psiBasin, AgingConfig& agingConfig, AgingBasin& agingBasin, EMaxt2& emaxt2)
json get_final_json(OnePointObservables& obs1, PsiConfig& psiConfig, PsiBasin& psiBasin, AgingConfig& agingConfig, AgingBasin& agingBasin, EMaxt2& emaxt2, const double elapsed)
{
json j;

Expand All @@ -66,6 +66,8 @@ json get_final_json(OnePointObservables& obs1, PsiConfig& psiConfig, PsiBasin& p
json emaxt2_json = emaxt2.as_json();
combine_json_(&j, &emaxt2_json);

j["elapsed"] = elapsed;

return j;
}

Expand Down Expand Up @@ -94,6 +96,10 @@ void execute(const int job_index, const utils::SimulationParameters const_params
AgingBasin agingBasin(params, sys);
EMaxt2 emaxt2(params, sys);


// Time the entire simulation
auto t_start = std::chrono::high_resolution_clock::now();

// Simulation clock is 0 before entering the while loop
while (true)
{
Expand Down Expand Up @@ -124,14 +130,17 @@ void execute(const int job_index, const utils::SimulationParameters const_params
if (simulation_clock > params.N_timesteps){break;}
}

const double elapsed = utils::get_time_delta(t_start);

// When the simulation is complete, write everything to disk
const json j_final = get_final_json(
json j_final = get_final_json(
obs1,
psiConfig,
psiBasin,
agingConfig,
agingBasin,
emaxt2
emaxt2,
elapsed
);
utils::json_to_file_no_format(j_final, fnames.json_final);
}
Expand Down
14 changes: 14 additions & 0 deletions src/processing_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ json get_aging_basin_statistics(const std::vector<json> results, const std::stri
}


std::vector<double> process_elapsed_time(const std::vector<json> results)
{
std::vector<double> v;
for (auto &result : results)
{
v.push_back(result["elapsed"]);
}
return v;
}



json load_grids()
{
Expand Down Expand Up @@ -429,6 +440,9 @@ void postprocess()
j["aging_basin_S"] = get_aging_basin_statistics(results, "aging_basin_S");
}

j["elapsed"] = process_elapsed_time(results);


j["grids"] = load_grids();
j["grids"]["psi"] = get_psi_grid(j["psi_config"]["mean"].size());

Expand Down

0 comments on commit 1baa415

Please # to comment.