Skip to content

Commit

Permalink
Add power measurement timings
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrete committed Dec 16, 2024
1 parent c413458 commit 502e99a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions inputs/exacb_turbulence.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ reference = to be written, see https://gitlab.com/pgrete/kathena/wikis/turbulenc
<job>
problem_id = turbulence

<exacb/power>
cycle_start = 50
cycle_end = 250

<parthenon/time>
cfl = 0.3 # The Courant, Friedrichs, & Lewy (CFL) Number
nlim = __NLIM__ # cycle limit
Expand Down
13 changes: 13 additions & 0 deletions src/hydro/hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,19 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
pkg->CheckRefinementBlock = Hydro::ProblemCheckRefinementBlock;
}

// EXACB custom modifications for power measurements
if (pin->DoesBlockExist("exacb/power")) {
const auto start = pin->GetOrAddInteger("exacb/power", "cycle_start", 50);
const auto end = pin->GetOrAddInteger("exacb/power", "cycle_stop", 250);
PARTHENON_REQUIRE_THROWS(end > start, "Measuring backwards does not make sense.");

const auto nlim = pin->GetInteger("parthenon/time", "nlim");
PARTHENON_REQUIRE_THROWS(nlim < 0 || nlim >= end, "end must be within nlim");

pkg->AddParam<int>("exacb/power/start", start);
pkg->AddParam<int>("exacb/power/end", end);
}

if (ProblemInitPackageData != nullptr) {
ProblemInitPackageData(pin, pkg.get());
}
Expand Down
19 changes: 19 additions & 0 deletions src/hydro/hydro_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,25 @@ TaskCollection HydroDriver::MakeTaskCollection(BlockList_t &blocks, int stage) {

const int num_partitions = pmesh->DefaultNumPartitions();

// EXACB custom modifications for power measurements
if (stage == 1 && hydro_pkg->AllParams().hasKey("exacb/power/start")) {
const auto start = hydro_pkg->Param<int>("exacb/power/start");
const auto end = hydro_pkg->Param<int>("exacb/power/end");
std::ofstream outfile;
if (start == tm.ncycle) {
outfile.open("energy.times");
outfile << "energy_start:";
}
if (end == tm.ncycle) {
outfile.open("energy.times", std::ios_base::app);
outfile << "energy_stop:";
}
outfile << std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count()
<< std::endl;
}

// calculate agn triggering accretion rate
if ((stage == 1) &&
hydro_pkg->AllParams().hasKey("agn_triggering_reduce_accretion_rate") &&
Expand Down

0 comments on commit 502e99a

Please sign in to comment.