-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vincent R. Pascuzzi
committed
May 24, 2021
1 parent
10ab4b5
commit 1e8fd0f
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2020 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file TsaiUrbanDistribution.test.cc | ||
//---------------------------------------------------------------------------// | ||
#include "physics/em/detail/TsaiUrbanDistribution.hh" | ||
|
||
#include <random> | ||
#include "base/Constants.hh" | ||
#include "base/Units.hh" | ||
#include "celeritas_test.hh" | ||
|
||
using celeritas::detail::TsaiUrbanDistribution; | ||
|
||
//---------------------------------------------------------------------------// | ||
// TEST HARNESS | ||
//---------------------------------------------------------------------------// | ||
|
||
class TsaiUrbanDistributionTest : public celeritas::Test | ||
{ | ||
protected: | ||
void SetUp() override {} | ||
|
||
std::mt19937 rng; | ||
}; | ||
|
||
//---------------------------------------------------------------------------// | ||
// TESTS | ||
//---------------------------------------------------------------------------// | ||
|
||
TEST_F(TsaiUrbanDistributionTest, bin) | ||
{ | ||
using namespace celeritas::constants; | ||
using namespace celeritas::units; | ||
|
||
std::vector<float> angles; | ||
// Loop over various electron energies | ||
for (double inc_e : {1.0, 10.0, 20.0, 50.0, 100.0}) | ||
{ | ||
TsaiUrbanDistribution sample_angle(MevEnergy{inc_e}, | ||
MevMass{electron_mass}); | ||
double angle = sample_angle(rng); | ||
angles.push_back(angle); | ||
} | ||
|
||
const float expected_angles[] = {0.3245577893213, | ||
-0.02649751911085, | ||
0.6002972458021, | ||
0.9822511633688, | ||
0.1573926944923}; | ||
EXPECT_VEC_EQ(expected_angles, angles); | ||
} |