From 7c9bf948b7495891b5e075e6831f44332ab6d2e4 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 28 Dec 2023 14:37:21 -0600 Subject: [PATCH] Ensure particle direction is normalized for plotting / volume calculations (#2816) --- include/openmc/plot.h | 3 ++- src/volume_calc.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 3e97e2544c0..ba82f43e27a 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -1,6 +1,7 @@ #ifndef OPENMC_PLOT_H #define OPENMC_PLOT_H +#include #include #include @@ -200,7 +201,7 @@ T SlicePlotBase::get_map() const xyz[out_i] = origin_[out_i] + width_[1] / 2. - out_pixel / 2.; // arbitrary direction - Direction dir = {0.7071, 0.7071, 0.0}; + Direction dir = {1. / std::sqrt(2.), 1. / std::sqrt(2.), 0.0}; #pragma omp parallel { diff --git a/src/volume_calc.cpp b/src/volume_calc.cpp index 859a0d5ac1b..6a47e9490b5 100644 --- a/src/volume_calc.cpp +++ b/src/volume_calc.cpp @@ -159,7 +159,7 @@ vector VolumeCalculation::execute() const p.n_coord() = 1; Position xi {prn(&seed), prn(&seed), prn(&seed)}; p.r() = lower_left_ + xi * (upper_right_ - lower_left_); - p.u() = {0.5, 0.5, 0.5}; + p.u() = {1. / std::sqrt(3.), 1. / std::sqrt(3.), 1. / std::sqrt(3.)}; // If this location is not in the geometry at all, move on to next block if (!exhaustive_find_cell(p))