Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optical Processes #1162

Closed
wants to merge 11 commits into from
5 changes: 5 additions & 0 deletions src/celeritas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ list(APPEND SOURCES
global/detail/ActionSequence.cc
global/detail/PinnedAllocator.cc
grid/GenericGridBuilder.cc
grid/GenericGridInserter.cc
grid/ValueGridBuilder.cc
grid/ValueGridInserter.cc
grid/ValueGridType.cc
io/AtomicRelaxationReader.cc
io/ImportData.cc
io/ImportMaterial.cc
io/ImportModel.cc
io/ImportOpticalProcess.cc
io/ImportPhysicsTable.cc
io/ImportPhysicsVector.cc
io/ImportProcess.cc
Expand All @@ -70,6 +72,8 @@ list(APPEND SOURCES
neutron/process/NeutronElasticProcess.cc
neutron/process/NeutronInelasticProcess.cc
optical/CerenkovParams.cc
optical/ImportedOpticalProcessAdapter.cc
optical/OpticalPhysicsParams.cc
optical/OpticalCollector.cc
optical/OpticalPropertyParams.cc
optical/OpticalTrackData.cc
Expand Down Expand Up @@ -256,6 +260,7 @@ celeritas_polysource(global/alongstep/AlongStepNeutralAction)
celeritas_polysource(global/alongstep/AlongStepUniformMscAction)
celeritas_polysource(global/alongstep/AlongStepRZMapFieldMscAction)
celeritas_polysource(neutron/model/ChipsNeutronElasticModel)
celeritas_polysource(optical/AbsorptionModel)
celeritas_polysource(neutron/model/NeutronInelasticModel)
celeritas_polysource(optical/detail/CerenkovPreGenAction)
celeritas_polysource(optical/detail/OpticalGenAlgorithms)
Expand Down
3 changes: 3 additions & 0 deletions src/celeritas/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ using ParticleId = OpaqueId<struct Particle_>;
//! Opaque index of physics process
using ProcessId = OpaqueId<class Process>;

//! Opaque index of optical process
using OpticalProcessId = OpaqueId<class OpticalProcess>;

//! Unique ID (for an event) of a track among all primaries and secondaries
using TrackId = OpaqueId<struct Track_>;

Expand Down
77 changes: 77 additions & 0 deletions src/celeritas/grid/GenericGridInserter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/grid/GenericGridInserter.cc
//---------------------------------------------------------------------------//
#include "GenericGridInserter.hh"

#include "celeritas/io/ImportPhysicsVector.hh"

namespace celeritas
{
// //---------------------------------------------------------------------------//
// /*!
// * Construct with a reference to mutable host data.
// */
// GenericGridInserter::GenericGridInserter(RealCollection* real_data,
// GenericGridCollection* grid)
// : grid_builder_(real_data), grids_(grid)
// {
// CELER_EXPECT(real_data && grid);
// }
//
// //---------------------------------------------------------------------------//
// /*!
// * Add an imported physics vector as a generic grid to the collection.
// * Returns the id of the inserted grid, or an empty id if the vector is
// empty.
// */
// auto GenericGridInserter::operator()(ImportPhysicsVector const& vec)
// -> GenericIndex
// {
// if (vec.x.empty())
// return GenericIndex{};
//
// return grids_.push_back(grid_builder_(vec));
// }
//
// //---------------------------------------------------------------------------//
// /*!
// * Add a grid of generic data with linear interpolation to the collection.
// */
// auto GenericGridInserter::operator()(SpanConstFlt grid, SpanConstFlt values)
// -> GenericIndex
// {
// if (grid.empty())
// return GenericIndex{};
//
// return grids_.push_back(grid_builder_(grid, values));
// }
//
// //---------------------------------------------------------------------------//
// /*!
// * Add a grid of generic data with linear interpolation to the collection.
// */
// auto GenericGridInserter::operator()(SpanConstDbl grid, SpanConstDbl values)
// -> GenericIndex
// {
// if (grid.empty())
// return GenericIndex{};
//
// return grids_.push_back(grid_builder_(grid, values));
// }
//
// //---------------------------------------------------------------------------//
// /*!
// * Add an empty grid. Useful for when there's no imported grid present for
// * a given material.
// */
// auto GenericGridInserter::operator()(void) -> GenericIndex
// {
// return grids_.push_back({});
// }
//
// //---------------------------------------------------------------------------//
} // namespace celeritas
64 changes: 64 additions & 0 deletions src/celeritas/io/ImportOpticalProcess.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/io/ImportOpticalProcess.cc
//---------------------------------------------------------------------------//
#include "ImportOpticalProcess.hh"

#include "corecel/io/EnumStringMapper.hh"
#include "corecel/io/StringEnumMapper.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Enumerator for the available optical physics processes.
*
* This enum was created to safely access the many physics tables imported.
*/
char const* to_cstring(ImportOpticalProcessClass value)
{
static EnumStringMapper<ImportOpticalProcessClass> const to_cstring_impl{
"",
"absorption",
"rayleigh",
"wls",
};
return to_cstring_impl(value);
}

//---------------------------------------------------------------------------//
/*!
* Get the default Geant4 process name for an ImportOpticalProcessClass.
*/
char const* to_geant_name(ImportOpticalProcessClass value)
{
static EnumStringMapper<ImportOpticalProcessClass> const to_name_impl{
"", // unknown,
"absorption",
"rayleigh",
"wls",
};
return to_name_impl(value);
}

//---------------------------------------------------------------------------//
/*!
* Convert a Geant4 process name to an IPC.
*
* This will throw a \c celeritas::RuntimeError if the string is not known to
* us.
*/
ImportOpticalProcessClass
geant_name_to_import_optical_process_class(std::string_view s)
{
static auto const from_string
= StringEnumMapper<ImportOpticalProcessClass>::from_cstring_func(
to_geant_name, "optical process class");

return from_string(s);
}
//---------------------------------------------------------------------------//
} // namespace celeritas
65 changes: 65 additions & 0 deletions src/celeritas/io/ImportOpticalProcess.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/io/ImportOpticalProcess.hh
//---------------------------------------------------------------------------//
#pragma once

#include "ImportProcess.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
*/
enum class ImportOpticalProcessClass
{
other,
// Optical
absorption,
rayleigh,
wavelength_shifting,
size_
};

//---------------------------------------------------------------------------//
/*!
* Brief class description.
*
* Optional detailed class description, and possibly example usage:
* \code
ImportOpticalProcess ...;
\endcode
*/
struct ImportOpticalProcess
{
const ImportProcessType process_type{ImportProcessType::optical};
ImportOpticalProcessClass process_class{ImportOpticalProcessClass::size_};
ImportPhysicsTable lambda_table;

explicit operator bool() const
{
return process_type == ImportProcessType::optical
&& process_class != ImportOpticalProcessClass::size_
&& lambda_table.table_type == ImportTableType::lambda
&& lambda_table;
}
};

//---------------------------------------------------------------------------//
// FREE FUNCTIONS
//---------------------------------------------------------------------------//

// Get the string form of one of the enumerations
char const* to_cstring(ImportOpticalProcessClass value);

// Get the default Geant4 process name
char const* to_geant_name(ImportOpticalProcessClass value);
// Convert a Geant4 process name to an IPC (throw RuntimeError if unsupported)
ImportOpticalProcessClass
geant_name_to_import_optical_process_class(std::string_view sv);

//---------------------------------------------------------------------------//
} // namespace celeritas
32 changes: 32 additions & 0 deletions src/celeritas/optical/AbsorptionModel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/optical/AbsorptionProcess.cc
//---------------------------------------------------------------------------//
#include "AbsorptionModel.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//

