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

Add volume-to-material mapping and change import data #1378

Merged
merged 18 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 64 additions & 63 deletions app/celer-dump-data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ void print_atomic_relaxation_data(
/*!
* Print optical material properties map.
*/
void print_optical_material_data(ImportData::ImportOpticalMap const& iom)
void print_optical_materials(std::vector<ImportOpticalMaterial> const& iom)
{
if (iom.empty())
{
Expand Down Expand Up @@ -779,81 +779,76 @@ void print_optical_material_data(ImportData::ImportOpticalMap const& iom)
cout << "\n# Optical properties\n";
cout << "\n## Common properties";
cout << header;
for (auto const& [mid, val] : iom)
for (auto mid : range(iom.size()))
{
auto const& prop = val.properties;
auto const& prop = iom[mid].properties;
cout << POM_STREAM_VECTOR(mid, prop, refractive_index, IU::unitless);
}

if (iom.begin()->second.scintillation)
cout << "\n## Scintillation";
cout << header;
static char const* comp_str[] = {"(fast)", " (mid)", "(slow)"};
for (auto mid : range(iom.size()))
{
cout << "\n## Scintillation";
cout << header;
char const* comp_str[] = {"(fast)", " (mid)", "(slow)"};
for (auto const& [mid, val] : iom)
auto const& scint = iom[mid].scintillation;
if (!scint)
{
auto const& scint = val.scintillation;
cout << POM_STREAM_SCALAR(
mid, scint, material.yield_per_energy, IU::inv_mev);
cout << POM_STREAM_SCALAR(
mid, scint, resolution_scale, IU::unitless);
for (auto i : range(scint.material.components.size()))
{
auto const& comp = scint.material.components[i];
cout << POM_STREAM_SCALAR_COMP(
mid, comp, yield_frac, IU::inv_mev, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, lambda_mean, IU::len, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, lambda_sigma, IU::len, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, rise_time, IU::time, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, fall_time, IU::time, comp_str[i]);
}
continue;
}
cout << POM_STREAM_SCALAR(
mid, scint, material.yield_per_energy, IU::inv_mev);
cout << POM_STREAM_SCALAR(mid, scint, resolution_scale, IU::unitless);
for (auto i : range(scint.material.components.size()))
{
auto const& comp = scint.material.components[i];
cout << POM_STREAM_SCALAR_COMP(
mid, comp, yield_frac, IU::inv_mev, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, lambda_mean, IU::len, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, lambda_sigma, IU::len, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, rise_time, IU::time, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, fall_time, IU::time, comp_str[i]);
}
}

if (iom.begin()->second.rayleigh)
cout << "\n## Rayleigh";
cout << header;
for (auto mid : range(iom.size()))
{
cout << "\n## Rayleigh";
cout << header;
for (auto const& [mid, val] : iom)
auto const& rayl = iom[mid].rayleigh;
if (!rayl)
{
auto const& rayl = val.rayleigh;
cout << POM_STREAM_SCALAR(mid, rayl, scale_factor, IU::unitless);
cout << POM_STREAM_SCALAR(
mid, rayl, compressibility, IU::len_time_sq_per_mass);
cout << POM_STREAM_VECTOR(mid, rayl, mfp, IU::len);
continue;
}
cout << POM_STREAM_SCALAR(mid, rayl, scale_factor, IU::unitless);
cout << POM_STREAM_SCALAR(
mid, rayl, compressibility, IU::len_time_sq_per_mass);
cout << POM_STREAM_VECTOR(mid, rayl, mfp, IU::len);
}

if (iom.begin()->second.absorption)
cout << "\n## Absorption";
cout << header;
for (auto mid : range(iom.size()))
{
cout << "\n## Absorption";
cout << header;
for (auto const& [mid, val] : iom)
{
auto const& abs = val.absorption;
cout << POM_STREAM_VECTOR(mid, abs, absorption_length, IU::len);
}
cout << endl;
auto const& abs = iom[mid].absorption;
cout << POM_STREAM_VECTOR(mid, abs, absorption_length, IU::len);
}
cout << endl;

if (iom.begin()->second.wls)
cout << "\n## WLS";
cout << header;
for (auto mid : range(iom.size()))
{
cout << "\n## WLS";
cout << header;
for (auto const& [mid, val] : iom)
{
auto const& wls = val.wls;
cout << POM_STREAM_SCALAR(mid, wls, mean_num_photons, IU::unitless);
cout << POM_STREAM_SCALAR(mid, wls, time_constant, IU::time);
cout << POM_STREAM_VECTOR(mid, wls, absorption_length, IU::len);
cout << POM_STREAM_VECTOR(mid, wls, component, IU::unitless);
}
cout << endl;
auto const& wls = iom[mid].wls;
cout << POM_STREAM_SCALAR(mid, wls, mean_num_photons, IU::unitless);
cout << POM_STREAM_SCALAR(mid, wls, time_constant, IU::time);
cout << POM_STREAM_VECTOR(mid, wls, absorption_length, IU::len);
cout << POM_STREAM_VECTOR(mid, wls, component, IU::unitless);
}
cout << endl;
#undef PEP_STREAM_SCALAR
#undef PEP_STREAM_VECTOR
}
Expand Down Expand Up @@ -909,22 +904,28 @@ int main(int argc, char* argv[])

auto const&& particle_params = ParticleParams::from_import(data);

print_particles(*particle_params);
print_elements(data.elements, data.isotopes);
print_isotopes(data.isotopes);

print_geo_materials(data.geo_materials, data.elements);
print_phys_materials(
data.phys_materials, data.geo_materials, *particle_params);
print_processes(data, *particle_params);
print_msc_models(data, *particle_params);
print_optical_materials(data.optical_materials);

print_regions(data.regions);
print_volumes(data.volumes, data.geo_materials, data.regions);
print_em_params(data.em_params);
print_trans_params(data.trans_params, *particle_params);

print_particles(*particle_params);
print_processes(data, *particle_params);
print_msc_models(data, *particle_params);

print_sb_data(data.sb_data);
print_livermore_pe_data(data.livermore_pe_data);
print_atomic_relaxation_data(data.atomic_relaxation_data);
print_optical_material_data(data.optical);

print_em_params(data.em_params);
print_trans_params(data.trans_params, *particle_params);
// TODO: print optical params?

return EXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion app/celer-export-geant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ void run(std::string const& gdml_filename,
GeantImporter import(
GeantSetup(gdml_filename, load_options(opts_filename)));
GeantImporter::DataSelection selection;
selection.particles = GeantImporter::DataSelection::em;
selection.particles = GeantImporter::DataSelection::em
| GeantImporter::DataSelection::optical;
selection.processes = selection.particles;
selection.reader_data = true;
return import(selection);
Expand Down
23 changes: 9 additions & 14 deletions app/celer-sim/Runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -559,33 +559,28 @@ void Runner::build_step_collectors(RunnerInput const& inp)
void Runner::build_optical_collector(RunnerInput const& inp,
ImportData const& imported)
{
CELER_EXPECT(core_params_);

using optical::CerenkovParams;
using optical::MaterialParams;
using optical::ScintillationParams;

//! \todo Update conditionals after implementing CelerOpticalPhysicsList
if (imported.optical.empty())
if (imported.optical_materials.empty())
{
// No optical materials are present
return;
}

CELER_EXPECT(core_params_);
OpticalCollector::Input oc_inp;
auto const& optical_data = imported.optical.begin()->second;
if (optical_data.properties)
{
oc_inp.material = MaterialParams::from_import(imported);
oc_inp.cerenkov = std::make_shared<CerenkovParams>(oc_inp.material);
}
if (optical_data.scintillation)
{
oc_inp.scintillation = ScintillationParams::from_import(
imported, core_params_->particle());
}
oc_inp.material = MaterialParams::from_import(
imported, *core_params_->geomaterial(), *core_params_->material());
oc_inp.cerenkov = std::make_shared<CerenkovParams>(oc_inp.material);
oc_inp.scintillation
= ScintillationParams::from_import(imported, core_params_->particle());
oc_inp.buffer_capacity = inp.optical_buffer_capacity;
CELER_ASSERT(oc_inp);

CELER_ASSERT(oc_inp);
optical_collector_
= std::make_shared<OpticalCollector>(*core_params_, std::move(oc_inp));
}
Expand Down
4 changes: 2 additions & 2 deletions doc/implementation/core-physics/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material and geometry properties
.. doxygenstruct:: celeritas::ImportTransParameters
.. doxygenstruct:: celeritas::ImportLoopingThreshold

.. doxygenenum:: ImportMaterialState
.. doxygenenum:: celeritas::ImportMaterialState
:no-link:

Physics properties
Expand All @@ -46,5 +46,5 @@ Physics properties
.. doxygenstruct:: celeritas::ImportPhysicsTable
.. doxygenstruct:: celeritas::ImportPhysicsVector

.. doxygenenum:: ImportUnits
.. doxygenenum:: celeritas::ImportUnits
:no-link:
9 changes: 8 additions & 1 deletion doc/implementation/optical-physics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ tracking loop:
Optical materials
=================

.. doxygenclass:: celeritas::optical::MaterialPropertyParams
Each "physics material" (see :cpp:class:`celeritas::ImportPhysMaterial`) can
have an associated "optical material." When importing from Geant4, each optical
material corresponds to a single "geometry material" (see
:cpp:class:`celeritas::ImportGeoMaterial`) that has a ``RINDEX`` material
property, and all physical materials that use the geometry material share
the same optical material.

.. doxygenclass:: celeritas::optical::MaterialParams

Offloading
==========
Expand Down
1 change: 1 addition & 0 deletions src/accel/SharedParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ void SharedParams::initialize_core(SetupOptions const& options)
celeritas::GeantImporter load_geant_data(
GeantImporter::get_world_volume());
// Convert ImportVolume names to GDML versions if we're exporting
// TODO: optical particle/process import
GeantImportDataSelection import_opts;
import_opts.particles = GeantImportDataSelection::em_basic;
import_opts.processes = import_opts.particles;
Expand Down
3 changes: 3 additions & 0 deletions src/celeritas/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ using MaterialId = OpaqueId<class Material_>;
//! Opaque index of model in the list of physics processes
using ModelId = OpaqueId<class Model>;

//! Opaque index to a material with optical properties
using OpticalMaterialId = OpaqueId<struct OpticalMaterial_>;

//! Opaque index to ParticleRecord in a vector: represents a particle type
using ParticleId = OpaqueId<struct Particle_>;

Expand Down
Loading
Loading