Skip to content

Commit

Permalink
Change fact --> factor
Browse files Browse the repository at this point in the history
  • Loading branch information
amandalund committed Mar 16, 2024
1 parent 05be582 commit f2e983d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/celeritas/em/msc/detail/UrbanMscMinimalStepLimit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ UrbanMscMinimalStepLimit::UrbanMscMinimalStepLimit(
// Store initial range properties if this is the track's first step
MscRange new_range;
new_range.range_init = numeric_limits<real_type>::infinity();
new_range.range_fact = physics->scalars().range_fact;
new_range.range_factor = physics->scalars().range_factor;
new_range.limit_min = 10 * shared.params.limit_min_fix();
physics->msc_range(new_range);
CELER_ASSERT(msc_range);
Expand All @@ -94,7 +94,7 @@ UrbanMscMinimalStepLimit::UrbanMscMinimalStepLimit(
{
// Update the MSC range for the new volume
MscRange new_range = msc_range;
new_range.range_init = msc_range.range_fact
new_range.range_init = msc_range.range_factor
* max(physics->dedx_range(), helper.msc_mfp());
new_range.range_init = max(new_range.range_init, limit_min_);
physics->msc_range(new_range);
Expand Down
12 changes: 6 additions & 6 deletions src/celeritas/em/msc/detail/UrbanMscSafetyStepLimit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ UrbanMscSafetyStepLimit::UrbanMscSafetyStepLimit(UrbanMscRef const& shared,
MscRange new_range;
// Initialize MSC range cache on the first step in a volume
// TODO for hadrons/muons: this value is hard-coded for electrons
new_range.range_fact = physics->scalars().range_fact;
new_range.range_factor = physics->scalars().range_factor;
// XXX the 1 MFP limitation is applied to the *geo* step, not the true
// step, so this isn't quite right (See UrbanMsc.hh)
new_range.range_init = use_safety_plus
Expand All @@ -140,9 +140,9 @@ UrbanMscSafetyStepLimit::UrbanMscSafetyStepLimit(UrbanMscRef const& shared,
if (helper_.msc_mfp() > physics->scalars().lambda_limit)
{
real_type c = use_safety_plus ? 0.84 : 0.75;
new_range.range_fact *= c
+ (1 - c) * helper_.msc_mfp()
/ physics->scalars().lambda_limit;
new_range.range_factor *= c
+ (1 - c) * helper_.msc_mfp()
/ physics->scalars().lambda_limit;
}
new_range.limit_min
= this->calc_limit_min(shared_.material_data[matid], inc_energy);
Expand All @@ -157,8 +157,8 @@ UrbanMscSafetyStepLimit::UrbanMscSafetyStepLimit(UrbanMscRef const& shared,
limit_ = range;
if (safety < range)
{
limit_ = max<real_type>(msc_range.range_fact * msc_range.range_init,
physics->scalars().safety_fact * safety);
limit_ = max<real_type>(msc_range.range_factor * msc_range.range_init,
physics->scalars().safety_factor * safety);
}
limit_ = max<real_type>(limit_, limit_min_);

Expand Down
4 changes: 2 additions & 2 deletions src/celeritas/phys/Interaction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ struct MscStep
struct MscRange
{
real_type range_init{}; //!< Initial msc range [len]
real_type range_fact{}; //!< Scale factor for the msc range
real_type range_factor{}; //!< Scale factor for the msc range
real_type limit_min{}; //!< Minimum of the true path limit [len]

explicit CELER_FUNCTION operator bool() const
{
return range_init > 0 && range_fact > 0 && limit_min > 0;
return range_init > 0 && range_factor > 0 && limit_min > 0;
}
};

Expand Down
13 changes: 8 additions & 5 deletions src/celeritas/phys/PhysicsData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ struct HardwiredModels
/*!
* Scalar (no template needed) quantities used by physics.
*
* The user-configurable constants are described in \c PhysicsParams .
* The user-configurable constants and multiple scattering options are
* described in \c PhysicsParams .
*
* The \c model_to_action value corresponds to the \c ActionId for the first \c
* ModelId . Additionally it implies (by construction in physics_params) the
Expand All @@ -239,9 +240,11 @@ struct PhysicsParamsScalars
Energy lowest_electron_energy{}; //!< Lowest e-/e+ kinetic energy
real_type linear_loss_limit{}; //!< For scaled range calculation
real_type fixed_step_limiter{}; //!< Global charged step size limit [len]

// User-configurable multiple scattering options
real_type lambda_limit{}; //!< lambda limit
real_type range_fact{}; //!< range factor for e-/e+ (0.2 for muon/h)
real_type safety_fact{}; //!< safety factor
real_type range_factor{}; //!< range factor for e-/e+ (0.2 for muon/h)
real_type safety_factor{}; //!< safety factor
MscStepLimitAlgorithm step_limit_algorithm{MscStepLimitAlgorithm::size_};

real_type secondary_stack_factor = 3; //!< Secondary storage per state
Expand All @@ -260,8 +263,8 @@ struct PhysicsParamsScalars
&& linear_loss_limit > 0 && secondary_stack_factor > 0
&& ((fixed_step_limiter > 0)
== static_cast<bool>(fixed_step_action))
&& lambda_limit > 0 && range_fact > 0 && range_fact < 1
&& safety_fact >= 0.1
&& lambda_limit > 0 && range_factor > 0 && range_factor < 1
&& safety_factor >= 0.1
&& step_limit_algorithm != MscStepLimitAlgorithm::size_;
}

Expand Down
12 changes: 6 additions & 6 deletions src/celeritas/phys/PhysicsParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ void PhysicsParams::build_options(Options const& opts, HostValue* data) const
CELER_VALIDATE(opts.lambda_limit > 0,
<< "invalid lambda_limit=" << opts.lambda_limit
<< " (should be positive)");
CELER_VALIDATE(opts.safety_fact >= 0.1,
<< "invalid safety_fact=" << opts.safety_fact
CELER_VALIDATE(opts.safety_factor >= 0.1,
<< "invalid safety_factor=" << opts.safety_factor
<< " (should be >= 0.1)");
CELER_VALIDATE(opts.range_fact > 0 && opts.range_fact < 1,
<< "invalid range_fact=" << opts.range_fact
CELER_VALIDATE(opts.range_factor > 0 && opts.range_factor < 1,
<< "invalid range_factor=" << opts.range_factor
<< " (should be within 0 < limit < 1)");
data->scalars.min_range = opts.min_range;
data->scalars.max_step_over_range = opts.max_step_over_range;
Expand All @@ -259,8 +259,8 @@ void PhysicsParams::build_options(Options const& opts, HostValue* data) const
data->scalars.linear_loss_limit = opts.linear_loss_limit;
data->scalars.secondary_stack_factor = opts.secondary_stack_factor;
data->scalars.lambda_limit = opts.lambda_limit;
data->scalars.range_fact = opts.range_fact;
data->scalars.safety_fact = opts.safety_fact;
data->scalars.range_factor = opts.range_factor;
data->scalars.safety_factor = opts.safety_factor;
data->scalars.step_limit_algorithm = opts.step_limit_algorithm;
if (data->scalars.step_limit_algorithm
== MscStepLimitAlgorithm::distance_to_boundary)
Expand Down
12 changes: 6 additions & 6 deletions src/celeritas/phys/PhysicsParams.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class ParticleParams;
* energy loss.
* - \c lowest_electron_energy: lowest kinetic energy for electrons/positrons
* - \c lambda_limit: limit on the MSC mean free path.
* - \c range_fact: used in the MSC step limitation algorithm to restrict the
* - \c range_factor: used in the MSC step limitation algorithm to restrict the
* step size to \f$ f_r \cdot max(r, \lambda) \f$ at the start of a track or
* after entering a volume, where \f$ f_r \f$ is the range factor, \f$ r \f$
* is the range, and \f$ \lambda \f$ is the mean free path.
* - \c safety_fact: used in the MSC step limitation algorithm to restrict the
* step size to \f$ f_s s \f$, where \f$ f_s \f$ is the safety factor and \f$
* s \f$ is the safety distance.
* - \c safety_factor: used in the MSC step limitation algorithm to restrict
* the step size to \f$ f_s s \f$, where \f$ f_s \f$ is the safety factor and
* \f$ s \f$ is the safety distance.
* - \c step_limit_algorithm: algorithm used to determine the MSC step limit.
* - \c secondary_stack_factor: the number of secondary slots per track slot
* allocated.
Expand Down Expand Up @@ -95,8 +95,8 @@ struct PhysicsParamsOptions
//!@{
//! \name Multiple scattering
real_type lambda_limit = 1 * units::millimeter;
real_type range_fact = 0.04;
real_type safety_fact = 0.6;
real_type range_factor = 0.04;
real_type safety_factor = 0.6;
MscStepLimitAlgorithm step_limit_algorithm{MscStepLimitAlgorithm::safety};
//!@}

Expand Down
22 changes: 11 additions & 11 deletions test/celeritas/em/UrbanMsc.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))

VecReal mean_step;
VecReal range_init;
VecReal range_fact;
VecReal range_factor;
VecReal limit_min;
};

Expand All @@ -413,7 +413,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
if (alg == Algorithm::minimal)
{
phys_params.scalars.step_limit_algorithm = Algorithm::minimal;
phys_params.scalars.range_fact = 0.2;
phys_params.scalars.range_factor = 0.2;
}
else if (alg == Algorithm::safety_plus)
{
Expand Down Expand Up @@ -458,7 +458,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))

auto const& msc_range = phys.msc_range();
result.range_init.push_back(to_cm(msc_range.range_init));
result.range_fact.push_back(msc_range.range_fact);
result.range_factor.push_back(msc_range.range_factor);
result.limit_min.push_back(to_cm(msc_range.limit_min));
}
return result;
Expand All @@ -473,14 +473,14 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
0.9059108153443,
8.8845468954557};
static double const expected_range_init[] = {inf, inf, inf, inf, inf};
static double const expected_range_fact[] = {0.2, 0.2, 0.2, 0.2, 0.2};
static double const expected_range_factor[] = {0.2, 0.2, 0.2, 0.2, 0.2};
static double const expected_limit_min[]
= {1e-08, 1e-08, 1e-08, 1e-08, 1e-08};

auto result = sample(Algorithm::minimal, false);
EXPECT_VEC_SOFT_EQ(expected_mean_step, result.mean_step);
EXPECT_VEC_EQ(expected_range_init, result.range_init);
EXPECT_VEC_EQ(expected_range_fact, result.range_fact);
EXPECT_VEC_EQ(expected_range_factor, result.range_factor);
EXPECT_VEC_EQ(expected_limit_min, result.limit_min);
}
{
Expand All @@ -495,14 +495,14 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
0.015413789233736,
0.21762788543933,
15.553546812173};
static double const expected_range_fact[] = {0.2, 0.2, 0.2, 0.2, 0.2};
static double const expected_range_factor[] = {0.2, 0.2, 0.2, 0.2, 0.2};
static double const expected_limit_min[]
= {1e-08, 1e-08, 1e-08, 1e-08, 1e-08};

auto result = sample(Algorithm::minimal, true);
EXPECT_VEC_SOFT_EQ(expected_mean_step, result.mean_step);
EXPECT_VEC_SOFT_EQ(expected_range_init, result.range_init);
EXPECT_VEC_EQ(expected_range_fact, result.range_fact);
EXPECT_VEC_EQ(expected_range_factor, result.range_factor);
EXPECT_VEC_EQ(expected_limit_min, result.limit_min);
}
{
Expand All @@ -517,7 +517,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
0.07706894616868,
1.0881394271966,
77.767734060865};
static double const expected_range_fact[]
static double const expected_range_factor[]
= {0.04, 0.04, 0.04, 0.13881394271966, 7.8067734060865};
static double const expected_limit_min[] = {1.9688399316472e-06,
1.0522532283188e-05,
Expand All @@ -528,7 +528,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
auto result = sample(Algorithm::safety, true);
EXPECT_VEC_SOFT_EQ(expected_mean_step, result.mean_step);
EXPECT_VEC_SOFT_EQ(expected_range_init, result.range_init);
EXPECT_VEC_SOFT_EQ(expected_range_fact, result.range_fact);
EXPECT_VEC_SOFT_EQ(expected_range_factor, result.range_factor);
EXPECT_VEC_SOFT_EQ(expected_limit_min, result.limit_min);
}
{
Expand All @@ -543,7 +543,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
0.07706894616868,
0.90591081534428,
8.8845468954556};
static double const expected_range_fact[]
static double const expected_range_factor[]
= {0.04, 0.04, 0.04, 0.10324092334058, 5.0107349798953};
static double const expected_limit_min[] = {1.9688399316472e-06,
1.0522532283188e-05,
Expand All @@ -554,7 +554,7 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit))
auto result = sample(Algorithm::safety_plus, true);
EXPECT_VEC_SOFT_EQ(expected_mean_step, result.mean_step);
EXPECT_VEC_SOFT_EQ(expected_range_init, result.range_init);
EXPECT_VEC_SOFT_EQ(expected_range_fact, result.range_fact);
EXPECT_VEC_SOFT_EQ(expected_range_factor, result.range_factor);
EXPECT_VEC_SOFT_EQ(expected_limit_min, result.limit_min);
}
}
Expand Down

0 comments on commit f2e983d

Please sign in to comment.