Skip to content

Commit

Permalink
Change NeutronInelasticIds to NeutronInelasticScalars and move other …
Browse files Browse the repository at this point in the history
…scalar data to NeutronInelasticScalars
  • Loading branch information
whokion committed Mar 19, 2024
1 parent f6aa522 commit 0cca2ce
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 52 deletions.
54 changes: 28 additions & 26 deletions src/celeritas/neutron/data/NeutronInelasticData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,33 @@ namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Model and particles IDs for neutron--nucleus inelastic interactions.
* Scalar data for neutron-nucleus inelastic interactions.
*/
struct NeutronInelasticIds
struct NeutronInelasticScalars
{
ActionId action;
ParticleId neutron;
//! Action and particle IDs
ActionId action_id;
ParticleId neutron_id;

//! Whether the IDs are assigned
explicit CELER_FUNCTION operator bool() const { return action && neutron; }
//! Particle mass * c^2 [MeV]
units::MevMass neutron_mass;

//! Model's minimum and maximum energy limit [MeV]
static CELER_CONSTEXPR_FUNCTION units::MevEnergy min_valid_energy()
{
return units::MevEnergy{1e-7};
}

static CELER_CONSTEXPR_FUNCTION units::MevEnergy max_valid_energy()
{
return units::MevEnergy{2e+4};
}

//! Whether data are assigned
explicit CELER_FUNCTION operator bool() const
{
return action_id && neutron_id && neutron_mass > zero_quantity();
}
};

//---------------------------------------------------------------------------//
Expand All @@ -46,41 +64,25 @@ struct NeutronInelasticData

//// MEMBER DATA ////

//! Particle IDs
NeutronInelasticIds ids;

//! Particle mass * c^2 [MeV]
units::MevMass neutron_mass;
//! Scalar data
NeutronInelasticScalars scalars;

//! Microscopic (element) cross section data (G4PARTICLEXS/neutron/inelZ)
Items<real_type> reals;
ElementItems<GenericGridData> micro_xs;

//! Model's minimum and maximum energy limit [MeV]
static CELER_CONSTEXPR_FUNCTION units::MevEnergy min_valid_energy()
{
return units::MevEnergy{1e-7};
}

static CELER_CONSTEXPR_FUNCTION units::MevEnergy max_valid_energy()
{
return units::MevEnergy{2e+4};
}

//! Whether the data are assigned
explicit CELER_FUNCTION operator bool() const
{
return ids && neutron_mass > zero_quantity() && !reals.empty()
&& !micro_xs.empty();
return scalars && !reals.empty() && !micro_xs.empty();
}

//! Assign from another set of data
template<Ownership W2, MemSpace M2>
NeutronInelasticData& operator=(NeutronInelasticData<W2, M2> const& other)
{
CELER_EXPECT(other);
ids = other.ids;
neutron_mass = other.neutron_mass;
scalars = other.scalars;
reals = other.reals;
micro_xs = other.micro_xs;
return *this;
Expand Down
11 changes: 2 additions & 9 deletions src/celeritas/neutron/interactor/NeutronInelasticInteractor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ NeutronInelasticInteractor::NeutronInelasticInteractor(
IsotopeView const& target)
: shared_(shared), inc_direction_(inc_direction), target_(target)
{
CELER_EXPECT(particle.particle_id() == shared_.ids.neutron);
CELER_EXPECT(particle.particle_id() == shared_.scalars.neutron_id);
}
//---------------------------------------------------------------------------//
/*!
Expand All @@ -79,14 +79,7 @@ NeutronInelasticInteractor::NeutronInelasticInteractor(
template<class Engine>
CELER_FUNCTION Interaction NeutronInelasticInteractor::operator()(Engine&)
{
// Dummy for now
Interaction result;
result.direction = inc_direction_;
real_type target_mass = value_as<Mass>(target_.nuclear_mass());
result.energy = Energy(target_mass);
CELER_ENSURE(result.action == Interaction::Action::absorbed);

return result;
CELER_NOT_IMPLEMENTED("Neutron inelastic interaction");
}

//---------------------------------------------------------------------------//
Expand Down
28 changes: 11 additions & 17 deletions src/celeritas/neutron/model/NeutronInelasticModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ NeutronInelasticModel::NeutronInelasticModel(ActionId id,
HostVal<NeutronInelasticData> data;

// Save IDs
data.ids.action = id;
data.ids.neutron = particles.find(pdg::neutron());
data.scalars.action_id = id;
data.scalars.neutron_id = particles.find(pdg::neutron());

CELER_VALIDATE(data.ids.neutron,
CELER_VALIDATE(data.scalars.neutron_id,
<< "missing neutron particles (required for "
<< this->description() << ")");

// Save particle properties
data.neutron_mass = particles.get(data.ids.neutron).mass();
data.scalars.neutron_mass = particles.get(data.scalars.neutron_id).mass();

// Load neutron elastic cross section data
make_builder(&data.micro_xs).reserve(materials.num_elements());
Expand All @@ -69,9 +69,9 @@ NeutronInelasticModel::NeutronInelasticModel(ActionId id,
auto NeutronInelasticModel::applicability() const -> SetApplicability
{
Applicability neutron_applic;
neutron_applic.particle = this->host_ref().ids.neutron;
neutron_applic.lower = this->host_ref().min_valid_energy();
neutron_applic.upper = this->host_ref().max_valid_energy();
neutron_applic.particle = this->host_ref().scalars.neutron_id;
neutron_applic.lower = this->host_ref().scalars.min_valid_energy();
neutron_applic.upper = this->host_ref().scalars.max_valid_energy();

return {neutron_applic};
}
Expand All @@ -91,15 +91,9 @@ auto NeutronInelasticModel::micro_xs(Applicability) const -> MicroXsBuilders
/*!
* Apply the interaction kernel.
*/
void NeutronInelasticModel::execute(CoreParams const& params,
CoreStateHost& state) const
void NeutronInelasticModel::execute(CoreParams const&, CoreStateHost&) const
{
auto execute = make_action_track_executor(
params.ptr<MemSpace::native>(),
state.ptr(),
this->action_id(),
InteractionApplier{NeutronInelasticExecutor{this->host_ref()}});
return launch_action(*this, params, state, execute);
CELER_NOT_IMPLEMENTED("Neutron inelastic interaction");
}

//---------------------------------------------------------------------------//
Expand All @@ -112,11 +106,11 @@ void NeutronInelasticModel::execute(CoreParams const&, CoreStateDevice&) const

//---------------------------------------------------------------------------//
/*!
* Get the model ID for this model.
* Get the acition ID for this model.
*/
ActionId NeutronInelasticModel::action_id() const
{
return this->host_ref().ids.action;
return this->host_ref().scalars.action_id;
}

//---------------------------------------------------------------------------//
Expand Down

0 comments on commit 0cca2ce

Please sign in to comment.