Apply clang-format

This commit is contained in:
Jose Ignacio Marquez Damian 2022-09-26 11:30:39 +02:00 committed by Thomas Kittelmann
parent 2e19260dea
commit 5afcc9e49b
6 changed files with 50 additions and 36 deletions

View file

@ -158,15 +158,18 @@ public:
#ifdef NCRYSTAL
//! Get pointer to NCrystal material object
//! \return Pointer to NCrystal material object
std::shared_ptr<const NCrystal::ProcImpl::Process> ncrystal_mat() const {return ncrystal_mat_; };
std::shared_ptr<const NCrystal::ProcImpl::Process> ncrystal_mat() const
{
return ncrystal_mat_;
};
#endif
//----------------------------------------------------------------------------
// Data
int32_t id_ {C_NONE}; //!< Unique ID
std::string name_; //!< Name of material
vector<int> nuclide_; //!< Indices in nuclides vector
vector<int> element_; //!< Indices in elements vector
int32_t id_ {C_NONE}; //!< Unique ID
std::string name_; //!< Name of material
vector<int> nuclide_; //!< Indices in nuclides vector
vector<int> element_; //!< Indices in elements vector
#ifdef NCRYSTAL
std::string ncrystal_cfg_; //!< NCrystal configuration string
std::shared_ptr<const NCrystal::ProcImpl::Process> ncrystal_mat_;

View file

@ -111,14 +111,17 @@ void split_particle(Particle& p);
//==============================================================================
class NCrystalRNGWrapper : public NCrystal::RNGStream {
uint64_t* openmc_seed_;
public:
constexpr NCrystalRNGWrapper(uint64_t* seed) noexcept : openmc_seed_(seed) {}
protected:
double actualGenerate() override {
return std::max<double>( std::numeric_limits<double>::min(), prn(openmc_seed_) );
}
uint64_t* openmc_seed_;
public:
constexpr NCrystalRNGWrapper(uint64_t* seed) noexcept : openmc_seed_(seed) {}
protected:
double actualGenerate() override
{
return std::max<double>(
std::numeric_limits<double>::min(), prn(openmc_seed_));
}
};
#endif

View file

@ -121,7 +121,8 @@ extern "C" int verbosity; //!< How verbose to make output
extern double weight_cutoff; //!< Weight cutoff for Russian roulette
extern double weight_survive; //!< Survival weight after Russian roulette
#ifdef NCRYSTAL
extern double ncrystal_max_energy; // Energy in eV to switch between NCrystal and ENDF
extern double
ncrystal_max_energy; //!< Energy in eV to switch between NCrystal and ENDF
#endif
} // namespace settings

View file

@ -64,7 +64,7 @@ Material::Material(pugi::xml_node node)
if (check_for_node(node, "cfg")) {
cfg_ = get_node_value(node, "cfg");
write_message(5, "NCrystal config string: '{}'", ncrystal_cfg_);
ncrystal_mat_ = NCrystal::FactImpl::createScatter(ncrystal_cfg_);
ncrystal_mat_ = NCrystal::FactImpl::createScatter(ncrystal_cfg_);
}
#endif
@ -375,8 +375,8 @@ void Material::finalize()
this->init_thermal();
}
// Normalize density
this->normalize_density();
// Normalize density
this->normalize_density();
}
void Material::normalize_density()
@ -803,11 +803,14 @@ void Material::calculate_neutron_xs(Particle& p) const
#ifdef NCRYSTAL
double ncrystal_xs = -1;
if (ncrystal_mat_ && p.E() < settings::ncrystal_max_energy){
if (ncrystal_mat_ && p.E() < settings::ncrystal_max_energy) {
// Calculate scattering XS per atom with NCrystal, only once per material
NCrystal::CachePtr dummy_cache;
auto nc_energy = NCrystal::NeutronEnergy{p.E()};
ncrystal_xs = ncrystal_mat_->crossSection( dummy_cache, nc_energy, {p.u().x, p.u().y, p.u().z}).get();
auto nc_energy = NCrystal::NeutronEnergy {p.E()};
ncrystal_xs =
ncrystal_mat_
->crossSection(dummy_cache, nc_energy, {p.u().x, p.u().y, p.u().z})
.get();
}
#endif
@ -859,15 +862,15 @@ void Material::calculate_neutron_xs(Particle& p) const
i_sab != micro.index_sab || sab_frac != micro.sab_frac) {
data::nuclides[i_nuclide]->calculate_xs(i_sab, i_grid, sab_frac, p);
#ifdef NCRYSTAL
if (ncrystal_xs >= 0.0){
if ( micro.thermal > 0 || micro.thermal_elastic > 0) {
fatal_error("S(a,b) treatment and NCrystal are not compatible.");
}
data::nuclides[i_nuclide]->calculate_elastic_xs(p);
// remove free atom cross section
// and replace it by scattering cross section per atom from NCrystal
micro.total = micro.total - micro.elastic + ncrystal_xs;
micro.elastic = ncrystal_xs;
if (ncrystal_xs >= 0.0) {
if (micro.thermal > 0 || micro.thermal_elastic > 0) {
fatal_error("S(a,b) treatment and NCrystal are not compatible.");
}
data::nuclides[i_nuclide]->calculate_elastic_xs(p);
// remove free atom cross section
// and replace it by scattering cross section per atom from NCrystal
micro.total = micro.total - micro.elastic + ncrystal_xs;
micro.elastic = ncrystal_xs;
}
#endif
}

View file

@ -138,20 +138,24 @@ void sample_neutron_reaction(Particle& p)
if (!p.alive())
return;
// Sample a scattering reaction and determine the secondary energy of the
// exiting neutron
// Sample a scattering reaction and determine the secondary energy of the
// exiting neutron
#ifdef NCRYSTAL
if (model::materials[p.material()]->ncrystal_mat() && p.E() < settings::ncrystal_max_energy){
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
// create a cache pointer for multi thread physics
NCrystal::CachePtr dummy_cache;
auto nc_energy = NCrystal::NeutronEnergy{p.E()};
auto outcome = model::materials[p.material()]->ncrystal_mat()->sampleScatter( dummy_cache, rng , nc_energy, {p.u().x, p.u().y, p.u().z});
auto nc_energy = NCrystal::NeutronEnergy {p.E()};
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.u() = Direction(
outcome.direction[0], outcome.direction[1], outcome.direction[2]);
p.mu() = u_old.dot(p.u());
p.event_mt() = ELASTIC;
} else {

View file

@ -119,7 +119,7 @@ double weight_cutoff {0.25};
double weight_survive {1.0};
#ifdef NCRYSTAL
double ncrystal_max_energy{5.0};
double ncrystal_max_energy {5.0};
#endif
} // namespace settings