AbsorptionModel::AbsorptionModel(ActionId id, MaterialParams const&)
: OpticalModel(id)
{
}

void AbsorptionModel::execute(OpticalParams const& params,
OpticalStateHost& state) const
{
}

#if !CELER_USE_DEVICE
void AbsorptionModel::execute(OpticalParams const&, OpticalStateDevice&) const
{
CELER_NOT_CONFIGURED("CUDA OR HIP");
}
#endif

//---------------------------------------------------------------------------//
} // namespace celeritas
18 changes: 18 additions & 0 deletions src/celeritas/optical/AbsorptionModel.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//---------------------------------*-CUDA-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/optical/AbsorptionProcess.cu
//---------------------------------------------------------------------------//
#include "AbsorptionModel.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
void AbsorptionModel::execute(OpticalParams const& params,
OpticalStateDevice& state) const
{
}
//---------------------------------------------------------------------------//
} // namespace celeritas
63 changes: 63 additions & 0 deletions src/celeritas/optical/AbsorptionModel.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/optical/AbsorptionProcess.hh
//---------------------------------------------------------------------------//
#pragma once

#include "celeritas/io/ImportOpticalProcess.hh"

#include "OpticalModel.hh"

namespace celeritas
{
class MaterialParams;
//---------------------------------------------------------------------------//
/*!
* Optical absorption model.
*
* Models absorption of optical photons in a material based on the materials
* absorption (attenuation) length. The absorption length determines the
* step length, and calling the interaction simply kills the track and
* deposits the energy.
*/
class AbsorptionModel : public OpticalModel
{
public:
//! Construct an absorption model with the action id.
AbsorptionModel(ActionId id, MaterialParams const&);

//! Execute the absorption interaction on the host
void execute(OpticalParams const&, OpticalStateHost&) const override final;

//! Execute the absorption interaction on the device
void
execute(OpticalParams const&, OpticalStateDevice&) const override final;

//! Label of the absorption model.
std::string_view label() const override final
{
return "optical-absorption";
}

//! Description of the absorption model.
std::string_view description() const override final
{
return "optical photon absorbed by material";
}

//! Label of the absorption process.
static std::string_view process_label() { return "Absorption"; }

//! IPC of the absorption process.
constexpr static ImportOpticalProcessClass process_class()
{
return ImportOpticalProcessClass::absorption;
}

// No data used by absorption
};
//---------------------------------------------------------------------------//
} // namespace celeritas
Loading
Loading