Skip to content

Commit

Permalink
Release v0.5.0 (#1442)
Browse files Browse the repository at this point in the history
* Update goldfinger ndebug environment
* Use ordered map for enhanced reproducibility
* Add release notes
* Improve slot diagnostic examples
* Update documentation
* Add some documentation to msc
* Remove deprecated code
  • Loading branch information
sethrj authored Oct 7, 2024
1 parent 8248052 commit a3088af
Show file tree
Hide file tree
Showing 19 changed files with 413 additions and 41 deletions.
1 change: 1 addition & 0 deletions doc/appendix/release-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Release History
:maxdepth: 2
:caption: Appendices

release-history/v0.5.rst
release-history/v0.4.rst
release-history/v0.3.rst
release-history/v0.2.rst
Expand Down
339 changes: 339 additions & 0 deletions doc/appendix/release-history/v0.5.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/cmake-presets/goldfinger.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@
"CELERITAS_USE_ROOT": {"type": "BOOL", "value": "OFF"},
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "ON"},
"CMAKE_CXX_COMPILER_LAUNCHER": "/opt/homebrew/bin/ccache",
"Geant4_DIR": "/Users/seth/Code/geant4-dev/build",
"Geant4_DIR": "/Users/seth/Code/geant4-dev/install/lib/cmake/Geant4",
"CELERITAS_BUILD_DEMOS": {"type": "BOOL", "value": "OFF"},
"CELERITAS_BUILD_TESTS": {"type": "BOOL", "value": "OFF"},
"CELERITAS_UNITS": "CLHEP"
},
"environment": {
"PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/Library/Apple/usr/bin",
"CMAKE_PREFIX_PATH": "/opt/spack/opt/spack/sonoma/googletest/1.14.0/wjvv2w2:/opt/spack/opt/spack/sonoma/vecgeom/1.2.8/t4hnxz2:/opt/spack/opt/spack/sonoma/xerces-c/3.2.4/umj37ov:/opt/spack/opt/spack/sonoma/curl/8.4.0/x4tl4tu:/opt/spack/opt/spack/sonoma/zlib-ng/2.1.3/udbedjf:/opt/spack/opt/spack/sonoma/nghttp2/1.52.0/dzvtf5b:/opt/spack/opt/spack/sonoma/veccore/0.8.1/ye5hcpf:/opt/spack/opt/spack/sonoma/libpng/1.6.39/wl4oyhp:/opt/spack/opt/spack/sonoma/zlib-ng/2.1.3/udbedjf"
"CMAKE_PREFIX_PATH": "/opt/spack/opt/spack/sequoia/libpng/1.6.39/3g6j5kh:/opt/spack/opt/spack/sequoia/zlib-ng/2.2.1/6s4rdcx:/opt/spack/opt/spack/sequoia/vecgeom/1.2.8/own7ofl:/opt/spack/opt/spack/sequoia/xerces-c/3.2.5/3zdtn2m:/opt/spack/opt/spack/sequoia/veccore/0.8.1/x34t746:/opt/spack/opt/spack/sequoia/nlohmann-json/3.11.3/fpe7aef:/opt/spack/opt/spack/sequoia/hepmc3/3.3.0/rrfyfcx:/opt/spack/opt/spack/sequoia/googletest/1.14.0/cwduo4b"
}
}
],
Expand Down
2 changes: 2 additions & 0 deletions src/celeritas/Units.hh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ CELER_ICRT gauss = real_type(1e-4) * tesla;

//!@{
//! \name Other common units
CELER_ICRT micrometer = real_type(1e-4) * centimeter;
CELER_ICRT nanometer = real_type(1e-7) * centimeter;
CELER_ICRT femtometer = real_type(1e-13) * centimeter;
CELER_ICRT barn = real_type(1e-24) * centimeter * centimeter;
//!@}
Expand Down
8 changes: 4 additions & 4 deletions src/celeritas/em/data/UrbanMscData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ struct UrbanMscParameters
Energy low_energy_limit{0};
Energy high_energy_limit{0};

//! A scale factor for the range
static CELER_CONSTEXPR_FUNCTION real_type dtrl() { return 5e-2; }
//! Fraction of the range below which a step is assumed constant xs
static CELER_CONSTEXPR_FUNCTION real_type dtrl() { return 0.05; }

//! The minimum value of the true path length limit: 0.01 nm
static CELER_CONSTEXPR_FUNCTION real_type limit_min_fix()
{
return 1e-9 * units::centimeter;
return real_type(0.01) * units::nanometer;
}

//! Minimum true path when not calculated in the step limiting
Expand All @@ -57,7 +57,7 @@ struct UrbanMscParameters
//! For steps below this value, true = geometrical (no MSC to be applied)
static CELER_CONSTEXPR_FUNCTION real_type min_step()
{
return 100 * limit_min_fix();
return 1 * units::nanometer;
}

