Skip to content

Commit

Permalink
moved thresholds from analysis pkg to progenitor pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
mari2895 committed Mar 20, 2024
1 parent 2b604be commit d4073c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/analysis/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
auto analysis_pkg = std::make_shared<StateDescriptor>("analysis");
Params &params = analysis_pkg->AllParams();
Real sigma = pin->GetOrAddReal("analysis", "sigma", 2e-3);
Real outside_pns_threshold =
pin->GetOrAddReal("analysis", "outside_pns_threshold",
2.42e-5); // corresponds to entropy > 3 kb/baryon
Real inside_pns_threshold = pin->GetOrAddReal("analysis", "inside_pns_threshold",
0.008); // corresponds to r < 80 km
Real radius_cutoff_mdot =
pin->GetOrAddReal("analysis", "radius_cutoff_mdot", 0.04); // default 400km
if (sigma < 0) {
PARTHENON_THROW("sigma must be greater than 0");
}
params.Add("sigma", sigma);
params.Add("outside_pns_threshold", outside_pns_threshold);
params.Add("inside_pns_threshold", inside_pns_threshold);
params.Add("radius_cutoff_mdot", radius_cutoff_mdot);

return analysis_pkg;
} // initialize
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ Real CalculateMdot(MeshData<Real> *md, Real rc, bool gain) {
const parthenon::AllReduce<bool> *pdo_gain_reducer =
rad->MutableParam<parthenon::AllReduce<bool>>("do_gain_reducer");
const bool do_gain = pdo_gain_reducer->val;
auto analysis = pmb->packages.Get("analysis").get();
const Real inside_pns_threshold = analysis->Param<Real>("inside_pns_threshold");
auto progenitor = pmb->packages.Get("progenitor").get();
const Real inside_pns_threshold = progenitor->Param<Real>("inside_pns_threshold");

parthenon::par_reduce(
parthenon::LoopPatternMDRange(), "Calculates mass accretion rate (SN)",
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/history.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Real ReduceInGain(MeshData<Real> *md, bool is_conserved, int idx = 0) {
Real result = 0.0;

auto geom = Geometry::GetCoordinateSystem(md);
auto analysis = pmb->packages.Get("analysis").get();
const Real outside_pns_threshold = analysis->Param<Real>("outside_pns_threshold");
auto progenitor = pmb->packages.Get("progenitor").get();
const Real outside_pns_threshold = progenitor->Param<Real>("outside_pns_threshold");

parthenon::par_reduce(
parthenon::LoopPatternMDRange(),
Expand Down
18 changes: 16 additions & 2 deletions src/progenitor/progenitordata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
auto S_adm_dev = S_adm.getOnDevice();
auto Srr_adm_dev = Srr_adm.getOnDevice();

// Post-processing params
Real outside_pns_threshold =
pin->GetOrAddReal("progenitor", "outside_pns_threshold",
2.42e-5); // corresponds to entropy > 3 kb/baryon
Real inside_pns_threshold = pin->GetOrAddReal("progenitor", "inside_pns_threshold",
0.008); // corresponds to r < 80 km
Real radius_cutoff_mdot =
pin->GetOrAddReal("progenitor", "radius_cutoff_mdot", 0.04); // default 400km

// Add Params
params.Add("mass_density", mass_density);
params.Add("temp", temp);
Expand All @@ -109,8 +118,11 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
params.Add("S_adm_dev", S_adm_dev);
params.Add("Srr_adm_dev", Srr_adm_dev);

params.Add("outside_pns_threshold", outside_pns_threshold);
params.Add("inside_pns_threshold", inside_pns_threshold);
params.Add("radius_cutoff_mdot", radius_cutoff_mdot);

// Reductions
const Real rc = pin->GetReal("analysis", "radius_cutoff_mdot");
auto HstSum = parthenon::UserHistoryOperation::sum;
auto HstMax = parthenon::UserHistoryOperation::max;
using History::ReduceInGain;
Expand All @@ -124,7 +136,9 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
return ReduceInGain<internal_variables::GcovHeat>(md, 0, 0) -
ReduceInGain<internal_variables::GcovCool>(md, 0, 0);
};
auto Mdot400 = [rc](MeshData<Real> *md) { return History::CalculateMdot(md, rc, 0); };
auto Mdot400 = [radius_cutoff_mdot](MeshData<Real> *md) {
return History::CalculateMdot(md, radius_cutoff_mdot, 0);
};

Real x1max = pin->GetReal("parthenon/mesh", "x1max");
auto Mdot_gain = [x1max](MeshData<Real> *md) {
Expand Down

0 comments on commit d4073c5

Please sign in to comment.