Implement recommended changes

This commit is contained in:
Jose Ignacio Marquez Damian 2022-09-26 11:19:54 +02:00 committed by Thomas Kittelmann
parent 29a10eafd3
commit 2e19260dea
6 changed files with 35 additions and 42 deletions

View file

@ -142,18 +142,18 @@ void sample_neutron_reaction(Particle& p)
// exiting neutron
#ifdef NCRYSTAL
if (model::materials[p.material()]->m_NCrystal_mat() != nullptr && p.E() < settings::ncrystal_max_energy){
NcrystalRNG_Wrapper rng(p.current_seed()); // Initialize RNG
if (model::materials[p.material()]->ncrystal_mat() && p.E() < settings::ncrystal_max_energy){
NCrystalRNGWrapper rng(p.current_seed()); // Initialize RNG
//create a cache pointer for multi thread physics
NCrystal::CachePtr dummyCache;//fixme: avoid recreating here (triggers malloc)
NCrystal::CachePtr dummy_cache;
auto nc_energy = NCrystal::NeutronEnergy{p.E()};
auto outcome = model::materials[p.material()]->m_NCrystal_mat()->sampleScatter( dummyCache, rng , nc_energy, {p.u().x, p.u().y, p.u().z});
auto outcome = model::materials[p.material()]->ncrystal_mat()->sampleScatter( dummy_cache, rng , nc_energy, {p.u().x, p.u().y, p.u().z});
p.E_last() = p.E();
p.E() = outcome.ekin.get();
Direction u_old {p.u()};
p.u() = Direction(outcome.direction[0], outcome.direction[1], outcome.direction[2]);
p.mu() = u_old.dot(p.u());
p.event_mt() = ELASTIC;//fixme: define a new label for NCrystal?
p.event_mt() = ELASTIC;
} else {
scatter(p, i_nuclide);
}