//! Below this endpoint energy, don't sample scattering: 1 eV
Expand Down
2 changes: 2 additions & 0 deletions src/celeritas/em/msc/detail/UrbanMscSafetyStepLimit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ CELER_FUNCTION real_type UrbanMscSafetyStepLimit::operator()(Engine& rng)
//---------------------------------------------------------------------------//
/*!
* Calculate the minimum of the true path length limit.
*
* See \c G4UrbanMscModel::ComputeTlimitmin .
*/
CELER_FUNCTION real_type UrbanMscSafetyStepLimit::calc_limit_min(
UrbanMscMaterialData const& msc, Energy const inc_energy) const
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/msc/detail/UrbanMscScatter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ UrbanMscScatter::UrbanMscScatter(UrbanMscRef const& shared,
// many of the class member data
theta0_ = this->compute_theta0();

if (theta0_ < 1e-8)
if (theta0_ < real_type(1e-8))
{
// Arbitrarily (?) small angle change (theta_0^2 < 1e-16):
// skip sampling angular distribution if width of direction
Expand Down
3 changes: 1 addition & 2 deletions src/celeritas/ext/GeantImporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,7 @@ auto import_processes(GeantImporter::DataSelection::Flags process_flags,

static celeritas::TypeDemangler<G4VProcess> const demangle_process;
std::unordered_map<G4VProcess const*, G4ParticleDefinition const*> visited;
detail::GeantProcessImporter import_process(
detail::TableSelection::minimal, materials, elements);
detail::GeantProcessImporter import_process(materials, elements);
detail::GeantOpticalModelImporter import_optical_model(materials);

auto append_process = [&](G4ParticleDefinition const& particle,
Expand Down
1 change: 0 additions & 1 deletion src/celeritas/ext/detail/GeantProcessImporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ bool all_are_assigned(std::vector<T> const& arr)
* Construct with a selected list of tables.
*/
GeantProcessImporter::GeantProcessImporter(
TableSelection,
std::vector<ImportPhysMaterial> const& materials,
std::vector<ImportElement> const& elements)
: materials_(materials), elements_(elements)
Expand Down
13 changes: 2 additions & 11 deletions src/celeritas/ext/detail/GeantProcessImporter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ namespace celeritas
{
namespace detail
{
//---------------------------------------------------------------------------//
// DEPRECATED: remove in v0.5
enum class TableSelection
{
minimal, //!< Store only lambda, dedx, and range
all
};

//---------------------------------------------------------------------------//
/*!
* Simplify the convoluted mechanism to store Geant4 process, model, and XS
Expand All @@ -54,7 +46,7 @@ enum class TableSelection
*
* \code
* std::vector<ImportProcess> processes;
* GeantProcessImporter import(TableSelection::all, materials, elements);
* GeantProcessImporter import(materials, elements);
*
* G4ParticleTable::G4PTblDicIterator& particle_iterator
* = *(G4ParticleTable::GetParticleTable()->GetIterator());
Expand Down Expand Up @@ -82,8 +74,7 @@ class GeantProcessImporter
{
public:
// Construct with selected list of tables
GeantProcessImporter(TableSelection which_tables,
std::vector<ImportPhysMaterial> const& materials,
GeantProcessImporter(std::vector<ImportPhysMaterial> const& materials,
std::vector<ImportElement> const& elements);

// Import processes
Expand Down
4 changes: 2 additions & 2 deletions src/celeritas/io/ImportParameters.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//---------------------------------------------------------------------------//
#pragma once

#include <unordered_map>
#include <map>

#include "celeritas/Constants.hh"
#include "celeritas/Types.hh"
Expand Down Expand Up @@ -107,7 +107,7 @@ struct ImportTransParameters
//!@{
//! \name Type aliases
using PDGInt = int;
using ImportLoopingMap = std::unordered_map<PDGInt, ImportLoopingThreshold>;
using ImportLoopingMap = std::map<PDGInt, ImportLoopingThreshold>;
//!@}

//! Thresholds for killing looping tracks
Expand Down
7 changes: 7 additions & 0 deletions src/celeritas/track/ExtendFromSecondariesAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ void ExtendFromSecondariesAction::step_impl(CoreParams const& core_params,

/*! \todo If we don't have space for all the secondaries, we will need to
* buffer the current track initializers to create room.
*
* This isn't trivial because we will need to:
* - Allocate a new buffer (probably do something like 2x, rounding up to
* nearest power of 2)?
* - Update the collection references for track sim
* - Update the *copies* of that reference (?) like in track state
* - Copy to device to update the on-device refrences (state.ptr)
*/
counters.num_initializers += counters.num_secondaries;
CELER_VALIDATE(counters.num_initializers <= init.initializers.size(),
Expand Down
Binary file modified test/celeritas/data/four-steel-slabs.root
Binary file not shown.
Binary file modified test/celeritas/data/lar-sphere.root
Binary file not shown.
Binary file modified test/celeritas/data/simple-cms.root
Binary file not shown.
16 changes: 8 additions & 8 deletions test/celeritas/ext/RootJsonDumper.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ TEST_F(RootJsonDumperTest, all)
"name" : "G4_STAINLESS-STEEL",
"state" : 1,
"temperature" : 293.15,
"number_density" : 86993489258991530803200,
"number_density" : 86993489258991547580416,
"elements" : [{
"_typename" : "celeritas::ImportMatElemComponent",
"element_id" : 0,
Expand Down Expand Up @@ -263,8 +263,8 @@ TEST_F(RootJsonDumperTest, all)
"range" : 0.1
}}]
}],
"optical_models" : [],
"optical_materials" : [],
"optical_models": [],
"regions" : [{
"_typename" : "celeritas::ImportRegion",
"name" : "DefaultRegionForTheWorld",
Expand Down Expand Up @@ -387,7 +387,7 @@ TEST_F(RootJsonDumperTest, all)
"_typename" : "celeritas::ImportPhysicsVector",
"vector_type" : 2,
"x" : [1e-4, 100],
"y" : [0.0919755519795958, 128.588033594672]
"y" : [0.0919755519795959, 128.588033594672]
}]
}
}, {
Expand Down Expand Up @@ -441,23 +441,23 @@ TEST_F(RootJsonDumperTest, all)
},
"trans_params" : {
"_typename" : "celeritas::ImportTransParameters",
"looping" : [{"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : -11, "second" : {
"looping" : [{"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : -13, "second" : {
"_typename" : "celeritas::ImportLoopingThreshold",
"threshold_trials" : 10,
"important_energy" : 250
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : 11, "second" : {
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : -11, "second" : {
"_typename" : "celeritas::ImportLoopingThreshold",
"threshold_trials" : 10,
"important_energy" : 250
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : 22, "second" : {
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : 11, "second" : {
"_typename" : "celeritas::ImportLoopingThreshold",
"threshold_trials" : 10,
"important_energy" : 250
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : -13, "second" : {
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : 13, "second" : {
"_typename" : "celeritas::ImportLoopingThreshold",
"threshold_trials" : 10,
"important_energy" : 250
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : 13, "second" : {
}}, {"$pair" : "pair<int,celeritas::ImportLoopingThreshold>", "first" : 22, "second" : {
"_typename" : "celeritas::ImportLoopingThreshold",
"threshold_trials" : 10,
"important_energy" : 250
Expand Down
17 changes: 13 additions & 4 deletions test/celeritas/user/SimpleLoopTestBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ namespace celeritas
{
namespace test
{
//---------------------------------------------------------------------------//
/*!
* Number primaries given number track slots.
*
* Default is passthrough.
*/
size_type SimpleLoopTestBase::initial_occupancy(size_type num_tracks) const
{
return num_tracks;
}

//---------------------------------------------------------------------------//
/*!
* Run a stepping loop with the core data.
Expand All @@ -30,11 +41,9 @@ void SimpleLoopTestBase::run_impl(size_type num_tracks, size_type num_steps)
Stepper<M> step(step_inp);
LogContextException log_context{this->output_reg().get()};

double primary_frac = this->initial_occupancy();
CELER_VALIDATE(primary_frac >= 0, << "invalid initial occupancy");
size_type num_primaries = this->initial_occupancy(num_tracks);
// Initial step
auto primaries = this->make_primaries(
static_cast<size_type>(num_tracks * primary_frac));
auto primaries = this->make_primaries(num_primaries);
StepperResult count;
CELER_TRY_HANDLE(count = step(make_span(primaries)), log_context);

Expand Down
4 changes: 2 additions & 2 deletions test/celeritas/user/SimpleLoopTestBase.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class SimpleLoopTestBase : virtual public GlobalTestBase
public:
virtual VecPrimary make_primaries(size_type count) const = 0;

//! # primaries / # track slots
virtual double initial_occupancy() const { return 1.0; }
// # primaries given # track slots: default is passthrough
virtual size_type initial_occupancy(size_type num_tracks) const;

protected:
template<MemSpace M>
Expand Down
31 changes: 27 additions & 4 deletions test/celeritas/user/SlotDiagnostic.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ void SlotDiagnosticTest::RunResult::print_expected() const
class TestEm3SlotTest : virtual public TestEm3Base,
virtual public SlotDiagnosticTest
{
double initial_occupancy() const override { return 0.125; }
protected:
size_type initial_occupancy(size_type track_slots) const override
{
return static_cast<size_type>(0.125 * track_slots);
}

auto build_init() -> SPConstTrackInit override
{
Expand Down Expand Up @@ -265,15 +269,34 @@ TEST_F(TestEm3SlotTest, TEST_IF_CELER_DEVICE(device))
}
}

TEST_F(TestEm3SlotTest, DISABLED_long_demo)
//---------------------------------------------------------------------------//
class LongDemoTest : public TestEm3SlotTest
{
protected:
size_type initial_occupancy(size_type) const final { return 16; }
};

TEST_F(LongDemoTest, more_steps)
{
if (celeritas::device())
{
this->run<MemSpace::device>(32, 512);
}
else
{
this->run<MemSpace::host>(32, 512);
}
}

TEST_F(LongDemoTest, more_slots)
{
if (celeritas::device())
{
this->run<MemSpace::device>(512, 256);
this->run<MemSpace::device>(96, 512);
}
else
{
this->run<MemSpace::host>(512, 256);
this->run<MemSpace::host>(96, 512);
}
}

Expand Down

0 comments on commit a3088af

Please sign in to comment.