Skip to content

Commit

Permalink
Changed parameters in pulse_grey test to reduce runtime (#625)
Browse files Browse the repository at this point in the history
### Description

Address issue #624 . I reduced `max_time` of the
test_radhydro_pulse_grey test by ~5. Now the runtime of this test on my
Mac Studio reduced from 28 s to 6 s.

### Related issues

Fixes #624.

### Checklist
_Before this pull request can be reviewed, all of these tasks should be
completed. Denote completed tasks with an `x` inside the square brackets
`[ ]` in the Markdown source below:_
- [x] I have added a description (see above).
- [x] I have added a link to any related issues see (see above).
- [x] I have read the [Contributing
Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md).
- [x] I have added tests for any new physics that this PR adds to the
code.
- [x] I have tested this PR on my local computer and all tests pass.
- [x] I have manually triggered the GPU tests with the magic comment
`/azp run`.
- [x] I have requested a reviewer for this PR.
  • Loading branch information
chongchonghe authored May 2, 2024
1 parent f97d823 commit f7d0e90
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/RadhydroPulseGrey/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ if (AMReX_SPACEDIM EQUAL 1)
setup_target_for_cuda_compilation(test_radhydro_pulse_grey)
endif(AMReX_GPU_BACKEND MATCHES "CUDA")

add_test(NAME RadhydroPulseGrey COMMAND test_radhydro_pulse_grey RadhydroPulse.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests)
add_test(NAME RadhydroPulseGrey COMMAND test_radhydro_pulse_grey RadhydroPulseGrey.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests)
endif()
20 changes: 13 additions & 7 deletions src/RadhydroPulseGrey/test_radhydro_pulse_grey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ constexpr double erad_floor = a_rad * T0 * T0 * T0 * T0 * 1.0e-10;
constexpr double mu = 2.33 * C::m_u;
constexpr double k_B = C::k_B;

// static diffusion: tau = 2e3, beta = 3e-5, beta tau = 6e-2
constexpr double kappa0 = 100.; // cm^2 g^-1
constexpr double v0_adv = 1.0e6; // advecting pulse
constexpr double max_time = 4.8e-5; // max_time = 2.0 * width / v1;
// Default parameters: static diffusion, tau = 2e3, beta = 3e-5, beta tau = 6e-2
AMREX_GPU_MANAGED double kappa0 = 100.; // NOLINT
AMREX_GPU_MANAGED double v0_adv = 1.0e6; // NOLINT
// AMREX_GPU_MANAGED double max_time = 4.8e-5; // max_time = 2.0 * width / v1;

// dynamic diffusion: tau = 2e4, beta = 3e-3, beta tau = 60
// constexpr double kappa0 = 1000.; // cm^2 g^-1
Expand Down Expand Up @@ -221,6 +221,12 @@ auto problem_main() -> int
// Problem initialization
RadhydroSimulation<PulseProblem> sim(BCs_cc);

double max_time = 4.8e-5;
amrex::ParmParse pp; // NOLINT
pp.query("kappa0", kappa0);
pp.query("v0_adv", v0_adv);
pp.query("max_time", max_time);

sim.radiationReconstructionOrder_ = 3; // PPM
sim.stopTime_ = max_time;
sim.radiationCflNumber_ = CFL_number;
Expand Down Expand Up @@ -338,14 +344,14 @@ auto problem_main() -> int
// Tmax = std::max(Tmax, Tgas2[i]);
}
// const double Tmax_tol = 1.37e7;
const double error_tol = 1e-3;
const double error_tol = 8e-3;
const double rel_error = err_norm / sol_norm;
amrex::Print() << "Relative L1 error norm = " << rel_error << std::endl;

// symmetry check
double symm_err = 0.;
double symm_norm = 0.;
const double symm_err_tol = 1.0e-3;
const double symm_err_tol = 0.02;
for (size_t i = 0; i < xs2.size(); ++i) {
symm_err += std::abs(Tgas2[i] - Tgas2[xs2.size() - 1 - i]);
symm_norm += std::abs(Tgas2[i]);
Expand All @@ -370,7 +376,7 @@ auto problem_main() -> int
matplotlibcpp::plot(xs2, Tgas2, Tgas_args);
matplotlibcpp::xlabel("length x (cm)");
matplotlibcpp::ylabel("temperature (K)");
matplotlibcpp::ylim(0.98e7, 1.3499e7);
matplotlibcpp::ylim(0.98e7, 2.02e7);
matplotlibcpp::legend();
matplotlibcpp::title(fmt::format("time t = {:.4g}", sim2.tNew_[0]));
matplotlibcpp::tight_layout();
Expand Down
29 changes: 29 additions & 0 deletions tests/RadhydroPulseGrey.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
kappa0 = 100.0
v0_adv = 1.0e6
max_time = 1e-5

# *****************************************************************
# Problem size and geometry
# *****************************************************************
geometry.prob_lo = -512.0 0.0 0.0
geometry.prob_hi = 512.0 1.0 1.0
geometry.is_periodic = 1 1 1

# *****************************************************************
# VERBOSITY
# *****************************************************************
amr.v = 0 # verbosity in Amr

# *****************************************************************
# Resolution and refinement
# *****************************************************************
amr.n_cell = 64 4 4
amr.max_level = 0 # number of levels = max_level + 1
amr.blocking_factor = 4 # grid size must be divisible by this
amr.max_grid_size_x = 64
amr.max_grid_size_y = 4
amr.max_grid_size_z = 4

do_reflux = 0
do_subcycle = 0
suppress_output = 1

0 comments on commit f7d0e90

Please sign in to comment.