Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Dec 18, 2023
1 parent 1d965f2 commit c0ff821
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Util/model_parser/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ int main(int argc, char *argv[]) {
std::string model = "sub_chandra.M_WD-1.10.M_He-0.050.hse.CO.N14.N.10.00km";
read_model_file(model);

// test locate and ensure that the index we get is such that
// profile.r(idx) < r < profile.r(idx+1)

Real r{3.89e7};

std::cout << "testing locate" << std::endl;
Expand All @@ -34,8 +37,20 @@ int main(int argc, char *argv[]) {
std::cout << "testing interpolate" << std::endl;

// density is monotonically decreasing
// test to make sure that we see that

auto dens = interpolate(r, model::idens);
AMREX_ALWAYS_ASSERT(dens <= model::profile(0).state(idx, model::idens) &&
dens >= model::profile(0).state(idx+1, model::idens));

// test the bounds. Our model spans r = [5.e5, 4.0955e9]

std::cout << "testing boundaries of the model" << std::endl;

auto idx_lo_bnd = locate(-1.0, 0);
AMREX_ALWAYS_ASSERT(idx_lo_bnd == 0);

auto idx_hi_bnd = locate(4.1e9, 0);
AMREX_ALWAYS_ASSERT(idx_hi_bnd == model::npts-2);

}

0 comments on commit c0ff821

Please sign in to comment.