Skip to content

Commit

Permalink
Merge pull request #14 from lanl/jmm/instrument-stellar-collapse-prof…
Browse files Browse the repository at this point in the history
…iler

add histogram for profile stellar collapse
  • Loading branch information
Yurlungur authored Jun 8, 2021
2 parents d1d57ba + 101084b commit d2839ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions eos/eos_stellar_collapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,10 @@ Real StellarCollapse::lTFromlRhoSie_(const Real lRho, const Real sie,
// TODO(JMM): Rethink this as needed.
if (sie <= eCold_.interpToReal(Ye, lRho)) {
lT = lTGuess = lTMin_;
counts.increment(0);
} else if (sie >= eHot_.interpToReal(Ye, lRho)) {
lT = lTGuess = lTMax_;
counts.increment(0);
} else {
// if the guess isn't in the bounds, bound it
if (!(lTMin_ <= lTGuess && lTGuess <= lTMax_)) {
Expand Down
29 changes: 27 additions & 2 deletions test/profile_stellar_collapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,25 @@ int main(int argc, char *argv[]) {
Kokkos::deep_copy(diffs_t_hv, diffs_t_dv);
#endif

std::cout << "\t...Running once on host to histogram accesses..."
<< std::endl;
std::vector<Real> lambdas_v(nfine*nfine*nfine*2);
DataBox lambdas_h(lambdas_v.data(), nfine, nfine, nfine, 2);
for (int trial = 0; trial < NTRIALS; ++trial) {
for (int iYe = 0; iYe < nfine; ++iYe) {
for (int iE = 0; iE < nfine; ++iE) {
for (int irho = 0; irho < nfine; ++irho) {
const Real rho = lRhoBounds.i2lin(irho);
const Real sie = lEBounds.i2lin(iE);
const Real Ye = YeBounds.i2lin(iYe);
Real *lambda = &lambdas_h(iYe, iE, irho, 0);
lambdas_h(iYe, iE, irho, 0) = Ye;
sc.TemperatureFromDensityInternalEnergy(rho, sie, lambda);
}
}
}
}

std::cout
<< "\nRESULTS:\n"
<< "Don't worry if errors are large. These are absolute, and include "
Expand All @@ -269,8 +288,14 @@ int main(int argc, char *argv[]) {
<< "\n"
<< "\tDelta T bounded by = "
<< std::max(std::abs(diffs_t_h.min()), std::abs(diffs_t_h.max()))
<< std::endl;

<< "\n"
<< "Root finding:\n"
<< "its\tpercent taken:\n";
Real tot = sc.counts.total();
for (int i = 0; i < sc.counts.nBins(); ++i) {
std::cout << i << "\t" << 100.0*sc.counts[i]/tot << "\n";
}
std::cout << std::endl;
sc_d.Finalize();
ig_d.Finalize();
}
Expand Down

0 comments on commit d2839ee

Please sign in to comment.