mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
Apply clang-format on entire source
This commit is contained in:
parent
4c17061a1d
commit
1bc2bd8460
181 changed files with 7372 additions and 6952 deletions
|
|
@ -14,11 +14,11 @@ namespace openmc {
|
|||
|
||||
class AngleEnergy {
|
||||
public:
|
||||
virtual void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const = 0;
|
||||
virtual void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const = 0;
|
||||
virtual ~AngleEnergy() = default;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_ANGLE_ENERGY_H
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ public:
|
|||
//! to directly modify anything about the particle, but it will do so
|
||||
//! indirectly by calling the particle's appropriate cross_*_bc function.
|
||||
//! \param surf The specific surface on the boundary the particle struck.
|
||||
virtual void
|
||||
handle_particle(Particle& p, const Surface& surf) const = 0;
|
||||
virtual void handle_particle(Particle& p, const Surface& surf) const = 0;
|
||||
|
||||
//! Return a string classification of this BC.
|
||||
virtual std::string type() const = 0;
|
||||
|
|
@ -33,10 +32,9 @@ public:
|
|||
|
||||
class VacuumBC : public BoundaryCondition {
|
||||
public:
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
void handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
std::string type() const override {return "vacuum";}
|
||||
std::string type() const override { return "vacuum"; }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -45,10 +43,9 @@ public:
|
|||
|
||||
class ReflectiveBC : public BoundaryCondition {
|
||||
public:
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
void handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
std::string type() const override {return "reflective";}
|
||||
std::string type() const override { return "reflective"; }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -57,10 +54,9 @@ public:
|
|||
|
||||
class WhiteBC : public BoundaryCondition {
|
||||
public:
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
void handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
std::string type() const override {return "white";}
|
||||
std::string type() const override { return "white"; }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -69,11 +65,9 @@ public:
|
|||
|
||||
class PeriodicBC : public BoundaryCondition {
|
||||
public:
|
||||
PeriodicBC(int i_surf, int j_surf)
|
||||
: i_surf_(i_surf), j_surf_(j_surf)
|
||||
{};
|
||||
PeriodicBC(int i_surf, int j_surf) : i_surf_(i_surf), j_surf_(j_surf) {};
|
||||
|
||||
std::string type() const override {return "periodic";}
|
||||
std::string type() const override { return "periodic"; }
|
||||
|
||||
protected:
|
||||
int i_surf_;
|
||||
|
|
@ -88,8 +82,7 @@ class TranslationalPeriodicBC : public PeriodicBC {
|
|||
public:
|
||||
TranslationalPeriodicBC(int i_surf, int j_surf);
|
||||
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
void handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
protected:
|
||||
//! Vector along which incident particles will be moved
|
||||
|
|
@ -106,8 +99,7 @@ class RotationalPeriodicBC : public PeriodicBC {
|
|||
public:
|
||||
RotationalPeriodicBC(int i_surf, int j_surf);
|
||||
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
void handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
protected:
|
||||
//! Angle about the axis by which particle coordinates will be rotated
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ namespace openmc {
|
|||
class BremsstrahlungData {
|
||||
public:
|
||||
// Data
|
||||
xt::xtensor<double, 2> pdf; //!< Bremsstrahlung energy PDF
|
||||
xt::xtensor<double, 2> cdf; //!< Bremsstrahlung energy CDF
|
||||
xt::xtensor<double, 2> pdf; //!< Bremsstrahlung energy PDF
|
||||
xt::xtensor<double, 2> cdf; //!< Bremsstrahlung energy CDF
|
||||
xt::xtensor<double, 1> yield; //!< Photon yield
|
||||
};
|
||||
|
||||
|
|
@ -32,8 +32,10 @@ public:
|
|||
|
||||
namespace data {
|
||||
|
||||
extern xt::xtensor<double, 1> ttb_e_grid; //! energy T of incident electron in [eV]
|
||||
extern xt::xtensor<double, 1> ttb_k_grid; //! reduced energy W/T of emitted photon
|
||||
extern xt::xtensor<double, 1>
|
||||
ttb_e_grid; //! energy T of incident electron in [eV]
|
||||
extern xt::xtensor<double, 1>
|
||||
ttb_k_grid; //! reduced energy W/T of emitted photon
|
||||
|
||||
} // namespace data
|
||||
|
||||
|
|
|
|||
|
|
@ -1,211 +1,231 @@
|
|||
#ifndef OPENMC_CAPI_H
|
||||
#define OPENMC_CAPI_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int openmc_calculate_volumes();
|
||||
int openmc_cell_filter_get_bins(int32_t index, const int32_t** cells, int32_t* n);
|
||||
int openmc_cell_get_fill(int32_t index, int* type, int32_t** indices, int32_t* n);
|
||||
int openmc_cell_get_id(int32_t index, int32_t* id);
|
||||
int openmc_cell_get_temperature(int32_t index, const int32_t* instance, double* T);
|
||||
int openmc_cell_get_translation(int32_t index, double xyz[]);
|
||||
int openmc_cell_get_rotation(int32_t index, double rot[], size_t* n);
|
||||
int openmc_cell_get_name(int32_t index, const char** name);
|
||||
int openmc_cell_get_num_instances(int32_t index, int32_t* num_instances);
|
||||
int openmc_cell_set_name(int32_t index, const char* name);
|
||||
int openmc_cell_set_fill(int32_t index, int type, int32_t n, const int32_t* indices);
|
||||
int openmc_cell_set_id(int32_t index, int32_t id);
|
||||
int openmc_cell_set_temperature(int32_t index, double T, const int32_t* instance, bool set_contained = false);
|
||||
int openmc_cell_set_translation(int32_t index, const double xyz[]);
|
||||
int openmc_cell_set_rotation(int32_t index, const double rot[], size_t rot_len);
|
||||
int openmc_energy_filter_get_bins(int32_t index, const double** energies, size_t* n);
|
||||
int openmc_energy_filter_set_bins(int32_t index, size_t n, const double* energies);
|
||||
int openmc_energyfunc_filter_get_energy(int32_t index, size_t* n, const double** energy);
|
||||
int openmc_energyfunc_filter_get_y(int32_t index, size_t* n, const double** y);
|
||||
int openmc_energyfunc_filter_set_data(int32_t index, size_t n,
|
||||
const double* energies, const double* y);
|
||||
int openmc_extend_cells(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_filters(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_materials(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_meshes(int32_t n, const char* type, int32_t* index_start,
|
||||
int32_t* index_end);
|
||||
int openmc_extend_tallies(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_filter_get_id(int32_t index, int32_t* id);
|
||||
int openmc_filter_get_type(int32_t index, char* type);
|
||||
int openmc_filter_set_id(int32_t index, int32_t id);
|
||||
int openmc_finalize();
|
||||
int openmc_find_cell(const double* xyz, int32_t* index, int32_t* instance);
|
||||
int openmc_cell_bounding_box(const int32_t index, double* llc, double* urc);
|
||||
int openmc_global_bounding_box(double* llc, double* urc);
|
||||
int openmc_fission_bank(void** ptr, int64_t* n);
|
||||
int openmc_get_cell_index(int32_t id, int32_t* index);
|
||||
int openmc_get_filter_index(int32_t id, int32_t* index);
|
||||
void openmc_get_filter_next_id(int32_t* id);
|
||||
int openmc_get_keff(double k_combined[]);
|
||||
int openmc_get_material_index(int32_t id, int32_t* index);
|
||||
int openmc_get_mesh_index(int32_t id, int32_t* index);
|
||||
int openmc_get_n_batches(int* n_batches, bool get_max_batches);
|
||||
int openmc_get_nuclide_index(const char name[], int* index);
|
||||
int openmc_add_unstructured_mesh(const char filename[], const char library[], int* id);
|
||||
int64_t openmc_get_seed();
|
||||
int openmc_get_tally_index(int32_t id, int32_t* index);
|
||||
void openmc_get_tally_next_id(int32_t* id);
|
||||
int openmc_global_tallies(double** ptr);
|
||||
int openmc_hard_reset();
|
||||
int openmc_init(int argc, char* argv[], const void* intracomm);
|
||||
bool openmc_is_statepoint_batch();
|
||||
int openmc_legendre_filter_get_order(int32_t index, int* order);
|
||||
int openmc_legendre_filter_set_order(int32_t index, int order);
|
||||
int openmc_load_nuclide(const char* name, const double* temps, int n);
|
||||
int openmc_material_add_nuclide(int32_t index, const char name[], double density);
|
||||
int openmc_material_get_densities(int32_t index, const int** nuclides, const double** densities, int* n);
|
||||
int openmc_material_get_id(int32_t index, int32_t* id);
|
||||
int openmc_material_get_fissionable(int32_t index, bool* fissionable);
|
||||
int openmc_material_get_density(int32_t index, double* density);
|
||||
int openmc_material_get_volume(int32_t index, double* volume);
|
||||
int openmc_material_set_density(int32_t index, double density, const char* units);
|
||||
int openmc_material_set_densities(int32_t index, int n, const char** name, const double* density);
|
||||
int openmc_material_set_id(int32_t index, int32_t id);
|
||||
int openmc_material_get_name(int32_t index, const char** name);
|
||||
int openmc_material_set_name(int32_t index, const char* name);
|
||||
int openmc_material_set_volume(int32_t index, double volume);
|
||||
int openmc_material_filter_get_bins(int32_t index, const int32_t** bins, size_t* n);
|
||||
int openmc_material_filter_set_bins(int32_t index, size_t n, const int32_t* bins);
|
||||
int openmc_mesh_filter_get_mesh(int32_t index, int32_t* index_mesh);
|
||||
int openmc_mesh_filter_set_mesh(int32_t index, int32_t index_mesh);
|
||||
int openmc_mesh_filter_get_translation(int32_t index, double translation[3]);
|
||||
int openmc_mesh_filter_set_translation(int32_t index, double translation[3]);
|
||||
int openmc_mesh_get_id(int32_t index, int32_t* id);
|
||||
int openmc_mesh_set_id(int32_t index, int32_t id);
|
||||
int openmc_meshsurface_filter_get_mesh(int32_t index, int32_t* index_mesh);
|
||||
int openmc_meshsurface_filter_set_mesh(int32_t index, int32_t index_mesh);
|
||||
int openmc_new_filter(const char* type, int32_t* index);
|
||||
int openmc_next_batch(int* status);
|
||||
int openmc_nuclide_name(int index, const char** name);
|
||||
int openmc_plot_geometry();
|
||||
int openmc_id_map(const void* slice, int32_t* data_out);
|
||||
int openmc_property_map(const void* slice, double* data_out);
|
||||
int openmc_rectilinear_mesh_get_grid(int32_t index, double** grid_x, int* nx,
|
||||
double** grid_y, int* ny, double** grid_z, int* nz);
|
||||
int openmc_rectilinear_mesh_set_grid(int32_t index, const double* grid_x,
|
||||
const int nx, const double* grid_y, const int ny,
|
||||
const double* grid_z, const int nz);
|
||||
int openmc_regular_mesh_get_dimension(int32_t index, int** id, int* n);
|
||||
int openmc_regular_mesh_get_params(int32_t index, double** ll, double** ur, double** width, int* n);
|
||||
int openmc_regular_mesh_set_dimension(int32_t index, int n, const int* dims);
|
||||
int openmc_regular_mesh_set_params(int32_t index, int n, const double* ll, const double* ur, const double* width);
|
||||
int openmc_reset();
|
||||
int openmc_reset_timers();
|
||||
int openmc_run();
|
||||
void openmc_set_seed(int64_t new_seed);
|
||||
int openmc_set_n_batches(int32_t n_batches, bool set_max_batches,
|
||||
bool add_statepoint_batch);
|
||||
int openmc_simulation_finalize();
|
||||
int openmc_simulation_init();
|
||||
int openmc_source_bank(void** ptr, int64_t* n);
|
||||
int openmc_spatial_legendre_filter_get_order(int32_t index, int* order);
|
||||
int openmc_spatial_legendre_filter_get_params(int32_t index, int* axis, double* min, double* max);
|
||||
int openmc_spatial_legendre_filter_set_order(int32_t index, int order);
|
||||
int openmc_spatial_legendre_filter_set_params(int32_t index, const int* axis,
|
||||
const double* min, const double* max);
|
||||
int openmc_sphharm_filter_get_order(int32_t index, int* order);
|
||||
int openmc_sphharm_filter_get_cosine(int32_t index, char cosine[]);
|
||||
int openmc_sphharm_filter_set_order(int32_t index, int order);
|
||||
int openmc_sphharm_filter_set_cosine(int32_t index, const char cosine[]);
|
||||
int openmc_statepoint_write(const char* filename, bool* write_source);
|
||||
int openmc_tally_allocate(int32_t index, const char* type);
|
||||
int openmc_tally_get_active(int32_t index, bool* active);
|
||||
int openmc_tally_get_estimator(int32_t index, int* estimator);
|
||||
int openmc_tally_get_id(int32_t index, int32_t* id);
|
||||
int openmc_tally_get_filters(int32_t index, const int32_t** indices, size_t* n);
|
||||
int openmc_tally_get_n_realizations(int32_t index, int32_t* n);
|
||||
int openmc_tally_get_nuclides(int32_t index, int** nuclides, int* n);
|
||||
int openmc_tally_get_scores(int32_t index, int** scores, int* n);
|
||||
int openmc_tally_get_type(int32_t index, int32_t* type);
|
||||
int openmc_tally_get_writable(int32_t index, bool* writable);
|
||||
int openmc_tally_reset(int32_t index);
|
||||
int openmc_tally_results(int32_t index, double** ptr, size_t shape_[3]);
|
||||
int openmc_tally_set_active(int32_t index, bool active);
|
||||
int openmc_tally_set_estimator(int32_t index, const char* estimator);
|
||||
int openmc_tally_set_filters(int32_t index, size_t n, const int32_t* indices);
|
||||
int openmc_tally_set_id(int32_t index, int32_t id);
|
||||
int openmc_tally_set_nuclides(int32_t index, int n, const char** nuclides);
|
||||
int openmc_tally_set_scores(int32_t index, int n, const char** scores);
|
||||
int openmc_tally_set_type(int32_t index, const char* type);
|
||||
int openmc_tally_set_writable(int32_t index, bool writable);
|
||||
int openmc_zernike_filter_get_order(int32_t index, int* order);
|
||||
int openmc_zernike_filter_get_params(int32_t index, double* x, double* y, double* r);
|
||||
int openmc_zernike_filter_set_order(int32_t index, int order);
|
||||
int openmc_zernike_filter_set_params(int32_t index, const double* x,
|
||||
const double* y, const double* r);
|
||||
int openmc_calculate_volumes();
|
||||
int openmc_cell_filter_get_bins(
|
||||
int32_t index, const int32_t** cells, int32_t* n);
|
||||
int openmc_cell_get_fill(
|
||||
int32_t index, int* type, int32_t** indices, int32_t* n);
|
||||
int openmc_cell_get_id(int32_t index, int32_t* id);
|
||||
int openmc_cell_get_temperature(
|
||||
int32_t index, const int32_t* instance, double* T);
|
||||
int openmc_cell_get_translation(int32_t index, double xyz[]);
|
||||
int openmc_cell_get_rotation(int32_t index, double rot[], size_t* n);
|
||||
int openmc_cell_get_name(int32_t index, const char** name);
|
||||
int openmc_cell_get_num_instances(int32_t index, int32_t* num_instances);
|
||||
int openmc_cell_set_name(int32_t index, const char* name);
|
||||
int openmc_cell_set_fill(
|
||||
int32_t index, int type, int32_t n, const int32_t* indices);
|
||||
int openmc_cell_set_id(int32_t index, int32_t id);
|
||||
int openmc_cell_set_temperature(
|
||||
int32_t index, double T, const int32_t* instance, bool set_contained = false);
|
||||
int openmc_cell_set_translation(int32_t index, const double xyz[]);
|
||||
int openmc_cell_set_rotation(int32_t index, const double rot[], size_t rot_len);
|
||||
int openmc_energy_filter_get_bins(
|
||||
int32_t index, const double** energies, size_t* n);
|
||||
int openmc_energy_filter_set_bins(
|
||||
int32_t index, size_t n, const double* energies);
|
||||
int openmc_energyfunc_filter_get_energy(
|
||||
int32_t index, size_t* n, const double** energy);
|
||||
int openmc_energyfunc_filter_get_y(int32_t index, size_t* n, const double** y);
|
||||
int openmc_energyfunc_filter_set_data(
|
||||
int32_t index, size_t n, const double* energies, const double* y);
|
||||
int openmc_extend_cells(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_filters(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_materials(
|
||||
int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_meshes(
|
||||
int32_t n, const char* type, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_extend_tallies(int32_t n, int32_t* index_start, int32_t* index_end);
|
||||
int openmc_filter_get_id(int32_t index, int32_t* id);
|
||||
int openmc_filter_get_type(int32_t index, char* type);
|
||||
int openmc_filter_set_id(int32_t index, int32_t id);
|
||||
int openmc_finalize();
|
||||
int openmc_find_cell(const double* xyz, int32_t* index, int32_t* instance);
|
||||
int openmc_cell_bounding_box(const int32_t index, double* llc, double* urc);
|
||||
int openmc_global_bounding_box(double* llc, double* urc);
|
||||
int openmc_fission_bank(void** ptr, int64_t* n);
|
||||
int openmc_get_cell_index(int32_t id, int32_t* index);
|
||||
int openmc_get_filter_index(int32_t id, int32_t* index);
|
||||
void openmc_get_filter_next_id(int32_t* id);
|
||||
int openmc_get_keff(double k_combined[]);
|
||||
int openmc_get_material_index(int32_t id, int32_t* index);
|
||||
int openmc_get_mesh_index(int32_t id, int32_t* index);
|
||||
int openmc_get_n_batches(int* n_batches, bool get_max_batches);
|
||||
int openmc_get_nuclide_index(const char name[], int* index);
|
||||
int openmc_add_unstructured_mesh(
|
||||
const char filename[], const char library[], int* id);
|
||||
int64_t openmc_get_seed();
|
||||
int openmc_get_tally_index(int32_t id, int32_t* index);
|
||||
void openmc_get_tally_next_id(int32_t* id);
|
||||
int openmc_global_tallies(double** ptr);
|
||||
int openmc_hard_reset();
|
||||
int openmc_init(int argc, char* argv[], const void* intracomm);
|
||||
bool openmc_is_statepoint_batch();
|
||||
int openmc_legendre_filter_get_order(int32_t index, int* order);
|
||||
int openmc_legendre_filter_set_order(int32_t index, int order);
|
||||
int openmc_load_nuclide(const char* name, const double* temps, int n);
|
||||
int openmc_material_add_nuclide(
|
||||
int32_t index, const char name[], double density);
|
||||
int openmc_material_get_densities(
|
||||
int32_t index, const int** nuclides, const double** densities, int* n);
|
||||
int openmc_material_get_id(int32_t index, int32_t* id);
|
||||
int openmc_material_get_fissionable(int32_t index, bool* fissionable);
|
||||
int openmc_material_get_density(int32_t index, double* density);
|
||||
int openmc_material_get_volume(int32_t index, double* volume);
|
||||
int openmc_material_set_density(
|
||||
int32_t index, double density, const char* units);
|
||||
int openmc_material_set_densities(
|
||||
int32_t index, int n, const char** name, const double* density);
|
||||
int openmc_material_set_id(int32_t index, int32_t id);
|
||||
int openmc_material_get_name(int32_t index, const char** name);
|
||||
int openmc_material_set_name(int32_t index, const char* name);
|
||||
int openmc_material_set_volume(int32_t index, double volume);
|
||||
int openmc_material_filter_get_bins(
|
||||
int32_t index, const int32_t** bins, size_t* n);
|
||||
int openmc_material_filter_set_bins(
|
||||
int32_t index, size_t n, const int32_t* bins);
|
||||
int openmc_mesh_filter_get_mesh(int32_t index, int32_t* index_mesh);
|
||||
int openmc_mesh_filter_set_mesh(int32_t index, int32_t index_mesh);
|
||||
int openmc_mesh_filter_get_translation(int32_t index, double translation[3]);
|
||||
int openmc_mesh_filter_set_translation(int32_t index, double translation[3]);
|
||||
int openmc_mesh_get_id(int32_t index, int32_t* id);
|
||||
int openmc_mesh_set_id(int32_t index, int32_t id);
|
||||
int openmc_meshsurface_filter_get_mesh(int32_t index, int32_t* index_mesh);
|
||||
int openmc_meshsurface_filter_set_mesh(int32_t index, int32_t index_mesh);
|
||||
int openmc_new_filter(const char* type, int32_t* index);
|
||||
int openmc_next_batch(int* status);
|
||||
int openmc_nuclide_name(int index, const char** name);
|
||||
int openmc_plot_geometry();
|
||||
int openmc_id_map(const void* slice, int32_t* data_out);
|
||||
int openmc_property_map(const void* slice, double* data_out);
|
||||
int openmc_rectilinear_mesh_get_grid(int32_t index, double** grid_x, int* nx,
|
||||
double** grid_y, int* ny, double** grid_z, int* nz);
|
||||
int openmc_rectilinear_mesh_set_grid(int32_t index, const double* grid_x,
|
||||
const int nx, const double* grid_y, const int ny, const double* grid_z,
|
||||
const int nz);
|
||||
int openmc_regular_mesh_get_dimension(int32_t index, int** id, int* n);
|
||||
int openmc_regular_mesh_get_params(
|
||||
int32_t index, double** ll, double** ur, double** width, int* n);
|
||||
int openmc_regular_mesh_set_dimension(int32_t index, int n, const int* dims);
|
||||
int openmc_regular_mesh_set_params(int32_t index, int n, const double* ll,
|
||||
const double* ur, const double* width);
|
||||
int openmc_reset();
|
||||
int openmc_reset_timers();
|
||||
int openmc_run();
|
||||
void openmc_set_seed(int64_t new_seed);
|
||||
int openmc_set_n_batches(
|
||||
int32_t n_batches, bool set_max_batches, bool add_statepoint_batch);
|
||||
int openmc_simulation_finalize();
|
||||
int openmc_simulation_init();
|
||||
int openmc_source_bank(void** ptr, int64_t* n);
|
||||
int openmc_spatial_legendre_filter_get_order(int32_t index, int* order);
|
||||
int openmc_spatial_legendre_filter_get_params(
|
||||
int32_t index, int* axis, double* min, double* max);
|
||||
int openmc_spatial_legendre_filter_set_order(int32_t index, int order);
|
||||
int openmc_spatial_legendre_filter_set_params(
|
||||
int32_t index, const int* axis, const double* min, const double* max);
|
||||
int openmc_sphharm_filter_get_order(int32_t index, int* order);
|
||||
int openmc_sphharm_filter_get_cosine(int32_t index, char cosine[]);
|
||||
int openmc_sphharm_filter_set_order(int32_t index, int order);
|
||||
int openmc_sphharm_filter_set_cosine(int32_t index, const char cosine[]);
|
||||
int openmc_statepoint_write(const char* filename, bool* write_source);
|
||||
int openmc_tally_allocate(int32_t index, const char* type);
|
||||
int openmc_tally_get_active(int32_t index, bool* active);
|
||||
int openmc_tally_get_estimator(int32_t index, int* estimator);
|
||||
int openmc_tally_get_id(int32_t index, int32_t* id);
|
||||
int openmc_tally_get_filters(int32_t index, const int32_t** indices, size_t* n);
|
||||
int openmc_tally_get_n_realizations(int32_t index, int32_t* n);
|
||||
int openmc_tally_get_nuclides(int32_t index, int** nuclides, int* n);
|
||||
int openmc_tally_get_scores(int32_t index, int** scores, int* n);
|
||||
int openmc_tally_get_type(int32_t index, int32_t* type);
|
||||
int openmc_tally_get_writable(int32_t index, bool* writable);
|
||||
int openmc_tally_reset(int32_t index);
|
||||
int openmc_tally_results(int32_t index, double** ptr, size_t shape_[3]);
|
||||
int openmc_tally_set_active(int32_t index, bool active);
|
||||
int openmc_tally_set_estimator(int32_t index, const char* estimator);
|
||||
int openmc_tally_set_filters(int32_t index, size_t n, const int32_t* indices);
|
||||
int openmc_tally_set_id(int32_t index, int32_t id);
|
||||
int openmc_tally_set_nuclides(int32_t index, int n, const char** nuclides);
|
||||
int openmc_tally_set_scores(int32_t index, int n, const char** scores);
|
||||
int openmc_tally_set_type(int32_t index, const char* type);
|
||||
int openmc_tally_set_writable(int32_t index, bool writable);
|
||||
int openmc_zernike_filter_get_order(int32_t index, int* order);
|
||||
int openmc_zernike_filter_get_params(
|
||||
int32_t index, double* x, double* y, double* r);
|
||||
int openmc_zernike_filter_set_order(int32_t index, int order);
|
||||
int openmc_zernike_filter_set_params(
|
||||
int32_t index, const double* x, const double* y, const double* r);
|
||||
|
||||
//! Sets the mesh and energy grid for CMFD reweight
|
||||
//! \param[in] meshtyally_id id of CMFD Mesh Tally
|
||||
//! \param[in] cmfd_indices indices storing spatial and energy dimensions of CMFD problem
|
||||
//! \param[in] norm CMFD normalization factor
|
||||
void openmc_initialize_mesh_egrid(const int meshtally_id, const int* cmfd_indices,
|
||||
const double norm);
|
||||
//! Sets the mesh and energy grid for CMFD reweight
|
||||
//! \param[in] meshtyally_id id of CMFD Mesh Tally
|
||||
//! \param[in] cmfd_indices indices storing spatial and energy dimensions of
|
||||
//! CMFD problem \param[in] norm CMFD normalization factor
|
||||
void openmc_initialize_mesh_egrid(
|
||||
const int meshtally_id, const int* cmfd_indices, const double norm);
|
||||
|
||||
//! Sets the mesh and energy grid for CMFD reweight
|
||||
//! \param[in] feedback whether or not to run CMFD feedback
|
||||
//! \param[in] cmfd_src computed CMFD source
|
||||
void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src);
|
||||
//! Sets the mesh and energy grid for CMFD reweight
|
||||
//! \param[in] feedback whether or not to run CMFD feedback
|
||||
//! \param[in] cmfd_src computed CMFD source
|
||||
void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src);
|
||||
|
||||
//! Sets the fixed variables that are used for CMFD linear solver
|
||||
//! \param[in] indptr CSR format index pointer array of loss matrix
|
||||
//! \param[in] len_indptr length of indptr
|
||||
//! \param[in] indices CSR format index array of loss matrix
|
||||
//! \param[in] n_elements number of non-zero elements in CMFD loss matrix
|
||||
//! \param[in] dim dimension n of nxn CMFD loss matrix
|
||||
//! \param[in] spectral spectral radius of CMFD matrices and tolerances
|
||||
//! \param[in] map coremap for problem, storing accelerated regions
|
||||
//! \param[in] use_all_threads whether to use all threads when running CMFD solver
|
||||
void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
||||
const int* indices, int n_elements,
|
||||
int dim, double spectral,
|
||||
const int* map, bool use_all_threads);
|
||||
//! Sets the fixed variables that are used for CMFD linear solver
|
||||
//! \param[in] indptr CSR format index pointer array of loss matrix
|
||||
//! \param[in] len_indptr length of indptr
|
||||
//! \param[in] indices CSR format index array of loss matrix
|
||||
//! \param[in] n_elements number of non-zero elements in CMFD loss matrix
|
||||
//! \param[in] dim dimension n of nxn CMFD loss matrix
|
||||
//! \param[in] spectral spectral radius of CMFD matrices and tolerances
|
||||
//! \param[in] map coremap for problem, storing accelerated regions
|
||||
//! \param[in] use_all_threads whether to use all threads when running CMFD
|
||||
//! solver
|
||||
void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
||||
const int* indices, int n_elements, int dim, double spectral, const int* map,
|
||||
bool use_all_threads);
|
||||
|
||||
//! Runs a Gauss Seidel linear solver to solve CMFD matrix equations
|
||||
//! linear solver
|
||||
//! \param[in] A_data CSR format data array of coefficient matrix
|
||||
//! \param[in] b right hand side vector
|
||||
//! \param[out] x unknown vector
|
||||
//! \param[in] tol tolerance on final error
|
||||
//! \return number of inner iterations required to reach convergence
|
||||
int openmc_run_linsolver(const double* A_data, const double* b,
|
||||
double* x, double tol);
|
||||
//! Runs a Gauss Seidel linear solver to solve CMFD matrix equations
|
||||
//! linear solver
|
||||
//! \param[in] A_data CSR format data array of coefficient matrix
|
||||
//! \param[in] b right hand side vector
|
||||
//! \param[out] x unknown vector
|
||||
//! \param[in] tol tolerance on final error
|
||||
//! \return number of inner iterations required to reach convergence
|
||||
int openmc_run_linsolver(
|
||||
const double* A_data, const double* b, double* x, double tol);
|
||||
|
||||
//! Export physical properties for model
|
||||
//! \param[in] filename Filename to write to
|
||||
//! \return Error code
|
||||
int openmc_properties_export(const char* filename);
|
||||
//! Export physical properties for model
|
||||
//! \param[in] filename Filename to write to
|
||||
//! \return Error code
|
||||
int openmc_properties_export(const char* filename);
|
||||
|
||||
//! Import physical properties for model
|
||||
//! \param[in] filename Filename to read from
|
||||
// \return Error code
|
||||
int openmc_properties_import(const char* filename);
|
||||
//! Import physical properties for model
|
||||
//! \param[in] filename Filename to read from
|
||||
// \return Error code
|
||||
int openmc_properties_import(const char* filename);
|
||||
|
||||
// Error codes
|
||||
extern int OPENMC_E_UNASSIGNED;
|
||||
extern int OPENMC_E_ALLOCATE;
|
||||
extern int OPENMC_E_OUT_OF_BOUNDS;
|
||||
extern int OPENMC_E_INVALID_SIZE;
|
||||
extern int OPENMC_E_INVALID_ARGUMENT;
|
||||
extern int OPENMC_E_INVALID_TYPE;
|
||||
extern int OPENMC_E_INVALID_ID;
|
||||
extern int OPENMC_E_GEOMETRY;
|
||||
extern int OPENMC_E_DATA;
|
||||
extern int OPENMC_E_PHYSICS;
|
||||
extern int OPENMC_E_WARNING;
|
||||
// Error codes
|
||||
extern int OPENMC_E_UNASSIGNED;
|
||||
extern int OPENMC_E_ALLOCATE;
|
||||
extern int OPENMC_E_OUT_OF_BOUNDS;
|
||||
extern int OPENMC_E_INVALID_SIZE;
|
||||
extern int OPENMC_E_INVALID_ARGUMENT;
|
||||
extern int OPENMC_E_INVALID_TYPE;
|
||||
extern int OPENMC_E_INVALID_ID;
|
||||
extern int OPENMC_E_GEOMETRY;
|
||||
extern int OPENMC_E_DATA;
|
||||
extern int OPENMC_E_PHYSICS;
|
||||
extern int OPENMC_E_WARNING;
|
||||
|
||||
// Global variables
|
||||
extern char openmc_err_msg[256];
|
||||
// Global variables
|
||||
extern char openmc_err_msg[256];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
|
|
@ -24,18 +24,14 @@ namespace openmc {
|
|||
// Constants
|
||||
//==============================================================================
|
||||
|
||||
enum class Fill {
|
||||
MATERIAL,
|
||||
UNIVERSE,
|
||||
LATTICE
|
||||
};
|
||||
enum class Fill { MATERIAL, UNIVERSE, LATTICE };
|
||||
|
||||
// TODO: Convert to enum
|
||||
constexpr int32_t OP_LEFT_PAREN {std::numeric_limits<int32_t>::max()};
|
||||
constexpr int32_t OP_RIGHT_PAREN {std::numeric_limits<int32_t>::max() - 1};
|
||||
constexpr int32_t OP_COMPLEMENT {std::numeric_limits<int32_t>::max() - 2};
|
||||
constexpr int32_t OP_LEFT_PAREN {std::numeric_limits<int32_t>::max()};
|
||||
constexpr int32_t OP_RIGHT_PAREN {std::numeric_limits<int32_t>::max() - 1};
|
||||
constexpr int32_t OP_COMPLEMENT {std::numeric_limits<int32_t>::max() - 2};
|
||||
constexpr int32_t OP_INTERSECTION {std::numeric_limits<int32_t>::max() - 3};
|
||||
constexpr int32_t OP_UNION {std::numeric_limits<int32_t>::max() - 4};
|
||||
constexpr int32_t OP_UNION {std::numeric_limits<int32_t>::max() - 4};
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
|
|
@ -48,29 +44,27 @@ class Universe;
|
|||
class UniversePartitioner;
|
||||
|
||||
namespace model {
|
||||
extern std::unordered_map<int32_t, int32_t> cell_map;
|
||||
extern vector<unique_ptr<Cell>> cells;
|
||||
extern std::unordered_map<int32_t, int32_t> cell_map;
|
||||
extern vector<unique_ptr<Cell>> cells;
|
||||
|
||||
extern std::unordered_map<int32_t, int32_t> universe_map;
|
||||
extern vector<unique_ptr<Universe>> universes;
|
||||
extern std::unordered_map<int32_t, int32_t> universe_map;
|
||||
extern vector<unique_ptr<Universe>> universes;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
//! A geometry primitive that fills all space and contains cells.
|
||||
//==============================================================================
|
||||
|
||||
class Universe
|
||||
{
|
||||
class Universe {
|
||||
public:
|
||||
|
||||
int32_t id_; //!< Unique ID
|
||||
vector<int32_t> cells_; //!< Cells within this universe
|
||||
int32_t id_; //!< Unique ID
|
||||
vector<int32_t> cells_; //!< Cells within this universe
|
||||
|
||||
//! \brief Write universe information to an HDF5 group.
|
||||
//! \param group_id An HDF5 group id.
|
||||
virtual void to_hdf5(hid_t group_id) const;
|
||||
|
||||
virtual bool find_cell(Particle &p) const;
|
||||
virtual bool find_cell(Particle& p) const;
|
||||
|
||||
BoundingBox bounding_box() const;
|
||||
|
||||
|
|
@ -117,12 +111,11 @@ public:
|
|||
//! \param on_surface The signed index of a surface that the coordinate is
|
||||
//! known to be on. This index takes precedence over surface sense
|
||||
//! calculations.
|
||||
virtual bool
|
||||
contains(Position r, Direction u, int32_t on_surface) const = 0;
|
||||
virtual bool contains(Position r, Direction u, int32_t on_surface) const = 0;
|
||||
|
||||
//! Find the oncoming boundary of this cell.
|
||||
virtual std::pair<double, int32_t>
|
||||
distance(Position r, Direction u, int32_t on_surface, Particle* p) const = 0;
|
||||
virtual std::pair<double, int32_t> distance(
|
||||
Position r, Direction u, int32_t on_surface, Particle* p) const = 0;
|
||||
|
||||
//! Write all information needed to reconstruct the cell to an HDF5 group.
|
||||
//! \param group_id An HDF5 group id.
|
||||
|
|
@ -157,7 +150,8 @@ public:
|
|||
//! \param[in] set_contained If this cell is not filled with a material,
|
||||
//! collect all contained cells with material fills and set their
|
||||
//! temperatures.
|
||||
void set_temperature(double T, int32_t instance = -1, bool set_contained = false);
|
||||
void set_temperature(
|
||||
double T, int32_t instance = -1, bool set_contained = false);
|
||||
|
||||
//! Set the rotation matrix of a cell instance
|
||||
//! \param[in] rot The rotation matrix of length 3 or 9
|
||||
|
|
@ -184,16 +178,16 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
int32_t id_; //!< Unique ID
|
||||
std::string name_; //!< User-defined name
|
||||
Fill type_; //!< Material, universe, or lattice
|
||||
int32_t universe_; //!< Universe # this cell is in
|
||||
int32_t fill_; //!< Universe # filling this cell
|
||||
int32_t n_instances_{0}; //!< Number of instances of this cell
|
||||
GeometryType geom_type_; //!< Geometric representation type (CSG, DAGMC)
|
||||
int32_t id_; //!< Unique ID
|
||||
std::string name_; //!< User-defined name
|
||||
Fill type_; //!< Material, universe, or lattice
|
||||
int32_t universe_; //!< Universe # this cell is in
|
||||
int32_t fill_; //!< Universe # filling this cell
|
||||
int32_t n_instances_ {0}; //!< Number of instances of this cell
|
||||
GeometryType geom_type_; //!< Geometric representation type (CSG, DAGMC)
|
||||
|
||||
//! \brief Index corresponding to this cell in distribcell arrays
|
||||
int distribcell_index_{C_NONE};
|
||||
int distribcell_index_ {C_NONE};
|
||||
|
||||
//! \brief Material(s) within this cell.
|
||||
//!
|
||||
|
|
@ -210,7 +204,7 @@ public:
|
|||
vector<std::int32_t> region_;
|
||||
//! Reverse Polish notation for region expression
|
||||
vector<std::int32_t> rpn_;
|
||||
bool simple_; //!< Does the region contain only intersections?
|
||||
bool simple_; //!< Does the region contain only intersections?
|
||||
|
||||
//! \brief Neighboring cells in the same universe.
|
||||
NeighborList neighbors_;
|
||||
|
|
@ -229,24 +223,22 @@ public:
|
|||
};
|
||||
|
||||
struct CellInstanceItem {
|
||||
int32_t index {-1}; //! Index into global cells array
|
||||
int lattice_indx{-1}; //! Flat index value of the lattice cell
|
||||
int32_t index {-1}; //! Index into global cells array
|
||||
int lattice_indx {-1}; //! Flat index value of the lattice cell
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class CSGCell : public Cell
|
||||
{
|
||||
class CSGCell : public Cell {
|
||||
public:
|
||||
CSGCell();
|
||||
|
||||
explicit CSGCell(pugi::xml_node cell_node);
|
||||
|
||||
bool
|
||||
contains(Position r, Direction u, int32_t on_surface) const;
|
||||
bool contains(Position r, Direction u, int32_t on_surface) const;
|
||||
|
||||
std::pair<double, int32_t>
|
||||
distance(Position r, Direction u, int32_t on_surface, Particle* p) const;
|
||||
std::pair<double, int32_t> distance(
|
||||
Position r, Direction u, int32_t on_surface, Particle* p) const;
|
||||
|
||||
void to_hdf5_inner(hid_t group_id) const override;
|
||||
|
||||
|
|
@ -285,8 +277,7 @@ protected:
|
|||
//! and spheres.
|
||||
//==============================================================================
|
||||
|
||||
class UniversePartitioner
|
||||
{
|
||||
class UniversePartitioner {
|
||||
public:
|
||||
explicit UniversePartitioner(const Universe& univ);
|
||||
|
||||
|
|
@ -307,7 +298,6 @@ private:
|
|||
vector<vector<int32_t>> partitions_;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//! Define a containing (parent) cell
|
||||
//==============================================================================
|
||||
|
|
@ -324,7 +314,9 @@ struct ParentCell {
|
|||
struct CellInstance {
|
||||
//! Check for equality
|
||||
bool operator==(const CellInstance& other) const
|
||||
{ return index_cell == other.index_cell && instance == other.instance; }
|
||||
{
|
||||
return index_cell == other.index_cell && instance == other.instance;
|
||||
}
|
||||
|
||||
gsl::index index_cell;
|
||||
gsl::index instance;
|
||||
|
|
@ -333,7 +325,7 @@ struct CellInstance {
|
|||
struct CellInstanceHash {
|
||||
std::size_t operator()(const CellInstance& k) const
|
||||
{
|
||||
return 4096*k.index_cell + k.instance;
|
||||
return 4096 * k.index_cell + k.instance;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -343,7 +335,6 @@ struct CellInstanceHash {
|
|||
|
||||
void read_cells(pugi::xml_node node);
|
||||
|
||||
|
||||
#ifdef DAGMC
|
||||
class DAGUniverse;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -79,16 +79,20 @@ constexpr double INFTY {std::numeric_limits<double>::max()};
|
|||
// (CODATA) 2018 recommendation (https://physics.nist.gov/cuu/Constants/).
|
||||
|
||||
// Physical constants
|
||||
constexpr double MASS_NEUTRON {1.00866491595}; // mass of a neutron in amu
|
||||
constexpr double MASS_NEUTRON_EV {939.56542052e6}; // mass of a neutron in eV/c^2
|
||||
constexpr double MASS_PROTON {1.007276466621}; // mass of a proton in amu
|
||||
constexpr double MASS_ELECTRON_EV {0.51099895000e6}; // electron mass energy equivalent in eV/c^2
|
||||
constexpr double FINE_STRUCTURE {137.035999084}; // inverse fine structure constant
|
||||
constexpr double PLANCK_C {1.2398419839593942e4}; // Planck's constant times c in eV-Angstroms
|
||||
constexpr double AMU {1.66053906660e-27}; // 1 amu in kg
|
||||
constexpr double C_LIGHT {2.99792458e8}; // speed of light in m/s
|
||||
constexpr double N_AVOGADRO {0.602214076}; // Avogadro's number in 10^24/mol
|
||||
constexpr double K_BOLTZMANN {8.617333262e-5}; // Boltzmann constant in eV/K
|
||||
constexpr double MASS_NEUTRON {1.00866491595}; // mass of a neutron in amu
|
||||
constexpr double MASS_NEUTRON_EV {
|
||||
939.56542052e6}; // mass of a neutron in eV/c^2
|
||||
constexpr double MASS_PROTON {1.007276466621}; // mass of a proton in amu
|
||||
constexpr double MASS_ELECTRON_EV {
|
||||
0.51099895000e6}; // electron mass energy equivalent in eV/c^2
|
||||
constexpr double FINE_STRUCTURE {
|
||||
137.035999084}; // inverse fine structure constant
|
||||
constexpr double PLANCK_C {
|
||||
1.2398419839593942e4}; // Planck's constant times c in eV-Angstroms
|
||||
constexpr double AMU {1.66053906660e-27}; // 1 amu in kg
|
||||
constexpr double C_LIGHT {2.99792458e8}; // speed of light in m/s
|
||||
constexpr double N_AVOGADRO {0.602214076}; // Avogadro's number in 10^24/mol
|
||||
constexpr double K_BOLTZMANN {8.617333262e-5}; // Boltzmann constant in eV/K
|
||||
|
||||
// Electron subshell labels
|
||||
constexpr array<const char*, 39> SUBSHELLS = {"K", "L1", "L2", "L3", "M1", "M2",
|
||||
|
|
@ -99,16 +103,13 @@ constexpr array<const char*, 39> SUBSHELLS = {"K", "L1", "L2", "L3", "M1", "M2",
|
|||
// Void material and nuclide
|
||||
// TODO: refactor and remove
|
||||
constexpr int MATERIAL_VOID {-1};
|
||||
constexpr int NUCLIDE_NONE {-1};
|
||||
constexpr int NUCLIDE_NONE {-1};
|
||||
|
||||
// ============================================================================
|
||||
// CROSS SECTION RELATED CONSTANTS
|
||||
|
||||
// Temperature treatment method
|
||||
enum class TemperatureMethod {
|
||||
NEAREST,
|
||||
INTERPOLATION
|
||||
};
|
||||
enum class TemperatureMethod { NEAREST, INTERPOLATION };
|
||||
|
||||
// Reaction types
|
||||
enum ReactionType {
|
||||
|
|
@ -117,105 +118,105 @@ enum ReactionType {
|
|||
ELASTIC = 2,
|
||||
N_NONELASTIC = 3,
|
||||
N_LEVEL = 4,
|
||||
MISC = 5,
|
||||
N_2ND = 11,
|
||||
N_2N = 16,
|
||||
N_3N = 17,
|
||||
MISC = 5,
|
||||
N_2ND = 11,
|
||||
N_2N = 16,
|
||||
N_3N = 17,
|
||||
N_FISSION = 18,
|
||||
N_F = 19,
|
||||
N_NF = 20,
|
||||
N_2NF = 21,
|
||||
N_NA = 22,
|
||||
N_N3A = 23,
|
||||
N_2NA = 24,
|
||||
N_3NA = 25,
|
||||
N_NP = 28,
|
||||
N_N2A = 29,
|
||||
N_2N2A = 30,
|
||||
N_ND = 32,
|
||||
N_NT = 33,
|
||||
N_N3HE = 34,
|
||||
N_ND2A = 35,
|
||||
N_NT2A = 36,
|
||||
N_4N = 37,
|
||||
N_3NF = 38,
|
||||
N_2NP = 41,
|
||||
N_3NP = 42,
|
||||
N_N2P = 44,
|
||||
N_NPA = 45,
|
||||
N_N1 = 51,
|
||||
N_N40 = 90,
|
||||
N_NC = 91,
|
||||
N_F = 19,
|
||||
N_NF = 20,
|
||||
N_2NF = 21,
|
||||
N_NA = 22,
|
||||
N_N3A = 23,
|
||||
N_2NA = 24,
|
||||
N_3NA = 25,
|
||||
N_NP = 28,
|
||||
N_N2A = 29,
|
||||
N_2N2A = 30,
|
||||
N_ND = 32,
|
||||
N_NT = 33,
|
||||
N_N3HE = 34,
|
||||
N_ND2A = 35,
|
||||
N_NT2A = 36,
|
||||
N_4N = 37,
|
||||
N_3NF = 38,
|
||||
N_2NP = 41,
|
||||
N_3NP = 42,
|
||||
N_N2P = 44,
|
||||
N_NPA = 45,
|
||||
N_N1 = 51,
|
||||
N_N40 = 90,
|
||||
N_NC = 91,
|
||||
N_DISAPPEAR = 101,
|
||||
N_GAMMA = 102,
|
||||
N_P = 103,
|
||||
N_D = 104,
|
||||
N_T = 105,
|
||||
N_3HE = 106,
|
||||
N_A = 107,
|
||||
N_2A = 108,
|
||||
N_3A = 109,
|
||||
N_2P = 111,
|
||||
N_PA = 112,
|
||||
N_T2A = 113,
|
||||
N_D2A = 114,
|
||||
N_PD = 115,
|
||||
N_PT = 116,
|
||||
N_DA = 117,
|
||||
N_5N = 152,
|
||||
N_6N = 153,
|
||||
N_2NT = 154,
|
||||
N_TA = 155,
|
||||
N_4NP = 156,
|
||||
N_3ND = 157,
|
||||
N_NDA = 158,
|
||||
N_2NPA = 159,
|
||||
N_7N = 160,
|
||||
N_8N = 161,
|
||||
N_5NP = 162,
|
||||
N_6NP = 163,
|
||||
N_7NP = 164,
|
||||
N_4NA = 165,
|
||||
N_5NA = 166,
|
||||
N_6NA = 167,
|
||||
N_7NA = 168,
|
||||
N_4ND = 169,
|
||||
N_5ND = 170,
|
||||
N_6ND = 171,
|
||||
N_3NT = 172,
|
||||
N_4NT = 173,
|
||||
N_5NT = 174,
|
||||
N_6NT = 175,
|
||||
N_P = 103,
|
||||
N_D = 104,
|
||||
N_T = 105,
|
||||
N_3HE = 106,
|
||||
N_A = 107,
|
||||
N_2A = 108,
|
||||
N_3A = 109,
|
||||
N_2P = 111,
|
||||
N_PA = 112,
|
||||
N_T2A = 113,
|
||||
N_D2A = 114,
|
||||
N_PD = 115,
|
||||
N_PT = 116,
|
||||
N_DA = 117,
|
||||
N_5N = 152,
|
||||
N_6N = 153,
|
||||
N_2NT = 154,
|
||||
N_TA = 155,
|
||||
N_4NP = 156,
|
||||
N_3ND = 157,
|
||||
N_NDA = 158,
|
||||
N_2NPA = 159,
|
||||
N_7N = 160,
|
||||
N_8N = 161,
|
||||
N_5NP = 162,
|
||||
N_6NP = 163,
|
||||
N_7NP = 164,
|
||||
N_4NA = 165,
|
||||
N_5NA = 166,
|
||||
N_6NA = 167,
|
||||
N_7NA = 168,
|
||||
N_4ND = 169,
|
||||
N_5ND = 170,
|
||||
N_6ND = 171,
|
||||
N_3NT = 172,
|
||||
N_4NT = 173,
|
||||
N_5NT = 174,
|
||||
N_6NT = 175,
|
||||
N_2N3HE = 176,
|
||||
N_3N3HE = 177,
|
||||
N_4N3HE = 178,
|
||||
N_3N2P = 179,
|
||||
N_3N2A = 180,
|
||||
N_3NPA = 181,
|
||||
N_DT = 182,
|
||||
N_NPD = 183,
|
||||
N_NPT = 184,
|
||||
N_NDT = 185,
|
||||
N_3N2P = 179,
|
||||
N_3N2A = 180,
|
||||
N_3NPA = 181,
|
||||
N_DT = 182,
|
||||
N_NPD = 183,
|
||||
N_NPT = 184,
|
||||
N_NDT = 185,
|
||||
N_NP3HE = 186,
|
||||
N_ND3HE = 187,
|
||||
N_NT3HE = 188,
|
||||
N_NTA = 189,
|
||||
N_2N2P = 190,
|
||||
N_P3HE = 191,
|
||||
N_D3HE = 192,
|
||||
N_3HEA = 193,
|
||||
N_4N2P = 194,
|
||||
N_4N2A = 195,
|
||||
N_4NPA = 196,
|
||||
N_3P = 197,
|
||||
N_N3P = 198,
|
||||
N_NTA = 189,
|
||||
N_2N2P = 190,
|
||||
N_P3HE = 191,
|
||||
N_D3HE = 192,
|
||||
N_3HEA = 193,
|
||||
N_4N2P = 194,
|
||||
N_4N2A = 195,
|
||||
N_4NPA = 196,
|
||||
N_3P = 197,
|
||||
N_N3P = 198,
|
||||
N_3N2PA = 199,
|
||||
N_5N2P = 200,
|
||||
N_XP = 203,
|
||||
N_XD = 204,
|
||||
N_XT = 205,
|
||||
N_X3HE = 206,
|
||||
N_XA = 207,
|
||||
N_5N2P = 200,
|
||||
N_XP = 203,
|
||||
N_XD = 204,
|
||||
N_XT = 205,
|
||||
N_X3HE = 206,
|
||||
N_XA = 207,
|
||||
HEATING = 301,
|
||||
DAMAGE_ENERGY = 444,
|
||||
COHERENT = 502,
|
||||
|
|
@ -224,18 +225,18 @@ enum ReactionType {
|
|||
PAIR_PROD = 516,
|
||||
PAIR_PROD_NUC = 517,
|
||||
PHOTOELECTRIC = 522,
|
||||
N_P0 = 600,
|
||||
N_PC = 649,
|
||||
N_D0 = 650,
|
||||
N_DC = 699,
|
||||
N_T0 = 700,
|
||||
N_TC = 749,
|
||||
N_3HE0 = 750,
|
||||
N_3HEC = 799,
|
||||
N_A0 = 800,
|
||||
N_AC = 849,
|
||||
N_2N0 = 875,
|
||||
N_2NC = 891,
|
||||
N_P0 = 600,
|
||||
N_PC = 649,
|
||||
N_D0 = 650,
|
||||
N_DC = 699,
|
||||
N_T0 = 700,
|
||||
N_TC = 749,
|
||||
N_3HE0 = 750,
|
||||
N_3HEC = 799,
|
||||
N_A0 = 800,
|
||||
N_AC = 849,
|
||||
N_2N0 = 875,
|
||||
N_2NC = 891,
|
||||
HEATING_LOCAL = 901
|
||||
};
|
||||
|
||||
|
|
@ -255,9 +256,9 @@ constexpr int PARTIAL_FISSION_MAX {4};
|
|||
|
||||
// Resonance elastic scattering methods
|
||||
enum class ResScatMethod {
|
||||
rvs, // Relative velocity sampling
|
||||
rvs, // Relative velocity sampling
|
||||
dbrc, // Doppler broadening rejection correction
|
||||
cxs // Constant cross section
|
||||
cxs // Constant cross section
|
||||
};
|
||||
|
||||
enum class ElectronTreatment {
|
||||
|
|
@ -296,31 +297,13 @@ enum class MgxsType {
|
|||
// ============================================================================
|
||||
// TALLY-RELATED CONSTANTS
|
||||
|
||||
enum class TallyResult {
|
||||
VALUE,
|
||||
SUM,
|
||||
SUM_SQ
|
||||
};
|
||||
enum class TallyResult { VALUE, SUM, SUM_SQ };
|
||||
|
||||
enum class TallyType {
|
||||
VOLUME,
|
||||
MESH_SURFACE,
|
||||
SURFACE
|
||||
};
|
||||
enum class TallyType { VOLUME, MESH_SURFACE, SURFACE };
|
||||
|
||||
enum class TallyEstimator {
|
||||
ANALOG,
|
||||
TRACKLENGTH,
|
||||
COLLISION
|
||||
};
|
||||
enum class TallyEstimator { ANALOG, TRACKLENGTH, COLLISION };
|
||||
|
||||
enum class TallyEvent {
|
||||
SURFACE,
|
||||
LATTICE,
|
||||
KILL,
|
||||
SCATTER,
|
||||
ABSORB
|
||||
};
|
||||
enum class TallyEvent { SURFACE, LATTICE, KILL, SCATTER, ABSORB };
|
||||
|
||||
// Tally score type -- if you change these, make sure you also update the
|
||||
// _SCORES dictionary in openmc/capi/tally.py
|
||||
|
|
@ -329,40 +312,39 @@ enum class TallyEvent {
|
|||
// store one of these enum values usually also may be responsible for storing
|
||||
// MT numbers from the long enum above.
|
||||
enum TallyScore {
|
||||
SCORE_FLUX = -1, // flux
|
||||
SCORE_TOTAL = -2, // total reaction rate
|
||||
SCORE_SCATTER = -3, // scattering rate
|
||||
SCORE_NU_SCATTER = -4, // scattering production rate
|
||||
SCORE_ABSORPTION = -5, // absorption rate
|
||||
SCORE_FISSION = -6, // fission rate
|
||||
SCORE_NU_FISSION = -7, // neutron production rate
|
||||
SCORE_KAPPA_FISSION = -8, // fission energy production rate
|
||||
SCORE_CURRENT = -9, // current
|
||||
SCORE_EVENTS = -10, // number of events
|
||||
SCORE_FLUX = -1, // flux
|
||||
SCORE_TOTAL = -2, // total reaction rate
|
||||
SCORE_SCATTER = -3, // scattering rate
|
||||
SCORE_NU_SCATTER = -4, // scattering production rate
|
||||
SCORE_ABSORPTION = -5, // absorption rate
|
||||
SCORE_FISSION = -6, // fission rate
|
||||
SCORE_NU_FISSION = -7, // neutron production rate
|
||||
SCORE_KAPPA_FISSION = -8, // fission energy production rate
|
||||
SCORE_CURRENT = -9, // current
|
||||
SCORE_EVENTS = -10, // number of events
|
||||
SCORE_DELAYED_NU_FISSION = -11, // delayed neutron production rate
|
||||
SCORE_PROMPT_NU_FISSION = -12, // prompt neutron production rate
|
||||
SCORE_INVERSE_VELOCITY = -13, // flux-weighted inverse velocity
|
||||
SCORE_FISS_Q_PROMPT = -14, // prompt fission Q-value
|
||||
SCORE_FISS_Q_RECOV = -15, // recoverable fission Q-value
|
||||
SCORE_DECAY_RATE = -16 // delayed neutron precursor decay rate
|
||||
SCORE_PROMPT_NU_FISSION = -12, // prompt neutron production rate
|
||||
SCORE_INVERSE_VELOCITY = -13, // flux-weighted inverse velocity
|
||||
SCORE_FISS_Q_PROMPT = -14, // prompt fission Q-value
|
||||
SCORE_FISS_Q_RECOV = -15, // recoverable fission Q-value
|
||||
SCORE_DECAY_RATE = -16 // delayed neutron precursor decay rate
|
||||
};
|
||||
|
||||
// Global tally parameters
|
||||
constexpr int N_GLOBAL_TALLIES {4};
|
||||
enum class GlobalTally {
|
||||
K_COLLISION,
|
||||
K_ABSORPTION,
|
||||
K_TRACKLENGTH,
|
||||
LEAKAGE
|
||||
};
|
||||
enum class GlobalTally { K_COLLISION, K_ABSORPTION, K_TRACKLENGTH, LEAKAGE };
|
||||
|
||||
// Miscellaneous
|
||||
constexpr int C_NONE {-1};
|
||||
constexpr int F90_NONE {0}; //TODO: replace usage of this with C_NONE
|
||||
constexpr int F90_NONE {0}; // TODO: replace usage of this with C_NONE
|
||||
|
||||
// Interpolation rules
|
||||
enum class Interpolation {
|
||||
histogram = 1, lin_lin = 2, lin_log = 3, log_lin = 4, log_log = 5
|
||||
histogram = 1,
|
||||
lin_lin = 2,
|
||||
lin_log = 3,
|
||||
log_lin = 4,
|
||||
log_log = 5
|
||||
};
|
||||
|
||||
enum class RunMode {
|
||||
|
|
@ -383,11 +365,7 @@ constexpr int CMFD_NOACCEL {-1};
|
|||
//==============================================================================
|
||||
// Geometry Constants
|
||||
|
||||
enum class GeometryType {
|
||||
CSG,
|
||||
DAG
|
||||
};
|
||||
|
||||
enum class GeometryType { CSG, DAG };
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define OPENMC_CONTAINER_UTIL_H
|
||||
|
||||
#include <algorithm> // for find
|
||||
#include <iterator> // for begin, end
|
||||
#include <iterator> // for begin, end
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -12,6 +12,6 @@ inline bool contains(const C& v, const T& x)
|
|||
return std::end(v) != std::find(std::begin(v), std::end(v), x);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_CONTAINER_UTIL_H
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -18,22 +18,24 @@ class Library {
|
|||
public:
|
||||
// Types, enums
|
||||
enum class Type {
|
||||
neutron = 1, photon = 3, thermal = 2, multigroup = 4, wmp = 5
|
||||
neutron = 1,
|
||||
photon = 3,
|
||||
thermal = 2,
|
||||
multigroup = 4,
|
||||
wmp = 5
|
||||
};
|
||||
|
||||
// Constructors
|
||||
Library() { };
|
||||
Library() {};
|
||||
Library(pugi::xml_node node, const std::string& directory);
|
||||
|
||||
// Comparison operator (for using in map)
|
||||
bool operator<(const Library& other) {
|
||||
return path_ < other.path_;
|
||||
}
|
||||
bool operator<(const Library& other) { return path_ < other.path_; }
|
||||
|
||||
// Data members
|
||||
Type type_; //!< Type of data library
|
||||
Type type_; //!< Type of data library
|
||||
vector<std::string> materials_; //!< Materials contained in library
|
||||
std::string path_; //!< File path to library
|
||||
std::string path_; //!< File path to library
|
||||
};
|
||||
|
||||
using LibraryKey = std::pair<Library::Type, std::string>;
|
||||
|
|
@ -60,11 +62,11 @@ extern vector<Library> libraries;
|
|||
//! libraries
|
||||
void read_cross_sections_xml();
|
||||
|
||||
|
||||
//! Load nuclide and thermal scattering data from HDF5 files
|
||||
//
|
||||
//! \param[in] nuc_temps Temperatures for each nuclide in [K]
|
||||
//! \param[in] thermal_temps Temperatures for each thermal scattering table in [K]
|
||||
//! \param[in] thermal_temps Temperatures for each thermal scattering table in
|
||||
//! [K]
|
||||
void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
||||
const vector<vector<double>>& thermal_temps);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace openmc {
|
|||
void read_dagmc_universes(pugi::xml_node node);
|
||||
void check_dagmc_root_univ();
|
||||
|
||||
}
|
||||
} // namespace openmc
|
||||
|
||||
#ifdef DAGMC
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
private:
|
||||
std::shared_ptr<moab::DagMC> dagmc_ptr_; //!< Pointer to DagMC instance
|
||||
int32_t dag_index_; //!< DagMC index of surface
|
||||
int32_t dag_index_; //!< DagMC index of surface
|
||||
};
|
||||
|
||||
class DAGCell : public Cell {
|
||||
|
|
@ -58,8 +58,8 @@ public:
|
|||
|
||||
bool contains(Position r, Direction u, int32_t on_surface) const override;
|
||||
|
||||
std::pair<double, int32_t>
|
||||
distance(Position r, Direction u, int32_t on_surface, Particle* p) const override;
|
||||
std::pair<double, int32_t> distance(
|
||||
Position r, Direction u, int32_t on_surface, Particle* p) const override;
|
||||
|
||||
BoundingBox bounding_box() const override;
|
||||
|
||||
|
|
@ -71,24 +71,24 @@ public:
|
|||
|
||||
private:
|
||||
std::shared_ptr<moab::DagMC> dagmc_ptr_; //!< Pointer to DagMC instance
|
||||
int32_t dag_index_; //!< DagMC index of cell
|
||||
int32_t dag_index_; //!< DagMC index of cell
|
||||
};
|
||||
|
||||
class DAGUniverse : public Universe {
|
||||
|
||||
public:
|
||||
|
||||
explicit DAGUniverse(pugi::xml_node node);
|
||||
|
||||
//! Create a new DAGMC universe
|
||||
//! \param[in] filename Name of the DAGMC file
|
||||
//! \param[in] auto_geom_ids Whether or not to automatically assign cell and surface IDs
|
||||
//! \param[in] auto_mat_ids Whether or not to automatically assign material IDs
|
||||
explicit DAGUniverse(const std::string& filename,
|
||||
bool auto_geom_ids = false,
|
||||
bool auto_mat_ids = false);
|
||||
//! \param[in] auto_geom_ids Whether or not to automatically assign cell and
|
||||
//! surface IDs \param[in] auto_mat_ids Whether or not to automatically assign
|
||||
//! material IDs
|
||||
explicit DAGUniverse(const std::string& filename, bool auto_geom_ids = false,
|
||||
bool auto_mat_ids = false);
|
||||
|
||||
//! Initialize the DAGMC accel. data structures, indices, material assignments, etc.
|
||||
//! Initialize the DAGMC accel. data structures, indices, material
|
||||
//! assignments, etc.
|
||||
void initialize();
|
||||
|
||||
//! Reads UWUW materials and returns an ID map
|
||||
|
|
@ -97,54 +97,67 @@ public:
|
|||
//! \return True if UWUW materials are present, False if not
|
||||
bool uses_uwuw() const;
|
||||
|
||||
//! Returns the index to the implicit complement's index in OpenMC for this DAGMC universe
|
||||
//! Returns the index to the implicit complement's index in OpenMC for this
|
||||
//! DAGMC universe
|
||||
int32_t implicit_complement_idx() const;
|
||||
|
||||
//! Transform UWUW materials into an OpenMC-readable XML format
|
||||
//! \return A string representing a materials.xml file of the UWUW materials in this universe
|
||||
//! \return A string representing a materials.xml file of the UWUW materials
|
||||
//! in this universe
|
||||
std::string get_uwuw_materials_xml() const;
|
||||
|
||||
//! Writes the UWUW material file to XML (for debugging purposes)
|
||||
void write_uwuw_materials_xml(const std::string& outfile = "uwuw_materials.xml") const;
|
||||
void write_uwuw_materials_xml(
|
||||
const std::string& outfile = "uwuw_materials.xml") const;
|
||||
|
||||
//! Assign a material to a cell based
|
||||
//! \param[in] mat_string The DAGMC material assignment string
|
||||
//! \param[in] c The OpenMC cell to which the material is assigned
|
||||
void legacy_assign_material(std::string mat_string,
|
||||
std::unique_ptr<DAGCell>& c) const;
|
||||
void legacy_assign_material(
|
||||
std::string mat_string, std::unique_ptr<DAGCell>& c) const;
|
||||
|
||||
//! Generate a string representing the ranges of IDs present in the DAGMC model.
|
||||
//! Contiguous chunks of IDs are represented as a range (i.e. 1-10). If there is
|
||||
//! a single ID a chunk, it will be represented as a single number (i.e. 2, 4, 6, 8).
|
||||
//! \param[in] dim Dimension of the entities
|
||||
//! \return A string of the ID ranges for entities of dimension \p dim
|
||||
//! Generate a string representing the ranges of IDs present in the DAGMC
|
||||
//! model. Contiguous chunks of IDs are represented as a range (i.e. 1-10). If
|
||||
//! there is a single ID a chunk, it will be represented as a single number
|
||||
//! (i.e. 2, 4, 6, 8). \param[in] dim Dimension of the entities \return A
|
||||
//! string of the ID ranges for entities of dimension \p dim
|
||||
std::string dagmc_ids_for_dim(int dim) const;
|
||||
|
||||
bool find_cell(Particle &p) const override;
|
||||
bool find_cell(Particle& p) const override;
|
||||
|
||||
void to_hdf5(hid_t universes_group) const override;
|
||||
|
||||
// Data Members
|
||||
std::shared_ptr<moab::DagMC> dagmc_instance_; //!< DAGMC Instance for this universe
|
||||
int32_t cell_idx_offset_; //!< An offset to the start of the cells in this universe in OpenMC's cell vector
|
||||
int32_t surf_idx_offset_; //!< An offset to the start of the surfaces in this universe in OpenMC's surface vector
|
||||
std::shared_ptr<moab::DagMC>
|
||||
dagmc_instance_; //!< DAGMC Instance for this universe
|
||||
int32_t cell_idx_offset_; //!< An offset to the start of the cells in this
|
||||
//!< universe in OpenMC's cell vector
|
||||
int32_t surf_idx_offset_; //!< An offset to the start of the surfaces in this
|
||||
//!< universe in OpenMC's surface vector
|
||||
|
||||
// Accessors
|
||||
bool has_graveyard() const { return has_graveyard_; }
|
||||
|
||||
private:
|
||||
std::string filename_; //!< Name of the DAGMC file used to create this universe
|
||||
std::shared_ptr<UWUW> uwuw_; //!< Pointer to the UWUW instance for this universe
|
||||
bool adjust_geometry_ids_; //!< Indicates whether or not to automatically generate new cell and surface IDs for the universe
|
||||
bool adjust_material_ids_; //!< Indicates whether or not to automatically generate new material IDs for the universe
|
||||
bool has_graveyard_; //!< Indicates if the DAGMC geometry has a "graveyard" volume
|
||||
std::string
|
||||
filename_; //!< Name of the DAGMC file used to create this universe
|
||||
std::shared_ptr<UWUW>
|
||||
uwuw_; //!< Pointer to the UWUW instance for this universe
|
||||
bool adjust_geometry_ids_; //!< Indicates whether or not to automatically
|
||||
//!< generate new cell and surface IDs for the
|
||||
//!< universe
|
||||
bool adjust_material_ids_; //!< Indicates whether or not to automatically
|
||||
//!< generate new material IDs for the universe
|
||||
bool has_graveyard_; //!< Indicates if the DAGMC geometry has a "graveyard"
|
||||
//!< volume
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Non-member functions
|
||||
//==============================================================================
|
||||
|
||||
int32_t next_cell(DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed);
|
||||
int32_t next_cell(
|
||||
DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ private:
|
|||
class Uniform : public Distribution {
|
||||
public:
|
||||
explicit Uniform(pugi::xml_node node);
|
||||
Uniform(double a, double b) : a_{a}, b_{b} {};
|
||||
Uniform(double a, double b) : a_ {a}, b_ {b} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -66,6 +66,7 @@ public:
|
|||
|
||||
double a() const { return a_; }
|
||||
double b() const { return b_; }
|
||||
|
||||
private:
|
||||
double a_; //!< Lower bound of distribution
|
||||
double b_; //!< Upper bound of distribution
|
||||
|
|
@ -78,7 +79,7 @@ private:
|
|||
class Maxwell : public Distribution {
|
||||
public:
|
||||
explicit Maxwell(pugi::xml_node node);
|
||||
Maxwell(double theta) : theta_{theta} { };
|
||||
Maxwell(double theta) : theta_ {theta} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -86,6 +87,7 @@ public:
|
|||
double sample(uint64_t* seed) const;
|
||||
|
||||
double theta() const { return theta_; }
|
||||
|
||||
private:
|
||||
double theta_; //!< Factor in exponential [eV]
|
||||
};
|
||||
|
|
@ -97,7 +99,7 @@ private:
|
|||
class Watt : public Distribution {
|
||||
public:
|
||||
explicit Watt(pugi::xml_node node);
|
||||
Watt(double a, double b) : a_{a}, b_{b} { };
|
||||
Watt(double a, double b) : a_ {a}, b_ {b} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -106,19 +108,22 @@ public:
|
|||
|
||||
double a() const { return a_; }
|
||||
double b() const { return b_; }
|
||||
|
||||
private:
|
||||
double a_; //!< Factor in exponential [eV]
|
||||
double b_; //!< Factor in square root [1/eV]
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Normal distributions with form 1/2*std_dev*sqrt(pi) exp (-(e-E0)/2*std_dev)^2
|
||||
//! Normal distributions with form 1/2*std_dev*sqrt(pi) exp
|
||||
//! (-(e-E0)/2*std_dev)^2
|
||||
//==============================================================================
|
||||
|
||||
class Normal : public Distribution {
|
||||
public:
|
||||
explicit Normal(pugi::xml_node node);
|
||||
Normal(double mean_value, double std_dev) : mean_value_{mean_value}, std_dev_{std_dev} { };
|
||||
Normal(double mean_value, double std_dev)
|
||||
: mean_value_ {mean_value}, std_dev_ {std_dev} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -127,9 +132,10 @@ public:
|
|||
|
||||
double mean_value() const { return mean_value_; }
|
||||
double std_dev() const { return std_dev_; }
|
||||
|
||||
private:
|
||||
double mean_value_; //!< middle of distribution [eV]
|
||||
double std_dev_; //!< standard deviation [eV]
|
||||
double mean_value_; //!< middle of distribution [eV]
|
||||
double std_dev_; //!< standard deviation [eV]
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -140,7 +146,8 @@ private:
|
|||
class Muir : public Distribution {
|
||||
public:
|
||||
explicit Muir(pugi::xml_node node);
|
||||
Muir(double e0, double m_rat, double kt) : e0_{e0}, m_rat_{m_rat}, kt_{kt} { };
|
||||
Muir(double e0, double m_rat, double kt)
|
||||
: e0_ {e0}, m_rat_ {m_rat}, kt_ {kt} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -150,6 +157,7 @@ public:
|
|||
double e0() const { return e0_; }
|
||||
double m_rat() const { return m_rat_; }
|
||||
double kt() const { return kt_; }
|
||||
|
||||
private:
|
||||
// example DT fusion m_rat = 5 (D = 2 + T = 3)
|
||||
// ion temp = 20000 eV
|
||||
|
|
@ -167,7 +175,7 @@ class Tabular : public Distribution {
|
|||
public:
|
||||
explicit Tabular(pugi::xml_node node);
|
||||
Tabular(const double* x, const double* p, int n, Interpolation interp,
|
||||
const double* c=nullptr);
|
||||
const double* c = nullptr);
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -179,18 +187,19 @@ public:
|
|||
const vector<double>& x() const { return x_; }
|
||||
const vector<double>& p() const { return p_; }
|
||||
Interpolation interp() const { return interp_; }
|
||||
|
||||
private:
|
||||
vector<double> x_; //!< tabulated independent variable
|
||||
vector<double> p_; //!< tabulated probability density
|
||||
vector<double> c_; //!< cumulative distribution at tabulated values
|
||||
Interpolation interp_; //!< interpolation rule
|
||||
vector<double> x_; //!< tabulated independent variable
|
||||
vector<double> p_; //!< tabulated probability density
|
||||
vector<double> c_; //!< cumulative distribution at tabulated values
|
||||
Interpolation interp_; //!< interpolation rule
|
||||
|
||||
//! Initialize tabulated probability density function
|
||||
//! \param x Array of values for independent variable
|
||||
//! \param p Array of tabulated probabilities
|
||||
//! \param n Number of tabulated values
|
||||
void init(const double* x, const double* p, std::size_t n,
|
||||
const double* c=nullptr);
|
||||
void init(
|
||||
const double* x, const double* p, std::size_t n, const double* c = nullptr);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -200,7 +209,7 @@ private:
|
|||
class Equiprobable : public Distribution {
|
||||
public:
|
||||
explicit Equiprobable(pugi::xml_node node);
|
||||
Equiprobable(const double* x, int n) : x_{x, x+n} { };
|
||||
Equiprobable(const double* x, int n) : x_ {x, x + n} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#ifndef OPENMC_DISTRIBUTION_ENERGY_H
|
||||
#define OPENMC_DISTRIBUTION_ENERGY_H
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include "hdf5.h"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/endf.h"
|
||||
|
|
@ -38,11 +38,12 @@ public:
|
|||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
//! \return Sampled energy in [eV]
|
||||
double sample(double E, uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
int primary_flag_; //!< Indicator of whether the photon is a primary or
|
||||
//!< non-primary photon.
|
||||
double energy_; //!< Photon energy or binding energy
|
||||
double A_; //!< Atomic weight ratio of the target nuclide
|
||||
double energy_; //!< Photon energy or binding energy
|
||||
double A_; //!< Atomic weight ratio of the target nuclide
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
|
@ -58,8 +59,9 @@ public:
|
|||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
//! \return Sampled energy in [eV]
|
||||
double sample(double E, uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
double threshold_; //!< Energy threshold in lab, (A + 1)/A * |Q|
|
||||
double threshold_; //!< Energy threshold in lab, (A + 1)/A * |Q|
|
||||
double mass_ratio_; //!< (A/(A+1))^2
|
||||
};
|
||||
|
||||
|
|
@ -78,17 +80,18 @@ public:
|
|||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
//! \return Sampled energy in [eV]
|
||||
double sample(double E, uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
//! Outgoing energy for a single incoming energy
|
||||
struct CTTable {
|
||||
Interpolation interpolation; //!< Interpolation law
|
||||
int n_discrete; //!< Number of of discrete energies
|
||||
Interpolation interpolation; //!< Interpolation law
|
||||
int n_discrete; //!< Number of of discrete energies
|
||||
xt::xtensor<double, 1> e_out; //!< Outgoing energies in [eV]
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
};
|
||||
|
||||
int n_region_; //!< Number of inteprolation regions
|
||||
int n_region_; //!< Number of inteprolation regions
|
||||
vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
vector<double> energy_; //!< Incident energy in [eV]
|
||||
|
|
@ -108,9 +111,10 @@ public:
|
|||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
//! \return Sampled energy in [eV]
|
||||
double sample(double E, uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
Tabulated1D theta_; //!< Incoming energy dependent parameter
|
||||
double u_; //!< Restriction energy
|
||||
double u_; //!< Restriction energy
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
|
@ -127,9 +131,10 @@ public:
|
|||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
//! \return Sampled energy in [eV]
|
||||
double sample(double E, uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
Tabulated1D theta_; //!< Incoming energy dependent parameter
|
||||
double u_; //!< Restriction energy
|
||||
double u_; //!< Restriction energy
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
|
@ -146,10 +151,11 @@ public:
|
|||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
//! \return Sampled energy in [eV]
|
||||
double sample(double E, uint64_t* seed) const;
|
||||
|
||||
private:
|
||||
Tabulated1D a_; //!< Energy-dependent 'a' parameter
|
||||
Tabulated1D b_; //!< Energy-dependent 'b' parameter
|
||||
double u_; //!< Restriction energy
|
||||
double u_; //!< Restriction energy
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ namespace openmc {
|
|||
|
||||
class UnitSphereDistribution {
|
||||
public:
|
||||
UnitSphereDistribution() { };
|
||||
explicit UnitSphereDistribution(Direction u) : u_ref_{u} { };
|
||||
UnitSphereDistribution() {};
|
||||
explicit UnitSphereDistribution(Direction u) : u_ref_ {u} {};
|
||||
explicit UnitSphereDistribution(pugi::xml_node node);
|
||||
virtual ~UnitSphereDistribution() = default;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public:
|
|||
//! \return Direction sampled
|
||||
virtual Direction sample(uint64_t* seed) const = 0;
|
||||
|
||||
Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
|
||||
Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -61,7 +61,7 @@ Direction isotropic_direction(uint64_t* seed);
|
|||
|
||||
class Isotropic : public UnitSphereDistribution {
|
||||
public:
|
||||
Isotropic() { };
|
||||
Isotropic() {};
|
||||
|
||||
//! Sample a direction from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -75,8 +75,9 @@ public:
|
|||
|
||||
class Monodirectional : public UnitSphereDistribution {
|
||||
public:
|
||||
Monodirectional(Direction u) : UnitSphereDistribution{u} { };
|
||||
explicit Monodirectional(pugi::xml_node node) : UnitSphereDistribution{node} { };
|
||||
Monodirectional(Direction u) : UnitSphereDistribution {u} {};
|
||||
explicit Monodirectional(pugi::xml_node node)
|
||||
: UnitSphereDistribution {node} {};
|
||||
|
||||
//! Sample a direction from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
Distribution* x() const { return x_.get(); }
|
||||
Distribution* y() const { return y_.get(); }
|
||||
Distribution* z() const { return z_.get(); }
|
||||
|
||||
private:
|
||||
UPtrDist x_; //!< Distribution of x coordinates
|
||||
UPtrDist y_; //!< Distribution of y coordinates
|
||||
|
|
@ -55,19 +56,19 @@ public:
|
|||
//! \param seed Pseudorandom number seed pointer
|
||||
//! \return Sampled position
|
||||
Position sample(uint64_t* seed) const;
|
||||
|
||||
|
||||
Distribution* r() const { return r_.get(); }
|
||||
Distribution* phi() const { return phi_.get(); }
|
||||
Distribution* z() const { return z_.get(); }
|
||||
Position origin() const { return origin_; }
|
||||
|
||||
private:
|
||||
UPtrDist r_; //!< Distribution of r coordinates
|
||||
UPtrDist phi_; //!< Distribution of phi coordinates
|
||||
UPtrDist z_; //!< Distribution of z coordinates
|
||||
UPtrDist r_; //!< Distribution of r coordinates
|
||||
UPtrDist phi_; //!< Distribution of phi coordinates
|
||||
UPtrDist z_; //!< Distribution of z coordinates
|
||||
Position origin_; //!< Cartesian coordinates of the cylinder center
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//! Distribution of points specified by spherical coordinates r,theta,phi
|
||||
//==============================================================================
|
||||
|
|
@ -84,11 +85,12 @@ public:
|
|||
Distribution* r() const { return r_.get(); }
|
||||
Distribution* theta() const { return theta_.get(); }
|
||||
Distribution* phi() const { return phi_.get(); }
|
||||
Position origin () const { return origin_; }
|
||||
Position origin() const { return origin_; }
|
||||
|
||||
private:
|
||||
UPtrDist r_; //!< Distribution of r coordinates
|
||||
UPtrDist theta_; //!< Distribution of theta coordinates
|
||||
UPtrDist phi_; //!< Distribution of phi coordinates
|
||||
UPtrDist r_; //!< Distribution of r coordinates
|
||||
UPtrDist theta_; //!< Distribution of theta coordinates
|
||||
UPtrDist phi_; //!< Distribution of phi coordinates
|
||||
Position origin_; //!< Cartesian coordinates of the sphere center
|
||||
};
|
||||
|
||||
|
|
@ -98,7 +100,7 @@ private:
|
|||
|
||||
class SpatialBox : public SpatialDistribution {
|
||||
public:
|
||||
explicit SpatialBox(pugi::xml_node node, bool fission=false);
|
||||
explicit SpatialBox(pugi::xml_node node, bool fission = false);
|
||||
|
||||
//! Sample a position from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -109,9 +111,10 @@ public:
|
|||
bool only_fissionable() const { return only_fissionable_; }
|
||||
Position lower_left() const { return lower_left_; }
|
||||
Position upper_right() const { return upper_right_; }
|
||||
|
||||
private:
|
||||
Position lower_left_; //!< Lower-left coordinates of box
|
||||
Position upper_right_; //!< Upper-right coordinates of box
|
||||
Position lower_left_; //!< Lower-left coordinates of box
|
||||
Position upper_right_; //!< Upper-right coordinates of box
|
||||
bool only_fissionable_ {false}; //!< Only accept sites in fissionable region?
|
||||
};
|
||||
|
||||
|
|
@ -121,8 +124,8 @@ private:
|
|||
|
||||
class SpatialPoint : public SpatialDistribution {
|
||||
public:
|
||||
SpatialPoint() : r_{} { };
|
||||
SpatialPoint(Position r) : r_{r} { };
|
||||
SpatialPoint() : r_ {} {};
|
||||
SpatialPoint(Position r) : r_ {r} {};
|
||||
explicit SpatialPoint(pugi::xml_node node);
|
||||
|
||||
//! Sample a position from the distribution
|
||||
|
|
@ -131,6 +134,7 @@ public:
|
|||
Position sample(uint64_t* seed) const;
|
||||
|
||||
Position r() const { return r_; }
|
||||
|
||||
private:
|
||||
Position r_; //!< Single position at which sites are generated
|
||||
};
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public:
|
|||
//! \param[in] x independent variable
|
||||
//! \return Polynomial evaluated at x
|
||||
double operator()(double x) const override;
|
||||
|
||||
private:
|
||||
vector<double> coef_; //!< Polynomial coefficients
|
||||
};
|
||||
|
|
@ -86,9 +87,9 @@ private:
|
|||
std::size_t n_regions_ {0}; //!< number of interpolation regions
|
||||
vector<int> nbt_; //!< values separating interpolation regions
|
||||
vector<Interpolation> int_; //!< interpolation schemes
|
||||
std::size_t n_pairs_; //!< number of (x,y) pairs
|
||||
vector<double> x_; //!< values of abscissa
|
||||
vector<double> y_; //!< values of ordinate
|
||||
std::size_t n_pairs_; //!< number of (x,y) pairs
|
||||
vector<double> x_; //!< values of abscissa
|
||||
vector<double> y_; //!< values of ordinate
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -118,9 +119,11 @@ public:
|
|||
explicit IncoherentElasticXS(hid_t dset);
|
||||
|
||||
double operator()(double E) const override;
|
||||
|
||||
private:
|
||||
double bound_xs_; //!< Characteristic bound xs in [b]
|
||||
double debye_waller_; //!< Debye-Waller integral divided by atomic mass in [eV^-1]
|
||||
double
|
||||
debye_waller_; //!< Debye-Waller integral divided by atomic mass in [eV^-1]
|
||||
};
|
||||
|
||||
//! Read 1D function from HDF5 dataset
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#define OPENMC_ERROR_H
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
|
|
@ -18,50 +18,43 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
inline void
|
||||
set_errmsg(const char* message)
|
||||
inline void set_errmsg(const char* message)
|
||||
{
|
||||
std::strcpy(openmc_err_msg, message);
|
||||
}
|
||||
|
||||
inline void
|
||||
set_errmsg(const std::string& message)
|
||||
inline void set_errmsg(const std::string& message)
|
||||
{
|
||||
std::strcpy(openmc_err_msg, message.c_str());
|
||||
}
|
||||
|
||||
inline void
|
||||
set_errmsg(const std::stringstream& message)
|
||||
inline void set_errmsg(const std::stringstream& message)
|
||||
{
|
||||
std::strcpy(openmc_err_msg, message.str().c_str());
|
||||
}
|
||||
|
||||
[[noreturn]] void fatal_error(const std::string& message, int err=-1);
|
||||
[[noreturn]] void fatal_error(const std::string& message, int err = -1);
|
||||
|
||||
[[noreturn]] inline
|
||||
void fatal_error(const std::stringstream& message)
|
||||
[[noreturn]] inline void fatal_error(const std::stringstream& message)
|
||||
{
|
||||
fatal_error(message.str());
|
||||
}
|
||||
|
||||
[[noreturn]] inline
|
||||
void fatal_error(const char* message)
|
||||
[[noreturn]] inline void fatal_error(const char* message)
|
||||
{
|
||||
fatal_error(std::string{message, std::strlen(message)});
|
||||
fatal_error(std::string {message, std::strlen(message)});
|
||||
}
|
||||
|
||||
void warning(const std::string& message);
|
||||
|
||||
inline
|
||||
void warning(const std::stringstream& message)
|
||||
inline void warning(const std::stringstream& message)
|
||||
{
|
||||
warning(message.str());
|
||||
}
|
||||
|
||||
void write_message(const std::string& message, int level=0);
|
||||
void write_message(const std::string& message, int level = 0);
|
||||
|
||||
inline
|
||||
void write_message(const std::stringstream& message, int level)
|
||||
inline void write_message(const std::stringstream& message, int level)
|
||||
{
|
||||
write_message(message.str(), level);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include "openmc/particle.h"
|
||||
#include "openmc/shared_array.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -17,17 +16,17 @@ namespace openmc {
|
|||
// In the event-based model, instead of moving or sorting the particles
|
||||
// themselves based on which event they need, a queue is used to store the
|
||||
// index (and other useful info) for each event type.
|
||||
// The EventQueueItem struct holds the relevant information about a particle needed
|
||||
// for sorting the queue. For very high particle counts, a sorted queue has the
|
||||
// potential to result in greatly improved cache efficiency. However, sorting
|
||||
// will introduce some overhead due to the sorting process itself, and may not
|
||||
// result in any benefits if not enough particles are present for them to achieve
|
||||
// consistent locality improvements.
|
||||
struct EventQueueItem{
|
||||
int64_t idx; //!< particle index in event-based particle buffer
|
||||
ParticleType type; //!< particle type
|
||||
int64_t material; //!< material that particle is in
|
||||
double E; //!< particle energy
|
||||
// The EventQueueItem struct holds the relevant information about a particle
|
||||
// needed for sorting the queue. For very high particle counts, a sorted queue
|
||||
// has the potential to result in greatly improved cache efficiency. However,
|
||||
// sorting will introduce some overhead due to the sorting process itself, and
|
||||
// may not result in any benefits if not enough particles are present for them
|
||||
// to achieve consistent locality improvements.
|
||||
struct EventQueueItem {
|
||||
int64_t idx; //!< particle index in event-based particle buffer
|
||||
ParticleType type; //!< particle type
|
||||
int64_t material; //!< material that particle is in
|
||||
double E; //!< particle energy
|
||||
|
||||
// Constructors
|
||||
EventQueueItem() = default;
|
||||
|
|
@ -35,16 +34,18 @@ struct EventQueueItem{
|
|||
: idx(buffer_idx), type(p.type()), material(p.material()), E(p.E())
|
||||
{}
|
||||
|
||||
// Compare by particle type, then by material type (4.5% fuel/7.0% fuel/cladding/etc),
|
||||
// then by energy.
|
||||
// TODO: Currently in OpenMC, the material ID corresponds not only to a general
|
||||
// type, but also specific isotopic densities. Ideally we would
|
||||
// like to be able to just sort by general material type, regardless of densities.
|
||||
// A more general material type ID may be added in the future, in which case we
|
||||
// can update the material field of this struct to contain the more general id.
|
||||
// Compare by particle type, then by material type (4.5% fuel/7.0%
|
||||
// fuel/cladding/etc), then by energy.
|
||||
// TODO: Currently in OpenMC, the material ID corresponds not only to a
|
||||
// general type, but also specific isotopic densities. Ideally we would like
|
||||
// to be able to just sort by general material type, regardless of densities.
|
||||
// A more general material type ID may be added in the future, in which case
|
||||
// we can update the material field of this struct to contain the more general
|
||||
// id.
|
||||
bool operator<(const EventQueueItem& rhs) const
|
||||
{
|
||||
return std::tie(type, material, E) < std::tie(rhs.type, rhs.material, rhs.E);
|
||||
return std::tie(type, material, E) <
|
||||
std::tie(rhs.type, rhs.material, rhs.E);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef OPENMC_FINALIZE_H
|
||||
#define OPENMC_FINALIZE_H
|
||||
|
||||
namespace openmc {
|
||||
|
||||
} // namespace openmc
|
||||
namespace openmc {} // namespace openmc
|
||||
|
||||
#endif // OPENMC_FINALIZE_H
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Particle;
|
|||
|
||||
namespace model {
|
||||
|
||||
extern int root_universe; //!< Index of root universe
|
||||
extern int root_universe; //!< Index of root universe
|
||||
extern "C" int n_coord_levels; //!< Number of CSG coordinate levels
|
||||
|
||||
extern vector<int64_t> overlap_check_count;
|
||||
|
|
@ -30,7 +30,8 @@ extern vector<int64_t> overlap_check_count;
|
|||
//! Check two distances by coincidence tolerance
|
||||
//==============================================================================
|
||||
|
||||
inline bool coincident(double d1, double d2) {
|
||||
inline bool coincident(double d1, double d2)
|
||||
{
|
||||
return std::abs(d1 - d2) < FP_COINCIDENT;
|
||||
}
|
||||
|
||||
|
|
@ -38,15 +39,15 @@ inline bool coincident(double d1, double d2) {
|
|||
//! Check for overlapping cells at a particle's position.
|
||||
//==============================================================================
|
||||
|
||||
bool check_cell_overlap(Particle& p, bool error=true);
|
||||
bool check_cell_overlap(Particle& p, bool error = true);
|
||||
|
||||
//==============================================================================
|
||||
//! Get the cell instance for a particle at the specified universe level
|
||||
//!
|
||||
//! \param p A particle for which to compute the instance using
|
||||
//! its coordinates
|
||||
//! \param level The level (zero indexed) of the geometry where the instance should be computed.
|
||||
//! \return The instance of the cell at the specified level.
|
||||
//! \param level The level (zero indexed) of the geometry where the instance
|
||||
//! should be computed. \return The instance of the cell at the specified level.
|
||||
//==============================================================================
|
||||
|
||||
int cell_instance_at_level(const Particle& p, int level);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@
|
|||
namespace openmc {
|
||||
|
||||
namespace model {
|
||||
extern std::unordered_map<int32_t, std::unordered_map<int32_t, int32_t>> universe_cell_counts;
|
||||
extern std::unordered_map<int32_t, int32_t> universe_level_counts;
|
||||
extern std::unordered_map<int32_t, std::unordered_map<int32_t, int32_t>>
|
||||
universe_cell_counts;
|
||||
extern std::unordered_map<int32_t, int32_t> universe_level_counts;
|
||||
} // namespace model
|
||||
|
||||
void read_geometry_xml();
|
||||
|
|
@ -69,7 +70,8 @@ int32_t find_root_universe();
|
|||
//! filter.
|
||||
//==============================================================================
|
||||
|
||||
void prepare_distribcell(const std::vector<int32_t>* user_distribcells = nullptr);
|
||||
void prepare_distribcell(
|
||||
const std::vector<int32_t>* user_distribcells = nullptr);
|
||||
|
||||
//==============================================================================
|
||||
//! Recursively search through the geometry and count cell instances.
|
||||
|
|
@ -106,8 +108,8 @@ int count_universe_instances(int32_t search_univ, int32_t target_univ_id,
|
|||
//! desired instance of the target cell.
|
||||
//==============================================================================
|
||||
|
||||
std::string
|
||||
distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset);
|
||||
std::string distribcell_path(
|
||||
int32_t target_cell, int32_t map, int32_t target_offset);
|
||||
|
||||
//==============================================================================
|
||||
//! Determine the maximum number of nested coordinate levels in the geometry.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include <complex>
|
||||
#include <cstddef>
|
||||
#include <cstring> // for strlen
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "hdf5.h"
|
||||
|
|
@ -25,8 +25,7 @@ namespace openmc {
|
|||
// Low-level internal functions
|
||||
//==============================================================================
|
||||
|
||||
void read_attr(hid_t obj_id, const char* name, hid_t mem_type_id,
|
||||
void* buffer);
|
||||
void read_attr(hid_t obj_id, const char* name, hid_t mem_type_id, void* buffer);
|
||||
|
||||
void write_attr(hid_t obj_id, int ndim, const hsize_t* dims, const char* name,
|
||||
hid_t mem_type_id, const void* buffer);
|
||||
|
|
@ -47,17 +46,18 @@ bool using_mpio_device(hid_t obj_id);
|
|||
hid_t create_group(hid_t parent_id, const std::string& name);
|
||||
|
||||
inline hid_t create_group(hid_t parent_id, const std::stringstream& name)
|
||||
{return create_group(parent_id, name.str());}
|
||||
{
|
||||
return create_group(parent_id, name.str());
|
||||
}
|
||||
|
||||
|
||||
hid_t file_open(const std::string& filename, char mode, bool parallel=false);
|
||||
hid_t file_open(const std::string& filename, char mode, bool parallel = false);
|
||||
hid_t open_group(hid_t group_id, const std::string& name);
|
||||
void write_string(hid_t group_id, const char* name, const std::string& buffer,
|
||||
bool indep);
|
||||
void write_string(
|
||||
hid_t group_id, const char* name, const std::string& buffer, bool indep);
|
||||
|
||||
vector<hsize_t> attribute_shape(hid_t obj_id, const char* name);
|
||||
vector<std::string> dataset_names(hid_t group_id);
|
||||
void ensure_exists(hid_t obj_id, const char* name, bool attribute=false);
|
||||
void ensure_exists(hid_t obj_id, const char* name, bool attribute = false);
|
||||
vector<std::string> group_names(hid_t group_id);
|
||||
vector<hsize_t> object_shape(hid_t obj_id);
|
||||
std::string object_name(hid_t obj_id);
|
||||
|
|
@ -67,56 +67,54 @@ std::string object_name(hid_t obj_id);
|
|||
//==============================================================================
|
||||
|
||||
extern "C" {
|
||||
bool attribute_exists(hid_t obj_id, const char* name);
|
||||
size_t attribute_typesize(hid_t obj_id, const char* name);
|
||||
hid_t create_group(hid_t parent_id, const char* name);
|
||||
void close_dataset(hid_t dataset_id);
|
||||
void close_group(hid_t group_id);
|
||||
int dataset_ndims(hid_t dset);
|
||||
size_t dataset_typesize(hid_t obj_id, const char* name);
|
||||
hid_t file_open(const char* filename, char mode, bool parallel);
|
||||
void file_close(hid_t file_id);
|
||||
void get_name(hid_t obj_id, char* name);
|
||||
int get_num_datasets(hid_t group_id);
|
||||
int get_num_groups(hid_t group_id);
|
||||
void get_datasets(hid_t group_id, char* name[]);
|
||||
void get_groups(hid_t group_id, char* name[]);
|
||||
void get_shape(hid_t obj_id, hsize_t* dims);
|
||||
void get_shape_attr(hid_t obj_id, const char* name, hsize_t* dims);
|
||||
bool object_exists(hid_t object_id, const char* name);
|
||||
hid_t open_dataset(hid_t group_id, const char* name);
|
||||
hid_t open_group(hid_t group_id, const char* name);
|
||||
void read_attr_double(hid_t obj_id, const char* name, double* buffer);
|
||||
void read_attr_int(hid_t obj_id, const char* name, int* buffer);
|
||||
void read_attr_string(hid_t obj_id, const char* name, size_t slen,
|
||||
char* buffer);
|
||||
void read_complex(hid_t obj_id, const char* name,
|
||||
std::complex<double>* buffer, bool indep);
|
||||
void read_double(hid_t obj_id, const char* name, double* buffer, bool indep);
|
||||
void read_int(hid_t obj_id, const char* name, int* buffer, bool indep);
|
||||
void read_llong(hid_t obj_id, const char* name, long long* buffer,
|
||||
bool indep);
|
||||
void read_string(hid_t obj_id, const char* name, size_t slen, char* buffer,
|
||||
bool indep);
|
||||
bool attribute_exists(hid_t obj_id, const char* name);
|
||||
size_t attribute_typesize(hid_t obj_id, const char* name);
|
||||
hid_t create_group(hid_t parent_id, const char* name);
|
||||
void close_dataset(hid_t dataset_id);
|
||||
void close_group(hid_t group_id);
|
||||
int dataset_ndims(hid_t dset);
|
||||
size_t dataset_typesize(hid_t obj_id, const char* name);
|
||||
hid_t file_open(const char* filename, char mode, bool parallel);
|
||||
void file_close(hid_t file_id);
|
||||
void get_name(hid_t obj_id, char* name);
|
||||
int get_num_datasets(hid_t group_id);
|
||||
int get_num_groups(hid_t group_id);
|
||||
void get_datasets(hid_t group_id, char* name[]);
|
||||
void get_groups(hid_t group_id, char* name[]);
|
||||
void get_shape(hid_t obj_id, hsize_t* dims);
|
||||
void get_shape_attr(hid_t obj_id, const char* name, hsize_t* dims);
|
||||
bool object_exists(hid_t object_id, const char* name);
|
||||
hid_t open_dataset(hid_t group_id, const char* name);
|
||||
hid_t open_group(hid_t group_id, const char* name);
|
||||
void read_attr_double(hid_t obj_id, const char* name, double* buffer);
|
||||
void read_attr_int(hid_t obj_id, const char* name, int* buffer);
|
||||
void read_attr_string(
|
||||
hid_t obj_id, const char* name, size_t slen, char* buffer);
|
||||
void read_complex(
|
||||
hid_t obj_id, const char* name, std::complex<double>* buffer, bool indep);
|
||||
void read_double(hid_t obj_id, const char* name, double* buffer, bool indep);
|
||||
void read_int(hid_t obj_id, const char* name, int* buffer, bool indep);
|
||||
void read_llong(hid_t obj_id, const char* name, long long* buffer, bool indep);
|
||||
void read_string(
|
||||
hid_t obj_id, const char* name, size_t slen, char* buffer, bool indep);
|
||||
|
||||
|
||||
void read_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score,
|
||||
double* results);
|
||||
void write_attr_double(hid_t obj_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const double* buffer);
|
||||
void write_attr_int(hid_t obj_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const int* buffer);
|
||||
void write_attr_string(hid_t obj_id, const char* name, const char* buffer);
|
||||
void write_double(hid_t group_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const double* buffer, bool indep);
|
||||
void write_int(hid_t group_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const int* buffer, bool indep);
|
||||
void write_llong(hid_t group_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const long long* buffer, bool indep);
|
||||
void write_string(hid_t group_id, int ndim, const hsize_t* dims, size_t slen,
|
||||
const char* name, char const* buffer, bool indep);
|
||||
void write_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score,
|
||||
const double* results);
|
||||
void read_tally_results(
|
||||
hid_t group_id, hsize_t n_filter, hsize_t n_score, double* results);
|
||||
void write_attr_double(hid_t obj_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const double* buffer);
|
||||
void write_attr_int(hid_t obj_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const int* buffer);
|
||||
void write_attr_string(hid_t obj_id, const char* name, const char* buffer);
|
||||
void write_double(hid_t group_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const double* buffer, bool indep);
|
||||
void write_int(hid_t group_id, int ndim, const hsize_t* dims, const char* name,
|
||||
const int* buffer, bool indep);
|
||||
void write_llong(hid_t group_id, int ndim, const hsize_t* dims,
|
||||
const char* name, const long long* buffer, bool indep);
|
||||
void write_string(hid_t group_id, int ndim, const hsize_t* dims, size_t slen,
|
||||
const char* name, char const* buffer, bool indep);
|
||||
void write_tally_results(
|
||||
hid_t group_id, hsize_t n_filter, hsize_t n_score, const double* results);
|
||||
} // extern "C"
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -127,7 +125,9 @@ extern "C" {
|
|||
//==============================================================================
|
||||
|
||||
template<typename T>
|
||||
struct H5TypeMap { static const hid_t type_id; };
|
||||
struct H5TypeMap {
|
||||
static const hid_t type_id;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Templates/overloads for read_attribute
|
||||
|
|
@ -185,8 +185,7 @@ void read_attribute(hid_t obj_id, const char* name, xt::xarray<T>& arr)
|
|||
}
|
||||
|
||||
// overload for std::string
|
||||
inline void
|
||||
read_attribute(hid_t obj_id, const char* name, std::string& str)
|
||||
inline void read_attribute(hid_t obj_id, const char* name, std::string& str)
|
||||
{
|
||||
// Create buffer to read data into
|
||||
auto n = attribute_typesize(obj_id, name);
|
||||
|
|
@ -194,7 +193,7 @@ read_attribute(hid_t obj_id, const char* name, std::string& str)
|
|||
|
||||
// Read attribute and set string
|
||||
read_attr_string(obj_id, name, n, buffer);
|
||||
str = std::string{buffer, n};
|
||||
str = std::string {buffer, n};
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +206,7 @@ inline void read_attribute(
|
|||
|
||||
// Allocate a C char array to get strings
|
||||
auto n = attribute_typesize(obj_id, name);
|
||||
char* buffer = new char[m*n];
|
||||
char* buffer = new char[m * n];
|
||||
|
||||
// Read char data in attribute
|
||||
read_attr_string(obj_id, name, n, buffer);
|
||||
|
|
@ -216,10 +215,12 @@ inline void read_attribute(
|
|||
// Determine proper length of string -- strlen doesn't work because
|
||||
// buffer[i] might not have any null characters
|
||||
std::size_t k = 0;
|
||||
for (; k < n; ++k) if (buffer[i*n + k] == '\0') break;
|
||||
for (; k < n; ++k)
|
||||
if (buffer[i * n + k] == '\0')
|
||||
break;
|
||||
|
||||
// Create string based on (char*, size_t) constructor
|
||||
vec.emplace_back(&buffer[i*n], k);
|
||||
vec.emplace_back(&buffer[i * n], k);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
|
|
@ -232,17 +233,17 @@ inline void read_attribute(
|
|||
// this version of read_dataset for vectors, arrays, or other non-scalar types.
|
||||
// enable_if_t allows us to conditionally remove the function from overload
|
||||
// resolution when the type T doesn't meet a certain criterion.
|
||||
template<typename T> inline
|
||||
std::enable_if_t<std::is_scalar<std::decay_t<T>>::value>
|
||||
read_dataset(hid_t obj_id, const char* name, T& buffer, bool indep=false)
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_scalar<std::decay_t<T>>::value> read_dataset(
|
||||
hid_t obj_id, const char* name, T& buffer, bool indep = false)
|
||||
{
|
||||
read_dataset_lowlevel(obj_id, name, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
&buffer);
|
||||
read_dataset_lowlevel(
|
||||
obj_id, name, H5TypeMap<T>::type_id, H5S_ALL, indep, &buffer);
|
||||
}
|
||||
|
||||
// overload for std::string
|
||||
inline void
|
||||
read_dataset(hid_t obj_id, const char* name, std::string& str, bool indep=false)
|
||||
inline void read_dataset(
|
||||
hid_t obj_id, const char* name, std::string& str, bool indep = false)
|
||||
{
|
||||
// Create buffer to read data into
|
||||
auto n = dataset_typesize(obj_id, name);
|
||||
|
|
@ -250,7 +251,7 @@ read_dataset(hid_t obj_id, const char* name, std::string& str, bool indep=false)
|
|||
|
||||
// Read attribute and set string
|
||||
read_string(obj_id, name, n, buffer, indep);
|
||||
str = std::string{buffer, n};
|
||||
str = std::string {buffer, n};
|
||||
}
|
||||
|
||||
// array version
|
||||
|
|
@ -258,8 +259,8 @@ template<typename T, std::size_t N>
|
|||
inline void read_dataset(
|
||||
hid_t dset, const char* name, array<T, N>& buffer, bool indep = false)
|
||||
{
|
||||
read_dataset_lowlevel(dset, name, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
buffer.data());
|
||||
read_dataset_lowlevel(
|
||||
dset, name, H5TypeMap<T>::type_id, H5S_ALL, indep, buffer.data());
|
||||
}
|
||||
|
||||
// vector version
|
||||
|
|
@ -273,8 +274,8 @@ void read_dataset(hid_t dset, vector<T>& vec, bool indep = false)
|
|||
vec.resize(shape[0]);
|
||||
|
||||
// Read data into vector
|
||||
read_dataset_lowlevel(dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
vec.data());
|
||||
read_dataset_lowlevel(
|
||||
dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep, vec.data());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -286,8 +287,8 @@ void read_dataset(
|
|||
close_dataset(dset);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void read_dataset(hid_t dset, xt::xarray<T>& arr, bool indep=false)
|
||||
template<typename T>
|
||||
void read_dataset(hid_t dset, xt::xarray<T>& arr, bool indep = false)
|
||||
{
|
||||
// Get shape of dataset
|
||||
vector<hsize_t> shape = object_shape(dset);
|
||||
|
|
@ -299,17 +300,17 @@ void read_dataset(hid_t dset, xt::xarray<T>& arr, bool indep=false)
|
|||
arr.resize(shape);
|
||||
|
||||
// Read data from attribute
|
||||
read_dataset_lowlevel(dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
arr.data());
|
||||
read_dataset_lowlevel(
|
||||
dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep, arr.data());
|
||||
}
|
||||
|
||||
template<>
|
||||
void read_dataset(hid_t dset, xt::xarray<std::complex<double>>& arr,
|
||||
bool indep);
|
||||
void read_dataset(
|
||||
hid_t dset, xt::xarray<std::complex<double>>& arr, bool indep);
|
||||
|
||||
template <typename T>
|
||||
void read_dataset(hid_t obj_id, const char* name, xt::xarray<T>& arr,
|
||||
bool indep=false)
|
||||
template<typename T>
|
||||
void read_dataset(
|
||||
hid_t obj_id, const char* name, xt::xarray<T>& arr, bool indep = false)
|
||||
{
|
||||
// Open dataset and read array
|
||||
hid_t dset = open_dataset(obj_id, name);
|
||||
|
|
@ -317,10 +318,9 @@ void read_dataset(hid_t obj_id, const char* name, xt::xarray<T>& arr,
|
|||
close_dataset(dset);
|
||||
}
|
||||
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
void read_dataset(hid_t obj_id, const char* name, xt::xtensor<T, N>& arr,
|
||||
bool indep=false)
|
||||
template<typename T, std::size_t N>
|
||||
void read_dataset(
|
||||
hid_t obj_id, const char* name, xt::xtensor<T, N>& arr, bool indep = false)
|
||||
{
|
||||
// Open dataset and read array
|
||||
hid_t dset = open_dataset(obj_id, name);
|
||||
|
|
@ -346,8 +346,8 @@ void read_dataset(hid_t obj_id, const char* name, xt::xtensor<T, N>& arr,
|
|||
}
|
||||
|
||||
// overload for Position
|
||||
inline void
|
||||
read_dataset(hid_t obj_id, const char* name, Position& r, bool indep=false)
|
||||
inline void read_dataset(
|
||||
hid_t obj_id, const char* name, Position& r, bool indep = false)
|
||||
{
|
||||
array<double, 3> x;
|
||||
read_dataset(obj_id, name, x, indep);
|
||||
|
|
@ -356,9 +356,9 @@ read_dataset(hid_t obj_id, const char* name, Position& r, bool indep=false)
|
|||
r.z = x[2];
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
inline void read_dataset_as_shape(hid_t obj_id, const char* name,
|
||||
xt::xtensor<T, N>& arr, bool indep=false)
|
||||
template<typename T, std::size_t N>
|
||||
inline void read_dataset_as_shape(
|
||||
hid_t obj_id, const char* name, xt::xtensor<T, N>& arr, bool indep = false)
|
||||
{
|
||||
hid_t dset = open_dataset(obj_id, name);
|
||||
|
||||
|
|
@ -369,8 +369,8 @@ inline void read_dataset_as_shape(hid_t obj_id, const char* name,
|
|||
vector<T> buffer(size);
|
||||
|
||||
// Read data from attribute
|
||||
read_dataset_lowlevel(dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
buffer.data());
|
||||
read_dataset_lowlevel(
|
||||
dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep, buffer.data());
|
||||
|
||||
// Adapt into xarray
|
||||
arr = xt::adapt(buffer, arr.shape());
|
||||
|
|
@ -378,10 +378,9 @@ inline void read_dataset_as_shape(hid_t obj_id, const char* name,
|
|||
close_dataset(dset);
|
||||
}
|
||||
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
template<typename T, std::size_t N>
|
||||
inline void read_nd_vector(hid_t obj_id, const char* name,
|
||||
xt::xtensor<T, N>& result, bool must_have=false)
|
||||
xt::xtensor<T, N>& result, bool must_have = false)
|
||||
{
|
||||
if (object_exists(obj_id, name)) {
|
||||
read_dataset_as_shape(obj_id, name, result, true);
|
||||
|
|
@ -394,20 +393,19 @@ inline void read_nd_vector(hid_t obj_id, const char* name,
|
|||
// Templates/overloads for write_attribute
|
||||
//==============================================================================
|
||||
|
||||
template<typename T> inline void
|
||||
write_attribute(hid_t obj_id, const char* name, T buffer)
|
||||
template<typename T>
|
||||
inline void write_attribute(hid_t obj_id, const char* name, T buffer)
|
||||
{
|
||||
write_attr(obj_id, 0, nullptr, name, H5TypeMap<T>::type_id, &buffer);
|
||||
}
|
||||
|
||||
inline void
|
||||
write_attribute(hid_t obj_id, const char* name, const char* buffer)
|
||||
inline void write_attribute(hid_t obj_id, const char* name, const char* buffer)
|
||||
{
|
||||
write_attr_string(obj_id, name, buffer);
|
||||
}
|
||||
|
||||
inline void
|
||||
write_attribute(hid_t obj_id, const char* name, const std::string& buffer)
|
||||
inline void write_attribute(
|
||||
hid_t obj_id, const char* name, const std::string& buffer)
|
||||
{
|
||||
write_attr_string(obj_id, name, buffer.c_str());
|
||||
}
|
||||
|
|
@ -428,30 +426,26 @@ inline void write_attribute(
|
|||
write_attr(obj_id, 1, dims, name, H5TypeMap<T>::type_id, buffer.data());
|
||||
}
|
||||
|
||||
inline void
|
||||
write_attribute(hid_t obj_id, const char* name, Position r)
|
||||
inline void write_attribute(hid_t obj_id, const char* name, Position r)
|
||||
{
|
||||
array<double, 3> buffer {r.x, r.y, r.z};
|
||||
write_attribute(obj_id, name, buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// Templates/overloads for write_dataset
|
||||
//==============================================================================
|
||||
|
||||
// Template for scalars (ensured by SFINAE)
|
||||
template<typename T> inline
|
||||
std::enable_if_t<std::is_scalar<std::decay_t<T>>::value>
|
||||
write_dataset(hid_t obj_id, const char* name, T buffer)
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_scalar<std::decay_t<T>>::value> write_dataset(
|
||||
hid_t obj_id, const char* name, T buffer)
|
||||
{
|
||||
write_dataset_lowlevel(obj_id, 0, nullptr, name, H5TypeMap<T>::type_id,
|
||||
H5S_ALL, false, &buffer);
|
||||
write_dataset_lowlevel(
|
||||
obj_id, 0, nullptr, name, H5TypeMap<T>::type_id, H5S_ALL, false, &buffer);
|
||||
}
|
||||
|
||||
inline void
|
||||
write_dataset(hid_t obj_id, const char* name, const char* buffer)
|
||||
inline void write_dataset(hid_t obj_id, const char* name, const char* buffer)
|
||||
{
|
||||
write_string(obj_id, name, buffer, false);
|
||||
}
|
||||
|
|
@ -461,8 +455,8 @@ inline void write_dataset(
|
|||
hid_t obj_id, const char* name, const array<T, N>& buffer)
|
||||
{
|
||||
hsize_t dims[] {N};
|
||||
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id,
|
||||
H5S_ALL, false, buffer.data());
|
||||
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id, H5S_ALL,
|
||||
false, buffer.data());
|
||||
}
|
||||
|
||||
inline void write_dataset(
|
||||
|
|
@ -478,10 +472,10 @@ inline void write_dataset(
|
|||
}
|
||||
|
||||
// Copy data into contiguous buffer
|
||||
char* temp = new char[n*m];
|
||||
std::fill(temp, temp + n*m, '\0');
|
||||
char* temp = new char[n * m];
|
||||
std::fill(temp, temp + n * m, '\0');
|
||||
for (decltype(n) i = 0; i < n; ++i) {
|
||||
std::copy(buffer[i].begin(), buffer[i].end(), temp + i*m);
|
||||
std::copy(buffer[i].begin(), buffer[i].end(), temp + i * m);
|
||||
}
|
||||
|
||||
// Write 2D data
|
||||
|
|
@ -496,30 +490,29 @@ inline void write_dataset(
|
|||
hid_t obj_id, const char* name, const vector<T>& buffer)
|
||||
{
|
||||
hsize_t dims[] {buffer.size()};
|
||||
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id,
|
||||
H5S_ALL, false, buffer.data());
|
||||
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id, H5S_ALL,
|
||||
false, buffer.data());
|
||||
}
|
||||
|
||||
// Template for xarray, xtensor, etc.
|
||||
template<typename D> inline void
|
||||
write_dataset(hid_t obj_id, const char* name, const xt::xcontainer<D>& arr)
|
||||
template<typename D>
|
||||
inline void write_dataset(
|
||||
hid_t obj_id, const char* name, const xt::xcontainer<D>& arr)
|
||||
{
|
||||
using T = typename D::value_type;
|
||||
auto s = arr.shape();
|
||||
vector<hsize_t> dims {s.cbegin(), s.cend()};
|
||||
write_dataset_lowlevel(obj_id, dims.size(), dims.data(), name,
|
||||
H5TypeMap<T>::type_id, H5S_ALL, false, arr.data());
|
||||
H5TypeMap<T>::type_id, H5S_ALL, false, arr.data());
|
||||
}
|
||||
|
||||
inline void
|
||||
write_dataset(hid_t obj_id, const char* name, Position r)
|
||||
inline void write_dataset(hid_t obj_id, const char* name, Position r)
|
||||
{
|
||||
array<double, 3> buffer {r.x, r.y, r.z};
|
||||
write_dataset(obj_id, name, buffer);
|
||||
}
|
||||
|
||||
inline void
|
||||
write_dataset(hid_t obj_id, const char* name, std::string buffer)
|
||||
inline void write_dataset(hid_t obj_id, const char* name, std::string buffer)
|
||||
{
|
||||
write_string(obj_id, name, buffer.c_str(), false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ void initialize_mpi(MPI_Comm intracomm);
|
|||
#endif
|
||||
void read_input_xml();
|
||||
|
||||
}
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_INITIALIZE_H
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ namespace openmc {
|
|||
// Module constants
|
||||
//==============================================================================
|
||||
|
||||
constexpr int32_t NO_OUTER_UNIVERSE{-1};
|
||||
constexpr int32_t NO_OUTER_UNIVERSE {-1};
|
||||
|
||||
enum class LatticeType {
|
||||
rect, hex
|
||||
};
|
||||
enum class LatticeType { rect, hex };
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
|
|
@ -33,8 +31,8 @@ enum class LatticeType {
|
|||
class Lattice;
|
||||
|
||||
namespace model {
|
||||
extern std::unordered_map<int32_t, int32_t> lattice_map;
|
||||
extern vector<unique_ptr<Lattice>> lattices;
|
||||
extern std::unordered_map<int32_t, int32_t> lattice_map;
|
||||
extern vector<unique_ptr<Lattice>> lattices;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -45,15 +43,14 @@ namespace model {
|
|||
class LatticeIter;
|
||||
class ReverseLatticeIter;
|
||||
|
||||
class Lattice
|
||||
{
|
||||
class Lattice {
|
||||
public:
|
||||
int32_t id_; //!< Universe ID number
|
||||
std::string name_; //!< User-defined name
|
||||
int32_t id_; //!< Universe ID number
|
||||
std::string name_; //!< User-defined name
|
||||
LatticeType type_;
|
||||
vector<int32_t> universes_; //!< Universes filling each lattice tile
|
||||
int32_t outer_ {NO_OUTER_UNIVERSE}; //!< Universe tiled outside the lattice
|
||||
vector<int32_t> offsets_; //!< Distribcell offset table
|
||||
vector<int32_t> universes_; //!< Universes filling each lattice tile
|
||||
int32_t outer_ {NO_OUTER_UNIVERSE}; //!< Universe tiled outside the lattice
|
||||
vector<int32_t> offsets_; //!< Distribcell offset table
|
||||
|
||||
explicit Lattice(pugi::xml_node lat_node);
|
||||
|
||||
|
|
@ -72,7 +69,9 @@ public:
|
|||
|
||||
//! Allocate offset table for distribcell.
|
||||
void allocate_offset_table(int n_maps)
|
||||
{offsets_.resize(n_maps * universes_.size(), C_NONE);}
|
||||
{
|
||||
offsets_.resize(n_maps * universes_.size(), C_NONE);
|
||||
}
|
||||
|
||||
//! Populate the distribcell offset tables.
|
||||
int32_t fill_offset_table(int32_t offset, int32_t target_univ_id, int map,
|
||||
|
|
@ -112,7 +111,9 @@ public:
|
|||
//! \return true if the given index fit within the lattice bounds. False
|
||||
//! otherwise.
|
||||
virtual bool is_valid_index(int indx) const
|
||||
{return (indx >= 0) && (indx < universes_.size());}
|
||||
{
|
||||
return (indx >= 0) && (indx < universes_.size());
|
||||
}
|
||||
|
||||
//! \brief Get the distribcell offset for a lattice tile.
|
||||
//! \param The map index for the target cell.
|
||||
|
|
@ -138,7 +139,7 @@ public:
|
|||
void to_hdf5(hid_t group_id) const;
|
||||
|
||||
protected:
|
||||
bool is_3d_; //!< Has divisions along the z-axis?
|
||||
bool is_3d_; //!< Has divisions along the z-axis?
|
||||
|
||||
virtual void to_hdf5_inner(hid_t group_id) const = 0;
|
||||
};
|
||||
|
|
@ -147,26 +148,24 @@ protected:
|
|||
//! An iterator over lattice universes.
|
||||
//==============================================================================
|
||||
|
||||
class LatticeIter
|
||||
{
|
||||
class LatticeIter {
|
||||
public:
|
||||
int indx_; //!< An index to a Lattice universes or offsets array.
|
||||
int indx_; //!< An index to a Lattice universes or offsets array.
|
||||
|
||||
LatticeIter(Lattice &lat, int indx)
|
||||
: indx_(indx), lat_(lat)
|
||||
{}
|
||||
LatticeIter(Lattice& lat, int indx) : indx_(indx), lat_(lat) {}
|
||||
|
||||
bool operator==(const LatticeIter &rhs) {return (indx_ == rhs.indx_);}
|
||||
bool operator==(const LatticeIter& rhs) { return (indx_ == rhs.indx_); }
|
||||
|
||||
bool operator!=(const LatticeIter &rhs) {return !(*this == rhs);}
|
||||
bool operator!=(const LatticeIter& rhs) { return !(*this == rhs); }
|
||||
|
||||
int32_t& operator*() {return lat_.universes_[indx_];}
|
||||
int32_t& operator*() { return lat_.universes_[indx_]; }
|
||||
|
||||
LatticeIter& operator++()
|
||||
{
|
||||
while (indx_ < lat_.universes_.size()) {
|
||||
++indx_;
|
||||
if (lat_.is_valid_index(indx_)) return *this;
|
||||
if (lat_.is_valid_index(indx_))
|
||||
return *this;
|
||||
}
|
||||
indx_ = lat_.universes_.size();
|
||||
return *this;
|
||||
|
|
@ -180,18 +179,16 @@ protected:
|
|||
//! A reverse iterator over lattice universes.
|
||||
//==============================================================================
|
||||
|
||||
class ReverseLatticeIter : public LatticeIter
|
||||
{
|
||||
class ReverseLatticeIter : public LatticeIter {
|
||||
public:
|
||||
ReverseLatticeIter(Lattice &lat, int indx)
|
||||
: LatticeIter {lat, indx}
|
||||
{}
|
||||
ReverseLatticeIter(Lattice& lat, int indx) : LatticeIter {lat, indx} {}
|
||||
|
||||
ReverseLatticeIter& operator++()
|
||||
{
|
||||
while (indx_ > -1) {
|
||||
--indx_;
|
||||
if (lat_.is_valid_index(indx_)) return *this;
|
||||
if (lat_.is_valid_index(indx_))
|
||||
return *this;
|
||||
}
|
||||
indx_ = -1;
|
||||
return *this;
|
||||
|
|
@ -200,8 +197,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
|
||||
class RectLattice : public Lattice
|
||||
{
|
||||
class RectLattice : public Lattice {
|
||||
public:
|
||||
explicit RectLattice(pugi::xml_node lat_node);
|
||||
|
||||
|
|
@ -225,15 +221,14 @@ public:
|
|||
void to_hdf5_inner(hid_t group_id) const;
|
||||
|
||||
private:
|
||||
array<int, 3> n_cells_; //!< Number of cells along each axis
|
||||
Position lower_left_; //!< Global lower-left corner of the lattice
|
||||
Position pitch_; //!< Lattice tile width along each axis
|
||||
array<int, 3> n_cells_; //!< Number of cells along each axis
|
||||
Position lower_left_; //!< Global lower-left corner of the lattice
|
||||
Position pitch_; //!< Lattice tile width along each axis
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
class HexLattice : public Lattice
|
||||
{
|
||||
class HexLattice : public Lattice {
|
||||
public:
|
||||
explicit HexLattice(pugi::xml_node lat_node);
|
||||
|
||||
|
|
@ -264,8 +259,8 @@ public:
|
|||
|
||||
private:
|
||||
enum class Orientation {
|
||||
y, //!< Flat side of lattice parallel to y-axis
|
||||
x //!< Flat side of lattice parallel to x-axis
|
||||
y, //!< Flat side of lattice parallel to y-axis
|
||||
x //!< Flat side of lattice parallel to x-axis
|
||||
};
|
||||
|
||||
//! Fill universes_ vector for 'y' orientation
|
||||
|
|
@ -274,11 +269,11 @@ private:
|
|||
//! Fill universes_ vector for 'x' orientation
|
||||
void fill_lattice_x(const vector<std::string>& univ_words);
|
||||
|
||||
int n_rings_; //!< Number of radial tile positions
|
||||
int n_axial_; //!< Number of axial tile positions
|
||||
Orientation orientation_; //!< Orientation of lattice
|
||||
Position center_; //!< Global center of lattice
|
||||
array<double, 2> pitch_; //!< Lattice tile width and height
|
||||
int n_rings_; //!< Number of radial tile positions
|
||||
int n_axial_; //!< Number of axial tile positions
|
||||
Orientation orientation_; //!< Orientation of lattice
|
||||
Position center_; //!< Global center of lattice
|
||||
array<double, 2> pitch_; //!< Lattice tile width and height
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include <hdf5.h>
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl>
|
||||
#include <hdf5.h>
|
||||
|
||||
#include "openmc/bremsstrahlung.h"
|
||||
#include "openmc/constants.h"
|
||||
|
|
@ -34,15 +34,14 @@ extern vector<unique_ptr<Material>> materials;
|
|||
//! A substance with constituent nuclides and thermal scattering data
|
||||
//==============================================================================
|
||||
|
||||
class Material
|
||||
{
|
||||
class Material {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Types
|
||||
struct ThermalTable {
|
||||
int index_table; //!< Index of table in data::thermal_scatt
|
||||
int index_table; //!< Index of table in data::thermal_scatt
|
||||
int index_nuclide; //!< Index in nuclide_
|
||||
double fraction; //!< How often to use table
|
||||
double fraction; //!< How often to use table
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -116,11 +115,17 @@ public:
|
|||
|
||||
//! Get nuclides in material
|
||||
//! \return Indices into the global nuclides vector
|
||||
gsl::span<const int> nuclides() const { return {nuclide_.data(), nuclide_.size()}; }
|
||||
gsl::span<const int> nuclides() const
|
||||
{
|
||||
return {nuclide_.data(), nuclide_.size()};
|
||||
}
|
||||
|
||||
//! Get densities of each nuclide in material
|
||||
//! \return Densities in [atom/b-cm]
|
||||
gsl::span<const double> densities() const { return {atom_density_.data(), atom_density_.size()}; }
|
||||
gsl::span<const double> densities() const
|
||||
{
|
||||
return {atom_density_.data(), atom_density_.size()};
|
||||
}
|
||||
|
||||
//! Get ID of material
|
||||
//! \return ID of material
|
||||
|
|
@ -145,15 +150,16 @@ public:
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
// Data
|
||||
int32_t id_ {C_NONE}; //!< Unique ID
|
||||
std::string name_; //!< Name of material
|
||||
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
|
||||
xt::xtensor<double, 1> atom_density_; //!< Nuclide atom density in [atom/b-cm]
|
||||
double density_; //!< Total atom density in [atom/b-cm]
|
||||
double density_gpcc_; //!< Total atom density in [g/cm^3]
|
||||
double volume_ {-1.0}; //!< Volume in [cm^3]
|
||||
bool fissionable_ {false}; //!< Does this material contain fissionable nuclides
|
||||
double density_; //!< Total atom density in [atom/b-cm]
|
||||
double density_gpcc_; //!< Total atom density in [g/cm^3]
|
||||
double volume_ {-1.0}; //!< Volume in [cm^3]
|
||||
bool fissionable_ {
|
||||
false}; //!< Does this material contain fissionable nuclides
|
||||
bool depletable_ {false}; //!< Is the material depletable?
|
||||
vector<bool> p0_; //!< Indicate which nuclides are to be treated with
|
||||
//!< iso-in-lab scattering
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include "openmc/position.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -130,11 +129,11 @@ extern "C" void calc_zn_rad(int n, double rho, double zn_rad[]);
|
|||
//! \param seed A pointer to the pseudorandom seed
|
||||
//==============================================================================
|
||||
|
||||
extern "C" void rotate_angle_c(double uvw[3], double mu, const double* phi,
|
||||
uint64_t* seed);
|
||||
extern "C" void rotate_angle_c(
|
||||
double uvw[3], double mu, const double* phi, uint64_t* seed);
|
||||
|
||||
Direction rotate_angle(Direction u, double mu, const double* phi,
|
||||
uint64_t* seed);
|
||||
Direction rotate_angle(
|
||||
Direction u, double mu, const double* phi, uint64_t* seed);
|
||||
|
||||
//==============================================================================
|
||||
//! Constructs a natural cubic spline.
|
||||
|
|
@ -167,8 +166,8 @@ void spline(int n, const double x[], const double y[], double z[]);
|
|||
//! \return Interpolated value
|
||||
//==============================================================================
|
||||
|
||||
double spline_interpolate(int n, const double x[], const double y[],
|
||||
const double z[], double xint);
|
||||
double spline_interpolate(
|
||||
int n, const double x[], const double y[], const double z[], double xint);
|
||||
|
||||
//==============================================================================
|
||||
//! Evaluate the definite integral of the interpolating cubic spline between
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@
|
|||
#include "openmc/vector.h"
|
||||
|
||||
#ifdef DAGMC
|
||||
#include "moab/Core.hpp"
|
||||
#include "moab/AdaptiveKDTree.hpp"
|
||||
#include "moab/Matrix3.hpp"
|
||||
#include "moab/Core.hpp"
|
||||
#include "moab/GeomUtil.hpp"
|
||||
#include "moab/Matrix3.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef LIBMESH
|
||||
|
|
@ -56,11 +56,10 @@ namespace settings {
|
|||
// used when creating new libMesh::Mesh instances
|
||||
extern unique_ptr<libMesh::LibMeshInit> libmesh_init;
|
||||
extern const libMesh::Parallel::Communicator* libmesh_comm;
|
||||
}
|
||||
} // namespace settings
|
||||
#endif
|
||||
|
||||
class Mesh
|
||||
{
|
||||
class Mesh {
|
||||
public:
|
||||
// Constructors and destructor
|
||||
Mesh() = default;
|
||||
|
|
@ -76,11 +75,8 @@ public:
|
|||
//! \param[in] u Particle direction
|
||||
//! \param[out] bins Bins that were crossed
|
||||
//! \param[out] lengths Fraction of tracklength in each bin
|
||||
virtual void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const = 0;
|
||||
virtual void bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins, vector<double>& lengths) const = 0;
|
||||
|
||||
//! Determine which surface bins were crossed by a particle
|
||||
//
|
||||
|
|
@ -88,11 +84,8 @@ public:
|
|||
//! \param[in] r1 Current position of the particle
|
||||
//! \param[in] u Particle direction
|
||||
//! \param[out] bins Surface bins that were crossed
|
||||
virtual void
|
||||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins) const = 0;
|
||||
virtual void surface_bins_crossed(
|
||||
Position r0, Position r1, const Direction& u, vector<int>& bins) const = 0;
|
||||
|
||||
//! Get bin at a given position in space
|
||||
//
|
||||
|
|
@ -107,7 +100,7 @@ public:
|
|||
virtual int n_surface_bins() const = 0;
|
||||
|
||||
//! Set the mesh ID
|
||||
void set_id(int32_t id=-1);
|
||||
void set_id(int32_t id = -1);
|
||||
|
||||
//! Write mesh data to an HDF5 group
|
||||
//
|
||||
|
|
@ -131,7 +124,7 @@ public:
|
|||
virtual std::string bin_label(int bin) const = 0;
|
||||
|
||||
// Data members
|
||||
int id_ {-1}; //!< User-specified ID
|
||||
int id_ {-1}; //!< User-specified ID
|
||||
int n_dimension_; //!< Number of dimensions
|
||||
};
|
||||
|
||||
|
|
@ -147,11 +140,8 @@ public:
|
|||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const override;
|
||||
void bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins, vector<double>& lengths) const override;
|
||||
|
||||
//! Count number of bank sites in each mesh bin / energy bin
|
||||
//
|
||||
|
|
@ -210,7 +200,7 @@ public:
|
|||
std::string bin_label(int bin) const override;
|
||||
|
||||
// Data members
|
||||
xt::xtensor<double, 1> lower_left_; //!< Lower-left coordinates of mesh
|
||||
xt::xtensor<double, 1> lower_left_; //!< Lower-left coordinates of mesh
|
||||
xt::xtensor<double, 1> upper_right_; //!< Upper-right coordinates of mesh
|
||||
xt::xtensor<int, 1> shape_; //!< Number of mesh elements in each dimension
|
||||
|
||||
|
|
@ -224,19 +214,15 @@ protected:
|
|||
//! Tessellation of n-dimensional Euclidean space by congruent squares or cubes
|
||||
//==============================================================================
|
||||
|
||||
class RegularMesh : public StructuredMesh
|
||||
{
|
||||
class RegularMesh : public StructuredMesh {
|
||||
public:
|
||||
// Constructors
|
||||
RegularMesh() = default;
|
||||
RegularMesh(pugi::xml_node node);
|
||||
|
||||
// Overridden methods
|
||||
void
|
||||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
|
|
@ -260,24 +246,19 @@ public:
|
|||
const SourceSite* bank, int64_t length, bool* outside) const;
|
||||
|
||||
// Data members
|
||||
double volume_frac_; //!< Volume fraction of each mesh element
|
||||
double volume_frac_; //!< Volume fraction of each mesh element
|
||||
xt::xtensor<double, 1> width_; //!< Width of each mesh element
|
||||
};
|
||||
|
||||
|
||||
class RectilinearMesh : public StructuredMesh
|
||||
{
|
||||
class RectilinearMesh : public StructuredMesh {
|
||||
public:
|
||||
// Constructors
|
||||
RectilinearMesh() = default;
|
||||
RectilinearMesh(pugi::xml_node node);
|
||||
|
||||
// Overridden methods
|
||||
void
|
||||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
|
|
@ -305,11 +286,8 @@ public:
|
|||
UnstructuredMesh(const std::string& filename);
|
||||
|
||||
// Overridden Methods
|
||||
void
|
||||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
|
||||
void to_hdf5(hid_t group) const override;
|
||||
|
||||
|
|
@ -349,7 +327,8 @@ public:
|
|||
virtual std::string library() const = 0;
|
||||
|
||||
// Data members
|
||||
bool output_ {true}; //!< Write tallies onto the unstructured mesh at the end of a run
|
||||
bool output_ {
|
||||
true}; //!< Write tallies onto the unstructured mesh at the end of a run
|
||||
std::string filename_; //!< Path to unstructured mesh file
|
||||
|
||||
private:
|
||||
|
|
@ -370,12 +349,8 @@ public:
|
|||
|
||||
// Overridden Methods
|
||||
|
||||
void
|
||||
bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const override;
|
||||
void bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins, vector<double>& lengths) const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
|
|
@ -383,9 +358,8 @@ public:
|
|||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
std::pair<vector<double>, vector<double>>
|
||||
plot(Position plot_ll,
|
||||
Position plot_ur) const override;
|
||||
std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
std::string library() const override;
|
||||
|
||||
|
|
@ -396,9 +370,8 @@ public:
|
|||
void remove_scores() override;
|
||||
|
||||
//! Set data for a score
|
||||
void set_score_data(const std::string& score,
|
||||
const vector<double>& values,
|
||||
const vector<double>& std_dev) override;
|
||||
void set_score_data(const std::string& score, const vector<double>& values,
|
||||
const vector<double>& std_dev) override;
|
||||
|
||||
//! Write the mesh with any current tally data
|
||||
void write(const std::string& base_filename) const override;
|
||||
|
|
@ -408,7 +381,6 @@ public:
|
|||
double volume(int bin) const override;
|
||||
|
||||
private:
|
||||
|
||||
void initialize() override;
|
||||
|
||||
// Methods
|
||||
|
|
@ -438,8 +410,9 @@ private:
|
|||
moab::EntityHandle get_tet(const Position& r) const;
|
||||
|
||||
//! Return the containing tet given a position
|
||||
moab::EntityHandle get_tet(const moab::CartVect& r) const {
|
||||
return get_tet(Position(r[0], r[1], r[2]));
|
||||
moab::EntityHandle get_tet(const moab::CartVect& r) const
|
||||
{
|
||||
return get_tet(Position(r[0], r[1], r[2]));
|
||||
};
|
||||
|
||||
//! Check for point containment within a tet; uses
|
||||
|
|
@ -448,8 +421,7 @@ private:
|
|||
//! \param[in] r Position to check
|
||||
//! \param[in] MOAB terahedron to check
|
||||
//! \return True if r is inside, False if r is outside
|
||||
bool point_in_tet(const moab::CartVect& r,
|
||||
moab::EntityHandle tet) const;
|
||||
bool point_in_tet(const moab::CartVect& r, moab::EntityHandle tet) const;
|
||||
|
||||
//! Compute barycentric coordinate data for all tetrahedra
|
||||
//! in the mesh.
|
||||
|
|
@ -500,12 +472,11 @@ private:
|
|||
//
|
||||
//! \param[in] score Name of the score
|
||||
//! \return The MOAB value and error tag handles, respectively
|
||||
std::pair<moab::Tag, moab::Tag>
|
||||
get_score_tags(std::string score) const;
|
||||
std::pair<moab::Tag, moab::Tag> get_score_tags(std::string score) const;
|
||||
|
||||
// Data members
|
||||
moab::Range ehs_; //!< Range of tetrahedra EntityHandle's in the mesh
|
||||
moab::EntityHandle tetset_; //!< EntitySet containing all tetrahedra
|
||||
moab::EntityHandle tetset_; //!< EntitySet containing all tetrahedra
|
||||
moab::EntityHandle kdtree_root_; //!< Root of the MOAB KDTree
|
||||
std::shared_ptr<moab::Interface> mbi_; //!< MOAB instance
|
||||
unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
|
||||
|
|
@ -524,11 +495,8 @@ public:
|
|||
LibMesh(const std::string& filename);
|
||||
|
||||
// Overridden Methods
|
||||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const override;
|
||||
void bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins, vector<double>& lengths) const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
|
|
@ -536,9 +504,8 @@ public:
|
|||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
std::pair<vector<double>, vector<double>>
|
||||
plot(Position plot_ll,
|
||||
Position plot_ur) const override;
|
||||
std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
std::string library() const override;
|
||||
|
||||
|
|
@ -546,9 +513,8 @@ public:
|
|||
|
||||
void remove_scores() override;
|
||||
|
||||
void set_score_data(const std::string& var_name,
|
||||
const vector<double>& values,
|
||||
const vector<double>& std_dev) override;
|
||||
void set_score_data(const std::string& var_name, const vector<double>& values,
|
||||
const vector<double>& std_dev) override;
|
||||
|
||||
void write(const std::string& base_filename) const override;
|
||||
|
||||
|
|
@ -557,7 +523,6 @@ public:
|
|||
double volume(int bin) const override;
|
||||
|
||||
private:
|
||||
|
||||
void initialize() override;
|
||||
|
||||
// Methods
|
||||
|
|
@ -573,11 +538,15 @@ private:
|
|||
vector<unique_ptr<libMesh::PointLocatorBase>>
|
||||
pl_; //!< per-thread point locators
|
||||
unique_ptr<libMesh::EquationSystems>
|
||||
equation_systems_; //!< pointer to the equation systems of the mesh
|
||||
std::string eq_system_name_; //!< name of the equation system holding OpenMC results
|
||||
std::unordered_map<std::string, unsigned int> variable_map_; //!< mapping of variable names (tally scores) to libMesh variable numbers
|
||||
equation_systems_; //!< pointer to the equation systems of the mesh
|
||||
std::string
|
||||
eq_system_name_; //!< name of the equation system holding OpenMC results
|
||||
std::unordered_map<std::string, unsigned int>
|
||||
variable_map_; //!< mapping of variable names (tally scores) to libMesh
|
||||
//!< variable numbers
|
||||
libMesh::BoundingBox bbox_; //!< bounding box of the mesh
|
||||
libMesh::dof_id_type first_element_id_; //!< id of the first element in the mesh
|
||||
libMesh::dof_id_type
|
||||
first_element_id_; //!< id of the first element in the mesh
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
namespace openmc {
|
||||
namespace mpi {
|
||||
|
||||
extern int rank;
|
||||
extern int n_procs;
|
||||
extern bool master;
|
||||
extern int rank;
|
||||
extern int n_procs;
|
||||
extern bool master;
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
extern MPI_Datatype source_site;
|
||||
extern MPI_Comm intracomm;
|
||||
extern MPI_Datatype source_site;
|
||||
extern MPI_Comm intracomm;
|
||||
#endif
|
||||
|
||||
} // namespace mpi
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ namespace openmc {
|
|||
|
||||
struct CacheData {
|
||||
double sqrtkT; // last temperature corresponding to t
|
||||
int t; // temperature index
|
||||
int a; // angle index
|
||||
int t; // temperature index
|
||||
int a; // angle index
|
||||
// last angle that corresponds to a
|
||||
double u;
|
||||
double v;
|
||||
|
|
@ -35,156 +35,150 @@ struct CacheData {
|
|||
//==============================================================================
|
||||
|
||||
class Mgxs {
|
||||
private:
|
||||
private:
|
||||
xt::xtensor<double, 1> kTs; // temperature in eV (k * T)
|
||||
AngleDistributionType
|
||||
scatter_format; // flag for if this is legendre, histogram, or tabular
|
||||
int num_groups; // number of energy groups
|
||||
int num_delayed_groups; // number of delayed neutron groups
|
||||
vector<XsData> xs; // Cross section data
|
||||
// MGXS Incoming Flux Angular grid information
|
||||
bool is_isotropic; // used to skip search for angle indices if isotropic
|
||||
int n_pol;
|
||||
int n_azi;
|
||||
vector<double> polar;
|
||||
vector<double> azimuthal;
|
||||
|
||||
xt::xtensor<double, 1> kTs; // temperature in eV (k * T)
|
||||
AngleDistributionType scatter_format; // flag for if this is legendre, histogram, or tabular
|
||||
int num_groups; // number of energy groups
|
||||
int num_delayed_groups; // number of delayed neutron groups
|
||||
vector<XsData> xs; // Cross section data
|
||||
// MGXS Incoming Flux Angular grid information
|
||||
bool is_isotropic; // used to skip search for angle indices if isotropic
|
||||
int n_pol;
|
||||
int n_azi;
|
||||
vector<double> polar;
|
||||
vector<double> azimuthal;
|
||||
//! \brief Initializes the Mgxs object metadata
|
||||
//!
|
||||
//! @param in_name Name of the object.
|
||||
//! @param in_awr atomic-weight ratio.
|
||||
//! @param in_kTs temperatures (in units of eV) that data is available.
|
||||
//! @param in_fissionable Is this item fissionable or not.
|
||||
//! @param in_scatter_format Denotes whether Legendre, Tabular, or
|
||||
//! Histogram scattering is used.
|
||||
//! @param in_is_isotropic Is this an isotropic or angular with respect to
|
||||
//! the incoming particle.
|
||||
//! @param in_polar Polar angle grid.
|
||||
//! @param in_azimuthal Azimuthal angle grid.
|
||||
void init(const std::string& in_name, double in_awr,
|
||||
const vector<double>& in_kTs, bool in_fissionable,
|
||||
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const vector<double>& in_polar, const vector<double>& in_azimuthal);
|
||||
|
||||
//! \brief Initializes the Mgxs object metadata
|
||||
//!
|
||||
//! @param in_name Name of the object.
|
||||
//! @param in_awr atomic-weight ratio.
|
||||
//! @param in_kTs temperatures (in units of eV) that data is available.
|
||||
//! @param in_fissionable Is this item fissionable or not.
|
||||
//! @param in_scatter_format Denotes whether Legendre, Tabular, or
|
||||
//! Histogram scattering is used.
|
||||
//! @param in_is_isotropic Is this an isotropic or angular with respect to
|
||||
//! the incoming particle.
|
||||
//! @param in_polar Polar angle grid.
|
||||
//! @param in_azimuthal Azimuthal angle grid.
|
||||
void init(const std::string& in_name, double in_awr,
|
||||
const vector<double>& in_kTs, bool in_fissionable,
|
||||
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const vector<double>& in_polar, const vector<double>& in_azimuthal);
|
||||
//! \brief Initializes the Mgxs object metadata from the HDF5 file
|
||||
//!
|
||||
//! @param xs_id HDF5 group id for the cross section data.
|
||||
//! @param temperature Temperatures to read.
|
||||
//! @param temps_to_read Resultant list of temperatures in the library
|
||||
//! to read which correspond to the requested temperatures.
|
||||
//! @param order_dim Resultant dimensionality of the scattering order.
|
||||
void metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
|
||||
vector<int>& temps_to_read, int& order_dim);
|
||||
|
||||
//! \brief Initializes the Mgxs object metadata from the HDF5 file
|
||||
//!
|
||||
//! @param xs_id HDF5 group id for the cross section data.
|
||||
//! @param temperature Temperatures to read.
|
||||
//! @param temps_to_read Resultant list of temperatures in the library
|
||||
//! to read which correspond to the requested temperatures.
|
||||
//! @param order_dim Resultant dimensionality of the scattering order.
|
||||
void metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
|
||||
vector<int>& temps_to_read, int& order_dim);
|
||||
//! \brief Performs the actual act of combining the microscopic data for a
|
||||
//! single temperature.
|
||||
//!
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
//! @param micro_ts The temperature index of the microscopic objects that
|
||||
//! corresponds to the temperature of interest.
|
||||
//! @param this_t The temperature index of the macroscopic object.
|
||||
void combine(const vector<Mgxs*>& micros, const vector<double>& scalars,
|
||||
const vector<int>& micro_ts, int this_t);
|
||||
|
||||
//! \brief Performs the actual act of combining the microscopic data for a
|
||||
//! single temperature.
|
||||
//!
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
//! @param micro_ts The temperature index of the microscopic objects that
|
||||
//! corresponds to the temperature of interest.
|
||||
//! @param this_t The temperature index of the macroscopic object.
|
||||
void combine(const vector<Mgxs*>& micros, const vector<double>& scalars,
|
||||
const vector<int>& micro_ts, int this_t);
|
||||
//! \brief Checks to see if this and that are able to be combined
|
||||
//!
|
||||
//! This comparison is used when building macroscopic cross sections
|
||||
//! from microscopic cross sections.
|
||||
//! @param that The other Mgxs to compare to this one.
|
||||
//! @return True if they can be combined, False otherwise.
|
||||
bool equiv(const Mgxs& that);
|
||||
|
||||
//! \brief Checks to see if this and that are able to be combined
|
||||
//!
|
||||
//! This comparison is used when building macroscopic cross sections
|
||||
//! from microscopic cross sections.
|
||||
//! @param that The other Mgxs to compare to this one.
|
||||
//! @return True if they can be combined, False otherwise.
|
||||
bool equiv(const Mgxs& that);
|
||||
public:
|
||||
std::string name; // name of dataset, e.g., UO2
|
||||
double awr; // atomic weight ratio
|
||||
bool fissionable; // Is this fissionable
|
||||
vector<CacheData> cache; // index and data cache
|
||||
|
||||
public:
|
||||
Mgxs() = default;
|
||||
|
||||
std::string name; // name of dataset, e.g., UO2
|
||||
double awr; // atomic weight ratio
|
||||
bool fissionable; // Is this fissionable
|
||||
vector<CacheData> cache; // index and data cache
|
||||
//! \brief Constructor that loads the Mgxs object from the HDF5 file
|
||||
//!
|
||||
//! @param xs_id HDF5 group id for the cross section data.
|
||||
//! @param temperature Temperatures to read.
|
||||
//! @param num_group number of energy groups
|
||||
//! @param num_delay number of delayed groups
|
||||
Mgxs(hid_t xs_id, const vector<double>& temperature, int num_group,
|
||||
int num_delay);
|
||||
|
||||
Mgxs() = default;
|
||||
//! \brief Constructor that initializes and populates all data to build a
|
||||
//! macroscopic cross section from microscopic cross sections.
|
||||
//!
|
||||
//! @param in_name Name of the object.
|
||||
//! @param mat_kTs temperatures (in units of eV) that data is needed.
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param atom_densities Atom densities of those microscopic quantities.
|
||||
//! @param num_group number of energy groups
|
||||
//! @param num_delay number of delayed groups
|
||||
Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
||||
const vector<Mgxs*>& micros, const vector<double>& atom_densities,
|
||||
int num_group, int num_delay);
|
||||
|
||||
//! \brief Constructor that loads the Mgxs object from the HDF5 file
|
||||
//!
|
||||
//! @param xs_id HDF5 group id for the cross section data.
|
||||
//! @param temperature Temperatures to read.
|
||||
//! @param num_group number of energy groups
|
||||
//! @param num_delay number of delayed groups
|
||||
Mgxs(hid_t xs_id, const vector<double>& temperature, int num_group,
|
||||
int num_delay);
|
||||
//! \brief Provides a cross section value given certain parameters
|
||||
//!
|
||||
//! @param xstype Type of cross section requested, according to the
|
||||
//! enumerated constants.
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Outgoing energy group; use nullptr if irrelevant, or if a
|
||||
//! sum is requested.
|
||||
//! @param mu Cosine of the change-in-angle, for scattering quantities;
|
||||
//! use nullptr if irrelevant.
|
||||
//! @param dg delayed group index; use nullptr if irrelevant.
|
||||
//! @return Requested cross section value.
|
||||
double get_xs(
|
||||
MgxsType xstype, int gin, const int* gout, const double* mu, const int* dg);
|
||||
|
||||
//! \brief Constructor that initializes and populates all data to build a
|
||||
//! macroscopic cross section from microscopic cross sections.
|
||||
//!
|
||||
//! @param in_name Name of the object.
|
||||
//! @param mat_kTs temperatures (in units of eV) that data is needed.
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param atom_densities Atom densities of those microscopic quantities.
|
||||
//! @param num_group number of energy groups
|
||||
//! @param num_delay number of delayed groups
|
||||
Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
||||
const vector<Mgxs*>& micros, const vector<double>& atom_densities,
|
||||
int num_group, int num_delay);
|
||||
inline double get_xs(MgxsType xstype, int gin)
|
||||
{
|
||||
return get_xs(xstype, gin, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
//! \brief Provides a cross section value given certain parameters
|
||||
//!
|
||||
//! @param xstype Type of cross section requested, according to the
|
||||
//! enumerated constants.
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Outgoing energy group; use nullptr if irrelevant, or if a
|
||||
//! sum is requested.
|
||||
//! @param mu Cosine of the change-in-angle, for scattering quantities;
|
||||
//! use nullptr if irrelevant.
|
||||
//! @param dg delayed group index; use nullptr if irrelevant.
|
||||
//! @return Requested cross section value.
|
||||
double
|
||||
get_xs(MgxsType xstype, int gin, const int* gout, const double* mu,
|
||||
const int* dg);
|
||||
//! \brief Samples the fission neutron energy and if prompt or delayed.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param dg Sampled delayed group index.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param seed Pseudorandom seed pointer
|
||||
void sample_fission_energy(int gin, int& dg, int& gout, uint64_t* seed);
|
||||
|
||||
inline double
|
||||
get_xs(MgxsType xstype, int gin)
|
||||
{return get_xs(xstype, gin, nullptr, nullptr, nullptr);}
|
||||
//! \brief Samples the outgoing energy and angle from a scatter event.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param mu Sampled cosine of the change-in-angle.
|
||||
//! @param wgt Weight of the particle to be adjusted.
|
||||
//! @param seed Pseudorandom seed pointer.
|
||||
void sample_scatter(
|
||||
int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
//! \brief Calculates cross section quantities needed for tracking.
|
||||
//!
|
||||
//! @param p The particle whose attributes set which MGXS to get.
|
||||
void calculate_xs(Particle& p);
|
||||
|
||||
//! \brief Samples the fission neutron energy and if prompt or delayed.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param dg Sampled delayed group index.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param seed Pseudorandom seed pointer
|
||||
void
|
||||
sample_fission_energy(int gin, int& dg, int& gout, uint64_t* seed);
|
||||
//! \brief Sets the temperature index in cache given a temperature
|
||||
//!
|
||||
//! @param sqrtkT Temperature of the material.
|
||||
void set_temperature_index(double sqrtkT);
|
||||
|
||||
//! \brief Samples the outgoing energy and angle from a scatter event.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param mu Sampled cosine of the change-in-angle.
|
||||
//! @param wgt Weight of the particle to be adjusted.
|
||||
//! @param seed Pseudorandom seed pointer.
|
||||
void
|
||||
sample_scatter(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
//! \brief Sets the angle index in cache given a direction
|
||||
//!
|
||||
//! @param u Incoming particle direction.
|
||||
void set_angle_index(Direction u);
|
||||
|
||||
//! \brief Calculates cross section quantities needed for tracking.
|
||||
//!
|
||||
//! @param p The particle whose attributes set which MGXS to get.
|
||||
void
|
||||
calculate_xs(Particle& p);
|
||||
|
||||
//! \brief Sets the temperature index in cache given a temperature
|
||||
//!
|
||||
//! @param sqrtkT Temperature of the material.
|
||||
void
|
||||
set_temperature_index(double sqrtkT);
|
||||
|
||||
//! \brief Sets the angle index in cache given a direction
|
||||
//!
|
||||
//! @param u Incoming particle direction.
|
||||
void
|
||||
set_angle_index(Direction u);
|
||||
|
||||
//! \brief Provide const access to list of XsData held by this
|
||||
const vector<XsData>& get_xsdata() const { return xs; }
|
||||
//! \brief Provide const access to list of XsData held by this
|
||||
const vector<XsData>& get_xsdata() const { return xs; }
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ namespace openmc {
|
|||
|
||||
class MgxsInterface {
|
||||
public:
|
||||
|
||||
MgxsInterface() = default;
|
||||
|
||||
// Construct from path to cross sections file, as well as a list
|
||||
|
|
@ -49,10 +48,10 @@ public:
|
|||
|
||||
int num_energy_groups_;
|
||||
int num_delayed_groups_;
|
||||
vector<std::string> xs_names_; // available names in HDF5 file
|
||||
vector<std::string> xs_to_read_; // XS which appear in materials
|
||||
vector<vector<double>> xs_temps_to_read_; // temperatures used
|
||||
std::string cross_sections_path_; // path to MGXS h5 file
|
||||
vector<std::string> xs_names_; // available names in HDF5 file
|
||||
vector<std::string> xs_to_read_; // XS which appear in materials
|
||||
vector<vector<double>> xs_temps_to_read_; // temperatures used
|
||||
std::string cross_sections_path_; // path to MGXS h5 file
|
||||
vector<Mgxs> nuclides_;
|
||||
vector<Mgxs> macro_xs_;
|
||||
vector<double> energy_bins_;
|
||||
|
|
@ -62,7 +61,7 @@ public:
|
|||
};
|
||||
|
||||
namespace data {
|
||||
extern MgxsInterface mg;
|
||||
extern MgxsInterface mg;
|
||||
}
|
||||
|
||||
// Puts available XS in MGXS file to globals so that when
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ namespace openmc {
|
|||
//! number of threads can safely read data without locks or reference counting.
|
||||
//==============================================================================
|
||||
|
||||
class NeighborList
|
||||
{
|
||||
class NeighborList {
|
||||
public:
|
||||
using value_type = int32_t;
|
||||
using const_iterator = std::forward_list<value_type>::const_iterator;
|
||||
|
|
@ -43,7 +42,8 @@ public:
|
|||
if (!list_.empty()) {
|
||||
auto it1 = list_.cbegin();
|
||||
auto it2 = ++list_.cbegin();
|
||||
while (it2 != list_.cend()) it1 = it2++;
|
||||
while (it2 != list_.cend())
|
||||
it1 = it2++;
|
||||
list_.insert_after(it1, new_elem);
|
||||
} else {
|
||||
list_.push_front(new_elem);
|
||||
|
|
@ -52,12 +52,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
{return list_.cbegin();}
|
||||
|
||||
const_iterator cend() const
|
||||
{return list_.cend();}
|
||||
const_iterator cbegin() const { return list_.cbegin(); }
|
||||
|
||||
const_iterator cend() const { return list_.cend(); }
|
||||
|
||||
private:
|
||||
std::forward_list<value_type> list_;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
void calculate_sab_xs(int i_sab, double sab_frac, Particle& p);
|
||||
|
||||
// Methods
|
||||
double nu(double E, EmissionMode mode, int group=0) const;
|
||||
double nu(double E, EmissionMode mode, int group = 0) const;
|
||||
void calculate_elastic_xs(Particle& p) const;
|
||||
|
||||
//! Determines the microscopic 0K elastic cross section at a trial relative
|
||||
|
|
@ -66,15 +66,15 @@ public:
|
|||
//! \param[in] energy Energy group boundaries in [eV]
|
||||
//! \param[in] flux Flux in each energy group (not normalized per eV)
|
||||
//! \return Reaction rate
|
||||
double collapse_rate(int MT, double temperature, gsl::span<const double> energy,
|
||||
gsl::span<const double> flux) const;
|
||||
double collapse_rate(int MT, double temperature,
|
||||
gsl::span<const double> energy, gsl::span<const double> flux) const;
|
||||
|
||||
// Data members
|
||||
std::string name_; //!< Name of nuclide, e.g. "U235"
|
||||
int Z_; //!< Atomic number
|
||||
int A_; //!< Mass number
|
||||
int metastable_; //!< Metastable state
|
||||
double awr_; //!< Atomic weight ratio
|
||||
int Z_; //!< Atomic number
|
||||
int A_; //!< Mass number
|
||||
int metastable_; //!< Metastable state
|
||||
double awr_; //!< Atomic weight ratio
|
||||
gsl::index index_; //!< Index in the nuclides array
|
||||
|
||||
// Temperature dependent cross section data
|
||||
|
|
@ -86,11 +86,11 @@ public:
|
|||
unique_ptr<WindowedMultipole> multipole_;
|
||||
|
||||
// Fission data
|
||||
bool fissionable_ {false}; //!< Whether nuclide is fissionable
|
||||
bool fissionable_ {false}; //!< Whether nuclide is fissionable
|
||||
bool has_partial_fission_ {false}; //!< has partial fission reactions?
|
||||
vector<Reaction*> fission_rx_; //!< Fission reactions
|
||||
int n_precursor_ {0}; //!< Number of delayed neutron precursors
|
||||
unique_ptr<Function1D> total_nu_; //!< Total neutron yield
|
||||
int n_precursor_ {0}; //!< Number of delayed neutron precursors
|
||||
unique_ptr<Function1D> total_nu_; //!< Total neutron yield
|
||||
unique_ptr<Function1D> fission_q_prompt_; //!< Prompt fission energy release
|
||||
unique_ptr<Function1D>
|
||||
fission_q_recov_; //!< Recoverable fission energy release
|
||||
|
|
@ -115,7 +115,8 @@ public:
|
|||
vector<int> index_inelastic_scatter_;
|
||||
|
||||
private:
|
||||
void create_derived(const Function1D* prompt_photons, const Function1D* delayed_photons);
|
||||
void create_derived(
|
||||
const Function1D* prompt_photons, const Function1D* delayed_photons);
|
||||
|
||||
//! Determine temperature index and interpolation factor
|
||||
//
|
||||
|
|
|
|||
|
|
@ -13,37 +13,36 @@ namespace openmc {
|
|||
//! This type meets the C++ "Lockable" requirements.
|
||||
//==============================================================================
|
||||
|
||||
class OpenMPMutex
|
||||
{
|
||||
class OpenMPMutex {
|
||||
public:
|
||||
OpenMPMutex()
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
omp_init_lock(&mutex_);
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
omp_init_lock(&mutex_);
|
||||
#endif
|
||||
}
|
||||
|
||||
~OpenMPMutex()
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
omp_destroy_lock(&mutex_);
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
omp_destroy_lock(&mutex_);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Mutexes cannot be copied. We need to explicitly delete the copy
|
||||
// constructor and copy assignment operator to ensure the compiler doesn't
|
||||
// "help" us by implicitly trying to copy the underlying mutexes.
|
||||
OpenMPMutex(const OpenMPMutex&) = delete;
|
||||
OpenMPMutex& operator= (const OpenMPMutex&) = delete;
|
||||
OpenMPMutex& operator=(const OpenMPMutex&) = delete;
|
||||
|
||||
//! Lock the mutex.
|
||||
//
|
||||
//! This function blocks execution until the lock succeeds.
|
||||
void lock()
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
omp_set_lock(&mutex_);
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
omp_set_lock(&mutex_);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Try to lock the mutex and indicate success.
|
||||
|
|
@ -52,25 +51,25 @@ public:
|
|||
//! the lock is unavailable.
|
||||
bool try_lock() noexcept
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
return omp_test_lock(&mutex_);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
return omp_test_lock(&mutex_);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Unlock the mutex.
|
||||
void unlock() noexcept
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
omp_unset_lock(&mutex_);
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
omp_unset_lock(&mutex_);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef _OPENMP
|
||||
omp_lock_t mutex_;
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
omp_lock_t mutex_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Surface;
|
|||
|
||||
class Particle : public ParticleData {
|
||||
public:
|
||||
|
||||
//==========================================================================
|
||||
// Constructors
|
||||
|
||||
|
|
@ -86,18 +85,22 @@ public:
|
|||
//! \param new_u The direction of the particle after translation/rotation.
|
||||
//! \param new_surface The signed index of the surface that the particle will
|
||||
//! reside on after translation/rotation.
|
||||
void cross_periodic_bc(const Surface& surf, Position new_r, Direction new_u,
|
||||
int new_surface);
|
||||
void cross_periodic_bc(
|
||||
const Surface& surf, Position new_r, Direction new_u, int new_surface);
|
||||
|
||||
//! mark a particle as lost and create a particle restart file
|
||||
//! \param message A warning message to display
|
||||
void mark_as_lost(const char* message);
|
||||
|
||||
void mark_as_lost(const std::string& message)
|
||||
{mark_as_lost(message.c_str());}
|
||||
{
|
||||
mark_as_lost(message.c_str());
|
||||
}
|
||||
|
||||
void mark_as_lost(const std::stringstream& message)
|
||||
{mark_as_lost(message.str());}
|
||||
{
|
||||
mark_as_lost(message.str());
|
||||
}
|
||||
|
||||
//! create a particle restart HDF5 file
|
||||
void write_restart() const;
|
||||
|
|
|
|||
|
|
@ -207,18 +207,18 @@ private:
|
|||
// Cross section caches
|
||||
vector<NuclideMicroXS> neutron_xs_; //!< Microscopic neutron cross sections
|
||||
vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
|
||||
MacroXS macro_xs_; //!< Macroscopic cross sections
|
||||
MacroXS macro_xs_; //!< Macroscopic cross sections
|
||||
|
||||
int64_t id_; //!< Unique ID
|
||||
ParticleType type_ {ParticleType::neutron}; //!< Particle type (n, p, e, etc.)
|
||||
|
||||
int n_coord_ {1}; //!< number of current coordinate levels
|
||||
int cell_instance_; //!< offset for distributed properties
|
||||
vector<LocalCoord> coord_; //!< coordinates for all levels
|
||||
int n_coord_ {1}; //!< number of current coordinate levels
|
||||
int cell_instance_; //!< offset for distributed properties
|
||||
vector<LocalCoord> coord_; //!< coordinates for all levels
|
||||
|
||||
// Particle coordinates before crossing a surface
|
||||
int n_coord_last_ {1}; //!< number of current coordinates
|
||||
vector<int> cell_last_; //!< coordinates for all levels
|
||||
int n_coord_last_ {1}; //!< number of current coordinates
|
||||
vector<int> cell_last_; //!< coordinates for all levels
|
||||
|
||||
// Energy data
|
||||
double E_; //!< post-collision energy in eV
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl>
|
||||
#include <hdf5.h>
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
|
@ -23,9 +23,9 @@ namespace openmc {
|
|||
class ElectronSubshell {
|
||||
public:
|
||||
// Constructors
|
||||
ElectronSubshell() { };
|
||||
ElectronSubshell() {};
|
||||
|
||||
int index_subshell; //!< index in SUBSHELLS
|
||||
int index_subshell; //!< index in SUBSHELLS
|
||||
int threshold;
|
||||
double n_electrons;
|
||||
double binding_energy;
|
||||
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
// Data members
|
||||
std::string name_; //!< Name of element, e.g. "Zr"
|
||||
int Z_; //!< Atomic number
|
||||
int Z_; //!< Atomic number
|
||||
gsl::index index_; //!< Index in global elements vector
|
||||
|
||||
// Microscopic cross sections
|
||||
|
|
@ -79,8 +79,9 @@ public:
|
|||
Tabulated1D coherent_anomalous_imag_;
|
||||
|
||||
// Photoionization and atomic relaxation data
|
||||
std::unordered_map<int, int> shell_map_; //!< Given a shell designator, e.g. 3, this
|
||||
//!< dictionary gives an index in shells_
|
||||
std::unordered_map<int, int>
|
||||
shell_map_; //!< Given a shell designator, e.g. 3, this
|
||||
//!< dictionary gives an index in shells_
|
||||
vector<ElectronSubshell> shells_;
|
||||
|
||||
// Compton profile data
|
||||
|
|
@ -99,8 +100,8 @@ public:
|
|||
xt::xtensor<double, 2> dcs_;
|
||||
|
||||
private:
|
||||
void compton_doppler(double alpha, double mu, double* E_out, int* i_shell,
|
||||
uint64_t* seed) const;
|
||||
void compton_doppler(
|
||||
double alpha, double mu, double* E_out, int* i_shell, uint64_t* seed) const;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -117,7 +118,8 @@ void free_memory_photon();
|
|||
|
||||
namespace data {
|
||||
|
||||
extern xt::xtensor<double, 1> compton_profile_pz; //! Compton profile momentum grid
|
||||
extern xt::xtensor<double, 1>
|
||||
compton_profile_pz; //! Compton profile momentum grid
|
||||
|
||||
//! Photon interaction data for each element
|
||||
extern std::unordered_map<std::string, int> element_map;
|
||||
|
|
|
|||
|
|
@ -26,16 +26,17 @@ void sample_neutron_reaction(Particle& p);
|
|||
void sample_photon_reaction(Particle& p);
|
||||
|
||||
//! Terminates the particle and either deposits all energy locally
|
||||
//! (electron_treatment = ElectronTreatment::LED) or creates secondary bremsstrahlung
|
||||
//! photons from electron deflections with charged particles (electron_treatment
|
||||
//! = ElectronTreatment::TTB).
|
||||
//! (electron_treatment = ElectronTreatment::LED) or creates secondary
|
||||
//! bremsstrahlung photons from electron deflections with charged particles
|
||||
//! (electron_treatment = ElectronTreatment::TTB).
|
||||
void sample_electron_reaction(Particle& p);
|
||||
|
||||
//! Terminates the particle and either deposits all energy locally
|
||||
//! (electron_treatment = ElectronTreatment::LED) or creates secondary bremsstrahlung
|
||||
//! photons from electron deflections with charged particles (electron_treatment
|
||||
//! = ElectronTreatment::TTB). Two annihilation photons of energy MASS_ELECTRON_EV (0.511
|
||||
//! MeV) are created and travel in opposite directions.
|
||||
//! (electron_treatment = ElectronTreatment::LED) or creates secondary
|
||||
//! bremsstrahlung photons from electron deflections with charged particles
|
||||
//! (electron_treatment = ElectronTreatment::TTB). Two annihilation photons of
|
||||
//! energy MASS_ELECTRON_EV (0.511 MeV) are created and travel in opposite
|
||||
//! directions.
|
||||
void sample_positron_reaction(Particle& p);
|
||||
|
||||
//! Sample a nuclide based on their total cross sections and densities within
|
||||
|
|
@ -53,15 +54,15 @@ int sample_element(Particle& p);
|
|||
|
||||
Reaction& sample_fission(int i_nuclide, Particle& p);
|
||||
|
||||
void sample_photon_product(int i_nuclide, Particle& p, int* i_rx, int* i_product);
|
||||
void sample_photon_product(
|
||||
int i_nuclide, Particle& p, int* i_rx, int* i_product);
|
||||
|
||||
void absorption(Particle& p, int i_nuclide);
|
||||
|
||||
void scatter(Particle& p, int i_nuclide);
|
||||
|
||||
//! Treats the elastic scattering of a neutron with a target.
|
||||
void elastic_scatter(int i_nuclide, const Reaction& rx, double kT,
|
||||
Particle& p);
|
||||
void elastic_scatter(int i_nuclide, const Reaction& rx, double kT, Particle& p);
|
||||
|
||||
void sab_scatter(int i_nuclide, int i_sab, Particle& p);
|
||||
|
||||
|
|
@ -76,8 +77,8 @@ Direction sample_target_velocity(const Nuclide& nuc, double E, Direction u,
|
|||
//! by most Monte Carlo codes, in which cross section is assumed to be constant
|
||||
//! in energy. Excellent documentation for this method can be found in
|
||||
//! FRA-TM-123.
|
||||
Direction sample_cxs_target_velocity(double awr, double E, Direction u, double kT,
|
||||
uint64_t* seed);
|
||||
Direction sample_cxs_target_velocity(
|
||||
double awr, double E, Direction u, double kT, uint64_t* seed);
|
||||
|
||||
void sample_fission_neutron(int i_nuclide, const Reaction& rx, double E_in,
|
||||
SourceSite* site, uint64_t* seed);
|
||||
|
|
|
|||
|
|
@ -12,32 +12,27 @@ namespace openmc {
|
|||
|
||||
//! \brief samples particle behavior after a collision event.
|
||||
//! \param p Particle to operate on
|
||||
void
|
||||
collision_mg(Particle& p);
|
||||
void collision_mg(Particle& p);
|
||||
|
||||
//! \brief samples a reaction type.
|
||||
//!
|
||||
//! Note that there is special logic when suvival biasing is turned on since
|
||||
//! fission and disappearance are treated implicitly.
|
||||
//! \param p Particle to operate on
|
||||
void
|
||||
sample_reaction(Particle& p);
|
||||
void sample_reaction(Particle& p);
|
||||
|
||||
//! \brief Samples the scattering event
|
||||
//! \param p Particle to operate on
|
||||
void
|
||||
scatter(Particle& p);
|
||||
void scatter(Particle& p);
|
||||
|
||||
//! \brief Determines the average total, prompt and delayed neutrons produced
|
||||
//! from fission and creates the appropriate bank sites.
|
||||
//! \param p Particle to operate on
|
||||
void
|
||||
create_fission_sites(Particle& p);
|
||||
void create_fission_sites(Particle& p);
|
||||
|
||||
//! \brief Handles an absorption event
|
||||
//! \param p Particle to operate on
|
||||
void
|
||||
absorption(Particle& p);
|
||||
void absorption(Particle& p);
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_PHYSICS_MG_H
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
#ifndef OPENMC_PLOT_H
|
||||
#define OPENMC_PLOT_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xarray.hpp"
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/geometry.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -30,8 +30,9 @@ namespace model {
|
|||
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
|
||||
extern vector<Plot> plots; //!< Plot instance container
|
||||
|
||||
extern uint64_t plotter_prn_seeds[N_STREAMS]; // Random number seeds used for plotter
|
||||
extern int plotter_stream; // Stream index used by the plotter
|
||||
extern uint64_t
|
||||
plotter_prn_seeds[N_STREAMS]; // Random number seeds used for plotter
|
||||
extern int plotter_stream; // Stream index used by the plotter
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -40,10 +41,10 @@ extern int plotter_stream; // Stream index used by the plotter
|
|||
//===============================================================================
|
||||
|
||||
struct RGBColor {
|
||||
//Constructors
|
||||
RGBColor() : red(0), green(0), blue(0) { };
|
||||
RGBColor(const int v[3]) : red(v[0]), green(v[1]), blue(v[2]) { };
|
||||
RGBColor(int r, int g, int b) : red(r), green(g), blue(b) { };
|
||||
// Constructors
|
||||
RGBColor() : red(0), green(0), blue(0) {};
|
||||
RGBColor(const int v[3]) : red(v[0]), green(v[1]), blue(v[2]) {};
|
||||
RGBColor(int r, int g, int b) : red(r), green(g), blue(b) {};
|
||||
|
||||
RGBColor(const vector<int>& v)
|
||||
{
|
||||
|
|
@ -55,7 +56,8 @@ struct RGBColor {
|
|||
blue = v[2];
|
||||
}
|
||||
|
||||
bool operator ==(const RGBColor& other) {
|
||||
bool operator==(const RGBColor& other)
|
||||
{
|
||||
return red == other.red && green == other.green && blue == other.blue;
|
||||
}
|
||||
|
||||
|
|
@ -65,8 +67,7 @@ struct RGBColor {
|
|||
|
||||
// some default colors
|
||||
const RGBColor WHITE {255, 255, 255};
|
||||
const RGBColor RED {255, 0, 0};
|
||||
|
||||
const RGBColor RED {255, 0, 0};
|
||||
|
||||
typedef xt::xtensor<RGBColor, 2> ImageData;
|
||||
|
||||
|
|
@ -94,48 +95,40 @@ struct PropertyData {
|
|||
xt::xtensor<double, 3> data_; //!< 2D array of temperature & density data
|
||||
};
|
||||
|
||||
enum class PlotType {
|
||||
slice = 1,
|
||||
voxel = 2
|
||||
};
|
||||
enum class PlotType { slice = 1, voxel = 2 };
|
||||
|
||||
enum class PlotBasis {
|
||||
xy = 1,
|
||||
xz = 2,
|
||||
yz = 3
|
||||
};
|
||||
enum class PlotBasis { xy = 1, xz = 2, yz = 3 };
|
||||
|
||||
enum class PlotColorBy {
|
||||
cells = 0,
|
||||
mats = 1
|
||||
};
|
||||
enum class PlotColorBy { cells = 0, mats = 1 };
|
||||
|
||||
//===============================================================================
|
||||
// Plot class
|
||||
//===============================================================================
|
||||
class PlotBase {
|
||||
public:
|
||||
template<class T> T get_map() const;
|
||||
template<class T>
|
||||
T get_map() const;
|
||||
|
||||
// Members
|
||||
public:
|
||||
Position origin_; //!< Plot origin in geometry
|
||||
Position width_; //!< Plot width in geometry
|
||||
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
|
||||
Position origin_; //!< Plot origin in geometry
|
||||
Position width_; //!< Plot width in geometry
|
||||
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
|
||||
array<size_t, 3> pixels_; //!< Plot size in pixels
|
||||
bool color_overlaps_; //!< Show overlapping cells?
|
||||
int level_; //!< Plot universe level
|
||||
bool color_overlaps_; //!< Show overlapping cells?
|
||||
int level_; //!< Plot universe level
|
||||
};
|
||||
|
||||
template<class T>
|
||||
T PlotBase::get_map() const {
|
||||
T PlotBase::get_map() const
|
||||
{
|
||||
|
||||
size_t width = pixels_[0];
|
||||
size_t height = pixels_[1];
|
||||
|
||||
// get pixel size
|
||||
double in_pixel = (width_[0])/static_cast<double>(width);
|
||||
double out_pixel = (width_[1])/static_cast<double>(height);
|
||||
double in_pixel = (width_[0]) / static_cast<double>(width);
|
||||
double out_pixel = (width_[1]) / static_cast<double>(height);
|
||||
|
||||
// size data array
|
||||
T data(width, height);
|
||||
|
|
@ -143,16 +136,16 @@ T PlotBase::get_map() const {
|
|||
// setup basis indices and initial position centered on pixel
|
||||
int in_i, out_i;
|
||||
Position xyz = origin_;
|
||||
switch(basis_) {
|
||||
case PlotBasis::xy :
|
||||
switch (basis_) {
|
||||
case PlotBasis::xy:
|
||||
in_i = 0;
|
||||
out_i = 1;
|
||||
break;
|
||||
case PlotBasis::xz :
|
||||
case PlotBasis::xz:
|
||||
in_i = 0;
|
||||
out_i = 2;
|
||||
break;
|
||||
case PlotBasis::yz :
|
||||
case PlotBasis::yz:
|
||||
in_i = 1;
|
||||
out_i = 2;
|
||||
break;
|
||||
|
|
@ -167,25 +160,27 @@ T PlotBase::get_map() const {
|
|||
// arbitrary direction
|
||||
Direction dir = {0.7071, 0.7071, 0.0};
|
||||
|
||||
#pragma omp parallel
|
||||
#pragma omp parallel
|
||||
{
|
||||
Particle p;
|
||||
p.r() = xyz;
|
||||
p.u() = dir;
|
||||
p.coord(0).universe = model::root_universe;
|
||||
int level = level_;
|
||||
int j{};
|
||||
int j {};
|
||||
|
||||
#pragma omp for
|
||||
#pragma omp for
|
||||
for (int y = 0; y < height; y++) {
|
||||
p.r()[out_i] = xyz[out_i] - out_pixel * y;
|
||||
p.r()[out_i] = xyz[out_i] - out_pixel * y;
|
||||
for (int x = 0; x < width; x++) {
|
||||
p.r()[in_i] = xyz[in_i] + in_pixel * x;
|
||||
p.n_coord() = 1;
|
||||
// local variables
|
||||
bool found_cell = exhaustive_find_cell(p);
|
||||
j = p.n_coord() - 1;
|
||||
if (level >= 0) { j = level; }
|
||||
if (level >= 0) {
|
||||
j = level;
|
||||
}
|
||||
if (found_cell) {
|
||||
data.set_value(y, x, p, j);
|
||||
}
|
||||
|
|
@ -193,8 +188,8 @@ T PlotBase::get_map() const {
|
|||
data.set_overlap(y, x);
|
||||
}
|
||||
} // inner for
|
||||
} // outer for
|
||||
} // omp parallel
|
||||
} // outer for
|
||||
} // omp parallel
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -221,18 +216,18 @@ private:
|
|||
void set_mask(pugi::xml_node plot_node);
|
||||
void set_overlap_color(pugi::xml_node plot_node);
|
||||
|
||||
// Members
|
||||
// Members
|
||||
public:
|
||||
int id_; //!< Plot ID
|
||||
PlotType type_; //!< Plot type (Slice/Voxel)
|
||||
PlotColorBy color_by_; //!< Plot coloring (cell/material)
|
||||
int meshlines_width_; //!< Width of lines added to the plot
|
||||
int id_; //!< Plot ID
|
||||
PlotType type_; //!< Plot type (Slice/Voxel)
|
||||
PlotColorBy color_by_; //!< Plot coloring (cell/material)
|
||||
int meshlines_width_; //!< Width of lines added to the plot
|
||||
int index_meshlines_mesh_ {-1}; //!< Index of the mesh to draw on the plot
|
||||
RGBColor meshlines_color_; //!< Color of meshlines on the plot
|
||||
RGBColor not_found_ {WHITE}; //!< Plot background color
|
||||
RGBColor overlap_color_ {RED}; //!< Plot overlap color
|
||||
vector<RGBColor> colors_; //!< Plot colors
|
||||
std::string path_plot_; //!< Plot output filename
|
||||
RGBColor meshlines_color_; //!< Color of meshlines on the plot
|
||||
RGBColor not_found_ {WHITE}; //!< Plot background color
|
||||
RGBColor overlap_color_ {RED}; //!< Plot overlap color
|
||||
vector<RGBColor> colors_; //!< Plot colors
|
||||
std::string path_plot_; //!< Plot output filename
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
|
@ -255,16 +250,16 @@ void output_ppm(Plot const& pl, const ImageData& data);
|
|||
//! \param[out] dataspace pointer to voxel data
|
||||
//! \param[out] dataset pointer to voxesl data
|
||||
//! \param[out] pointer to memory space of voxel data
|
||||
void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace,
|
||||
hid_t* dset, hid_t* memspace);
|
||||
void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace, hid_t* dset,
|
||||
hid_t* memspace);
|
||||
|
||||
//! Write a section of the voxel data to hdf5
|
||||
//! \param[in] voxel slice
|
||||
//! \param[out] dataspace pointer to voxel data
|
||||
//! \param[out] dataset pointer to voxesl data
|
||||
//! \param[out] pointer to data to write
|
||||
void voxel_write_slice(int x, hid_t dspace, hid_t dset,
|
||||
hid_t memspace, void* buf);
|
||||
void voxel_write_slice(
|
||||
int x, hid_t dspace, hid_t dset, hid_t memspace, void* buf);
|
||||
|
||||
//! Close voxel file entities
|
||||
//! \param[in] data space to close
|
||||
|
|
@ -291,6 +286,5 @@ void create_voxel(Plot const& pl);
|
|||
//! \return RGBColor with random value
|
||||
RGBColor random_color();
|
||||
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_PLOT_H
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ namespace openmc {
|
|||
struct Position {
|
||||
// Constructors
|
||||
Position() = default;
|
||||
Position(double x_, double y_, double z_) : x{x_}, y{y_}, z{z_} { };
|
||||
Position(const double xyz[]) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
|
||||
Position(double x_, double y_, double z_) : x {x_}, y {y_}, z {z_} {};
|
||||
Position(const double xyz[]) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
|
||||
Position(const vector<double>& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
|
||||
Position(const array<double, 3>& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
|
||||
|
||||
|
|
@ -33,22 +33,30 @@ struct Position {
|
|||
Position& operator/=(double);
|
||||
Position operator-() const;
|
||||
|
||||
const double& operator[](int i) const {
|
||||
const double& operator[](int i) const
|
||||
{
|
||||
switch (i) {
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
case 2: return z;
|
||||
default:
|
||||
throw std::out_of_range{"Index in Position must be between 0 and 2."};
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
default:
|
||||
throw std::out_of_range {"Index in Position must be between 0 and 2."};
|
||||
}
|
||||
}
|
||||
double& operator[](int i) {
|
||||
double& operator[](int i)
|
||||
{
|
||||
switch (i) {
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
case 2: return z;
|
||||
default:
|
||||
throw std::out_of_range{"Index in Position must be between 0 and 2."};
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
default:
|
||||
throw std::out_of_range {"Index in Position must be between 0 and 2."};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,12 +77,11 @@ struct Position {
|
|||
//! Dot product of two vectors
|
||||
//! \param[in] other Vector to take dot product with
|
||||
//! \result Resulting dot product
|
||||
inline double dot(Position other) const {
|
||||
return x*other.x + y*other.y + z*other.z;
|
||||
}
|
||||
inline double norm() const {
|
||||
return std::sqrt(x*x + y*y + z*z);
|
||||
inline double dot(Position other) const
|
||||
{
|
||||
return x * other.x + y * other.y + z * other.z;
|
||||
}
|
||||
inline double norm() const { return std::sqrt(x * x + y * y + z * z); }
|
||||
|
||||
//! Reflect a direction across a normal vector
|
||||
//! \param[in] other Vector to reflect across
|
||||
|
|
@ -123,23 +130,60 @@ inline double& Position::get<2>()
|
|||
}
|
||||
|
||||
// Binary operators
|
||||
inline Position operator+(Position a, Position b) { return a += b; }
|
||||
inline Position operator+(Position a, double b) { return a += b; }
|
||||
inline Position operator+(double a, Position b) { return b += a; }
|
||||
inline Position operator+(Position a, Position b)
|
||||
{
|
||||
return a += b;
|
||||
}
|
||||
inline Position operator+(Position a, double b)
|
||||
{
|
||||
return a += b;
|
||||
}
|
||||
inline Position operator+(double a, Position b)
|
||||
{
|
||||
return b += a;
|
||||
}
|
||||
|
||||
inline Position operator-(Position a, Position b) { return a -= b; }
|
||||
inline Position operator-(Position a, double b) { return a -= b; }
|
||||
inline Position operator-(double a, Position b) { return b -= a; }
|
||||
inline Position operator-(Position a, Position b)
|
||||
{
|
||||
return a -= b;
|
||||
}
|
||||
inline Position operator-(Position a, double b)
|
||||
{
|
||||
return a -= b;
|
||||
}
|
||||
inline Position operator-(double a, Position b)
|
||||
{
|
||||
return b -= a;
|
||||
}
|
||||
|
||||
inline Position operator*(Position a, Position b) { return a *= b; }
|
||||
inline Position operator*(Position a, double b) { return a *= b; }
|
||||
inline Position operator*(double a, Position b) { return b *= a; }
|
||||
inline Position operator*(Position a, Position b)
|
||||
{
|
||||
return a *= b;
|
||||
}
|
||||
inline Position operator*(Position a, double b)
|
||||
{
|
||||
return a *= b;
|
||||
}
|
||||
inline Position operator*(double a, Position b)
|
||||
{
|
||||
return b *= a;
|
||||
}
|
||||
|
||||
inline Position operator/(Position a, Position b) { return a /= b; }
|
||||
inline Position operator/(Position a, double b) { return a /= b; }
|
||||
inline Position operator/(double a, Position b) { return b /= a; }
|
||||
inline Position operator/(Position a, Position b)
|
||||
{
|
||||
return a /= b;
|
||||
}
|
||||
inline Position operator/(Position a, double b)
|
||||
{
|
||||
return a /= b;
|
||||
}
|
||||
inline Position operator/(double a, Position b)
|
||||
{
|
||||
return b /= a;
|
||||
}
|
||||
|
||||
inline Position Position::reflect(Position n) const {
|
||||
inline Position Position::reflect(Position n) const
|
||||
{
|
||||
const double projection = n.dot(*this);
|
||||
const double magnitude = n.dot(n);
|
||||
n *= (2.0 * projection / magnitude);
|
||||
|
|
@ -147,10 +191,14 @@ inline Position Position::reflect(Position n) const {
|
|||
}
|
||||
|
||||
inline bool operator==(Position a, Position b)
|
||||
{return a.x == b.x && a.y == b.y && a.z == b.z;}
|
||||
{
|
||||
return a.x == b.x && a.y == b.y && a.z == b.z;
|
||||
}
|
||||
|
||||
inline bool operator!=(Position a, Position b)
|
||||
{return a.x != b.x || a.y != b.y || a.z != b.z;}
|
||||
{
|
||||
return a.x != b.x || a.y != b.y || a.z != b.z;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, Position a);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@
|
|||
|
||||
class ProgressBar {
|
||||
|
||||
public:
|
||||
public:
|
||||
// Constructor
|
||||
ProgressBar();
|
||||
|
||||
void set_value(double val);
|
||||
|
||||
|
||||
private:
|
||||
std::string bar;
|
||||
char bar_old[72] = "???% | |";
|
||||
|
||||
char bar_old[72] =
|
||||
"???% | |";
|
||||
};
|
||||
|
||||
|
||||
#endif // OPENMC_PROGRESSBAR_H
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ extern "C" double normal_variate(double mean, double std_dev, uint64_t* seed);
|
|||
//! \result The sampled outgoing energy
|
||||
//==============================================================================
|
||||
|
||||
extern "C" double muir_spectrum(double e0, double m_rat, double kt, uint64_t* seed);
|
||||
extern "C" double muir_spectrum(
|
||||
double e0, double m_rat, double kt, uint64_t* seed);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,18 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Module constants.
|
||||
//==============================================================================
|
||||
|
||||
constexpr int N_STREAMS {4};
|
||||
constexpr int STREAM_TRACKING {0};
|
||||
constexpr int STREAM_SOURCE {1};
|
||||
constexpr int N_STREAMS {4};
|
||||
constexpr int STREAM_TRACKING {0};
|
||||
constexpr int STREAM_SOURCE {1};
|
||||
constexpr int STREAM_URR_PTABLE {2};
|
||||
constexpr int STREAM_VOLUME {3};
|
||||
constexpr int64_t DEFAULT_SEED {1};
|
||||
constexpr int STREAM_VOLUME {3};
|
||||
constexpr int64_t DEFAULT_SEED {1};
|
||||
|
||||
//==============================================================================
|
||||
//! Generate a pseudo-random number using a linear congruential generator.
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include "hdf5.h"
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/reaction_product.h"
|
||||
#include "openmc/vector.h"
|
||||
|
|
@ -43,10 +43,10 @@ public:
|
|||
vector<double> value;
|
||||
};
|
||||
|
||||
int mt_; //!< ENDF MT value
|
||||
double q_value_; //!< Reaction Q value in [eV]
|
||||
bool scatter_in_cm_; //!< scattering system in center-of-mass?
|
||||
bool redundant_; //!< redundant reaction?
|
||||
int mt_; //!< ENDF MT value
|
||||
double q_value_; //!< Reaction Q value in [eV]
|
||||
bool scatter_in_cm_; //!< scattering system in center-of-mass?
|
||||
bool redundant_; //!< redundant reaction?
|
||||
vector<TemperatureXS> xs_; //!< Cross section at each temperature
|
||||
vector<ReactionProduct> products_; //!< Reaction products
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,6 +52,6 @@ public:
|
|||
vector<Secondary> distribution_; //!< Secondary angle-energy distribution
|
||||
};
|
||||
|
||||
} // namespace opemc
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_REACTION_PRODUCT_H
|
||||
|
|
|
|||
|
|
@ -21,151 +21,138 @@ class ScattDataTabular;
|
|||
//==============================================================================
|
||||
|
||||
class ScattData {
|
||||
public:
|
||||
virtual ~ScattData() = default;
|
||||
protected:
|
||||
//! \brief Initializes the attributes of the base class.
|
||||
void
|
||||
base_init(int order, const xt::xtensor<int, 1>& in_gmin,
|
||||
const xt::xtensor<int, 1>& in_gmax, const double_2dvec& in_energy,
|
||||
const double_2dvec& in_mult);
|
||||
public:
|
||||
virtual ~ScattData() = default;
|
||||
|
||||
//! \brief Combines microscopic ScattDatas into a macroscopic one.
|
||||
void base_combine(size_t max_order, size_t order_dim,
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars,
|
||||
xt::xtensor<int, 1>& in_gmin, xt::xtensor<int, 1>& in_gmax,
|
||||
double_2dvec& sparse_mult, double_3dvec& sparse_scatter);
|
||||
protected:
|
||||
//! \brief Initializes the attributes of the base class.
|
||||
void base_init(int order, const xt::xtensor<int, 1>& in_gmin,
|
||||
const xt::xtensor<int, 1>& in_gmax, const double_2dvec& in_energy,
|
||||
const double_2dvec& in_mult);
|
||||
|
||||
public:
|
||||
//! \brief Combines microscopic ScattDatas into a macroscopic one.
|
||||
void base_combine(size_t max_order, size_t order_dim,
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars,
|
||||
xt::xtensor<int, 1>& in_gmin, xt::xtensor<int, 1>& in_gmax,
|
||||
double_2dvec& sparse_mult, double_3dvec& sparse_scatter);
|
||||
|
||||
double_2dvec energy; // Normalized p0 matrix for sampling Eout
|
||||
double_2dvec mult; // nu-scatter multiplication (nu-scatt/scatt)
|
||||
double_3dvec dist; // Angular distribution
|
||||
xt::xtensor<int, 1> gmin; // minimum outgoing group
|
||||
xt::xtensor<int, 1> gmax; // maximum outgoing group
|
||||
xt::xtensor<double, 1> scattxs; // Isotropic Sigma_{s,g_{in}}
|
||||
public:
|
||||
double_2dvec energy; // Normalized p0 matrix for sampling Eout
|
||||
double_2dvec mult; // nu-scatter multiplication (nu-scatt/scatt)
|
||||
double_3dvec dist; // Angular distribution
|
||||
xt::xtensor<int, 1> gmin; // minimum outgoing group
|
||||
xt::xtensor<int, 1> gmax; // maximum outgoing group
|
||||
xt::xtensor<double, 1> scattxs; // Isotropic Sigma_{s,g_{in}}
|
||||
|
||||
//! \brief Calculates the value of normalized f(mu).
|
||||
//!
|
||||
//! The value of f(mu) is normalized as in the integral of f(mu)dmu across
|
||||
//! [-1,1] is 1.
|
||||
//!
|
||||
//! @param gin Incoming energy group of interest.
|
||||
//! @param gout Outgoing energy group of interest.
|
||||
//! @param mu Cosine of the change-in-angle of interest.
|
||||
//! @return The value of f(mu).
|
||||
virtual double
|
||||
calc_f(int gin, int gout, double mu) = 0;
|
||||
//! \brief Calculates the value of normalized f(mu).
|
||||
//!
|
||||
//! The value of f(mu) is normalized as in the integral of f(mu)dmu across
|
||||
//! [-1,1] is 1.
|
||||
//!
|
||||
//! @param gin Incoming energy group of interest.
|
||||
//! @param gout Outgoing energy group of interest.
|
||||
//! @param mu Cosine of the change-in-angle of interest.
|
||||
//! @return The value of f(mu).
|
||||
virtual double calc_f(int gin, int gout, double mu) = 0;
|
||||
|
||||
//! \brief Samples the outgoing energy and angle from the ScattData info.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param mu Sampled cosine of the change-in-angle.
|
||||
//! @param wgt Weight of the particle to be adjusted.
|
||||
//! @param seed Pseudorandom number seed pointer
|
||||
virtual void
|
||||
sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed) = 0;
|
||||
//! \brief Samples the outgoing energy and angle from the ScattData info.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param mu Sampled cosine of the change-in-angle.
|
||||
//! @param wgt Weight of the particle to be adjusted.
|
||||
//! @param seed Pseudorandom number seed pointer
|
||||
virtual void sample(
|
||||
int gin, int& gout, double& mu, double& wgt, uint64_t* seed) = 0;
|
||||
|
||||
//! \brief Initializes the ScattData object from a given scatter and
|
||||
//! multiplicity matrix.
|
||||
//!
|
||||
//! @param in_gmin List of minimum outgoing groups for every incoming group
|
||||
//! @param in_gmax List of maximum outgoing groups for every incoming group
|
||||
//! @param in_mult Input sparse multiplicity matrix
|
||||
//! @param coeffs Input sparse scattering matrix
|
||||
virtual void
|
||||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs) = 0;
|
||||
//! \brief Initializes the ScattData object from a given scatter and
|
||||
//! multiplicity matrix.
|
||||
//!
|
||||
//! @param in_gmin List of minimum outgoing groups for every incoming group
|
||||
//! @param in_gmax List of maximum outgoing groups for every incoming group
|
||||
//! @param in_mult Input sparse multiplicity matrix
|
||||
//! @param coeffs Input sparse scattering matrix
|
||||
virtual void init(const xt::xtensor<int, 1>& in_gmin,
|
||||
const xt::xtensor<int, 1>& in_gmax, const double_2dvec& in_mult,
|
||||
const double_3dvec& coeffs) = 0;
|
||||
|
||||
//! \brief Combines the microscopic data.
|
||||
//!
|
||||
//! @param those_scatts Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
virtual void combine(const vector<ScattData*>& those_scatts,
|
||||
const vector<double>& scalars) = 0;
|
||||
//! \brief Combines the microscopic data.
|
||||
//!
|
||||
//! @param those_scatts Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
virtual void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars) = 0;
|
||||
|
||||
//! \brief Getter for the dimensionality of the scattering order.
|
||||
//!
|
||||
//! If Legendre this is the "n" in "Pn"; for Tabular, this is the number
|
||||
//! of points, and for Histogram this is the number of bins.
|
||||
//!
|
||||
//! @return The order.
|
||||
virtual size_t
|
||||
get_order() = 0;
|
||||
//! \brief Getter for the dimensionality of the scattering order.
|
||||
//!
|
||||
//! If Legendre this is the "n" in "Pn"; for Tabular, this is the number
|
||||
//! of points, and for Histogram this is the number of bins.
|
||||
//!
|
||||
//! @return The order.
|
||||
virtual size_t get_order() = 0;
|
||||
|
||||
//! \brief Builds a dense scattering matrix from the constituent parts
|
||||
//!
|
||||
//! @param max_order If Legendre this is the maximum value of "n" in "Pn"
|
||||
//! requested; ignored otherwise.
|
||||
//! @return The dense scattering matrix.
|
||||
virtual xt::xtensor<double, 3>
|
||||
get_matrix(size_t max_order) = 0;
|
||||
//! \brief Builds a dense scattering matrix from the constituent parts
|
||||
//!
|
||||
//! @param max_order If Legendre this is the maximum value of "n" in "Pn"
|
||||
//! requested; ignored otherwise.
|
||||
//! @return The dense scattering matrix.
|
||||
virtual xt::xtensor<double, 3> get_matrix(size_t max_order) = 0;
|
||||
|
||||
//! \brief Samples the outgoing energy from the ScattData info.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param i_gout Sampled outgoing energy group index.
|
||||
//! @param seed Pseudorandom number seed pointer
|
||||
void
|
||||
sample_energy(int gin, int& gout, int& i_gout, uint64_t* seed);
|
||||
//! \brief Samples the outgoing energy from the ScattData info.
|
||||
//!
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Sampled outgoing energy group.
|
||||
//! @param i_gout Sampled outgoing energy group index.
|
||||
//! @param seed Pseudorandom number seed pointer
|
||||
void sample_energy(int gin, int& gout, int& i_gout, uint64_t* seed);
|
||||
|
||||
//! \brief Provides a cross section value given certain parameters
|
||||
//!
|
||||
//! @param xstype Type of cross section requested, according to the
|
||||
//! enumerated constants.
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Outgoing energy group; use nullptr if irrelevant, or if a
|
||||
//! sum is requested.
|
||||
//! @param mu Cosine of the change-in-angle, for scattering quantities;
|
||||
//! use nullptr if irrelevant.
|
||||
//! @return Requested cross section value.
|
||||
double
|
||||
get_xs(MgxsType xstype, int gin, const int* gout, const double* mu);
|
||||
//! \brief Provides a cross section value given certain parameters
|
||||
//!
|
||||
//! @param xstype Type of cross section requested, according to the
|
||||
//! enumerated constants.
|
||||
//! @param gin Incoming energy group.
|
||||
//! @param gout Outgoing energy group; use nullptr if irrelevant, or if a
|
||||
//! sum is requested.
|
||||
//! @param mu Cosine of the change-in-angle, for scattering quantities;
|
||||
//! use nullptr if irrelevant.
|
||||
//! @return Requested cross section value.
|
||||
double get_xs(MgxsType xstype, int gin, const int* gout, const double* mu);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// ScattDataLegendre represents the angular distributions as Legendre kernels
|
||||
//==============================================================================
|
||||
|
||||
class ScattDataLegendre: public ScattData {
|
||||
class ScattDataLegendre : public ScattData {
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// Maximal value for rejection sampling from a rectangle
|
||||
double_2dvec max_val;
|
||||
|
||||
// Maximal value for rejection sampling from a rectangle
|
||||
double_2dvec max_val;
|
||||
// Friend convert_legendre_to_tabular so it has access to protected
|
||||
// parameters
|
||||
friend void convert_legendre_to_tabular(
|
||||
ScattDataLegendre& leg, ScattDataTabular& tab);
|
||||
|
||||
// Friend convert_legendre_to_tabular so it has access to protected
|
||||
// parameters
|
||||
friend void
|
||||
convert_legendre_to_tabular(ScattDataLegendre& leg, ScattDataTabular& tab);
|
||||
public:
|
||||
void init(const xt::xtensor<int, 1>& in_gmin,
|
||||
const xt::xtensor<int, 1>& in_gmax, const double_2dvec& in_mult,
|
||||
const double_3dvec& coeffs);
|
||||
|
||||
public:
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
|
||||
void
|
||||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs);
|
||||
//! \brief Find the maximal value of the angular distribution to use as a
|
||||
// bounding box with rejection sampling.
|
||||
void update_max_val();
|
||||
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
double calc_f(int gin, int gout, double mu);
|
||||
|
||||
//! \brief Find the maximal value of the angular distribution to use as a
|
||||
// bounding box with rejection sampling.
|
||||
void
|
||||
update_max_val();
|
||||
void sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
double
|
||||
calc_f(int gin, int gout, double mu);
|
||||
size_t get_order() { return dist[0][0].size() - 1; };
|
||||
|
||||
void
|
||||
sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
size_t
|
||||
get_order() {return dist[0][0].size() - 1;};
|
||||
|
||||
xt::xtensor<double, 3>
|
||||
get_matrix(size_t max_order);
|
||||
xt::xtensor<double, 3> get_matrix(size_t max_order);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -173,34 +160,28 @@ class ScattDataLegendre: public ScattData {
|
|||
// would be if it came from a "mu" tally in OpenMC
|
||||
//==============================================================================
|
||||
|
||||
class ScattDataHistogram: public ScattData {
|
||||
class ScattDataHistogram : public ScattData {
|
||||
|
||||
protected:
|
||||
protected:
|
||||
xt::xtensor<double, 1> mu; // Angle distribution mu bin boundaries
|
||||
double dmu; // Quick storage of the mu spacing
|
||||
double_3dvec fmu; // The angular distribution histogram
|
||||
|
||||
xt::xtensor<double, 1> mu; // Angle distribution mu bin boundaries
|
||||
double dmu; // Quick storage of the mu spacing
|
||||
double_3dvec fmu; // The angular distribution histogram
|
||||
public:
|
||||
void init(const xt::xtensor<int, 1>& in_gmin,
|
||||
const xt::xtensor<int, 1>& in_gmax, const double_2dvec& in_mult,
|
||||
const double_3dvec& coeffs);
|
||||
|
||||
public:
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
|
||||
void
|
||||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs);
|
||||
double calc_f(int gin, int gout, double mu);
|
||||
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
void sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
double
|
||||
calc_f(int gin, int gout, double mu);
|
||||
size_t get_order() { return dist[0][0].size(); };
|
||||
|
||||
void
|
||||
sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
size_t
|
||||
get_order() {return dist[0][0].size();};
|
||||
|
||||
xt::xtensor<double, 3>
|
||||
get_matrix(size_t max_order);
|
||||
xt::xtensor<double, 3> get_matrix(size_t max_order);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -208,39 +189,33 @@ class ScattDataHistogram: public ScattData {
|
|||
// f(mu)
|
||||
//==============================================================================
|
||||
|
||||
class ScattDataTabular: public ScattData {
|
||||
class ScattDataTabular : public ScattData {
|
||||
|
||||
protected:
|
||||
protected:
|
||||
xt::xtensor<double, 1> mu; // Angle distribution mu grid points
|
||||
double dmu; // Quick storage of the mu spacing
|
||||
double_3dvec fmu; // The angular distribution function
|
||||
|
||||
xt::xtensor<double, 1> mu; // Angle distribution mu grid points
|
||||
double dmu; // Quick storage of the mu spacing
|
||||
double_3dvec fmu; // The angular distribution function
|
||||
// Friend convert_legendre_to_tabular so it has access to protected
|
||||
// parameters
|
||||
friend void convert_legendre_to_tabular(
|
||||
ScattDataLegendre& leg, ScattDataTabular& tab);
|
||||
|
||||
// Friend convert_legendre_to_tabular so it has access to protected
|
||||
// parameters
|
||||
friend void
|
||||
convert_legendre_to_tabular(ScattDataLegendre& leg, ScattDataTabular& tab);
|
||||
public:
|
||||
void init(const xt::xtensor<int, 1>& in_gmin,
|
||||
const xt::xtensor<int, 1>& in_gmax, const double_2dvec& in_mult,
|
||||
const double_3dvec& coeffs);
|
||||
|
||||
public:
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
|
||||
void
|
||||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs);
|
||||
double calc_f(int gin, int gout, double mu);
|
||||
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
void sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
double
|
||||
calc_f(int gin, int gout, double mu);
|
||||
size_t get_order() { return dist[0][0].size(); };
|
||||
|
||||
void
|
||||
sample(int gin, int& gout, double& mu, double& wgt, uint64_t* seed);
|
||||
|
||||
size_t
|
||||
get_order() {return dist[0][0].size();};
|
||||
|
||||
xt::xtensor<double, 3>
|
||||
get_matrix(size_t max_order);
|
||||
xt::xtensor<double, 3> get_matrix(size_t max_order);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -253,9 +228,8 @@ class ScattDataTabular: public ScattData {
|
|||
//! @param leg The resultant ScattDataTabular object.
|
||||
//! @param n_mu The number of mu points to use when building the
|
||||
//! ScattDataTabular object.
|
||||
void
|
||||
convert_legendre_to_tabular(ScattDataLegendre& leg, ScattDataTabular& tab,
|
||||
int n_mu);
|
||||
void convert_legendre_to_tabular(
|
||||
ScattDataLegendre& leg, ScattDataTabular& tab, int n_mu);
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_SCATTDATA_H
|
||||
|
|
|
|||
|
|
@ -11,17 +11,18 @@ namespace openmc {
|
|||
//! Perform binary search
|
||||
|
||||
template<class It, class T>
|
||||
typename std::iterator_traits<It>::difference_type
|
||||
lower_bound_index(It first, It last, const T& value)
|
||||
typename std::iterator_traits<It>::difference_type lower_bound_index(
|
||||
It first, It last, const T& value)
|
||||
{
|
||||
if (*first == value) return 0;
|
||||
if (*first == value)
|
||||
return 0;
|
||||
It index = std::lower_bound(first, last, value) - 1;
|
||||
return (index == last) ? -1 : index - first;
|
||||
}
|
||||
|
||||
template<class It, class T>
|
||||
typename std::iterator_traits<It>::difference_type
|
||||
upper_bound_index(It first, It last, const T& value)
|
||||
typename std::iterator_traits<It>::difference_type upper_bound_index(
|
||||
It first, It last, const T& value)
|
||||
{
|
||||
It index = std::upper_bound(first, last, value) - 1;
|
||||
return (index == last) ? -1 : index - first;
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ class CorrelatedAngleEnergy : public AngleEnergy {
|
|||
public:
|
||||
//! Outgoing energy/angle at a single incoming energy
|
||||
struct CorrTable {
|
||||
int n_discrete; //!< Number of discrete lines
|
||||
Interpolation interpolation; //!< Interpolation law
|
||||
xt::xtensor<double, 1> e_out; //!< Outgoing energies [eV]
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
int n_discrete; //!< Number of discrete lines
|
||||
Interpolation interpolation; //!< Interpolation law
|
||||
xt::xtensor<double, 1> e_out; //!< Outgoing energies [eV]
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
vector<unique_ptr<Tabular>> angle; //!< Angle distribution
|
||||
};
|
||||
|
||||
|
|
@ -38,8 +38,8 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
// energy property
|
||||
vector<double>& energy() { return energy_; }
|
||||
|
|
@ -50,7 +50,7 @@ public:
|
|||
const vector<CorrTable>& distribution() const { return distribution_; }
|
||||
|
||||
private:
|
||||
int n_region_; //!< Number of interpolation regions
|
||||
int n_region_; //!< Number of interpolation regions
|
||||
vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
vector<double> energy_; //!< Energies [eV] at which distributions
|
||||
|
|
|
|||
|
|
@ -29,21 +29,22 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
//! Outgoing energy/angle at a single incoming energy
|
||||
struct KMTable {
|
||||
int n_discrete; //!< Number of discrete lines
|
||||
Interpolation interpolation; //!< Interpolation law
|
||||
int n_discrete; //!< Number of discrete lines
|
||||
Interpolation interpolation; //!< Interpolation law
|
||||
xt::xtensor<double, 1> e_out; //!< Outgoing energies [eV]
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
xt::xtensor<double, 1> r; //!< Pre-compound fraction
|
||||
xt::xtensor<double, 1> a; //!< Parameterized function
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
xt::xtensor<double, 1> r; //!< Pre-compound fraction
|
||||
xt::xtensor<double, 1> a; //!< Parameterized function
|
||||
};
|
||||
|
||||
int n_region_; //!< Number of interpolation regions
|
||||
int n_region_; //!< Number of interpolation regions
|
||||
vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
vector<double> energy_; //!< Energies [eV] at which distributions
|
||||
|
|
|
|||
|
|
@ -25,13 +25,14 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
int n_bodies_; //!< Number of particles distributed
|
||||
int n_bodies_; //!< Number of particles distributed
|
||||
double mass_ratio_; //!< Total mass of particles [neutron mass]
|
||||
double A_; //!< Atomic weight ratio
|
||||
double Q_; //!< Reaction Q-value [eV]
|
||||
double A_; //!< Atomic weight ratio
|
||||
double Q_; //!< Reaction Q-value [eV]
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
#include "openmc/secondary_correlated.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <hdf5.h>
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <hdf5.h>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -25,14 +25,14 @@ public:
|
|||
//! \param[in] xs Coherent elastic scattering cross section
|
||||
explicit CoherentElasticAE(const CoherentElasticXS& xs);
|
||||
|
||||
|
||||
//! Sample distribution for an angle and energy
|
||||
//! \param[in] E_in Incoming energy in [eV]
|
||||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
const CoherentElasticXS& xs_; //!< Coherent elastic scattering cross section
|
||||
};
|
||||
|
|
@ -53,8 +53,9 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
double debye_waller_;
|
||||
};
|
||||
|
|
@ -77,8 +78,9 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
const vector<double>& energy_; //!< Energies at which cosines are tabulated
|
||||
xt::xtensor<double, 2> mu_out_; //!< Cosines for each incident energy
|
||||
|
|
@ -102,12 +104,15 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
const vector<double>& energy_; //!< Incident energies
|
||||
xt::xtensor<double, 2> energy_out_; //!< Outgoing energies for each incident energy
|
||||
xt::xtensor<double, 3> mu_out_; //!< Outgoing cosines for each incident/outgoing energy
|
||||
const vector<double>& energy_; //!< Incident energies
|
||||
xt::xtensor<double, 2>
|
||||
energy_out_; //!< Outgoing energies for each incident energy
|
||||
xt::xtensor<double, 3>
|
||||
mu_out_; //!< Outgoing cosines for each incident/outgoing energy
|
||||
bool skewed_; //!< Whether outgoing energy distribution is skewed
|
||||
};
|
||||
|
||||
|
|
@ -127,12 +132,13 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom number seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
//! Secondary energy/angle distribution
|
||||
struct DistEnergySab {
|
||||
std::size_t n_e_out; //!< Number of outgoing energies
|
||||
std::size_t n_e_out; //!< Number of outgoing energies
|
||||
xt::xtensor<double, 1> e_out; //!< Outgoing energies
|
||||
xt::xtensor<double, 1> e_out_pdf; //!< Probability density function
|
||||
xt::xtensor<double, 1> e_out_cdf; //!< Cumulative distribution function
|
||||
|
|
@ -144,7 +150,6 @@ private:
|
|||
//!< each incident energy
|
||||
};
|
||||
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_SECONDARY_THERMAL_H
|
||||
|
|
|
|||
|
|
@ -29,13 +29,14 @@ public:
|
|||
//! \param[out] E_out Outgoing energy in [eV]
|
||||
//! \param[out] mu Outgoing cosine with respect to current direction
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
void sample(
|
||||
double E_in, double& E_out, double& mu, uint64_t* seed) const override;
|
||||
|
||||
// Accessors
|
||||
AngleDistribution& angle() { return angle_; }
|
||||
|
||||
private:
|
||||
AngleDistribution angle_; //!< Angle distribution
|
||||
AngleDistribution angle_; //!< Angle distribution
|
||||
unique_ptr<EnergyDistribution> energy_; //!< Energy distribution
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,89 +22,100 @@ namespace openmc {
|
|||
|
||||
namespace settings {
|
||||
|
||||
|
||||
// Boolean flags
|
||||
extern bool assume_separate; //!< assume tallies are spatially separate?
|
||||
extern bool check_overlaps; //!< check overlaps in geometry?
|
||||
extern bool confidence_intervals; //!< use confidence intervals for results?
|
||||
extern bool create_fission_neutrons; //!< create fission neutrons (fixed source)?
|
||||
extern "C" bool cmfd_run; //!< is a CMFD run?
|
||||
extern bool delayed_photon_scaling; //!< Scale fission photon yield to include delayed
|
||||
extern "C" bool entropy_on; //!< calculate Shannon entropy?
|
||||
extern bool event_based; //!< use event-based mode (instead of history-based)
|
||||
extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
|
||||
extern bool material_cell_offsets; //!< create material cells offsets?
|
||||
extern "C" bool output_summary; //!< write summary.h5?
|
||||
extern bool output_tallies; //!< write tallies.out?
|
||||
extern bool particle_restart_run; //!< particle restart run?
|
||||
extern "C" bool photon_transport; //!< photon transport turned on?
|
||||
extern "C" bool reduce_tallies; //!< reduce tallies at end of batch?
|
||||
extern bool res_scat_on; //!< use resonance upscattering method?
|
||||
extern "C" bool restart_run; //!< restart run?
|
||||
extern "C" bool run_CE; //!< run with continuous-energy data?
|
||||
extern bool source_latest; //!< write latest source at each batch?
|
||||
extern bool source_separate; //!< write source to separate file?
|
||||
extern bool source_write; //!< write source in HDF5 files?
|
||||
extern bool surf_source_write; //!< write surface source file?
|
||||
extern bool surf_source_read; //!< read surface source file?
|
||||
extern bool survival_biasing; //!< use survival biasing?
|
||||
extern bool temperature_multipole; //!< use multipole data?
|
||||
extern "C" bool trigger_on; //!< tally triggers enabled?
|
||||
extern bool trigger_predict; //!< predict batches for triggers?
|
||||
extern bool ufs_on; //!< uniform fission site method on?
|
||||
extern bool urr_ptables_on; //!< use unresolved resonance prob. tables?
|
||||
extern bool write_all_tracks; //!< write track files for every particle?
|
||||
extern bool write_initial_source; //!< write out initial source file?
|
||||
extern bool assume_separate; //!< assume tallies are spatially separate?
|
||||
extern bool check_overlaps; //!< check overlaps in geometry?
|
||||
extern bool confidence_intervals; //!< use confidence intervals for results?
|
||||
extern bool
|
||||
create_fission_neutrons; //!< create fission neutrons (fixed source)?
|
||||
extern "C" bool cmfd_run; //!< is a CMFD run?
|
||||
extern bool
|
||||
delayed_photon_scaling; //!< Scale fission photon yield to include delayed
|
||||
extern "C" bool entropy_on; //!< calculate Shannon entropy?
|
||||
extern bool event_based; //!< use event-based mode (instead of history-based)
|
||||
extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
|
||||
extern bool material_cell_offsets; //!< create material cells offsets?
|
||||
extern "C" bool output_summary; //!< write summary.h5?
|
||||
extern bool output_tallies; //!< write tallies.out?
|
||||
extern bool particle_restart_run; //!< particle restart run?
|
||||
extern "C" bool photon_transport; //!< photon transport turned on?
|
||||
extern "C" bool reduce_tallies; //!< reduce tallies at end of batch?
|
||||
extern bool res_scat_on; //!< use resonance upscattering method?
|
||||
extern "C" bool restart_run; //!< restart run?
|
||||
extern "C" bool run_CE; //!< run with continuous-energy data?
|
||||
extern bool source_latest; //!< write latest source at each batch?
|
||||
extern bool source_separate; //!< write source to separate file?
|
||||
extern bool source_write; //!< write source in HDF5 files?
|
||||
extern bool surf_source_write; //!< write surface source file?
|
||||
extern bool surf_source_read; //!< read surface source file?
|
||||
extern bool survival_biasing; //!< use survival biasing?
|
||||
extern bool temperature_multipole; //!< use multipole data?
|
||||
extern "C" bool trigger_on; //!< tally triggers enabled?
|
||||
extern bool trigger_predict; //!< predict batches for triggers?
|
||||
extern bool ufs_on; //!< uniform fission site method on?
|
||||
extern bool urr_ptables_on; //!< use unresolved resonance prob. tables?
|
||||
extern bool write_all_tracks; //!< write track files for every particle?
|
||||
extern bool write_initial_source; //!< write out initial source file?
|
||||
|
||||
// Paths to various files
|
||||
extern std::string path_cross_sections; //!< path to cross_sections.xml
|
||||
extern std::string path_input; //!< directory where main .xml files resides
|
||||
extern std::string path_output; //!< directory where output files are written
|
||||
extern std::string path_cross_sections; //!< path to cross_sections.xml
|
||||
extern std::string path_input; //!< directory where main .xml files resides
|
||||
extern std::string path_output; //!< directory where output files are written
|
||||
extern std::string path_particle_restart; //!< path to a particle restart file
|
||||
extern std::string path_sourcepoint; //!< path to a source file
|
||||
extern "C" std::string path_statepoint; //!< path to a statepoint file
|
||||
|
||||
extern "C" int32_t n_inactive; //!< number of inactive batches
|
||||
extern "C" int32_t max_lost_particles; //!< maximum number of lost particles
|
||||
extern double rel_max_lost_particles; //!< maximum number of lost particles, relative to the total number of particles
|
||||
extern "C" int32_t gen_per_batch; //!< number of generations per batch
|
||||
extern "C" int64_t n_particles; //!< number of particles per generation
|
||||
extern "C" int32_t n_inactive; //!< number of inactive batches
|
||||
extern "C" int32_t max_lost_particles; //!< maximum number of lost particles
|
||||
extern double
|
||||
rel_max_lost_particles; //!< maximum number of lost particles, relative to the
|
||||
//!< total number of particles
|
||||
extern "C" int32_t gen_per_batch; //!< number of generations per batch
|
||||
extern "C" int64_t n_particles; //!< number of particles per generation
|
||||
|
||||
extern int64_t
|
||||
max_particles_in_flight; //!< Max num. event-based particles in flight
|
||||
|
||||
extern int64_t max_particles_in_flight; //!< Max num. event-based particles in flight
|
||||
|
||||
extern ElectronTreatment electron_treatment; //!< how to treat secondary electrons
|
||||
extern ElectronTreatment
|
||||
electron_treatment; //!< how to treat secondary electrons
|
||||
extern array<double, 4>
|
||||
energy_cutoff; //!< Energy cutoff in [eV] for each particle type
|
||||
extern int legendre_to_tabular_points; //!< number of points to convert Legendres
|
||||
extern int max_order; //!< Maximum Legendre order for multigroup data
|
||||
extern int n_log_bins; //!< number of bins for logarithmic energy grid
|
||||
extern int n_batches; //!< number of (inactive+active) batches
|
||||
extern int n_max_batches; //!< Maximum number of batches
|
||||
extern int
|
||||
legendre_to_tabular_points; //!< number of points to convert Legendres
|
||||
extern int max_order; //!< Maximum Legendre order for multigroup data
|
||||
extern int n_log_bins; //!< number of bins for logarithmic energy grid
|
||||
extern int n_batches; //!< number of (inactive+active) batches
|
||||
extern int n_max_batches; //!< Maximum number of batches
|
||||
extern ResScatMethod res_scat_method; //!< resonance upscattering method
|
||||
extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering
|
||||
extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering
|
||||
extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering
|
||||
extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering
|
||||
extern vector<std::string>
|
||||
res_scat_nuclides; //!< Nuclides using res. upscattering treatment
|
||||
extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.)
|
||||
extern std::unordered_set<int> sourcepoint_batch; //!< Batches when source should be written
|
||||
extern std::unordered_set<int> statepoint_batch; //!< Batches when state should be written
|
||||
extern std::unordered_set<int> source_write_surf_id; //!< Surface ids where sources will be written
|
||||
extern int64_t max_surface_particles; //!< maximum number of particles to be banked on surfaces per process
|
||||
extern TemperatureMethod temperature_method; //!< method for choosing temperatures
|
||||
extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures
|
||||
extern double temperature_default; //!< Default T in [K]
|
||||
res_scat_nuclides; //!< Nuclides using res. upscattering treatment
|
||||
extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.)
|
||||
extern std::unordered_set<int>
|
||||
sourcepoint_batch; //!< Batches when source should be written
|
||||
extern std::unordered_set<int>
|
||||
statepoint_batch; //!< Batches when state should be written
|
||||
extern std::unordered_set<int>
|
||||
source_write_surf_id; //!< Surface ids where sources will be written
|
||||
extern int64_t max_surface_particles; //!< maximum number of particles to be
|
||||
//!< banked on surfaces per process
|
||||
extern TemperatureMethod
|
||||
temperature_method; //!< method for choosing temperatures
|
||||
extern double
|
||||
temperature_tolerance; //!< Tolerance in [K] on choosing temperatures
|
||||
extern double temperature_default; //!< Default T in [K]
|
||||
extern array<double, 2>
|
||||
temperature_range; //!< Min/max T in [K] over which to load xs
|
||||
extern int trace_batch; //!< Batch to trace particle on
|
||||
extern int trace_gen; //!< Generation to trace particle on
|
||||
extern int64_t trace_particle; //!< Particle ID to enable trace on
|
||||
temperature_range; //!< Min/max T in [K] over which to load xs
|
||||
extern int trace_batch; //!< Batch to trace particle on
|
||||
extern int trace_gen; //!< Generation to trace particle on
|
||||
extern int64_t trace_particle; //!< Particle ID to enable trace on
|
||||
extern vector<array<int, 3>>
|
||||
track_identifiers; //!< Particle numbers for writing tracks
|
||||
extern int trigger_batch_interval; //!< Batch interval for triggers
|
||||
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
|
||||
track_identifiers; //!< Particle numbers for writing tracks
|
||||
extern int trigger_batch_interval; //!< Batch interval for triggers
|
||||
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
|
||||
} // namespace settings
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ namespace openmc {
|
|||
// call the thread_safe_append() function concurrently and store data to the
|
||||
// object at the index returned from thread_safe_append() safely, but no other
|
||||
// operations are protected.
|
||||
template <typename T>
|
||||
class SharedArray {
|
||||
template<typename T>
|
||||
class SharedArray {
|
||||
|
||||
public:
|
||||
public:
|
||||
//==========================================================================
|
||||
// Constructors
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
//! Return a reference to the element at specified location i. No bounds
|
||||
//! checking is performed.
|
||||
T& operator[](int64_t i) {return data_[i];}
|
||||
T& operator[](int64_t i) { return data_[i]; }
|
||||
const T& operator[](int64_t i) const { return data_[i]; }
|
||||
|
||||
//! Allocate space in the container for the specified number of elements.
|
||||
|
|
@ -58,7 +58,7 @@ public:
|
|||
capacity_ = capacity;
|
||||
}
|
||||
|
||||
//! Increase the size of the container by one and append value to the
|
||||
//! Increase the size of the container by one and append value to the
|
||||
//! array. Returns an index to the element of the array written to. Also
|
||||
//! tests to enforce that the append operation does not read off the end
|
||||
//! of the array. In the event that this does happen, set the size to be
|
||||
|
|
@ -72,12 +72,12 @@ public:
|
|||
{
|
||||
// Atomically capture the index we want to write to
|
||||
int64_t idx;
|
||||
#pragma omp atomic capture seq_cst
|
||||
#pragma omp atomic capture seq_cst
|
||||
idx = size_++;
|
||||
|
||||
// Check that we haven't written off the end of the array
|
||||
if (idx >= capacity_) {
|
||||
#pragma omp atomic write seq_cst
|
||||
#pragma omp atomic write seq_cst
|
||||
size_ = capacity_;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -98,32 +98,31 @@ public:
|
|||
}
|
||||
|
||||
//! Return the number of elements in the container
|
||||
int64_t size() {return size_;}
|
||||
int64_t size() { return size_; }
|
||||
|
||||
//! Resize the container to contain a specified number of elements. This is
|
||||
//! useful in cases where the container is written to in a non-thread safe manner,
|
||||
//! where the internal size of the array needs to be manually updated.
|
||||
//! useful in cases where the container is written to in a non-thread safe
|
||||
//! manner, where the internal size of the array needs to be manually updated.
|
||||
//
|
||||
//! \param size The new size of the container
|
||||
void resize(int64_t size) {size_ = size;}
|
||||
void resize(int64_t size) { size_ = size; }
|
||||
|
||||
//! Return the number of elements that the container has currently allocated
|
||||
//! space for.
|
||||
int64_t capacity() {return capacity_;}
|
||||
int64_t capacity() { return capacity_; }
|
||||
|
||||
//! Return pointer to the underlying array serving as element storage.
|
||||
T* data() {return data_.get();}
|
||||
const T* data() const {return data_.get();}
|
||||
T* data() { return data_.get(); }
|
||||
const T* data() const { return data_.get(); }
|
||||
|
||||
private:
|
||||
private:
|
||||
//==========================================================================
|
||||
// Data members
|
||||
|
||||
unique_ptr<T[]> data_; //!< An RAII handle to the elements
|
||||
int64_t size_ {0}; //!< The current number of elements
|
||||
int64_t size_ {0}; //!< The current number of elements
|
||||
int64_t capacity_ {0}; //!< The total space allocated for elements
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -22,22 +22,24 @@ constexpr int STATUS_EXIT_ON_TRIGGER {2};
|
|||
|
||||
namespace simulation {
|
||||
|
||||
extern "C" int current_batch; //!< current batch
|
||||
extern "C" int current_gen; //!< current fission generation
|
||||
extern "C" bool initialized; //!< has simulation been initialized?
|
||||
extern "C" double keff; //!< average k over batches
|
||||
extern "C" double keff_std; //!< standard deviation of average k
|
||||
extern "C" double k_col_abs; //!< sum over batches of k_collision * k_absorption
|
||||
extern "C" double k_col_tra; //!< sum over batches of k_collision * k_tracklength
|
||||
extern "C" double k_abs_tra; //!< sum over batches of k_absorption * k_tracklength
|
||||
extern double log_spacing; //!< lethargy spacing for energy grid searches
|
||||
extern "C" int n_lost_particles; //!< cumulative number of lost particles
|
||||
extern "C" int current_batch; //!< current batch
|
||||
extern "C" int current_gen; //!< current fission generation
|
||||
extern "C" bool initialized; //!< has simulation been initialized?
|
||||
extern "C" double keff; //!< average k over batches
|
||||
extern "C" double keff_std; //!< standard deviation of average k
|
||||
extern "C" double k_col_abs; //!< sum over batches of k_collision * k_absorption
|
||||
extern "C" double
|
||||
k_col_tra; //!< sum over batches of k_collision * k_tracklength
|
||||
extern "C" double
|
||||
k_abs_tra; //!< sum over batches of k_absorption * k_tracklength
|
||||
extern double log_spacing; //!< lethargy spacing for energy grid searches
|
||||
extern "C" int n_lost_particles; //!< cumulative number of lost particles
|
||||
extern "C" bool need_depletion_rx; //!< need to calculate depletion rx?
|
||||
extern "C" int restart_batch; //!< batch at which a restart job resumed
|
||||
extern "C" bool satisfy_triggers; //!< have tally triggers been satisfied?
|
||||
extern "C" int total_gen; //!< total number of generations simulated
|
||||
extern double total_weight; //!< Total source weight in a batch
|
||||
extern int64_t work_per_rank; //!< number of particles per MPI rank
|
||||
extern "C" int restart_batch; //!< batch at which a restart job resumed
|
||||
extern "C" bool satisfy_triggers; //!< have tally triggers been satisfied?
|
||||
extern "C" int total_gen; //!< total number of generations simulated
|
||||
extern double total_weight; //!< Total source weight in a batch
|
||||
extern int64_t work_per_rank; //!< number of particles per MPI rank
|
||||
|
||||
extern const RegularMesh* entropy_mesh;
|
||||
extern const RegularMesh* ufs_mesh;
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ public:
|
|||
|
||||
private:
|
||||
ParticleType particle_ {ParticleType::neutron}; //!< Type of particle emitted
|
||||
double strength_ {1.0}; //!< Source strength
|
||||
UPtrSpace space_; //!< Spatial distribution
|
||||
UPtrAngle angle_; //!< Angular distribution
|
||||
UPtrDist energy_; //!< Energy distribution
|
||||
double strength_ {1.0}; //!< Source strength
|
||||
UPtrSpace space_; //!< Spatial distribution
|
||||
UPtrAngle angle_; //!< Angular distribution
|
||||
UPtrDist energy_; //!< Energy distribution
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -106,6 +106,7 @@ public:
|
|||
}
|
||||
|
||||
double strength() const override { return custom_source_->strength(); }
|
||||
|
||||
private:
|
||||
void* shared_library_; //!< library from dlopen
|
||||
unique_ptr<Source> custom_source_;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ void write_nuclides(hid_t file);
|
|||
void write_geometry(hid_t file);
|
||||
void write_materials(hid_t file);
|
||||
|
||||
}
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_SUMMARY_H
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef OPENMC_SURFACE_H
|
||||
#define OPENMC_SURFACE_H
|
||||
|
||||
#include <limits> // For numeric_limits
|
||||
#include <limits> // For numeric_limits
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
@ -24,16 +24,15 @@ namespace openmc {
|
|||
class Surface;
|
||||
|
||||
namespace model {
|
||||
extern std::unordered_map<int, int> surface_map;
|
||||
extern vector<unique_ptr<Surface>> surfaces;
|
||||
extern std::unordered_map<int, int> surface_map;
|
||||
extern vector<unique_ptr<Surface>> surfaces;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
//! Coordinates for an axis-aligned cuboid that bounds a geometric object.
|
||||
//==============================================================================
|
||||
|
||||
struct BoundingBox
|
||||
{
|
||||
struct BoundingBox {
|
||||
double xmin = -INFTY;
|
||||
double xmax = INFTY;
|
||||
double ymin = -INFTY;
|
||||
|
|
@ -41,19 +40,21 @@ struct BoundingBox
|
|||
double zmin = -INFTY;
|
||||
double zmax = INFTY;
|
||||
|
||||
|
||||
inline BoundingBox operator &(const BoundingBox& other) {
|
||||
inline BoundingBox operator&(const BoundingBox& other)
|
||||
{
|
||||
BoundingBox result = *this;
|
||||
return result &= other;
|
||||
}
|
||||
|
||||
inline BoundingBox operator |(const BoundingBox& other) {
|
||||
inline BoundingBox operator|(const BoundingBox& other)
|
||||
{
|
||||
BoundingBox result = *this;
|
||||
return result |= other;
|
||||
}
|
||||
|
||||
// intersect operator
|
||||
inline BoundingBox& operator &=(const BoundingBox& other) {
|
||||
inline BoundingBox& operator&=(const BoundingBox& other)
|
||||
{
|
||||
xmin = std::max(xmin, other.xmin);
|
||||
xmax = std::min(xmax, other.xmax);
|
||||
ymin = std::max(ymin, other.ymin);
|
||||
|
|
@ -64,7 +65,8 @@ struct BoundingBox
|
|||
}
|
||||
|
||||
// union operator
|
||||
inline BoundingBox& operator |=(const BoundingBox& other) {
|
||||
inline BoundingBox& operator|=(const BoundingBox& other)
|
||||
{
|
||||
xmin = std::min(xmin, other.xmin);
|
||||
xmax = std::max(xmax, other.xmax);
|
||||
ymin = std::min(ymin, other.ymin);
|
||||
|
|
@ -73,22 +75,19 @@ struct BoundingBox
|
|||
zmax = std::max(zmax, other.zmax);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! A geometry primitive used to define regions of 3D space.
|
||||
//==============================================================================
|
||||
|
||||
class Surface
|
||||
{
|
||||
class Surface {
|
||||
public:
|
||||
|
||||
int id_; //!< Unique ID
|
||||
std::string name_; //!< User-defined name
|
||||
int id_; //!< Unique ID
|
||||
std::string name_; //!< User-defined name
|
||||
std::shared_ptr<BoundaryCondition> bc_ {nullptr}; //!< Boundary condition
|
||||
GeometryType geom_type_; //!< Geometry type indicator (CSG or DAGMC)
|
||||
bool surf_source_ {false}; //!< Activate source banking for the surface?
|
||||
GeometryType geom_type_; //!< Geometry type indicator (CSG or DAGMC)
|
||||
bool surf_source_ {false}; //!< Activate source banking for the surface?
|
||||
|
||||
explicit Surface(pugi::xml_node surf_node);
|
||||
Surface();
|
||||
|
|
@ -110,8 +109,8 @@ public:
|
|||
//! \return Outgoing direction of the ray
|
||||
virtual Direction reflect(Position r, Direction u, Particle* p) const;
|
||||
|
||||
virtual Direction diffuse_reflect(Position r, Direction u,
|
||||
uint64_t* seed) const;
|
||||
virtual Direction diffuse_reflect(
|
||||
Position r, Direction u, uint64_t* seed) const;
|
||||
|
||||
//! Evaluate the equation describing the surface.
|
||||
//!
|
||||
|
|
@ -143,8 +142,7 @@ protected:
|
|||
virtual void to_hdf5_inner(hid_t group_id) const = 0;
|
||||
};
|
||||
|
||||
class CSGSurface : public Surface
|
||||
{
|
||||
class CSGSurface : public Surface {
|
||||
public:
|
||||
explicit CSGSurface(pugi::xml_node surf_node);
|
||||
CSGSurface();
|
||||
|
|
@ -159,8 +157,7 @@ protected:
|
|||
//! The plane is described by the equation \f$x - x_0 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceXPlane : public CSGSurface
|
||||
{
|
||||
class SurfaceXPlane : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceXPlane(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -178,8 +175,7 @@ public:
|
|||
//! The plane is described by the equation \f$y - y_0 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceYPlane : public CSGSurface
|
||||
{
|
||||
class SurfaceYPlane : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceYPlane(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -197,8 +193,7 @@ public:
|
|||
//! The plane is described by the equation \f$z - z_0 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceZPlane : public CSGSurface
|
||||
{
|
||||
class SurfaceZPlane : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceZPlane(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -216,8 +211,7 @@ public:
|
|||
//! The plane is described by the equation \f$A x + B y + C z - D = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfacePlane : public CSGSurface
|
||||
{
|
||||
class SurfacePlane : public CSGSurface {
|
||||
public:
|
||||
explicit SurfacePlane(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -235,8 +229,7 @@ public:
|
|||
//! \f$(y - y_0)^2 + (z - z_0)^2 - R^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceXCylinder : public CSGSurface
|
||||
{
|
||||
class SurfaceXCylinder : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceXCylinder(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -255,8 +248,7 @@ public:
|
|||
//! \f$(x - x_0)^2 + (z - z_0)^2 - R^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceYCylinder : public CSGSurface
|
||||
{
|
||||
class SurfaceYCylinder : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceYCylinder(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -275,8 +267,7 @@ public:
|
|||
//! \f$(x - x_0)^2 + (y - y_0)^2 - R^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceZCylinder : public CSGSurface
|
||||
{
|
||||
class SurfaceZCylinder : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceZCylinder(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -295,8 +286,7 @@ public:
|
|||
//! \f$(x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 - R^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceSphere : public CSGSurface
|
||||
{
|
||||
class SurfaceSphere : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceSphere(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -315,8 +305,7 @@ public:
|
|||
//! \f$(y - y_0)^2 + (z - z_0)^2 - R^2 (x - x_0)^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceXCone : public CSGSurface
|
||||
{
|
||||
class SurfaceXCone : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceXCone(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -334,8 +323,7 @@ public:
|
|||
//! \f$(x - x_0)^2 + (z - z_0)^2 - R^2 (y - y_0)^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceYCone : public CSGSurface
|
||||
{
|
||||
class SurfaceYCone : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceYCone(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -353,8 +341,7 @@ public:
|
|||
//! \f$(x - x_0)^2 + (y - y_0)^2 - R^2 (z - z_0)^2 = 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceZCone : public CSGSurface
|
||||
{
|
||||
class SurfaceZCone : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceZCone(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
@ -368,11 +355,11 @@ public:
|
|||
//==============================================================================
|
||||
//! A general surface described by a quadratic equation.
|
||||
//
|
||||
//! \f$A x^2 + B y^2 + C z^2 + D x y + E y z + F x z + G x + H y + J z + K = 0\f$
|
||||
//! \f$A x^2 + B y^2 + C z^2 + D x y + E y z + F x z + G x + H y + J z + K =
|
||||
//! 0\f$
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceQuadric : public CSGSurface
|
||||
{
|
||||
class SurfaceQuadric : public CSGSurface {
|
||||
public:
|
||||
explicit SurfaceQuadric(pugi::xml_node surf_node);
|
||||
double evaluate(Position r) const;
|
||||
|
|
|
|||
|
|
@ -15,18 +15,14 @@
|
|||
namespace openmc {
|
||||
|
||||
// Different independent variables
|
||||
enum class DerivativeVariable {
|
||||
DENSITY,
|
||||
NUCLIDE_DENSITY,
|
||||
TEMPERATURE
|
||||
};
|
||||
enum class DerivativeVariable { DENSITY, NUCLIDE_DENSITY, TEMPERATURE };
|
||||
|
||||
struct TallyDerivative {
|
||||
|
||||
DerivativeVariable variable; //!< Independent variable (like temperature)
|
||||
int id; //!< User-defined identifier
|
||||
int diff_material; //!< Material this derivative is applied to
|
||||
int diff_nuclide; //!< Nuclide this material is applied to
|
||||
DerivativeVariable variable; //!< Independent variable (like temperature)
|
||||
int id; //!< User-defined identifier
|
||||
int diff_material; //!< Material this derivative is applied to
|
||||
int diff_nuclide; //!< Nuclide this material is applied to
|
||||
|
||||
TallyDerivative() {}
|
||||
explicit TallyDerivative(pugi::xml_node node);
|
||||
|
|
@ -41,8 +37,7 @@ void read_tally_derivatives(pugi::xml_node node);
|
|||
|
||||
//! Scale the given score by its logarithmic derivative
|
||||
|
||||
void
|
||||
apply_derivative_to_score(const Particle& p, int i_tally, int i_nuclide,
|
||||
void apply_derivative_to_score(const Particle& p, int i_tally, int i_nuclide,
|
||||
double atom_density, int score_bin, double& score);
|
||||
|
||||
//! Adjust diff tally flux derivatives for a particle scattering event.
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ namespace openmc {
|
|||
//! Modifies tally score events.
|
||||
//==============================================================================
|
||||
|
||||
class Filter
|
||||
{
|
||||
class Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors, factory functions
|
||||
|
|
@ -67,12 +66,11 @@ public:
|
|||
//! \param[in] estimator Tally estimator being used
|
||||
//! \param[out] match will contain the matching bins and corresponding
|
||||
//! weights; note that there may be zero matching bins
|
||||
virtual void
|
||||
get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const = 0;
|
||||
virtual void get_all_bins(
|
||||
const Particle& p, TallyEstimator estimator, FilterMatch& match) const = 0;
|
||||
|
||||
//! Writes data describing this filter to an HDF5 statepoint group.
|
||||
virtual void
|
||||
to_statepoint(hid_t filter_group) const
|
||||
virtual void to_statepoint(hid_t filter_group) const
|
||||
{
|
||||
write_dataset(filter_group, "type", type());
|
||||
write_dataset(filter_group, "n_bins", n_bins_);
|
||||
|
|
@ -107,6 +105,7 @@ public:
|
|||
|
||||
protected:
|
||||
int n_bins_;
|
||||
|
||||
private:
|
||||
int32_t id_ {C_NONE};
|
||||
gsl::index index_;
|
||||
|
|
@ -117,10 +116,10 @@ private:
|
|||
//==============================================================================
|
||||
|
||||
namespace model {
|
||||
extern "C" int32_t n_filters;
|
||||
extern std::unordered_map<int, int> filter_map;
|
||||
extern vector<unique_ptr<Filter>> tally_filters;
|
||||
}
|
||||
extern "C" int32_t n_filters;
|
||||
extern std::unordered_map<int, int> filter_map;
|
||||
extern vector<unique_ptr<Filter>> tally_filters;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
// Non-member functions
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ namespace openmc {
|
|||
//! Bins the incident neutron azimuthal angle (relative to the global xy-plane).
|
||||
//==============================================================================
|
||||
|
||||
class AzimuthalFilter : public Filter
|
||||
{
|
||||
class AzimuthalFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -25,12 +24,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "azimuthal";}
|
||||
std::string type() const override { return "azimuthal"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ namespace openmc {
|
|||
//! Specifies which geometric cells tally events reside in.
|
||||
//==============================================================================
|
||||
|
||||
class CellFilter : public Filter
|
||||
{
|
||||
class CellFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -26,12 +25,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "cell";}
|
||||
std::string type() const override { return "cell"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "cellinstance";}
|
||||
std::string type() const override { return "cellinstance"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,16 +11,15 @@ namespace openmc {
|
|||
//! Specifies which cell the particle was born in.
|
||||
//==============================================================================
|
||||
|
||||
class CellbornFilter : public CellFilter
|
||||
{
|
||||
class CellbornFilter : public CellFilter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "cellborn";}
|
||||
std::string type() const override { return "cellborn"; }
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
std::string text_label(int bin) const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,16 +11,15 @@ namespace openmc {
|
|||
//! Specifies which geometric cells particles exit when crossing a surface.
|
||||
//==============================================================================
|
||||
|
||||
class CellFromFilter : public CellFilter
|
||||
{
|
||||
class CellFromFilter : public CellFilter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "cellfrom";}
|
||||
std::string type() const override { return "cellfrom"; }
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
std::string text_label(int bin) const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_COLLISIONS_H
|
||||
#define OPENMC_TALLIES_FILTER_COLLISIONS_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <gsl/gsl>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
|
@ -46,8 +46,7 @@ protected:
|
|||
|
||||
vector<int> bins_;
|
||||
|
||||
std::unordered_map<int,int> map_;
|
||||
|
||||
std::unordered_map<int, int> map_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ namespace openmc {
|
|||
//! iterated over in the scoring subroutines.
|
||||
//==============================================================================
|
||||
|
||||
class DelayedGroupFilter : public Filter
|
||||
{
|
||||
class DelayedGroupFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -26,12 +25,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "delayedgroup";}
|
||||
std::string type() const override { return "delayedgroup"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ namespace openmc {
|
|||
//! Specifies which distributed geometric cells tally events reside in.
|
||||
//==============================================================================
|
||||
|
||||
class DistribcellFilter : public Filter
|
||||
{
|
||||
class DistribcellFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -22,12 +21,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "distribcell";}
|
||||
std::string type() const override { return "distribcell"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ namespace openmc {
|
|||
//! Bins the incident neutron energy.
|
||||
//==============================================================================
|
||||
|
||||
class EnergyFilter : public Filter
|
||||
{
|
||||
class EnergyFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -23,12 +22,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "energy";}
|
||||
std::string type() const override { return "energy"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
@ -59,16 +58,15 @@ protected:
|
|||
//! tallies manually iterate over the filter bins.
|
||||
//==============================================================================
|
||||
|
||||
class EnergyoutFilter : public EnergyFilter
|
||||
{
|
||||
class EnergyoutFilter : public EnergyFilter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "energyout";}
|
||||
std::string type() const override { return "energyout"; }
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
std::string text_label(int bin) const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,29 +11,24 @@ namespace openmc {
|
|||
//! described by a piecewise linear-linear interpolation.
|
||||
//==============================================================================
|
||||
|
||||
class EnergyFunctionFilter : public Filter
|
||||
{
|
||||
class EnergyFunctionFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
||||
EnergyFunctionFilter()
|
||||
: Filter {}
|
||||
{
|
||||
n_bins_ = 1;
|
||||
}
|
||||
EnergyFunctionFilter() : Filter {} { n_bins_ = 1; }
|
||||
|
||||
~EnergyFunctionFilter() = default;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "energyfunction";}
|
||||
std::string type() const override { return "energyfunction"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ namespace openmc {
|
|||
//! Gives Legendre moments of the change in scattering angle
|
||||
//==============================================================================
|
||||
|
||||
class LegendreFilter : public Filter
|
||||
{
|
||||
class LegendreFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -22,12 +21,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "legendre";}
|
||||
std::string type() const override { return "legendre"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
#ifndef OPENMC_TALLIES_FILTERMATCH_H
|
||||
#define OPENMC_TALLIES_FILTERMATCH_H
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
//! Stores bins and weights for filtered tally events.
|
||||
//==============================================================================
|
||||
|
||||
class FilterMatch
|
||||
{
|
||||
class FilterMatch {
|
||||
public:
|
||||
vector<int> bins_;
|
||||
vector<double> weights_;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ namespace openmc {
|
|||
//! Specifies which material tally events reside in.
|
||||
//==============================================================================
|
||||
|
||||
class MaterialFilter : public Filter
|
||||
{
|
||||
class MaterialFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -26,12 +25,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "material";}
|
||||
std::string type() const override { return "material"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -14,8 +14,7 @@ namespace openmc {
|
|||
//! correspond to the fraction of the track length that lies in that bin.
|
||||
//==============================================================================
|
||||
|
||||
class MeshFilter : public Filter
|
||||
{
|
||||
class MeshFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -25,12 +24,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "mesh";}
|
||||
std::string type() const override { return "mesh"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
@ -39,7 +38,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
virtual int32_t mesh() const {return mesh_;}
|
||||
virtual int32_t mesh() const { return mesh_; }
|
||||
|
||||
virtual void set_mesh(int32_t mesh);
|
||||
|
||||
|
|
@ -47,10 +46,9 @@ public:
|
|||
|
||||
virtual void set_translation(const double translation[3]);
|
||||
|
||||
virtual const Position& translation() const {return translation_;}
|
||||
|
||||
virtual bool translated() const {return translated_;}
|
||||
virtual const Position& translation() const { return translation_; }
|
||||
|
||||
virtual bool translated() const { return translated_; }
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -5,16 +5,15 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
class MeshSurfaceFilter : public MeshFilter
|
||||
{
|
||||
class MeshSurfaceFilter : public MeshFilter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "meshsurface";}
|
||||
std::string type() const override { return "meshsurface"; }
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
std::string text_label(int bin) const override;
|
||||
|
||||
|
|
@ -24,18 +23,18 @@ public:
|
|||
void set_mesh(int32_t mesh) override;
|
||||
|
||||
enum class MeshDir {
|
||||
OUT_LEFT, // x min
|
||||
IN_LEFT, // x min
|
||||
OUT_LEFT, // x min
|
||||
IN_LEFT, // x min
|
||||
OUT_RIGHT, // x max
|
||||
IN_RIGHT, // x max
|
||||
OUT_BACK, // y min
|
||||
IN_BACK, // y min
|
||||
IN_RIGHT, // x max
|
||||
OUT_BACK, // y min
|
||||
IN_BACK, // y min
|
||||
OUT_FRONT, // y max
|
||||
IN_FRONT, // y max
|
||||
OUT_BOTTOM, // z min
|
||||
IN_BOTTOM, // z min
|
||||
OUT_TOP, // z max
|
||||
IN_TOP // z max
|
||||
IN_FRONT, // y max
|
||||
OUT_BOTTOM, // z min
|
||||
IN_BOTTOM, // z min
|
||||
OUT_TOP, // z max
|
||||
IN_TOP // z max
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ namespace openmc {
|
|||
//! reactions.
|
||||
//==============================================================================
|
||||
|
||||
class MuFilter : public Filter
|
||||
{
|
||||
class MuFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -24,12 +23,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "mu";}
|
||||
std::string type() const override { return "mu"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ namespace openmc {
|
|||
//! Bins by type of particle (e.g. neutron, photon).
|
||||
//==============================================================================
|
||||
|
||||
class ParticleFilter : public Filter
|
||||
{
|
||||
class ParticleFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -22,12 +21,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "particle";}
|
||||
std::string type() const override { return "particle"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ namespace openmc {
|
|||
//! Bins the incident neutron polar angle (relative to the global z-axis).
|
||||
//==============================================================================
|
||||
|
||||
class PolarFilter : public Filter
|
||||
{
|
||||
class PolarFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -25,12 +24,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "polar";}
|
||||
std::string type() const override { return "polar"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,16 +9,13 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
enum class SphericalHarmonicsCosine {
|
||||
scatter, particle
|
||||
};
|
||||
enum class SphericalHarmonicsCosine { scatter, particle };
|
||||
|
||||
//==============================================================================
|
||||
//! Gives spherical harmonics expansion moments of a tally score
|
||||
//==============================================================================
|
||||
|
||||
class SphericalHarmonicsFilter : public Filter
|
||||
{
|
||||
class SphericalHarmonicsFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -28,12 +25,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "sphericalharmonics";}
|
||||
std::string type() const override { return "sphericalharmonics"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,16 +7,13 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
enum class LegendreAxis {
|
||||
x, y, z
|
||||
};
|
||||
enum class LegendreAxis { x, y, z };
|
||||
|
||||
//==============================================================================
|
||||
//! Gives Legendre moments of the particle's normalized position along an axis
|
||||
//==============================================================================
|
||||
|
||||
class SpatialLegendreFilter : public Filter
|
||||
{
|
||||
class SpatialLegendreFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -26,12 +23,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "spatiallegendre";}
|
||||
std::string type() const override { return "spatiallegendre"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ namespace openmc {
|
|||
//! Specifies which surface particles are crossing
|
||||
//==============================================================================
|
||||
|
||||
class SurfaceFilter : public Filter
|
||||
{
|
||||
class SurfaceFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -26,12 +25,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "surface";}
|
||||
std::string type() const override { return "surface"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ namespace openmc {
|
|||
//! Specifies which geometric universes tally events reside in.
|
||||
//==============================================================================
|
||||
|
||||
class UniverseFilter : public Filter
|
||||
{
|
||||
class UniverseFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -26,12 +25,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "universe";}
|
||||
std::string type() const override { return "universe"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ namespace openmc {
|
|||
//! Gives Zernike polynomial moments of a particle's position
|
||||
//==============================================================================
|
||||
|
||||
class ZernikeFilter : public Filter
|
||||
{
|
||||
class ZernikeFilter : public Filter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructors, destructors
|
||||
|
|
@ -22,12 +21,12 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "zernike";}
|
||||
std::string type() const override { return "zernike"; }
|
||||
|
||||
void from_xml(pugi::xml_node node) override;
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
void to_statepoint(hid_t filter_group) const override;
|
||||
|
||||
|
|
@ -68,16 +67,15 @@ protected:
|
|||
//! Gives even order radial Zernike polynomial moments of a particle's position
|
||||
//==============================================================================
|
||||
|
||||
class ZernikeRadialFilter : public ZernikeFilter
|
||||
{
|
||||
class ZernikeRadialFilter : public ZernikeFilter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type() const override {return "zernikeradial";}
|
||||
std::string type() const override { return "zernikeradial"; }
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match)
|
||||
const override;
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
std::string text_label(int bin) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
#include "openmc/tallies/trigger.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xfixed.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
|
@ -49,18 +49,18 @@ public:
|
|||
|
||||
const vector<int32_t>& filters() const { return filters_; }
|
||||
|
||||
int32_t filters(int i) const {return filters_[i];}
|
||||
int32_t filters(int i) const { return filters_[i]; }
|
||||
|
||||
void set_filters(gsl::span<Filter*> filters);
|
||||
|
||||
//! Given already-set filters, set the stride lengths
|
||||
void set_strides();
|
||||
|
||||
int32_t strides(int i) const {return strides_[i];}
|
||||
int32_t strides(int i) const { return strides_[i]; }
|
||||
|
||||
int32_t n_filter_bins() const {return n_filter_bins_;}
|
||||
int32_t n_filter_bins() const { return n_filter_bins_; }
|
||||
|
||||
bool writable() const { return writable_;}
|
||||
bool writable() const { return writable_; }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Other methods.
|
||||
|
|
@ -148,23 +148,24 @@ private:
|
|||
//==============================================================================
|
||||
|
||||
namespace model {
|
||||
extern std::unordered_map<int, int> tally_map;
|
||||
extern vector<unique_ptr<Tally>> tallies;
|
||||
extern vector<int> active_tallies;
|
||||
extern vector<int> active_analog_tallies;
|
||||
extern vector<int> active_tracklength_tallies;
|
||||
extern vector<int> active_collision_tallies;
|
||||
extern vector<int> active_meshsurf_tallies;
|
||||
extern vector<int> active_surface_tallies;
|
||||
}
|
||||
extern std::unordered_map<int, int> tally_map;
|
||||
extern vector<unique_ptr<Tally>> tallies;
|
||||
extern vector<int> active_tallies;
|
||||
extern vector<int> active_analog_tallies;
|
||||
extern vector<int> active_tracklength_tallies;
|
||||
extern vector<int> active_collision_tallies;
|
||||
extern vector<int> active_meshsurf_tallies;
|
||||
extern vector<int> active_surface_tallies;
|
||||
} // namespace model
|
||||
|
||||
namespace simulation {
|
||||
//! Global tallies (such as k-effective estimators)
|
||||
extern xt::xtensor_fixed<double, xt::xshape<N_GLOBAL_TALLIES, 3>> global_tallies;
|
||||
//! Global tallies (such as k-effective estimators)
|
||||
extern xt::xtensor_fixed<double, xt::xshape<N_GLOBAL_TALLIES, 3>>
|
||||
global_tallies;
|
||||
|
||||
//! Number of realizations for global tallies
|
||||
extern "C" int32_t n_realizations;
|
||||
}
|
||||
//! Number of realizations for global tallies
|
||||
extern "C" int32_t n_realizations;
|
||||
} // namespace simulation
|
||||
|
||||
extern double global_tally_absorption;
|
||||
extern double global_tally_collision;
|
||||
|
|
@ -187,8 +188,9 @@ void setup_active_tallies();
|
|||
|
||||
// Alias for the type returned by xt::adapt(...). N is the dimension of the
|
||||
// multidimensional array
|
||||
template <std::size_t N>
|
||||
using adaptor_type = xt::xtensor_adaptor<xt::xbuffer_adaptor<double*&, xt::no_ownership>, N>;
|
||||
template<std::size_t N>
|
||||
using adaptor_type =
|
||||
xt::xtensor_adaptor<xt::xbuffer_adaptor<double*&, xt::no_ownership>, N>;
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
//! Collect all tally results onto master process
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@ namespace openmc {
|
|||
//! bins that are valid for the current tally event.
|
||||
//==============================================================================
|
||||
|
||||
class FilterBinIter
|
||||
{
|
||||
class FilterBinIter {
|
||||
public:
|
||||
|
||||
//! Construct an iterator over bins that match a given particle's state.
|
||||
FilterBinIter(const Tally& tally, Particle& p);
|
||||
|
||||
|
|
@ -32,10 +30,14 @@ public:
|
|||
const Tally& tally, bool end, vector<FilterMatch>* particle_filter_matches);
|
||||
|
||||
bool operator==(const FilterBinIter& other) const
|
||||
{return index_ == other.index_;}
|
||||
{
|
||||
return index_ == other.index_;
|
||||
}
|
||||
|
||||
bool operator!=(const FilterBinIter& other) const
|
||||
{return !(*this == other);}
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
FilterBinIter& operator++();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,21 +12,23 @@ namespace openmc {
|
|||
//==============================================================================
|
||||
|
||||
enum class TriggerMetric {
|
||||
variance, relative_error, standard_deviation, not_active
|
||||
variance,
|
||||
relative_error,
|
||||
standard_deviation,
|
||||
not_active
|
||||
};
|
||||
|
||||
//! Stops the simulation early if a desired tally uncertainty is reached.
|
||||
|
||||
struct Trigger {
|
||||
TriggerMetric metric; //!< The type of uncertainty (e.g. std dev) measured
|
||||
double threshold; //!< Uncertainty value below which trigger is satisfied
|
||||
int score_index; //!< Index of the relevant score in the tally's arrays
|
||||
TriggerMetric metric; //!< The type of uncertainty (e.g. std dev) measured
|
||||
double threshold; //!< Uncertainty value below which trigger is satisfied
|
||||
int score_index; //!< Index of the relevant score in the tally's arrays
|
||||
};
|
||||
|
||||
//! Stops the simulation early if a desired k-effective uncertainty is reached.
|
||||
|
||||
struct KTrigger
|
||||
{
|
||||
struct KTrigger {
|
||||
TriggerMetric metric {TriggerMetric::not_active};
|
||||
double threshold {0.};
|
||||
};
|
||||
|
|
@ -35,9 +37,9 @@ struct KTrigger
|
|||
// Global variable declarations
|
||||
//==============================================================================
|
||||
|
||||
//TODO: consider a different namespace
|
||||
// TODO: consider a different namespace
|
||||
namespace settings {
|
||||
extern KTrigger keff_trigger;
|
||||
extern KTrigger keff_trigger;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class ThermalScattering;
|
|||
namespace data {
|
||||
extern std::unordered_map<std::string, int> thermal_scatt_map;
|
||||
extern vector<unique_ptr<ThermalScattering>> thermal_scatt;
|
||||
}
|
||||
} // namespace data
|
||||
|
||||
//==============================================================================
|
||||
//! Secondary angle-energy data for thermal neutron scattering at a single
|
||||
|
|
@ -50,12 +50,13 @@ public:
|
|||
//! \param[out] E_out Outgoing neutron energy in [eV]
|
||||
//! \param[out] mu Outgoing scattering angle cosine
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(const NuclideMicroXS& micro_xs, double E_in,
|
||||
double* E_out, double* mu, uint64_t* seed);
|
||||
void sample(const NuclideMicroXS& micro_xs, double E_in, double* E_out,
|
||||
double* mu, uint64_t* seed);
|
||||
|
||||
private:
|
||||
struct Reaction {
|
||||
// Default constructor
|
||||
Reaction() { }
|
||||
Reaction() {}
|
||||
|
||||
// Data members
|
||||
unique_ptr<Function1D> xs; //!< Cross section
|
||||
|
|
@ -83,13 +84,13 @@ public:
|
|||
//! Determine inelastic/elastic cross section at given energy
|
||||
//!
|
||||
//! \param[in] E incoming energy in [eV]
|
||||
//! \param[in] sqrtkT square-root of temperature multipled by Boltzmann's constant
|
||||
//! \param[out] i_temp corresponding temperature index
|
||||
//! \param[out] elastic Thermal elastic scattering cross section
|
||||
//! \param[out] inelastic Thermal inelastic scattering cross section
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
//! \param[in] sqrtkT square-root of temperature multipled by Boltzmann's
|
||||
//! constant \param[out] i_temp corresponding temperature index \param[out]
|
||||
//! elastic Thermal elastic scattering cross section \param[out] inelastic
|
||||
//! Thermal inelastic scattering cross section \param[inout] seed Pseudorandom
|
||||
//! seed pointer
|
||||
void calculate_xs(double E, double sqrtkT, int* i_temp, double* elastic,
|
||||
double* inelastic, uint64_t* seed) const;
|
||||
double* inelastic, uint64_t* seed) const;
|
||||
|
||||
//! Determine whether table applies to a particular nuclide
|
||||
//!
|
||||
|
|
@ -98,13 +99,13 @@ public:
|
|||
bool has_nuclide(const char* name) const;
|
||||
|
||||
// Sample an outgoing energy and angle
|
||||
void sample(const NuclideMicroXS& micro_xs, double E_in,
|
||||
double* E_out, double* mu);
|
||||
void sample(
|
||||
const NuclideMicroXS& micro_xs, double E_in, double* E_out, double* mu);
|
||||
|
||||
std::string name_; //!< name of table, e.g. "c_H_in_H2O"
|
||||
double awr_; //!< weight of nucleus in neutron masses
|
||||
double energy_max_; //!< maximum energy for thermal scattering in [eV]
|
||||
vector<double> kTs_; //!< temperatures in [eV] (k*T)
|
||||
std::string name_; //!< name of table, e.g. "c_H_in_H2O"
|
||||
double awr_; //!< weight of nucleus in neutron masses
|
||||
double energy_max_; //!< maximum energy for thermal scattering in [eV]
|
||||
vector<double> kTs_; //!< temperatures in [eV] (k*T)
|
||||
vector<std::string> nuclides_; //!< Valid nuclides
|
||||
|
||||
//! cross sections and distributions at each temperature
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ public:
|
|||
void reset();
|
||||
|
||||
private:
|
||||
bool running_ {false}; //!< is timer running?
|
||||
bool running_ {false}; //!< is timer running?
|
||||
std::chrono::time_point<clock> start_; //!< starting point for clock
|
||||
double elapsed_ {0.0}; //!< elapsed time in [s]
|
||||
double elapsed_ {0.0}; //!< elapsed time in [s]
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace openmc {
|
|||
//! UrrData contains probability tables for the unresolved resonance range.
|
||||
//==============================================================================
|
||||
|
||||
class UrrData{
|
||||
class UrrData {
|
||||
public:
|
||||
Interpolation interp_; //!< interpolation type
|
||||
int inelastic_flag_; //!< inelastic competition flag
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <gsl/gsl>
|
||||
#include <string>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -28,14 +28,15 @@ public:
|
|||
vector<double> atoms; //!< Number of atoms for each nuclide
|
||||
vector<double> uncertainty; //!< Uncertainty on number of atoms
|
||||
int iterations; //!< Number of iterations needed to obtain the results
|
||||
}; // Results for a single domain
|
||||
}; // Results for a single domain
|
||||
|
||||
// Constructors
|
||||
VolumeCalculation(pugi::xml_node node);
|
||||
|
||||
// Methods
|
||||
|
||||
//! \brief Stochastically determine the volume of a set of domains along with the
|
||||
//! \brief Stochastically determine the volume of a set of domains along with
|
||||
//! the
|
||||
//! average number densities of nuclides within the domain
|
||||
//
|
||||
//! \return Vector of results for each user-specified domain
|
||||
|
|
@ -49,20 +50,17 @@ public:
|
|||
const std::string& filename, const vector<Result>& results) const;
|
||||
|
||||
// Tally filter and map types
|
||||
enum class TallyDomain {
|
||||
UNIVERSE,
|
||||
MATERIAL,
|
||||
CELL
|
||||
};
|
||||
enum class TallyDomain { UNIVERSE, MATERIAL, CELL };
|
||||
|
||||
// Data members
|
||||
TallyDomain domain_type_; //!< Type of domain (cell, material, etc.)
|
||||
size_t n_samples_; //!< Number of samples to use
|
||||
size_t n_samples_; //!< Number of samples to use
|
||||
double threshold_ {-1.0}; //!< Error threshold for domain volumes
|
||||
TriggerMetric trigger_type_ {TriggerMetric::not_active}; //!< Trigger metric for the volume calculation
|
||||
Position lower_left_; //!< Lower-left position of bounding box
|
||||
Position upper_right_; //!< Upper-right position of bounding box
|
||||
vector<int> domain_ids_; //!< IDs of domains to find volumes of
|
||||
TriggerMetric trigger_type_ {
|
||||
TriggerMetric::not_active}; //!< Trigger metric for the volume calculation
|
||||
Position lower_left_; //!< Lower-left position of bounding box
|
||||
Position upper_right_; //!< Upper-right position of bounding box
|
||||
vector<int> domain_ids_; //!< IDs of domains to find volumes of
|
||||
|
||||
private:
|
||||
//! \brief Check whether a material has already been hit for a given domain.
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class WindowedMultipole {
|
|||
public:
|
||||
// Types
|
||||
struct WindowInfo {
|
||||
int index_start; // Index of starting pole
|
||||
int index_end; // Index of ending pole
|
||||
int index_start; // Index of starting pole
|
||||
int index_end; // Index of ending pole
|
||||
bool broaden_poly; // Whether to broaden polynomial curvefit
|
||||
};
|
||||
|
||||
|
|
@ -54,7 +54,8 @@ public:
|
|||
//!
|
||||
//! \param E Incident neutron energy in [eV]
|
||||
//! \param sqrtkT Square root of temperature times Boltzmann constant
|
||||
//! \return Tuple of elastic scattering, absorption, and fission cross sections in [b]
|
||||
//! \return Tuple of elastic scattering, absorption, and fission cross
|
||||
//! sections in [b]
|
||||
std::tuple<double, double, double> evaluate(double E, double sqrtkT) const;
|
||||
|
||||
//! \brief Evaluates the windowed multipole equations for the derivative of
|
||||
|
|
@ -65,18 +66,20 @@ public:
|
|||
//! \param sqrtkT Square root of temperature times Boltzmann constant
|
||||
//! \return Tuple of derivatives of elastic scattering, absorption, and
|
||||
//! fission cross sections in [b/K]
|
||||
std::tuple<double, double, double> evaluate_deriv(double E, double sqrtkT) const;
|
||||
std::tuple<double, double, double> evaluate_deriv(
|
||||
double E, double sqrtkT) const;
|
||||
|
||||
// Data members
|
||||
std::string name_; //!< Name of nuclide
|
||||
double E_min_; //!< Minimum energy in [eV]
|
||||
double E_max_; //!< Maximum energy in [eV]
|
||||
double sqrt_awr_; //!< Square root of atomic weight ratio
|
||||
double inv_spacing_; //!< 1 / spacing in sqrt(E) space
|
||||
int fit_order_; //!< Order of the fit
|
||||
bool fissionable_; //!< Is the nuclide fissionable?
|
||||
vector<WindowInfo> window_info_; // Information about a window
|
||||
xt::xtensor<double, 3> curvefit_; // Curve fit coefficients (window, poly order, reaction)
|
||||
std::string name_; //!< Name of nuclide
|
||||
double E_min_; //!< Minimum energy in [eV]
|
||||
double E_max_; //!< Maximum energy in [eV]
|
||||
double sqrt_awr_; //!< Square root of atomic weight ratio
|
||||
double inv_spacing_; //!< 1 / spacing in sqrt(E) space
|
||||
int fit_order_; //!< Order of the fit
|
||||
bool fissionable_; //!< Is the nuclide fissionable?
|
||||
vector<WindowInfo> window_info_; // Information about a window
|
||||
xt::xtensor<double, 3>
|
||||
curvefit_; // Curve fit coefficients (window, poly order, reaction)
|
||||
xt::xtensor<std::complex<double>, 2> data_; //!< Poles and residues
|
||||
|
||||
// Constant data
|
||||
|
|
@ -99,7 +102,6 @@ void check_wmp_version(hid_t file);
|
|||
//! \param[in] i_nuclide Index in global nuclides array
|
||||
void read_multipole_data(int i_nuclide);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//! Doppler broadens the windowed multipole curvefit.
|
||||
//!
|
||||
|
|
@ -111,7 +113,8 @@ void read_multipole_data(int i_nuclide);
|
|||
//! \param factors The output leading coefficient
|
||||
//==============================================================================
|
||||
|
||||
extern "C" void broaden_wmp_polynomials(double E, double dopp, int n, double factors[]);
|
||||
extern "C" void broaden_wmp_polynomials(
|
||||
double E, double dopp, int n, double factors[]);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -6,21 +6,20 @@
|
|||
#include <string>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xarray.hpp"
|
||||
#include "xtensor/xadapt.hpp"
|
||||
#include "xtensor/xarray.hpp"
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
inline bool
|
||||
check_for_node(pugi::xml_node node, const char *name)
|
||||
inline bool check_for_node(pugi::xml_node node, const char* name)
|
||||
{
|
||||
return node.attribute(name) || node.child(name);
|
||||
}
|
||||
|
||||
std::string get_node_value(pugi::xml_node node, const char* name,
|
||||
bool lowercase=false, bool strip=false);
|
||||
bool lowercase = false, bool strip = false);
|
||||
|
||||
bool get_node_value_bool(pugi::xml_node node, const char* name);
|
||||
|
||||
|
|
@ -41,9 +40,9 @@ vector<T> get_node_array(
|
|||
return values;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
xt::xarray<T> get_node_xarray(pugi::xml_node node, const char* name,
|
||||
bool lowercase=false)
|
||||
template<typename T>
|
||||
xt::xarray<T> get_node_xarray(
|
||||
pugi::xml_node node, const char* name, bool lowercase = false)
|
||||
{
|
||||
vector<T> v = get_node_array<T>(node, name, lowercase);
|
||||
vector<std::size_t> shape = {v.size()};
|
||||
|
|
|
|||
|
|
@ -28,127 +28,117 @@ enum class AngleDistributionType {
|
|||
|
||||
class XsData {
|
||||
|
||||
private:
|
||||
private:
|
||||
//! \brief Reads scattering data from the HDF5 file
|
||||
void scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang,
|
||||
AngleDistributionType scatter_format,
|
||||
AngleDistributionType final_scatter_format, int order_data);
|
||||
|
||||
//! \brief Reads scattering data from the HDF5 file
|
||||
void
|
||||
scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, AngleDistributionType scatter_format,
|
||||
AngleDistributionType final_scatter_format, int order_data);
|
||||
//! \brief Reads fission data from the HDF5 file
|
||||
void fission_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic);
|
||||
|
||||
//! \brief Reads fission data from the HDF5 file
|
||||
void
|
||||
fission_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic);
|
||||
//! \brief Reads fission data formatted as chi and nu-fission vectors from
|
||||
// the HDF5 file when beta is provided.
|
||||
void fission_vector_beta_from_hdf5(
|
||||
hid_t xsdata_grp, size_t n_ang, bool is_isotropic);
|
||||
|
||||
//! \brief Reads fission data formatted as chi and nu-fission vectors from
|
||||
// the HDF5 file when beta is provided.
|
||||
void
|
||||
fission_vector_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic);
|
||||
//! \brief Reads fission data formatted as chi and nu-fission vectors from
|
||||
// the HDF5 file when beta is not provided.
|
||||
void fission_vector_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
|
||||
//! \brief Reads fission data formatted as chi and nu-fission vectors from
|
||||
// the HDF5 file when beta is not provided.
|
||||
void
|
||||
fission_vector_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
//! \brief Reads fission data formatted as chi and nu-fission vectors from
|
||||
// the HDF5 file when no delayed data is provided.
|
||||
void fission_vector_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
|
||||
//! \brief Reads fission data formatted as chi and nu-fission vectors from
|
||||
// the HDF5 file when no delayed data is provided.
|
||||
void
|
||||
fission_vector_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
//! \brief Reads fission data formatted as a nu-fission matrix from
|
||||
// the HDF5 file when beta is provided.
|
||||
void fission_matrix_beta_from_hdf5(
|
||||
hid_t xsdata_grp, size_t n_ang, bool is_isotropic);
|
||||
|
||||
//! \brief Reads fission data formatted as a nu-fission matrix from
|
||||
// the HDF5 file when beta is provided.
|
||||
void
|
||||
fission_matrix_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, bool is_isotropic);
|
||||
//! \brief Reads fission data formatted as a nu-fission matrix from
|
||||
// the HDF5 file when beta is not provided.
|
||||
void fission_matrix_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
|
||||
//! \brief Reads fission data formatted as a nu-fission matrix from
|
||||
// the HDF5 file when beta is not provided.
|
||||
void
|
||||
fission_matrix_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
//! \brief Reads fission data formatted as a nu-fission matrix from
|
||||
// the HDF5 file when no delayed data is provided.
|
||||
void fission_matrix_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
|
||||
//! \brief Reads fission data formatted as a nu-fission matrix from
|
||||
// the HDF5 file when no delayed data is provided.
|
||||
void
|
||||
fission_matrix_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang);
|
||||
//! Number of energy and delayed neutron groups
|
||||
size_t n_g_, n_dg_;
|
||||
|
||||
//! Number of energy and delayed neutron groups
|
||||
size_t n_g_, n_dg_;
|
||||
public:
|
||||
// The following quantities have the following dimensions:
|
||||
// [angle][incoming group]
|
||||
xt::xtensor<double, 2> total;
|
||||
xt::xtensor<double, 2> absorption;
|
||||
xt::xtensor<double, 2> nu_fission;
|
||||
xt::xtensor<double, 2> prompt_nu_fission;
|
||||
xt::xtensor<double, 2> kappa_fission;
|
||||
xt::xtensor<double, 2> fission;
|
||||
xt::xtensor<double, 2> inverse_velocity;
|
||||
|
||||
public:
|
||||
// decay_rate has the following dimensions:
|
||||
// [angle][delayed group]
|
||||
xt::xtensor<double, 2> decay_rate;
|
||||
// delayed_nu_fission has the following dimensions:
|
||||
// [angle][delayed group][incoming group]
|
||||
xt::xtensor<double, 3> delayed_nu_fission;
|
||||
// chi_prompt has the following dimensions:
|
||||
// [angle][incoming group][outgoing group]
|
||||
xt::xtensor<double, 3> chi_prompt;
|
||||
// chi_delayed has the following dimensions:
|
||||
// [angle][incoming group][outgoing group][delayed group]
|
||||
xt::xtensor<double, 4> chi_delayed;
|
||||
// scatter has the following dimensions: [angle]
|
||||
vector<std::shared_ptr<ScattData>> scatter;
|
||||
|
||||
// The following quantities have the following dimensions:
|
||||
// [angle][incoming group]
|
||||
xt::xtensor<double, 2> total;
|
||||
xt::xtensor<double, 2> absorption;
|
||||
xt::xtensor<double, 2> nu_fission;
|
||||
xt::xtensor<double, 2> prompt_nu_fission;
|
||||
xt::xtensor<double, 2> kappa_fission;
|
||||
xt::xtensor<double, 2> fission;
|
||||
xt::xtensor<double, 2> inverse_velocity;
|
||||
XsData() = default;
|
||||
|
||||
// decay_rate has the following dimensions:
|
||||
// [angle][delayed group]
|
||||
xt::xtensor<double, 2> decay_rate;
|
||||
// delayed_nu_fission has the following dimensions:
|
||||
// [angle][delayed group][incoming group]
|
||||
xt::xtensor<double, 3> delayed_nu_fission;
|
||||
// chi_prompt has the following dimensions:
|
||||
// [angle][incoming group][outgoing group]
|
||||
xt::xtensor<double, 3> chi_prompt;
|
||||
// chi_delayed has the following dimensions:
|
||||
// [angle][incoming group][outgoing group][delayed group]
|
||||
xt::xtensor<double, 4> chi_delayed;
|
||||
// scatter has the following dimensions: [angle]
|
||||
vector<std::shared_ptr<ScattData>> scatter;
|
||||
//! \brief Constructs the XsData object metadata.
|
||||
//!
|
||||
//! @param num_groups Number of energy groups.
|
||||
//! @param num_delayed_groups Number of delayed groups.
|
||||
//! @param fissionable Is this a fissionable data set or not.
|
||||
//! @param scatter_format The scattering representation of the file.
|
||||
//! @param n_pol Number of polar angles.
|
||||
//! @param n_azi Number of azimuthal angles.
|
||||
//! @param n_groups Number of energy groups.
|
||||
//! @param n_d_groups Number of delayed neutron groups.
|
||||
XsData(bool fissionable, AngleDistributionType scatter_format, int n_pol,
|
||||
int n_azi, size_t n_groups, size_t n_d_groups);
|
||||
|
||||
XsData() = default;
|
||||
//! \brief Loads the XsData object from the HDF5 file
|
||||
//!
|
||||
//! @param xs_id HDF5 group id for the cross section data.
|
||||
//! @param fissionable Is this a fissionable data set or not.
|
||||
//! @param scatter_format The scattering representation of the file.
|
||||
//! @param final_scatter_format The scattering representation after reading;
|
||||
//! this is different from scatter_format if converting a Legendre to
|
||||
//! a tabular representation.
|
||||
//! @param order_data The dimensionality of the scattering data in the file.
|
||||
//! @param is_isotropic Is this an isotropic or angular with respect to
|
||||
//! the incoming particle.
|
||||
//! @param n_pol Number of polar angles.
|
||||
//! @param n_azi Number of azimuthal angles.
|
||||
void from_hdf5(hid_t xsdata_grp, bool fissionable,
|
||||
AngleDistributionType scatter_format,
|
||||
AngleDistributionType final_scatter_format, int order_data,
|
||||
bool is_isotropic, int n_pol, int n_azi);
|
||||
|
||||
//! \brief Constructs the XsData object metadata.
|
||||
//!
|
||||
//! @param num_groups Number of energy groups.
|
||||
//! @param num_delayed_groups Number of delayed groups.
|
||||
//! @param fissionable Is this a fissionable data set or not.
|
||||
//! @param scatter_format The scattering representation of the file.
|
||||
//! @param n_pol Number of polar angles.
|
||||
//! @param n_azi Number of azimuthal angles.
|
||||
//! @param n_groups Number of energy groups.
|
||||
//! @param n_d_groups Number of delayed neutron groups.
|
||||
XsData(bool fissionable, AngleDistributionType scatter_format, int n_pol,
|
||||
int n_azi, size_t n_groups, size_t n_d_groups);
|
||||
//! \brief Combines the microscopic data to a macroscopic object.
|
||||
//!
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
void combine(const vector<XsData*>& those_xs, const vector<double>& scalars);
|
||||
|
||||
//! \brief Loads the XsData object from the HDF5 file
|
||||
//!
|
||||
//! @param xs_id HDF5 group id for the cross section data.
|
||||
//! @param fissionable Is this a fissionable data set or not.
|
||||
//! @param scatter_format The scattering representation of the file.
|
||||
//! @param final_scatter_format The scattering representation after reading;
|
||||
//! this is different from scatter_format if converting a Legendre to
|
||||
//! a tabular representation.
|
||||
//! @param order_data The dimensionality of the scattering data in the file.
|
||||
//! @param is_isotropic Is this an isotropic or angular with respect to
|
||||
//! the incoming particle.
|
||||
//! @param n_pol Number of polar angles.
|
||||
//! @param n_azi Number of azimuthal angles.
|
||||
void
|
||||
from_hdf5(hid_t xsdata_grp, bool fissionable, AngleDistributionType scatter_format,
|
||||
AngleDistributionType final_scatter_format, int order_data, bool is_isotropic, int n_pol,
|
||||
int n_azi);
|
||||
|
||||
//! \brief Combines the microscopic data to a macroscopic object.
|
||||
//!
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
void combine(
|
||||
const vector<XsData*>& those_xs, const vector<double>& scalars);
|
||||
|
||||
//! \brief Checks to see if this and that are able to be combined
|
||||
//!
|
||||
//! This comparison is used when building macroscopic cross sections
|
||||
//! from microscopic cross sections.
|
||||
//! @param that The other XsData to compare to this one.
|
||||
//! @return True if they can be combined.
|
||||
bool
|
||||
equiv(const XsData& that);
|
||||
//! \brief Checks to see if this and that are able to be combined
|
||||
//!
|
||||
//! This comparison is used when building macroscopic cross sections
|
||||
//! from microscopic cross sections.
|
||||
//! @param that The other XsData to compare to this one.
|
||||
//! @return True if they can be combined.
|
||||
bool equiv(const XsData& that);
|
||||
};
|
||||
|
||||
|
||||
} //namespace openmc
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_XSDATA_H
|
||||
|
|
|
|||
21
src/bank.cpp
21
src/bank.cpp
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -20,10 +19,11 @@ vector<SourceSite> source_bank;
|
|||
|
||||
SharedArray<SourceSite> surf_source_bank;
|
||||
|
||||
// The fission bank is allocated as a SharedArray, rather than a vector, as it will
|
||||
// be shared by all threads in the simulation. It will be allocated to a fixed
|
||||
// maximum capacity in the init_fission_bank() function. Then, Elements will be
|
||||
// added to it by using SharedArray's special thread_safe_append() function.
|
||||
// The fission bank is allocated as a SharedArray, rather than a vector, as it
|
||||
// will be shared by all threads in the simulation. It will be allocated to a
|
||||
// fixed maximum capacity in the init_fission_bank() function. Then, Elements
|
||||
// will be added to it by using SharedArray's special thread_safe_append()
|
||||
// function.
|
||||
SharedArray<SourceSite> fission_bank;
|
||||
|
||||
// Each entry in this vector corresponds to the number of progeny produced
|
||||
|
|
@ -69,7 +69,7 @@ void sort_fission_bank()
|
|||
int64_t tmp = simulation::progeny_per_particle[0];
|
||||
simulation::progeny_per_particle[0] = 0;
|
||||
for (int64_t i = 1; i < simulation::progeny_per_particle.size(); i++) {
|
||||
int64_t value = simulation::progeny_per_particle[i-1] + tmp;
|
||||
int64_t value = simulation::progeny_per_particle[i - 1] + tmp;
|
||||
tmp = simulation::progeny_per_particle[i];
|
||||
simulation::progeny_per_particle[i] = value;
|
||||
}
|
||||
|
|
@ -84,7 +84,8 @@ void sort_fission_bank()
|
|||
vector<SourceSite> sorted_bank_holder;
|
||||
|
||||
// If there is not enough space, allocate a temporary vector and point to it
|
||||
if (simulation::fission_bank.size() > simulation::fission_bank.capacity() / 2) {
|
||||
if (simulation::fission_bank.size() >
|
||||
simulation::fission_bank.capacity() / 2) {
|
||||
sorted_bank_holder.resize(simulation::fission_bank.size());
|
||||
sorted_bank = sorted_bank_holder.data();
|
||||
} else { // otherwise, point sorted_bank to unused portion of the fission bank
|
||||
|
|
@ -98,14 +99,14 @@ void sort_fission_bank()
|
|||
int64_t idx = simulation::progeny_per_particle[offset] + site.progeny_id;
|
||||
if (idx >= simulation::fission_bank.size()) {
|
||||
fatal_error("Mismatch detected between sum of all particle progeny and "
|
||||
"shared fission bank size.");
|
||||
"shared fission bank size.");
|
||||
}
|
||||
sorted_bank[idx] = site;
|
||||
}
|
||||
|
||||
// Copy sorted bank into the fission bank
|
||||
std::copy(sorted_bank, sorted_bank + simulation::fission_bank.size(),
|
||||
simulation::fission_bank.data());
|
||||
simulation::fission_bank.data());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -141,7 +142,7 @@ extern "C" int openmc_fission_bank(void** ptr, int64_t* n)
|
|||
return OPENMC_E_ALLOCATE;
|
||||
} else {
|
||||
*ptr = simulation::fission_bank.data();
|
||||
*n = simulation::fission_bank.size();
|
||||
*n = simulation::fission_bank.size();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ namespace openmc {
|
|||
// VacuumBC implementation
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
VacuumBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
void VacuumBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
p.cross_vacuum_bc(surf);
|
||||
}
|
||||
|
|
@ -24,8 +23,7 @@ VacuumBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
// ReflectiveBC implementation
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
void ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
Direction u = surf.reflect(p.r(), p.u(), &p);
|
||||
u /= u.norm();
|
||||
|
|
@ -37,8 +35,7 @@ ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
// WhiteBC implementation
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
WhiteBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
void WhiteBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
Direction u = surf.diffuse_reflect(p.r(), p.u(), p.current_seed());
|
||||
u /= u.norm();
|
||||
|
|
@ -62,7 +59,8 @@ TranslationalPeriodicBC::TranslationalPeriodicBC(int i_surf, int j_surf)
|
|||
} else if (const auto* ptr = dynamic_cast<const SurfaceZPlane*>(&surf1)) {
|
||||
} else if (const auto* ptr = dynamic_cast<const SurfacePlane*>(&surf1)) {
|
||||
} else {
|
||||
throw std::invalid_argument(fmt::format("Surface {} is an invalid type for "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Surface {} is an invalid type for "
|
||||
"translational periodic BCs. Only planes are supported for these BCs.",
|
||||
surf1.id_));
|
||||
}
|
||||
|
|
@ -73,7 +71,8 @@ TranslationalPeriodicBC::TranslationalPeriodicBC(int i_surf, int j_surf)
|
|||
} else if (const auto* ptr = dynamic_cast<const SurfaceZPlane*>(&surf2)) {
|
||||
} else if (const auto* ptr = dynamic_cast<const SurfacePlane*>(&surf2)) {
|
||||
} else {
|
||||
throw std::invalid_argument(fmt::format("Surface {} is an invalid type for "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Surface {} is an invalid type for "
|
||||
"translational periodic BCs. Only planes are supported for these BCs.",
|
||||
surf2.id_));
|
||||
}
|
||||
|
|
@ -109,8 +108,8 @@ TranslationalPeriodicBC::TranslationalPeriodicBC(int i_surf, int j_surf)
|
|||
translation_ = u * (d2 - d1);
|
||||
}
|
||||
|
||||
void
|
||||
TranslationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
void TranslationalPeriodicBC::handle_particle(
|
||||
Particle& p, const Surface& surf) const
|
||||
{
|
||||
// TODO: off-by-one on surface indices throughout this function.
|
||||
int i_particle_surf = std::abs(p.surface()) - 1;
|
||||
|
|
@ -126,7 +125,8 @@ TranslationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
new_r = p.r() - translation_;
|
||||
new_surface = p.surface() > 0 ? i_surf_ + 1 : -(i_surf_ + 1);
|
||||
} else {
|
||||
throw std::runtime_error("Called BoundaryCondition::handle_particle after "
|
||||
throw std::runtime_error(
|
||||
"Called BoundaryCondition::handle_particle after "
|
||||
"hitting a surface, but that surface is not recognized by the BC.");
|
||||
}
|
||||
|
||||
|
|
@ -153,9 +153,11 @@ RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf)
|
|||
} else if (const auto* ptr = dynamic_cast<const SurfacePlane*>(&surf1)) {
|
||||
surf1_is_xyplane = false;
|
||||
} else {
|
||||
throw std::invalid_argument(fmt::format("Surface {} is an invalid type for "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Surface {} is an invalid type for "
|
||||
"rotational periodic BCs. Only x-planes, y-planes, or general planes "
|
||||
"(that are perpendicular to z) are supported for these BCs.", surf1.id_));
|
||||
"(that are perpendicular to z) are supported for these BCs.",
|
||||
surf1.id_));
|
||||
}
|
||||
|
||||
// Check the type of the second surface
|
||||
|
|
@ -167,9 +169,11 @@ RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf)
|
|||
} else if (const auto* ptr = dynamic_cast<const SurfacePlane*>(&surf2)) {
|
||||
surf2_is_xyplane = false;
|
||||
} else {
|
||||
throw std::invalid_argument(fmt::format("Surface {} is an invalid type for "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Surface {} is an invalid type for "
|
||||
"rotational periodic BCs. Only x-planes, y-planes, or general planes "
|
||||
"(that are perpendicular to z) are supported for these BCs.", surf2.id_));
|
||||
"(that are perpendicular to z) are supported for these BCs.",
|
||||
surf2.id_));
|
||||
}
|
||||
|
||||
// Compute the surface normal vectors and make sure they are perpendicular
|
||||
|
|
@ -177,26 +181,34 @@ RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf)
|
|||
Direction norm1 = surf1.normal({0, 0, 0});
|
||||
Direction norm2 = surf2.normal({0, 0, 0});
|
||||
if (std::abs(norm1.z) > FP_PRECISION) {
|
||||
throw std::invalid_argument(fmt::format("Rotational periodic BCs are only "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Rotational periodic BCs are only "
|
||||
"supported for rotations about the z-axis, but surface {} is not "
|
||||
"perpendicular to the z-axis.", surf1.id_));
|
||||
"perpendicular to the z-axis.",
|
||||
surf1.id_));
|
||||
}
|
||||
if (std::abs(norm2.z) > FP_PRECISION) {
|
||||
throw std::invalid_argument(fmt::format("Rotational periodic BCs are only "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Rotational periodic BCs are only "
|
||||
"supported for rotations about the z-axis, but surface {} is not "
|
||||
"perpendicular to the z-axis.", surf2.id_));
|
||||
"perpendicular to the z-axis.",
|
||||
surf2.id_));
|
||||
}
|
||||
|
||||
// Make sure both surfaces intersect the origin
|
||||
if (std::abs(surf1.evaluate({0, 0, 0})) > FP_COINCIDENT) {
|
||||
throw std::invalid_argument(fmt::format("Rotational periodic BCs are only "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Rotational periodic BCs are only "
|
||||
"supported for rotations about the origin, but surface {} does not "
|
||||
"intersect the origin.", surf1.id_));
|
||||
"intersect the origin.",
|
||||
surf1.id_));
|
||||
}
|
||||
if (std::abs(surf2.evaluate({0, 0, 0})) > FP_COINCIDENT) {
|
||||
throw std::invalid_argument(fmt::format("Rotational periodic BCs are only "
|
||||
throw std::invalid_argument(fmt::format(
|
||||
"Rotational periodic BCs are only "
|
||||
"supported for rotations about the origin, but surface {} does not "
|
||||
"intersect the origin.", surf2.id_));
|
||||
"intersect the origin.",
|
||||
surf2.id_));
|
||||
}
|
||||
|
||||
// Compute the BC rotation angle. Here it is assumed that both surface
|
||||
|
|
@ -212,14 +224,15 @@ RotationalPeriodicBC::RotationalPeriodicBC(int i_surf, int j_surf)
|
|||
// Warn the user if the angle does not evenly divide a circle
|
||||
double rem = std::abs(std::remainder((2 * PI / angle_), 1.0));
|
||||
if (rem > FP_REL_PRECISION && rem < 1 - FP_REL_PRECISION) {
|
||||
warning(fmt::format("Rotational periodic BC specified with a rotation "
|
||||
warning(fmt::format(
|
||||
"Rotational periodic BC specified with a rotation "
|
||||
"angle of {} degrees which does not evenly divide 360 degrees.",
|
||||
angle_ * 180 / PI));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RotationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
void RotationalPeriodicBC::handle_particle(
|
||||
Particle& p, const Surface& surf) const
|
||||
{
|
||||
// TODO: off-by-one on surface indices throughout this function.
|
||||
int i_particle_surf = std::abs(p.surface()) - 1;
|
||||
|
|
@ -236,7 +249,8 @@ RotationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
theta = -angle_;
|
||||
new_surface = p.surface() > 0 ? -(i_surf_ + 1) : i_surf_ + 1;
|
||||
} else {
|
||||
throw std::runtime_error("Called BoundaryCondition::handle_particle after "
|
||||
throw std::runtime_error(
|
||||
"Called BoundaryCondition::handle_particle after "
|
||||
"hitting a surface, but that surface is not recognized by the BC.");
|
||||
}
|
||||
|
||||
|
|
@ -246,13 +260,9 @@ RotationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
double cos_theta = std::cos(theta);
|
||||
double sin_theta = std::sin(theta);
|
||||
Position new_r = {
|
||||
cos_theta*r.x - sin_theta*r.y,
|
||||
sin_theta*r.x + cos_theta*r.y,
|
||||
r.z};
|
||||
cos_theta * r.x - sin_theta * r.y, sin_theta * r.x + cos_theta * r.y, r.z};
|
||||
Direction new_u = {
|
||||
cos_theta*u.x - sin_theta*u.y,
|
||||
sin_theta*u.x + cos_theta*u.y,
|
||||
u.z};
|
||||
cos_theta * u.x - sin_theta * u.y, sin_theta * u.x + cos_theta * u.y, u.z};
|
||||
|
||||
// Pass the new location, direction, and surface to the particle.
|
||||
p.cross_periodic_bc(surf, new_r, new_u, new_surface);
|
||||
|
|
|
|||
|
|
@ -47,30 +47,32 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost)
|
|||
auto n_e = data::ttb_e_grid.size();
|
||||
|
||||
// Find the lower bounding index of the incident electron energy
|
||||
size_t j = lower_bound_index(data::ttb_e_grid.cbegin(),
|
||||
data::ttb_e_grid.cend(), e);
|
||||
if (j == n_e - 1) --j;
|
||||
size_t j =
|
||||
lower_bound_index(data::ttb_e_grid.cbegin(), data::ttb_e_grid.cend(), e);
|
||||
if (j == n_e - 1)
|
||||
--j;
|
||||
|
||||
// Get the interpolation bounds
|
||||
double e_l = data::ttb_e_grid(j);
|
||||
double e_r = data::ttb_e_grid(j+1);
|
||||
double e_r = data::ttb_e_grid(j + 1);
|
||||
double y_l = mat->yield(j);
|
||||
double y_r = mat->yield(j+1);
|
||||
double y_r = mat->yield(j + 1);
|
||||
|
||||
// Calculate the interpolation weight w_j+1 of the bremsstrahlung energy PDF
|
||||
// interpolated in log energy, which can be interpreted as the probability
|
||||
// of index j+1
|
||||
double f = (e - e_l)/(e_r - e_l);
|
||||
double f = (e - e_l) / (e_r - e_l);
|
||||
|
||||
// Get the photon number yield for the given energy using linear
|
||||
// interpolation on a log-log scale
|
||||
double y = std::exp(y_l + (y_r - y_l)*f);
|
||||
double y = std::exp(y_l + (y_r - y_l) * f);
|
||||
|
||||
// Sample number of secondary bremsstrahlung photons
|
||||
int n = y + prn(p.current_seed());
|
||||
|
||||
*E_lost = 0.0;
|
||||
if (n == 0) return;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
// Sample index of the tabulated PDF in the energy grid, j or j+1
|
||||
double c_max;
|
||||
|
|
@ -83,8 +85,8 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost)
|
|||
double p_l = mat->pdf(i_e, i_e - 1);
|
||||
double p_r = mat->pdf(i_e, i_e);
|
||||
double c_l = mat->cdf(i_e, i_e - 1);
|
||||
double a = std::log(p_r/p_l)/(e_r - e_l) + 1.0;
|
||||
c_max = c_l + std::exp(e_l)*p_l/a*(std::exp(a*(e - e_l)) - 1.0);
|
||||
double a = std::log(p_r / p_l) / (e_r - e_l) + 1.0;
|
||||
c_max = c_l + std::exp(e_l) * p_l / a * (std::exp(a * (e - e_l)) - 1.0);
|
||||
} else {
|
||||
i_e = j;
|
||||
|
||||
|
|
@ -96,7 +98,7 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost)
|
|||
for (int i = 0; i < n; ++i) {
|
||||
// Generate a random number r and determine the index i for which
|
||||
// cdf(i) <= r*cdf,max <= cdf(i+1)
|
||||
double c = prn(p.current_seed())*c_max;
|
||||
double c = prn(p.current_seed()) * c_max;
|
||||
int i_w = lower_bound_index(&mat->cdf(i_e, 0), &mat->cdf(i_e, 0) + i_e, c);
|
||||
|
||||
// Sample the photon energy
|
||||
|
|
@ -105,8 +107,9 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost)
|
|||
double p_l = mat->pdf(i_e, i_w);
|
||||
double p_r = mat->pdf(i_e, i_w + 1);
|
||||
double c_l = mat->cdf(i_e, i_w);
|
||||
double a = std::log(p_r/p_l)/(w_r - w_l) + 1.0;
|
||||
double w = std::exp(w_l)*std::pow(a*(c - c_l)/(std::exp(w_l)*p_l) + 1.0, 1.0/a);
|
||||
double a = std::log(p_r / p_l) / (w_r - w_l) + 1.0;
|
||||
double w = std::exp(w_l) *
|
||||
std::pow(a * (c - c_l) / (std::exp(w_l) * p_l) + 1.0, 1.0 / a);
|
||||
|
||||
if (w > settings::energy_cutoff[photon]) {
|
||||
// Create secondary photon
|
||||
|
|
|
|||
302
src/cell.cpp
302
src/cell.cpp
|
|
@ -31,11 +31,11 @@ namespace openmc {
|
|||
//==============================================================================
|
||||
|
||||
namespace model {
|
||||
std::unordered_map<int32_t, int32_t> cell_map;
|
||||
vector<unique_ptr<Cell>> cells;
|
||||
std::unordered_map<int32_t, int32_t> cell_map;
|
||||
vector<unique_ptr<Cell>> cells;
|
||||
|
||||
std::unordered_map<int32_t, int32_t> universe_map;
|
||||
vector<unique_ptr<Universe>> universes;
|
||||
std::unordered_map<int32_t, int32_t> universe_map;
|
||||
vector<unique_ptr<Universe>> universes;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -54,7 +54,7 @@ vector<int32_t> tokenize(const std::string region_spec)
|
|||
}
|
||||
|
||||
// Parse all halfspaces and operators except for intersection (whitespace).
|
||||
for (int i = 0; i < region_spec.size(); ) {
|
||||
for (int i = 0; i < region_spec.size();) {
|
||||
if (region_spec[i] == '(') {
|
||||
tokens.push_back(OP_LEFT_PAREN);
|
||||
i++;
|
||||
|
|
@ -71,34 +71,37 @@ vector<int32_t> tokenize(const std::string region_spec)
|
|||
tokens.push_back(OP_COMPLEMENT);
|
||||
i++;
|
||||
|
||||
} else if (region_spec[i] == '-' || region_spec[i] == '+'
|
||||
|| std::isdigit(region_spec[i])) {
|
||||
} else if (region_spec[i] == '-' || region_spec[i] == '+' ||
|
||||
std::isdigit(region_spec[i])) {
|
||||
// This is the start of a halfspace specification. Iterate j until we
|
||||
// find the end, then push-back everything between i and j.
|
||||
int j = i + 1;
|
||||
while (j < region_spec.size() && std::isdigit(region_spec[j])) {j++;}
|
||||
tokens.push_back(std::stoi(region_spec.substr(i, j-i)));
|
||||
while (j < region_spec.size() && std::isdigit(region_spec[j])) {
|
||||
j++;
|
||||
}
|
||||
tokens.push_back(std::stoi(region_spec.substr(i, j - i)));
|
||||
i = j;
|
||||
|
||||
} else if (std::isspace(region_spec[i])) {
|
||||
i++;
|
||||
|
||||
} else {
|
||||
auto err_msg = fmt::format(
|
||||
"Region specification contains invalid character, \"{}\"", region_spec[i]);
|
||||
auto err_msg =
|
||||
fmt::format("Region specification contains invalid character, \"{}\"",
|
||||
region_spec[i]);
|
||||
fatal_error(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Add in intersection operators where a missing operator is needed.
|
||||
int i = 0;
|
||||
while (i < tokens.size()-1) {
|
||||
while (i < tokens.size() - 1) {
|
||||
bool left_compat {(tokens[i] < OP_UNION) || (tokens[i] == OP_RIGHT_PAREN)};
|
||||
bool right_compat {(tokens[i+1] < OP_UNION)
|
||||
|| (tokens[i+1] == OP_LEFT_PAREN)
|
||||
|| (tokens[i+1] == OP_COMPLEMENT)};
|
||||
bool right_compat {(tokens[i + 1] < OP_UNION) ||
|
||||
(tokens[i + 1] == OP_LEFT_PAREN) ||
|
||||
(tokens[i + 1] == OP_COMPLEMENT)};
|
||||
if (left_compat && right_compat) {
|
||||
tokens.insert(tokens.begin()+i+1, OP_INTERSECTION);
|
||||
tokens.insert(tokens.begin() + i + 1, OP_INTERSECTION);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
@ -126,9 +129,8 @@ vector<int32_t> generate_rpn(int32_t cell_id, vector<int32_t> infix)
|
|||
while (stack.size() > 0) {
|
||||
int32_t op = stack.back();
|
||||
|
||||
if (op < OP_RIGHT_PAREN &&
|
||||
((token == OP_COMPLEMENT && token < op) ||
|
||||
(token != OP_COMPLEMENT && token <= op))) {
|
||||
if (op < OP_RIGHT_PAREN && ((token == OP_COMPLEMENT && token < op) ||
|
||||
(token != OP_COMPLEMENT && token <= op))) {
|
||||
// While there is an operator, op, on top of the stack, if the token
|
||||
// is left-associative and its precedence is less than or equal to
|
||||
// that of op or if the token is right-associative and its precedence
|
||||
|
|
@ -156,7 +158,8 @@ vector<int32_t> generate_rpn(int32_t cell_id, vector<int32_t> infix)
|
|||
// means there are mismatched parentheses.
|
||||
if (it == stack.rend()) {
|
||||
fatal_error(fmt::format(
|
||||
"Mismatched parentheses in region specification for cell {}", cell_id));
|
||||
"Mismatched parentheses in region specification for cell {}",
|
||||
cell_id));
|
||||
}
|
||||
rpn.push_back(stack.back());
|
||||
stack.pop_back();
|
||||
|
|
@ -187,8 +190,7 @@ vector<int32_t> generate_rpn(int32_t cell_id, vector<int32_t> infix)
|
|||
// Universe implementation
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
Universe::to_hdf5(hid_t universes_group) const
|
||||
void Universe::to_hdf5(hid_t universes_group) const
|
||||
{
|
||||
// Create a group for this universe.
|
||||
auto group = create_group(universes_group, fmt::format("universe {}", id_));
|
||||
|
|
@ -199,39 +201,39 @@ Universe::to_hdf5(hid_t universes_group) const
|
|||
// Write the contained cells.
|
||||
if (cells_.size() > 0) {
|
||||
vector<int32_t> cell_ids;
|
||||
for (auto i_cell : cells_) cell_ids.push_back(model::cells[i_cell]->id_);
|
||||
for (auto i_cell : cells_)
|
||||
cell_ids.push_back(model::cells[i_cell]->id_);
|
||||
write_dataset(group, "cells", cell_ids);
|
||||
}
|
||||
|
||||
close_group(group);
|
||||
}
|
||||
|
||||
bool
|
||||
Universe::find_cell(Particle& p) const {
|
||||
bool Universe::find_cell(Particle& p) const
|
||||
{
|
||||
const auto& cells {
|
||||
!partitioner_
|
||||
? cells_
|
||||
: partitioner_->get_cells(p.r_local(), p.u_local())
|
||||
};
|
||||
!partitioner_ ? cells_ : partitioner_->get_cells(p.r_local(), p.u_local())};
|
||||
|
||||
for (auto it = cells.begin(); it != cells.end(); it++) {
|
||||
int32_t i_cell = *it;
|
||||
int32_t i_univ = p.coord(p.n_coord()-1).universe;
|
||||
if (model::cells[i_cell]->universe_ != i_univ) continue;
|
||||
int32_t i_univ = p.coord(p.n_coord() - 1).universe;
|
||||
if (model::cells[i_cell]->universe_ != i_univ)
|
||||
continue;
|
||||
|
||||
// Check if this cell contains the particle;
|
||||
Position r {p.r_local()};
|
||||
Direction u {p.u_local()};
|
||||
auto surf = p.surface();
|
||||
if (model::cells[i_cell]->contains(r, u, surf)) {
|
||||
p.coord(p.n_coord()-1).cell = i_cell;
|
||||
p.coord(p.n_coord() - 1).cell = i_cell;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BoundingBox Universe::bounding_box() const {
|
||||
BoundingBox Universe::bounding_box() const
|
||||
{
|
||||
BoundingBox bbox = {INFTY, -INFTY, INFTY, -INFTY, INFTY, -INFTY};
|
||||
if (cells_.size() == 0) {
|
||||
return {};
|
||||
|
|
@ -248,8 +250,8 @@ BoundingBox Universe::bounding_box() const {
|
|||
// Cell implementation
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
Cell::set_rotation(const vector<double>& rot) {
|
||||
void Cell::set_rotation(const vector<double>& rot)
|
||||
{
|
||||
if (fill_ == C_NONE) {
|
||||
fatal_error(fmt::format("Cannot apply a rotation to cell {}"
|
||||
" because it is not filled with another universe",
|
||||
|
|
@ -290,40 +292,37 @@ Cell::set_rotation(const vector<double>& rot) {
|
|||
}
|
||||
}
|
||||
|
||||
double
|
||||
Cell::temperature(int32_t instance) const
|
||||
double Cell::temperature(int32_t instance) const
|
||||
{
|
||||
if (sqrtkT_.size() < 1) {
|
||||
throw std::runtime_error{"Cell temperature has not yet been set."};
|
||||
throw std::runtime_error {"Cell temperature has not yet been set."};
|
||||
}
|
||||
|
||||
if (instance >= 0) {
|
||||
double sqrtkT = sqrtkT_.size() == 1 ?
|
||||
sqrtkT_.at(0) :
|
||||
sqrtkT_.at(instance);
|
||||
double sqrtkT = sqrtkT_.size() == 1 ? sqrtkT_.at(0) : sqrtkT_.at(instance);
|
||||
return sqrtkT * sqrtkT / K_BOLTZMANN;
|
||||
} else {
|
||||
return sqrtkT_[0] * sqrtkT_[0] / K_BOLTZMANN;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Cell::set_temperature(double T, int32_t instance, bool set_contained)
|
||||
void Cell::set_temperature(double T, int32_t instance, bool set_contained)
|
||||
{
|
||||
if (settings::temperature_method == TemperatureMethod::INTERPOLATION) {
|
||||
if (T < data::temperature_min) {
|
||||
throw std::runtime_error{"Temperature is below minimum temperature at "
|
||||
"which data is available."};
|
||||
throw std::runtime_error {"Temperature is below minimum temperature at "
|
||||
"which data is available."};
|
||||
} else if (T > data::temperature_max) {
|
||||
throw std::runtime_error{"Temperature is above maximum temperature at "
|
||||
"which data is available."};
|
||||
throw std::runtime_error {"Temperature is above maximum temperature at "
|
||||
"which data is available."};
|
||||
}
|
||||
}
|
||||
|
||||
if (type_ == Fill::MATERIAL) {
|
||||
if (instance >= 0) {
|
||||
// If temperature vector is not big enough, resize it first
|
||||
if (sqrtkT_.size() != n_instances_) sqrtkT_.resize(n_instances_, sqrtkT_[0]);
|
||||
if (sqrtkT_.size() != n_instances_)
|
||||
sqrtkT_.resize(n_instances_, sqrtkT_[0]);
|
||||
|
||||
// Set temperature for the corresponding instance
|
||||
sqrtkT_.at(instance) = std::sqrt(K_BOLTZMANN * T);
|
||||
|
|
@ -335,15 +334,17 @@ Cell::set_temperature(double T, int32_t instance, bool set_contained)
|
|||
}
|
||||
} else {
|
||||
if (!set_contained) {
|
||||
throw std::runtime_error{fmt::format("Attempted to set the temperature of cell {} "
|
||||
"which is not filled by a material.", id_)};
|
||||
throw std::runtime_error {
|
||||
fmt::format("Attempted to set the temperature of cell {} "
|
||||
"which is not filled by a material.",
|
||||
id_)};
|
||||
}
|
||||
|
||||
auto contained_cells = this->get_contained_cells();
|
||||
for (const auto& entry : contained_cells) {
|
||||
auto& cell = model::cells[entry.first];
|
||||
Expects(cell->type_ == Fill::MATERIAL);
|
||||
auto& instances = entry.second;
|
||||
auto& instances = entry.second;
|
||||
for (auto instance : instances) {
|
||||
cell->set_temperature(T, instance);
|
||||
}
|
||||
|
|
@ -377,7 +378,8 @@ void Cell::import_properties_hdf5(hid_t group)
|
|||
auto n_temps = temps.size();
|
||||
if (n_temps > 1 && n_temps != n_instances_) {
|
||||
throw std::runtime_error(fmt::format(
|
||||
"Number of temperatures for cell {} doesn't match number of instances", id_));
|
||||
"Number of temperatures for cell {} doesn't match number of instances",
|
||||
id_));
|
||||
}
|
||||
|
||||
// Modify temperatures for the cell
|
||||
|
|
@ -390,9 +392,8 @@ void Cell::import_properties_hdf5(hid_t group)
|
|||
close_group(cell_group);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Cell::to_hdf5(hid_t cell_group) const {
|
||||
void Cell::to_hdf5(hid_t cell_group) const
|
||||
{
|
||||
|
||||
// Create a group for this cell.
|
||||
auto group = create_group(cell_group, fmt::format("cell {}", id_));
|
||||
|
|
@ -455,7 +456,8 @@ Cell::to_hdf5(hid_t cell_group) const {
|
|||
//==============================================================================
|
||||
|
||||
// default constructor
|
||||
CSGCell::CSGCell() {
|
||||
CSGCell::CSGCell()
|
||||
{
|
||||
geom_type_ = GeometryType::CSG;
|
||||
}
|
||||
|
||||
|
|
@ -483,19 +485,21 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
bool fill_present = check_for_node(cell_node, "fill");
|
||||
bool material_present = check_for_node(cell_node, "material");
|
||||
if (!(fill_present || material_present)) {
|
||||
fatal_error(fmt::format(
|
||||
"Neither material nor fill was specified for cell {}", id_));
|
||||
fatal_error(
|
||||
fmt::format("Neither material nor fill was specified for cell {}", id_));
|
||||
}
|
||||
if (fill_present && material_present) {
|
||||
fatal_error(fmt::format("Cell {} has both a material and a fill specified; "
|
||||
"only one can be specified per cell", id_));
|
||||
"only one can be specified per cell",
|
||||
id_));
|
||||
}
|
||||
|
||||
if (fill_present) {
|
||||
fill_ = std::stoi(get_node_value(cell_node, "fill"));
|
||||
if (fill_ == universe_) {
|
||||
fatal_error(fmt::format("Cell {} is filled with the same universe that"
|
||||
"it is contained in.", id_));
|
||||
"it is contained in.",
|
||||
id_));
|
||||
}
|
||||
} else {
|
||||
fill_ = C_NONE;
|
||||
|
|
@ -517,8 +521,8 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
fatal_error(fmt::format("An empty material element was specified for cell {}",
|
||||
id_));
|
||||
fatal_error(fmt::format(
|
||||
"An empty material element was specified for cell {}", id_));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -531,7 +535,8 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
if (material_.size() == 0) {
|
||||
fatal_error(fmt::format(
|
||||
"Cell {} was specified with a temperature but no material. Temperature"
|
||||
"specification is only valid for cells filled with a material.", id_));
|
||||
"specification is only valid for cells filled with a material.",
|
||||
id_));
|
||||
}
|
||||
|
||||
// Make sure all temperatures are non-negative.
|
||||
|
|
@ -563,8 +568,9 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
if (r < OP_UNION) {
|
||||
const auto& it {model::surface_map.find(abs(r))};
|
||||
if (it == model::surface_map.end()) {
|
||||
throw std::runtime_error{"Invalid surface ID " + std::to_string(abs(r))
|
||||
+ " specified in region for cell " + std::to_string(id_) + "."};
|
||||
throw std::runtime_error {
|
||||
"Invalid surface ID " + std::to_string(abs(r)) +
|
||||
" specified in region for cell " + std::to_string(id_) + "."};
|
||||
}
|
||||
r = (r > 0) ? it->second + 1 : -(it->second + 1);
|
||||
}
|
||||
|
|
@ -601,13 +607,14 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
if (check_for_node(cell_node, "translation")) {
|
||||
if (fill_ == C_NONE) {
|
||||
fatal_error(fmt::format("Cannot apply a translation to cell {}"
|
||||
" because it is not filled with another universe", id_));
|
||||
" because it is not filled with another universe",
|
||||
id_));
|
||||
}
|
||||
|
||||
auto xyz {get_node_array<double>(cell_node, "translation")};
|
||||
if (xyz.size() != 3) {
|
||||
fatal_error(fmt::format(
|
||||
"Non-3D translation vector applied to cell {}", id_));
|
||||
fatal_error(
|
||||
fmt::format("Non-3D translation vector applied to cell {}", id_));
|
||||
}
|
||||
translation_ = xyz;
|
||||
}
|
||||
|
|
@ -621,8 +628,7 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
CSGCell::contains(Position r, Direction u, int32_t on_surface) const
|
||||
bool CSGCell::contains(Position r, Direction u, int32_t on_surface) const
|
||||
{
|
||||
if (simple_) {
|
||||
return contains_simple(r, u, on_surface);
|
||||
|
|
@ -633,24 +639,25 @@ CSGCell::contains(Position r, Direction u, int32_t on_surface) const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
std::pair<double, int32_t>
|
||||
CSGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) const
|
||||
std::pair<double, int32_t> CSGCell::distance(
|
||||
Position r, Direction u, int32_t on_surface, Particle* p) const
|
||||
{
|
||||
double min_dist {INFTY};
|
||||
int32_t i_surf {std::numeric_limits<int32_t>::max()};
|
||||
|
||||
for (int32_t token : rpn_) {
|
||||
// Ignore this token if it corresponds to an operator rather than a region.
|
||||
if (token >= OP_UNION) continue;
|
||||
if (token >= OP_UNION)
|
||||
continue;
|
||||
|
||||
// Calculate the distance to this surface.
|
||||
// Note the off-by-one indexing
|
||||
bool coincident {std::abs(token) == std::abs(on_surface)};
|
||||
double d {model::surfaces[abs(token)-1]->distance(r, u, coincident)};
|
||||
double d {model::surfaces[abs(token) - 1]->distance(r, u, coincident)};
|
||||
|
||||
// Check if this distance is the new minimum.
|
||||
if (d < min_dist) {
|
||||
if (min_dist - d >= FP_PRECISION*min_dist) {
|
||||
if (min_dist - d >= FP_PRECISION * min_dist) {
|
||||
min_dist = d;
|
||||
i_surf = -token;
|
||||
}
|
||||
|
|
@ -662,8 +669,7 @@ CSGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) cons
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
CSGCell::to_hdf5_inner(hid_t group_id) const
|
||||
void CSGCell::to_hdf5_inner(hid_t group_id) const
|
||||
{
|
||||
|
||||
write_string(group_id, "geom_type", "csg", false);
|
||||
|
|
@ -683,19 +689,19 @@ CSGCell::to_hdf5_inner(hid_t group_id) const
|
|||
region_spec << " |";
|
||||
} else {
|
||||
// Note the off-by-one indexing
|
||||
auto surf_id = model::surfaces[abs(token)-1]->id_;
|
||||
auto surf_id = model::surfaces[abs(token) - 1]->id_;
|
||||
region_spec << " " << ((token > 0) ? surf_id : -surf_id);
|
||||
}
|
||||
}
|
||||
write_string(group_id, "region", region_spec.str(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BoundingBox CSGCell::bounding_box_simple() const {
|
||||
BoundingBox CSGCell::bounding_box_simple() const
|
||||
{
|
||||
BoundingBox bbox;
|
||||
for (int32_t token : rpn_) {
|
||||
bbox &= model::surfaces[abs(token)-1]->bounding_box(token > 0);
|
||||
bbox &= model::surfaces[abs(token) - 1]->bounding_box(token > 0);
|
||||
}
|
||||
return bbox;
|
||||
}
|
||||
|
|
@ -704,9 +710,13 @@ void CSGCell::apply_demorgan(
|
|||
vector<int32_t>::iterator start, vector<int32_t>::iterator stop)
|
||||
{
|
||||
while (start < stop) {
|
||||
if (*start < OP_UNION) { *start *= -1; }
|
||||
else if (*start == OP_UNION) { *start = OP_INTERSECTION; }
|
||||
else if (*start == OP_INTERSECTION) { *start = OP_UNION; }
|
||||
if (*start < OP_UNION) {
|
||||
*start *= -1;
|
||||
} else if (*start == OP_UNION) {
|
||||
*start = OP_INTERSECTION;
|
||||
} else if (*start == OP_INTERSECTION) {
|
||||
*start = OP_UNION;
|
||||
}
|
||||
start++;
|
||||
}
|
||||
}
|
||||
|
|
@ -725,7 +735,7 @@ vector<int32_t>::iterator CSGCell::find_left_parenthesis(
|
|||
// decrement parenthesis level if there are two adjacent surfaces
|
||||
if (one < OP_UNION && two < OP_UNION) {
|
||||
parenthesis_level--;
|
||||
// increment if there are two adjacent operators
|
||||
// increment if there are two adjacent operators
|
||||
} else if (one >= OP_UNION && two >= OP_UNION) {
|
||||
parenthesis_level++;
|
||||
}
|
||||
|
|
@ -787,14 +797,14 @@ BoundingBox CSGCell::bounding_box_complex(vector<int32_t> rpn)
|
|||
return stack.front();
|
||||
}
|
||||
|
||||
BoundingBox CSGCell::bounding_box() const {
|
||||
BoundingBox CSGCell::bounding_box() const
|
||||
{
|
||||
return simple_ ? bounding_box_simple() : bounding_box_complex(rpn_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
CSGCell::contains_simple(Position r, Direction u, int32_t on_surface) const
|
||||
bool CSGCell::contains_simple(Position r, Direction u, int32_t on_surface) const
|
||||
{
|
||||
for (int32_t token : rpn_) {
|
||||
// Assume that no tokens are operators. Evaluate the sense of particle with
|
||||
|
|
@ -806,8 +816,10 @@ CSGCell::contains_simple(Position r, Direction u, int32_t on_surface) const
|
|||
return false;
|
||||
} else {
|
||||
// Note the off-by-one indexing
|
||||
bool sense = model::surfaces[abs(token)-1]->sense(r, u);
|
||||
if (sense != (token > 0)) {return false;}
|
||||
bool sense = model::surfaces[abs(token) - 1]->sense(r, u);
|
||||
if (sense != (token > 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
@ -815,8 +827,8 @@ CSGCell::contains_simple(Position r, Direction u, int32_t on_surface) const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const
|
||||
bool CSGCell::contains_complex(
|
||||
Position r, Direction u, int32_t on_surface) const
|
||||
{
|
||||
// Make a stack of booleans. We don't know how big it needs to be, but we do
|
||||
// know that rpn.size() is an upper-bound.
|
||||
|
|
@ -828,11 +840,11 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const
|
|||
// the last two items on the stack. If the token is a unary operator
|
||||
// (complement), apply it to the last item on the stack.
|
||||
if (token == OP_UNION) {
|
||||
stack[i_stack-1] = stack[i_stack-1] || stack[i_stack];
|
||||
i_stack --;
|
||||
stack[i_stack - 1] = stack[i_stack - 1] || stack[i_stack];
|
||||
i_stack--;
|
||||
} else if (token == OP_INTERSECTION) {
|
||||
stack[i_stack-1] = stack[i_stack-1] && stack[i_stack];
|
||||
i_stack --;
|
||||
stack[i_stack - 1] = stack[i_stack - 1] && stack[i_stack];
|
||||
i_stack--;
|
||||
} else if (token == OP_COMPLEMENT) {
|
||||
stack[i_stack] = !stack[i_stack];
|
||||
} else {
|
||||
|
|
@ -840,14 +852,14 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const
|
|||
// respect to the surface and see if the token matches the sense. If the
|
||||
// particle's surface attribute is set and matches the token, that
|
||||
// overrides the determination based on sense().
|
||||
i_stack ++;
|
||||
i_stack++;
|
||||
if (token == on_surface) {
|
||||
stack[i_stack] = true;
|
||||
} else if (-token == on_surface) {
|
||||
stack[i_stack] = false;
|
||||
} else {
|
||||
// Note the off-by-one indexing
|
||||
bool sense = model::surfaces[abs(token)-1]->sense(r, u);
|
||||
bool sense = model::surfaces[abs(token) - 1]->sense(r, u);
|
||||
stack[i_stack] = (sense == (token > 0));
|
||||
}
|
||||
}
|
||||
|
|
@ -908,7 +920,8 @@ UniversePartitioner::UniversePartitioner(const Universe& univ)
|
|||
// It is difficult to determine the bounds of a complex cell, so add complex
|
||||
// cells to all partitions.
|
||||
if (!model::cells[i_cell]->simple_) {
|
||||
for (auto& p : partitions_) p.push_back(i_cell);
|
||||
for (auto& p : partitions_)
|
||||
p.push_back(i_cell);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -933,7 +946,8 @@ UniversePartitioner::UniversePartitioner(const Universe& univ)
|
|||
|
||||
// If there are no bounding z-planes, add this cell to all partitions.
|
||||
if (lower_token == 0) {
|
||||
for (auto& p : partitions_) p.push_back(i_cell);
|
||||
for (auto& p : partitions_)
|
||||
p.push_back(i_cell);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -989,7 +1003,7 @@ const vector<int32_t>& UniversePartitioner::get_cells(
|
|||
left = middle + 1;
|
||||
middle = right_leaf;
|
||||
} else {
|
||||
return partitions_[middle+1];
|
||||
return partitions_[middle + 1];
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -998,7 +1012,7 @@ const vector<int32_t>& UniversePartitioner::get_cells(
|
|||
// side of this surface.
|
||||
int left_leaf = left + (middle - left) / 2;
|
||||
if (left_leaf != middle) {
|
||||
right = middle-1;
|
||||
right = middle - 1;
|
||||
middle = left_leaf;
|
||||
} else {
|
||||
return partitions_[middle];
|
||||
|
|
@ -1015,7 +1029,9 @@ void read_cells(pugi::xml_node node)
|
|||
{
|
||||
// Count the number of cells.
|
||||
int n_cells = 0;
|
||||
for (pugi::xml_node cell_node: node.children("cell")) {n_cells++;}
|
||||
for (pugi::xml_node cell_node : node.children("cell")) {
|
||||
n_cells++;
|
||||
}
|
||||
|
||||
// Loop over XML cell elements and populate the array.
|
||||
model::cells.reserve(n_cells);
|
||||
|
|
@ -1030,7 +1046,8 @@ void read_cells(pugi::xml_node node)
|
|||
if (search == model::cell_map.end()) {
|
||||
model::cell_map[id] = i;
|
||||
} else {
|
||||
fatal_error(fmt::format("Two or more cells use the same unique ID: {}", id));
|
||||
fatal_error(
|
||||
fmt::format("Two or more cells use the same unique ID: {}", id));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1065,8 +1082,8 @@ void read_cells(pugi::xml_node node)
|
|||
// C-API functions
|
||||
//==============================================================================
|
||||
|
||||
extern "C" int
|
||||
openmc_cell_get_fill(int32_t index, int* type, int32_t** indices, int32_t* n)
|
||||
extern "C" int openmc_cell_get_fill(
|
||||
int32_t index, int* type, int32_t** indices, int32_t* n)
|
||||
{
|
||||
if (index >= 0 && index < model::cells.size()) {
|
||||
Cell& c {*model::cells[index]};
|
||||
|
|
@ -1085,9 +1102,8 @@ openmc_cell_get_fill(int32_t index, int* type, int32_t** indices, int32_t* n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
openmc_cell_set_fill(int32_t index, int type, int32_t n,
|
||||
const int32_t* indices)
|
||||
extern "C" int openmc_cell_set_fill(
|
||||
int32_t index, int type, int32_t n, const int32_t* indices)
|
||||
{
|
||||
Fill filltype = static_cast<Fill>(type);
|
||||
if (index >= 0 && index < model::cells.size()) {
|
||||
|
|
@ -1119,8 +1135,8 @@ openmc_cell_set_fill(int32_t index, int type, int32_t n,
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
openmc_cell_set_temperature(int32_t index, double T, const int32_t* instance, bool set_contained)
|
||||
extern "C" int openmc_cell_set_temperature(
|
||||
int32_t index, double T, const int32_t* instance, bool set_contained)
|
||||
{
|
||||
if (index < 0 || index >= model::cells.size()) {
|
||||
strcpy(openmc_err_msg, "Index in cells array is out of bounds.");
|
||||
|
|
@ -1137,8 +1153,8 @@ openmc_cell_set_temperature(int32_t index, double T, const int32_t* instance, bo
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
openmc_cell_get_temperature(int32_t index, const int32_t* instance, double* T)
|
||||
extern "C" int openmc_cell_get_temperature(
|
||||
int32_t index, const int32_t* instance, double* T)
|
||||
{
|
||||
if (index < 0 || index >= model::cells.size()) {
|
||||
strcpy(openmc_err_msg, "Index in cells array is out of bounds.");
|
||||
|
|
@ -1156,8 +1172,9 @@ openmc_cell_get_temperature(int32_t index, const int32_t* instance, double* T)
|
|||
}
|
||||
|
||||
//! Get the bounding box of a cell
|
||||
extern "C" int
|
||||
openmc_cell_bounding_box(const int32_t index, double* llc, double* urc) {
|
||||
extern "C" int openmc_cell_bounding_box(
|
||||
const int32_t index, double* llc, double* urc)
|
||||
{
|
||||
|
||||
BoundingBox bbox;
|
||||
|
||||
|
|
@ -1178,8 +1195,8 @@ openmc_cell_bounding_box(const int32_t index, double* llc, double* urc) {
|
|||
}
|
||||
|
||||
//! Get the name of a cell
|
||||
extern "C" int
|
||||
openmc_cell_get_name(int32_t index, const char** name) {
|
||||
extern "C" int openmc_cell_get_name(int32_t index, const char** name)
|
||||
{
|
||||
if (index < 0 || index >= model::cells.size()) {
|
||||
set_errmsg("Index in cells array is out of bounds.");
|
||||
return OPENMC_E_OUT_OF_BOUNDS;
|
||||
|
|
@ -1191,8 +1208,8 @@ openmc_cell_get_name(int32_t index, const char** name) {
|
|||
}
|
||||
|
||||
//! Set the name of a cell
|
||||
extern "C" int
|
||||
openmc_cell_set_name(int32_t index, const char* name) {
|
||||
extern "C" int openmc_cell_set_name(int32_t index, const char* name)
|
||||
{
|
||||
if (index < 0 || index >= model::cells.size()) {
|
||||
set_errmsg("Index in cells array is out of bounds.");
|
||||
return OPENMC_E_OUT_OF_BOUNDS;
|
||||
|
|
@ -1232,24 +1249,25 @@ void Cell::get_contained_cells_inner(
|
|||
instance += cell->offset_[distribcell_index_];
|
||||
} else if (cell->type_ == Fill::LATTICE) {
|
||||
auto& lattice = model::lattices[cell->fill_];
|
||||
instance += lattice->offset(this->distribcell_index_, parent_cell.lattice_index);
|
||||
instance += lattice->offset(
|
||||
this->distribcell_index_, parent_cell.lattice_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
// add entry to contained cells
|
||||
contained_cells[model::cell_map[id_]].push_back(instance);
|
||||
// filled with universe, add the containing cell to the parent cells
|
||||
// and recurse
|
||||
// filled with universe, add the containing cell to the parent cells
|
||||
// and recurse
|
||||
} else if (type_ == Fill::UNIVERSE) {
|
||||
parent_cells.push_back({model::cell_map[id_], -1});
|
||||
auto& univ = model::universes[fill_];
|
||||
for(auto cell_index : univ->cells_) {
|
||||
for (auto cell_index : univ->cells_) {
|
||||
auto& cell = model::cells[cell_index];
|
||||
cell->get_contained_cells_inner(contained_cells, parent_cells);
|
||||
}
|
||||
parent_cells.pop_back();
|
||||
// filled with a lattice, visit each universe in the lattice
|
||||
// with a recursive call to collect the cell instances
|
||||
// filled with a lattice, visit each universe in the lattice
|
||||
// with a recursive call to collect the cell instances
|
||||
} else if (type_ == Fill::LATTICE) {
|
||||
auto& lattice = model::lattices[fill_];
|
||||
for (auto i = lattice->begin(); i != lattice->end(); ++i) {
|
||||
|
|
@ -1265,8 +1283,7 @@ void Cell::get_contained_cells_inner(
|
|||
}
|
||||
|
||||
//! Return the index in the cells array of a cell with a given ID
|
||||
extern "C" int
|
||||
openmc_get_cell_index(int32_t id, int32_t* index)
|
||||
extern "C" int openmc_get_cell_index(int32_t id, int32_t* index)
|
||||
{
|
||||
auto it = model::cell_map.find(id);
|
||||
if (it != model::cell_map.end()) {
|
||||
|
|
@ -1279,8 +1296,7 @@ openmc_get_cell_index(int32_t id, int32_t* index)
|
|||
}
|
||||
|
||||
//! Return the ID of a cell
|
||||
extern "C" int
|
||||
openmc_cell_get_id(int32_t index, int32_t* id)
|
||||
extern "C" int openmc_cell_get_id(int32_t index, int32_t* id)
|
||||
{
|
||||
if (index >= 0 && index < model::cells.size()) {
|
||||
*id = model::cells[index]->id_;
|
||||
|
|
@ -1292,8 +1308,7 @@ openmc_cell_get_id(int32_t index, int32_t* id)
|
|||
}
|
||||
|
||||
//! Set the ID of a cell
|
||||
extern "C" int
|
||||
openmc_cell_set_id(int32_t index, int32_t id)
|
||||
extern "C" int openmc_cell_set_id(int32_t index, int32_t id)
|
||||
{
|
||||
if (index >= 0 && index < model::cells.size()) {
|
||||
model::cells[index]->id_ = id;
|
||||
|
|
@ -1327,7 +1342,7 @@ extern "C" int openmc_cell_set_translation(int32_t index, const double xyz[])
|
|||
if (model::cells[index]->fill_ == C_NONE) {
|
||||
set_errmsg(fmt::format("Cannot apply a translation to cell {}"
|
||||
" because it is not filled with another universe",
|
||||
index));
|
||||
index));
|
||||
return OPENMC_E_GEOMETRY;
|
||||
}
|
||||
model::cells[index]->translation_ = Position(xyz);
|
||||
|
|
@ -1353,8 +1368,8 @@ extern "C" int openmc_cell_get_rotation(int32_t index, double rot[], size_t* n)
|
|||
}
|
||||
|
||||
//! Set the flattened rotation matrix of a cell
|
||||
extern "C" int openmc_cell_set_rotation(int32_t index, const double rot[],
|
||||
size_t rot_len)
|
||||
extern "C" int openmc_cell_set_rotation(
|
||||
int32_t index, const double rot[], size_t rot_len)
|
||||
{
|
||||
if (index >= 0 && index < model::cells.size()) {
|
||||
if (model::cells[index]->fill_ == C_NONE) {
|
||||
|
|
@ -1373,8 +1388,8 @@ extern "C" int openmc_cell_set_rotation(int32_t index, const double rot[],
|
|||
}
|
||||
|
||||
//! Get the number of instances of the requested cell
|
||||
extern "C" int
|
||||
openmc_cell_get_num_instances(int32_t index, int32_t* num_instances)
|
||||
extern "C" int openmc_cell_get_num_instances(
|
||||
int32_t index, int32_t* num_instances)
|
||||
{
|
||||
if (index < 0 || index >= model::cells.size()) {
|
||||
set_errmsg("Index in cells array is out of bounds.");
|
||||
|
|
@ -1385,17 +1400,22 @@ openmc_cell_get_num_instances(int32_t index, int32_t* num_instances)
|
|||
}
|
||||
|
||||
//! Extend the cells array by n elements
|
||||
extern "C" int
|
||||
openmc_extend_cells(int32_t n, int32_t* index_start, int32_t* index_end)
|
||||
extern "C" int openmc_extend_cells(
|
||||
int32_t n, int32_t* index_start, int32_t* index_end)
|
||||
{
|
||||
if (index_start) *index_start = model::cells.size();
|
||||
if (index_end) *index_end = model::cells.size() + n - 1;
|
||||
if (index_start)
|
||||
*index_start = model::cells.size();
|
||||
if (index_end)
|
||||
*index_end = model::cells.size() + n - 1;
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
model::cells.push_back(make_unique<CSGCell>());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int cells_size() { return model::cells.size(); }
|
||||
extern "C" int cells_size()
|
||||
{
|
||||
return model::cells.size();
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ int get_cmfd_energy_bin(const double E)
|
|||
} else {
|
||||
// Iterate through energy grid to find matching bin
|
||||
for (int g = 0; g < cmfd::ng; g++) {
|
||||
if (E >= cmfd::egrid[g] && E < cmfd::egrid[g+1]) {
|
||||
if (E >= cmfd::egrid[g] && E < cmfd::egrid[g + 1]) {
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +79,8 @@ int get_cmfd_energy_bin(const double E)
|
|||
// COUNT_BANK_SITES bins fission sites according to CMFD mesh and energy
|
||||
//==============================================================================
|
||||
|
||||
xt::xtensor<double, 1> count_bank_sites(xt::xtensor<int, 1>& bins, bool* outside)
|
||||
xt::xtensor<double, 1> count_bank_sites(
|
||||
xt::xtensor<int, 1>& bins, bool* outside)
|
||||
{
|
||||
// Determine shape of array for counts
|
||||
std::size_t cnt_size = cmfd::nx * cmfd::ny * cmfd::nz * cmfd::ng;
|
||||
|
|
@ -106,22 +107,22 @@ xt::xtensor<double, 1> count_bank_sites(xt::xtensor<int, 1>& bins, bool* outside
|
|||
int energy_bin = get_cmfd_energy_bin(site.E);
|
||||
|
||||
// add to appropriate bin
|
||||
cnt(mesh_bin*cmfd::ng+energy_bin) += site.wgt;
|
||||
cnt(mesh_bin * cmfd::ng + energy_bin) += site.wgt;
|
||||
|
||||
// store bin index which is used again when updating weights
|
||||
bins[i] = mesh_bin*cmfd::ng+energy_bin;
|
||||
bins[i] = mesh_bin * cmfd::ng + energy_bin;
|
||||
}
|
||||
|
||||
// Create copy of count data. Since ownership will be acquired by xtensor,
|
||||
// std::allocator must be used to avoid Valgrind mismatched free() / delete
|
||||
// warnings.
|
||||
int total = cnt.size();
|
||||
double* cnt_reduced = std::allocator<double>{}.allocate(total);
|
||||
double* cnt_reduced = std::allocator<double> {}.allocate(total);
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
// collect values from all processors
|
||||
MPI_Reduce(cnt.data(), cnt_reduced, total, MPI_DOUBLE, MPI_SUM, 0,
|
||||
mpi::intracomm);
|
||||
MPI_Reduce(
|
||||
cnt.data(), cnt_reduced, total, MPI_DOUBLE, MPI_SUM, 0, mpi::intracomm);
|
||||
|
||||
// Check if there were sites outside the mesh for any processor
|
||||
MPI_Reduce(&outside_, outside, 1, MPI_C_BOOL, MPI_LOR, 0, mpi::intracomm);
|
||||
|
|
@ -142,8 +143,8 @@ xt::xtensor<double, 1> count_bank_sites(xt::xtensor<int, 1>& bins, bool* outside
|
|||
// OPENMC_CMFD_REWEIGHT performs reweighting of particles in source bank
|
||||
//==============================================================================
|
||||
|
||||
extern "C"
|
||||
void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src)
|
||||
extern "C" void openmc_cmfd_reweight(
|
||||
const bool feedback, const double* cmfd_src)
|
||||
{
|
||||
// Get size of source bank and cmfd_src
|
||||
auto bank_size = simulation::source_bank.size();
|
||||
|
|
@ -152,8 +153,8 @@ void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src)
|
|||
// count bank sites for CMFD mesh, store bins in bank_bins for reweighting
|
||||
xt::xtensor<int, 1> bank_bins({bank_size}, 0);
|
||||
bool sites_outside;
|
||||
xt::xtensor<double, 1> sourcecounts = count_bank_sites(bank_bins,
|
||||
&sites_outside);
|
||||
xt::xtensor<double, 1> sourcecounts =
|
||||
count_bank_sites(bank_bins, &sites_outside);
|
||||
|
||||
// Compute CMFD weightfactors
|
||||
xt::xtensor<double, 1> weightfactors = xt::xtensor<double, 1>({src_size}, 1.);
|
||||
|
|
@ -162,7 +163,7 @@ void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src)
|
|||
fatal_error("Source sites outside of the CMFD mesh");
|
||||
}
|
||||
|
||||
double norm = xt::sum(sourcecounts)()/cmfd::norm;
|
||||
double norm = xt::sum(sourcecounts)() / cmfd::norm;
|
||||
for (int i = 0; i < src_size; i++) {
|
||||
if (sourcecounts[i] > 0 && cmfd_src[i] > 0) {
|
||||
weightfactors[i] = cmfd_src[i] * norm / sourcecounts[i];
|
||||
|
|
@ -170,7 +171,8 @@ void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src)
|
|||
}
|
||||
}
|
||||
|
||||
if (!feedback) return;
|
||||
if (!feedback)
|
||||
return;
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
// Send weightfactors to all processors
|
||||
|
|
@ -188,9 +190,8 @@ void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src)
|
|||
// OPENMC_INITIALIZE_MESH_EGRID sets the mesh and energy grid for CMFD reweight
|
||||
//==============================================================================
|
||||
|
||||
extern "C"
|
||||
void openmc_initialize_mesh_egrid(const int meshtally_id, const int* cmfd_indices,
|
||||
const double norm)
|
||||
extern "C" void openmc_initialize_mesh_egrid(
|
||||
const int meshtally_id, const int* cmfd_indices, const double norm)
|
||||
{
|
||||
// Make sure all CMFD memory is freed
|
||||
free_memory_cmfd();
|
||||
|
|
@ -242,9 +243,9 @@ void openmc_initialize_mesh_egrid(const int meshtally_id, const int* cmfd_indice
|
|||
void matrix_to_indices(int irow, int& g, int& i, int& j, int& k)
|
||||
{
|
||||
g = irow % cmfd::ng;
|
||||
i = cmfd::indexmap(irow/cmfd::ng, 0);
|
||||
j = cmfd::indexmap(irow/cmfd::ng, 1);
|
||||
k = cmfd::indexmap(irow/cmfd::ng, 2);
|
||||
i = cmfd::indexmap(irow / cmfd::ng, 0);
|
||||
j = cmfd::indexmap(irow / cmfd::ng, 1);
|
||||
k = cmfd::indexmap(irow / cmfd::ng, 2);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -254,7 +255,7 @@ void matrix_to_indices(int irow, int& g, int& i, int& j, int& k)
|
|||
|
||||
int get_diagonal_index(int row)
|
||||
{
|
||||
for (int j = cmfd::indptr[row]; j < cmfd::indptr[row+1]; j++) {
|
||||
for (int j = cmfd::indptr[row]; j < cmfd::indptr[row + 1]; j++) {
|
||||
if (cmfd::indices[j] == row)
|
||||
return j;
|
||||
}
|
||||
|
|
@ -272,7 +273,7 @@ void set_indexmap(const int* coremap)
|
|||
for (int z = 0; z < cmfd::nz; z++) {
|
||||
for (int y = 0; y < cmfd::ny; y++) {
|
||||
for (int x = 0; x < cmfd::nx; x++) {
|
||||
int idx = (z*cmfd::ny*cmfd::nx) + (y*cmfd::nx) + x;
|
||||
int idx = (z * cmfd::ny * cmfd::nx) + (y * cmfd::nx) + x;
|
||||
if (coremap[idx] != CMFD_NOACCEL) {
|
||||
int counter = coremap[idx];
|
||||
cmfd::indexmap(counter, 0) = x;
|
||||
|
|
@ -288,8 +289,8 @@ void set_indexmap(const int* coremap)
|
|||
// CMFD_LINSOLVER_1G solves a one group CMFD linear system
|
||||
//==============================================================================
|
||||
|
||||
int cmfd_linsolver_1g(const double* A_data, const double* b, double* x,
|
||||
double tol)
|
||||
int cmfd_linsolver_1g(
|
||||
const double* A_data, const double* b, double* x, double tol)
|
||||
{
|
||||
// Set overrelaxation parameter
|
||||
double w = 1.0;
|
||||
|
|
@ -304,14 +305,15 @@ int cmfd_linsolver_1g(const double* A_data, const double* b, double* x,
|
|||
// Perform red/black Gauss-Seidel iterations
|
||||
for (int irb = 0; irb < 2; irb++) {
|
||||
|
||||
// Loop around matrix rows
|
||||
#pragma omp parallel for reduction (+:err) if(cmfd::use_all_threads)
|
||||
// Loop around matrix rows
|
||||
#pragma omp parallel for reduction(+ : err) if (cmfd::use_all_threads)
|
||||
for (int irow = 0; irow < cmfd::dim; irow++) {
|
||||
int g, i, j, k;
|
||||
matrix_to_indices(irow, g, i, j, k);
|
||||
|
||||
// Filter out black cells
|
||||
if ((i+j+k) % 2 != irb) continue;
|
||||
if ((i + j + k) % 2 != irb)
|
||||
continue;
|
||||
|
||||
// Get index of diagonal for current row
|
||||
int didx = get_diagonal_index(irow);
|
||||
|
|
@ -341,7 +343,7 @@ int cmfd_linsolver_1g(const double* A_data, const double* b, double* x,
|
|||
return igs;
|
||||
|
||||
// Calculate new overrelaxation parameter
|
||||
w = 1.0/(1.0 - 0.25 * cmfd::spectral * w);
|
||||
w = 1.0 / (1.0 - 0.25 * cmfd::spectral * w);
|
||||
}
|
||||
|
||||
// Throw error, as max iterations met
|
||||
|
|
@ -355,8 +357,8 @@ int cmfd_linsolver_1g(const double* A_data, const double* b, double* x,
|
|||
// CMFD_LINSOLVER_2G solves a two group CMFD linear system
|
||||
//==============================================================================
|
||||
|
||||
int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
||||
double tol)
|
||||
int cmfd_linsolver_2g(
|
||||
const double* A_data, const double* b, double* x, double tol)
|
||||
{
|
||||
// Set overrelaxation parameter
|
||||
double w = 1.0;
|
||||
|
|
@ -371,38 +373,41 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
|||
// Perform red/black Gauss-Seidel iterations
|
||||
for (int irb = 0; irb < 2; irb++) {
|
||||
|
||||
// Loop around matrix rows
|
||||
#pragma omp parallel for reduction (+:err) if(cmfd::use_all_threads)
|
||||
for (int irow = 0; irow < cmfd::dim; irow+=2) {
|
||||
// Loop around matrix rows
|
||||
#pragma omp parallel for reduction(+ : err) if (cmfd::use_all_threads)
|
||||
for (int irow = 0; irow < cmfd::dim; irow += 2) {
|
||||
int g, i, j, k;
|
||||
matrix_to_indices(irow, g, i, j, k);
|
||||
|
||||
// Filter out black cells
|
||||
if ((i+j+k) % 2 != irb) continue;
|
||||
if ((i + j + k) % 2 != irb)
|
||||
continue;
|
||||
|
||||
// Get index of diagonals for current row and next row
|
||||
int d1idx = get_diagonal_index(irow);
|
||||
int d2idx = get_diagonal_index(irow+1);
|
||||
int d2idx = get_diagonal_index(irow + 1);
|
||||
|
||||
// Get block diagonal
|
||||
double m11 = A_data[d1idx]; // group 1 diagonal
|
||||
double m12 = A_data[d1idx + 1]; // group 1 right of diagonal (sorted by col)
|
||||
double m21 = A_data[d2idx - 1]; // group 2 left of diagonal (sorted by col)
|
||||
double m22 = A_data[d2idx]; // group 2 diagonal
|
||||
double m11 = A_data[d1idx]; // group 1 diagonal
|
||||
double m12 =
|
||||
A_data[d1idx + 1]; // group 1 right of diagonal (sorted by col)
|
||||
double m21 =
|
||||
A_data[d2idx - 1]; // group 2 left of diagonal (sorted by col)
|
||||
double m22 = A_data[d2idx]; // group 2 diagonal
|
||||
|
||||
// Analytically invert the diagonal
|
||||
double dm = m11*m22 - m12*m21;
|
||||
double d11 = m22/dm;
|
||||
double d12 = -m12/dm;
|
||||
double d21 = -m21/dm;
|
||||
double d22 = m11/dm;
|
||||
double dm = m11 * m22 - m12 * m21;
|
||||
double d11 = m22 / dm;
|
||||
double d12 = -m12 / dm;
|
||||
double d21 = -m21 / dm;
|
||||
double d22 = m11 / dm;
|
||||
|
||||
// Perform temporary sums, first do left of diag, then right of diag
|
||||
double tmp1 = 0.0;
|
||||
double tmp2 = 0.0;
|
||||
for (int icol = cmfd::indptr[irow]; icol < d1idx; icol++)
|
||||
tmp1 += A_data[icol] * x[cmfd::indices[icol]];
|
||||
for (int icol = cmfd::indptr[irow+1]; icol < d2idx-1; icol++)
|
||||
for (int icol = cmfd::indptr[irow + 1]; icol < d2idx - 1; icol++)
|
||||
tmp2 += A_data[icol] * x[cmfd::indices[icol]];
|
||||
for (int icol = d1idx + 2; icol < cmfd::indptr[irow + 1]; icol++)
|
||||
tmp1 += A_data[icol] * x[cmfd::indices[icol]];
|
||||
|
|
@ -414,8 +419,8 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
|||
tmp2 = b[irow + 1] - tmp2;
|
||||
|
||||
// Solve for new x
|
||||
double x1 = d11*tmp1 + d12*tmp2;
|
||||
double x2 = d21*tmp1 + d22*tmp2;
|
||||
double x1 = d11 * tmp1 + d12 * tmp2;
|
||||
double x2 = d21 * tmp1 + d22 * tmp2;
|
||||
|
||||
// Perform overrelaxation
|
||||
x[irow] = (1.0 - w) * x[irow] + w * x1;
|
||||
|
|
@ -433,7 +438,7 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
|||
return igs;
|
||||
|
||||
// Calculate new overrelaxation parameter
|
||||
w = 1.0/(1.0 - 0.25 * cmfd::spectral * w);
|
||||
w = 1.0 / (1.0 - 0.25 * cmfd::spectral * w);
|
||||
}
|
||||
|
||||
// Throw error, as max iterations met
|
||||
|
|
@ -447,8 +452,8 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
|||
// CMFD_LINSOLVER_NG solves a general CMFD linear system
|
||||
//==============================================================================
|
||||
|
||||
int cmfd_linsolver_ng(const double* A_data, const double* b, double* x,
|
||||
double tol)
|
||||
int cmfd_linsolver_ng(
|
||||
const double* A_data, const double* b, double* x, double tol)
|
||||
{
|
||||
// Set overrelaxation parameter
|
||||
double w = 1.0;
|
||||
|
|
@ -489,7 +494,7 @@ int cmfd_linsolver_ng(const double* A_data, const double* b, double* x,
|
|||
return igs;
|
||||
|
||||
// Calculate new overrelaxation parameter
|
||||
w = 1.0/(1.0 - 0.25 * cmfd::spectral * w);
|
||||
w = 1.0 / (1.0 - 0.25 * cmfd::spectral * w);
|
||||
}
|
||||
|
||||
// Throw error, as max iterations met
|
||||
|
|
@ -504,11 +509,9 @@ int cmfd_linsolver_ng(const double* A_data, const double* b, double* x,
|
|||
// linear solver
|
||||
//==============================================================================
|
||||
|
||||
extern "C"
|
||||
void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
||||
const int* indices, int n_elements, int dim,
|
||||
double spectral, const int* map,
|
||||
bool use_all_threads)
|
||||
extern "C" void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
||||
const int* indices, int n_elements, int dim, double spectral, const int* map,
|
||||
bool use_all_threads)
|
||||
{
|
||||
// Store elements of indptr
|
||||
for (int i = 0; i < len_indptr; i++)
|
||||
|
|
@ -538,9 +541,8 @@ void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
|||
// equations
|
||||
//==============================================================================
|
||||
|
||||
extern "C"
|
||||
int openmc_run_linsolver(const double* A_data, const double* b, double* x,
|
||||
double tol)
|
||||
extern "C" int openmc_run_linsolver(
|
||||
const double* A_data, const double* b, double* x, double tol)
|
||||
{
|
||||
switch (cmfd::ng) {
|
||||
case 1:
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#include "openmc/constants.h"
|
||||
#include "openmc/container_util.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/geometry_aux.h"
|
||||
#include "openmc/file_utils.h"
|
||||
#include "openmc/geometry_aux.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/material.h"
|
||||
#include "openmc/message_passing.h"
|
||||
|
|
@ -15,10 +15,10 @@
|
|||
#include "openmc/settings.h"
|
||||
#include "openmc/simulation.h"
|
||||
#include "openmc/string_utils.h"
|
||||
#include "openmc/timer.h"
|
||||
#include "openmc/thermal.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
#include "openmc/timer.h"
|
||||
#include "openmc/wmp.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ namespace data {
|
|||
|
||||
std::map<LibraryKey, std::size_t> library_map;
|
||||
vector<Library> libraries;
|
||||
}
|
||||
} // namespace data
|
||||
|
||||
//==============================================================================
|
||||
// Library methods
|
||||
|
|
@ -111,7 +111,8 @@ void read_cross_sections_xml()
|
|||
if (settings::run_CE) {
|
||||
char* envvar = std::getenv("OPENMC_CROSS_SECTIONS");
|
||||
if (!envvar) {
|
||||
fatal_error("No cross_sections.xml file was specified in "
|
||||
fatal_error(
|
||||
"No cross_sections.xml file was specified in "
|
||||
"materials.xml or in the OPENMC_CROSS_SECTIONS"
|
||||
" environment variable. OpenMC needs such a file to identify "
|
||||
"where to find data libraries. Please consult the"
|
||||
|
|
@ -122,12 +123,13 @@ void read_cross_sections_xml()
|
|||
} else {
|
||||
char* envvar = std::getenv("OPENMC_MG_CROSS_SECTIONS");
|
||||
if (!envvar) {
|
||||
fatal_error("No mgxs.h5 file was specified in "
|
||||
"materials.xml or in the OPENMC_MG_CROSS_SECTIONS environment "
|
||||
"variable. OpenMC needs such a file to identify where to "
|
||||
"find MG cross section libraries. Please consult the user's "
|
||||
"guide at https://docs.openmc.org for information on "
|
||||
"how to set up MG cross section libraries.");
|
||||
fatal_error(
|
||||
"No mgxs.h5 file was specified in "
|
||||
"materials.xml or in the OPENMC_MG_CROSS_SECTIONS environment "
|
||||
"variable. OpenMC needs such a file to identify where to "
|
||||
"find MG cross section libraries. Please consult the user's "
|
||||
"guide at https://docs.openmc.org for information on "
|
||||
"how to set up MG cross section libraries.");
|
||||
}
|
||||
settings::path_cross_sections = envvar;
|
||||
}
|
||||
|
|
@ -157,8 +159,8 @@ void read_cross_sections_xml()
|
|||
for (const auto& name : settings::res_scat_nuclides) {
|
||||
LibraryKey key {Library::Type::neutron, name};
|
||||
if (data::library_map.find(key) == data::library_map.end()) {
|
||||
fatal_error("Could not find resonant scatterer " +
|
||||
name + " in cross_sections.xml file!");
|
||||
fatal_error("Could not find resonant scatterer " + name +
|
||||
" in cross_sections.xml file!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -188,11 +190,13 @@ void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
|||
std::string& name = nuclide_names[i_nuc];
|
||||
|
||||
// If we've already read this nuclide, skip it
|
||||
if (already_read.find(name) != already_read.end()) continue;
|
||||
if (already_read.find(name) != already_read.end())
|
||||
continue;
|
||||
|
||||
const auto& temps = nuc_temps[i_nuc];
|
||||
int err = openmc_load_nuclide(name.c_str(), temps.data(), temps.size());
|
||||
if (err < 0) throw std::runtime_error{openmc_err_msg};
|
||||
if (err < 0)
|
||||
throw std::runtime_error {openmc_err_msg};
|
||||
|
||||
already_read.insert(name);
|
||||
}
|
||||
|
|
@ -232,14 +236,17 @@ void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
|||
mat->finalize();
|
||||
} // materials
|
||||
|
||||
if (settings::photon_transport && settings::electron_treatment == ElectronTreatment::TTB) {
|
||||
if (settings::photon_transport &&
|
||||
settings::electron_treatment == ElectronTreatment::TTB) {
|
||||
// Take logarithm of energies since they are log-log interpolated
|
||||
data::ttb_e_grid = xt::log(data::ttb_e_grid);
|
||||
}
|
||||
|
||||
// Show minimum/maximum temperature
|
||||
write_message(4, "Minimum neutron data temperature: {} K", data::temperature_min);
|
||||
write_message(4, "Maximum neutron data temperature: {} K", data::temperature_max);
|
||||
write_message(
|
||||
4, "Minimum neutron data temperature: {} K", data::temperature_min);
|
||||
write_message(
|
||||
4, "Maximum neutron data temperature: {} K", data::temperature_max);
|
||||
|
||||
// If the user wants multipole, make sure we found a multipole library.
|
||||
if (settings::temperature_multipole) {
|
||||
|
|
@ -252,8 +259,8 @@ void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
|||
}
|
||||
if (mpi::master && !mp_found) {
|
||||
warning("Windowed multipole functionality is turned on, but no multipole "
|
||||
"libraries were found. Make sure that windowed multipole data is "
|
||||
"present in your cross_sections.xml file.");
|
||||
"libraries were found. Make sure that windowed multipole data is "
|
||||
"present in your cross_sections.xml file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -264,8 +271,7 @@ void read_ce_cross_sections_xml()
|
|||
const auto& filename = settings::path_cross_sections;
|
||||
if (!file_exists(filename)) {
|
||||
// Could not find cross_sections.xml file
|
||||
fatal_error("Cross sections XML file '" + filename +
|
||||
"' does not exist.");
|
||||
fatal_error("Cross sections XML file '" + filename + "' does not exist.");
|
||||
}
|
||||
|
||||
write_message("Reading cross sections XML file...", 5);
|
||||
|
|
@ -301,11 +307,13 @@ void read_ce_cross_sections_xml()
|
|||
|
||||
// Make sure file was not empty
|
||||
if (data::libraries.empty()) {
|
||||
fatal_error("No cross section libraries present in cross_sections.xml file.");
|
||||
fatal_error(
|
||||
"No cross section libraries present in cross_sections.xml file.");
|
||||
}
|
||||
}
|
||||
|
||||
void finalize_cross_sections(){
|
||||
void finalize_cross_sections()
|
||||
{
|
||||
if (settings::run_mode != RunMode::PLOTTING) {
|
||||
simulation::time_read_xs.start();
|
||||
if (settings::run_CE) {
|
||||
|
|
@ -326,7 +334,8 @@ void finalize_cross_sections(){
|
|||
}
|
||||
}
|
||||
|
||||
void library_clear() {
|
||||
void library_clear()
|
||||
{
|
||||
data::libraries.clear();
|
||||
data::library_map.clear();
|
||||
}
|
||||
|
|
|
|||
221
src/dagmc.cpp
221
src/dagmc.cpp
|
|
@ -8,19 +8,19 @@
|
|||
#include "openmc/geometry_aux.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/material.h"
|
||||
#include "openmc/string_utils.h"
|
||||
#include "openmc/settings.h"
|
||||
#include "openmc/string_utils.h"
|
||||
|
||||
#ifdef DAGMC
|
||||
#include "uwuw.hpp"
|
||||
#include "dagmcmetadata.hpp"
|
||||
#include "uwuw.hpp"
|
||||
#endif
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ const bool DAGMC_ENABLED = true;
|
|||
const bool DAGMC_ENABLED = false;
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace openmc
|
||||
|
||||
#ifdef DAGMC
|
||||
|
||||
|
|
@ -40,7 +40,8 @@ namespace openmc {
|
|||
// DAGMC Universe implementation
|
||||
//==============================================================================
|
||||
|
||||
DAGUniverse::DAGUniverse(pugi::xml_node node) {
|
||||
DAGUniverse::DAGUniverse(pugi::xml_node node)
|
||||
{
|
||||
if (check_for_node(node, "id")) {
|
||||
id_ = std::stoi(get_node_value(node, "id"));
|
||||
} else {
|
||||
|
|
@ -66,14 +67,16 @@ DAGUniverse::DAGUniverse(pugi::xml_node node) {
|
|||
initialize();
|
||||
}
|
||||
|
||||
DAGUniverse::DAGUniverse(const std::string& filename,
|
||||
bool auto_geom_ids,
|
||||
bool auto_mat_ids)
|
||||
: filename_(filename), adjust_geometry_ids_(auto_geom_ids), adjust_material_ids_(auto_mat_ids) {
|
||||
DAGUniverse::DAGUniverse(
|
||||
const std::string& filename, bool auto_geom_ids, bool auto_mat_ids)
|
||||
: filename_(filename), adjust_geometry_ids_(auto_geom_ids),
|
||||
adjust_material_ids_(auto_mat_ids)
|
||||
{
|
||||
// determine the next universe id
|
||||
int32_t next_univ_id = 0;
|
||||
for (const auto& u : model::universes) {
|
||||
if (u->id_ > next_univ_id) next_univ_id = u->id_;
|
||||
if (u->id_ > next_univ_id)
|
||||
next_univ_id = u->id_;
|
||||
}
|
||||
next_univ_id++;
|
||||
|
||||
|
|
@ -83,14 +86,15 @@ DAGUniverse::DAGUniverse(const std::string& filename,
|
|||
initialize();
|
||||
}
|
||||
|
||||
void
|
||||
DAGUniverse::initialize() {
|
||||
void DAGUniverse::initialize()
|
||||
{
|
||||
geom_type() = GeometryType::DAG;
|
||||
|
||||
// determine the next cell id
|
||||
int32_t next_cell_id = 0;
|
||||
for (const auto& c : model::cells) {
|
||||
if (c->id_ > next_cell_id) next_cell_id = c->id_;
|
||||
if (c->id_ > next_cell_id)
|
||||
next_cell_id = c->id_;
|
||||
}
|
||||
cell_idx_offset_ = model::cells.size();
|
||||
next_cell_id++;
|
||||
|
|
@ -98,7 +102,8 @@ DAGUniverse::initialize() {
|
|||
// determine the next surface id
|
||||
int32_t next_surf_id = 0;
|
||||
for (const auto& s : model::surfaces) {
|
||||
if (s->id_ > next_surf_id) next_surf_id = s->id_;
|
||||
if (s->id_ > next_surf_id)
|
||||
next_surf_id = s->id_;
|
||||
}
|
||||
surf_idx_offset_ = model::surfaces.size();
|
||||
next_surf_id++;
|
||||
|
|
@ -151,17 +156,20 @@ DAGUniverse::initialize() {
|
|||
|
||||
// set cell ids using global IDs
|
||||
auto c = std::make_unique<DAGCell>(dagmc_instance_, i + 1);
|
||||
c->id_ = adjust_geometry_ids_ ? next_cell_id++ : dagmc_instance_->id_by_index(3, c->dag_index());
|
||||
c->id_ = adjust_geometry_ids_
|
||||
? next_cell_id++
|
||||
: dagmc_instance_->id_by_index(3, c->dag_index());
|
||||
c->universe_ = this->id_;
|
||||
c->fill_ = C_NONE; // no fill, single universe
|
||||
|
||||
auto in_map = model::cell_map.find(c->id_);
|
||||
auto in_map = model::cell_map.find(c->id_);
|
||||
if (in_map == model::cell_map.end()) {
|
||||
model::cell_map[c->id_] = model::cells.size();
|
||||
} else {
|
||||
warning(fmt::format("DAGMC Cell IDs: {}", dagmc_ids_for_dim(3)));
|
||||
fatal_error(fmt::format("Cell ID {} exists in both DAGMC Universe {} "
|
||||
"and the CSG geometry.", c->id_, this->id_));
|
||||
"and the CSG geometry.",
|
||||
c->id_, this->id_));
|
||||
}
|
||||
|
||||
// --- Materials ---
|
||||
|
|
@ -188,11 +196,14 @@ DAGUniverse::initialize() {
|
|||
std::string uwuw_mat = DMD.volume_material_property_data_eh[vol_handle];
|
||||
if (uwuw_->material_library.count(uwuw_mat) != 0) {
|
||||
// Note: material numbers are set by UWUW
|
||||
int mat_number = uwuw_->material_library.get_material(uwuw_mat).metadata["mat_number"].asInt();
|
||||
int mat_number = uwuw_->material_library.get_material(uwuw_mat)
|
||||
.metadata["mat_number"]
|
||||
.asInt();
|
||||
c->material_.push_back(mat_number);
|
||||
} else {
|
||||
fatal_error(fmt::format("Material with value '{}' not found in the "
|
||||
"UWUW material library", mat_str));
|
||||
"UWUW material library",
|
||||
mat_str));
|
||||
}
|
||||
} else {
|
||||
legacy_assign_material(mat_str, c);
|
||||
|
|
@ -218,7 +229,8 @@ DAGUniverse::initialize() {
|
|||
} else if (mat->temperature() > 0.0) {
|
||||
c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * mat->temperature()));
|
||||
} else {
|
||||
c->sqrtkT_.push_back(std::sqrt(K_BOLTZMANN * settings::temperature_default));
|
||||
c->sqrtkT_.push_back(
|
||||
std::sqrt(K_BOLTZMANN * settings::temperature_default));
|
||||
}
|
||||
|
||||
model::cells.emplace_back(std::move(c));
|
||||
|
|
@ -236,31 +248,36 @@ DAGUniverse::initialize() {
|
|||
// initialize surface objects
|
||||
int n_surfaces = dagmc_instance_->num_entities(2);
|
||||
for (int i = 0; i < n_surfaces; i++) {
|
||||
moab::EntityHandle surf_handle = dagmc_instance_->entity_by_index(2, i+1);
|
||||
moab::EntityHandle surf_handle = dagmc_instance_->entity_by_index(2, i + 1);
|
||||
|
||||
// set cell ids using global IDs
|
||||
auto s = std::make_unique<DAGSurface>(dagmc_instance_, i+1);
|
||||
s->id_ = adjust_geometry_ids_ ? next_surf_id++ : dagmc_instance_->id_by_index(2, i+1);
|
||||
auto s = std::make_unique<DAGSurface>(dagmc_instance_, i + 1);
|
||||
s->id_ = adjust_geometry_ids_ ? next_surf_id++
|
||||
: dagmc_instance_->id_by_index(2, i + 1);
|
||||
|
||||
// set BCs
|
||||
std::string bc_value = DMD.get_surface_property("boundary", surf_handle);
|
||||
to_lower(bc_value);
|
||||
if (bc_value.empty() || bc_value == "transmit" || bc_value == "transmission") {
|
||||
if (bc_value.empty() || bc_value == "transmit" ||
|
||||
bc_value == "transmission") {
|
||||
// set to transmission by default (nullptr)
|
||||
} else if (bc_value == "vacuum") {
|
||||
s->bc_ = std::make_shared<VacuumBC>();
|
||||
} else if (bc_value == "reflective" || bc_value == "reflect" || bc_value == "reflecting") {
|
||||
} else if (bc_value == "reflective" || bc_value == "reflect" ||
|
||||
bc_value == "reflecting") {
|
||||
s->bc_ = std::make_shared<ReflectiveBC>();
|
||||
} else if (bc_value == "periodic") {
|
||||
fatal_error("Periodic boundary condition not supported in DAGMC.");
|
||||
} else {
|
||||
fatal_error(fmt::format("Unknown boundary condition \"{}\" specified "
|
||||
"on surface {}", bc_value, s->id_));
|
||||
"on surface {}",
|
||||
bc_value, s->id_));
|
||||
}
|
||||
|
||||
// graveyard check
|
||||
moab::Range parent_vols;
|
||||
rval = dagmc_instance_->moab_instance()->get_parent_meshsets(surf_handle, parent_vols);
|
||||
rval = dagmc_instance_->moab_instance()->get_parent_meshsets(
|
||||
surf_handle, parent_vols);
|
||||
MB_CHK_ERR_CONT(rval);
|
||||
|
||||
// if this surface belongs to the graveyard
|
||||
|
|
@ -277,15 +294,15 @@ DAGUniverse::initialize() {
|
|||
} else {
|
||||
warning(fmt::format("DAGMC Surface IDs: {}", dagmc_ids_for_dim(2)));
|
||||
fatal_error(fmt::format("Surface ID {} exists in both Universe {} "
|
||||
"and the CSG geometry.", s->id_, this->id_));
|
||||
"and the CSG geometry.",
|
||||
s->id_, this->id_));
|
||||
}
|
||||
|
||||
model::surfaces.emplace_back(std::move(s));
|
||||
} // end surface loop
|
||||
}
|
||||
|
||||
std::string
|
||||
DAGUniverse::dagmc_ids_for_dim(int dim) const
|
||||
std::string DAGUniverse::dagmc_ids_for_dim(int dim) const
|
||||
{
|
||||
// generate a vector of ids
|
||||
std::vector<int> id_vec;
|
||||
|
|
@ -313,14 +330,17 @@ DAGUniverse::dagmc_ids_for_dim(int dim) const
|
|||
if (id_vec[i + 1] > stop_id + 1) {
|
||||
|
||||
if (start_id != stop_id) {
|
||||
// there are several IDs in a row, print condensed version (i.e. 1-10, 12-20)
|
||||
// there are several IDs in a row, print condensed version (i.e. 1-10,
|
||||
// 12-20)
|
||||
out << start_id << "-" << stop_id;
|
||||
} else {
|
||||
// only one ID in this contiguous block (i.e. 3, 5, 7, 9)
|
||||
out << start_id;
|
||||
}
|
||||
// insert a comma as long as we aren't in the last ID set
|
||||
if (i < n_ents - 1) { out << ", "; }
|
||||
if (i < n_ents - 1) {
|
||||
out << ", ";
|
||||
}
|
||||
|
||||
// if we are at the end of a set, set the start ID to the first value
|
||||
// in the next set.
|
||||
|
|
@ -333,17 +353,18 @@ DAGUniverse::dagmc_ids_for_dim(int dim) const
|
|||
return out.str();
|
||||
}
|
||||
|
||||
int32_t
|
||||
DAGUniverse::implicit_complement_idx() const {
|
||||
int32_t DAGUniverse::implicit_complement_idx() const
|
||||
{
|
||||
moab::EntityHandle ic;
|
||||
moab::ErrorCode rval = dagmc_instance_->geom_tool()->get_implicit_complement(ic);
|
||||
moab::ErrorCode rval =
|
||||
dagmc_instance_->geom_tool()->get_implicit_complement(ic);
|
||||
MB_CHK_SET_ERR_CONT(rval, "Failed to get implicit complement");
|
||||
// off-by-one: DAGMC indices start at one
|
||||
return cell_idx_offset_ + dagmc_instance_->index_by_handle(ic) - 1;
|
||||
}
|
||||
|
||||
bool
|
||||
DAGUniverse::find_cell(Particle &p) const {
|
||||
bool DAGUniverse::find_cell(Particle& p) const
|
||||
{
|
||||
// if the particle isn't in any of the other DagMC
|
||||
// cells, place it in the implicit complement
|
||||
bool found = Universe::find_cell(p);
|
||||
|
|
@ -354,8 +375,8 @@ DAGUniverse::find_cell(Particle &p) const {
|
|||
return found;
|
||||
}
|
||||
|
||||
void
|
||||
DAGUniverse::to_hdf5(hid_t universes_group) const {
|
||||
void DAGUniverse::to_hdf5(hid_t universes_group) const
|
||||
{
|
||||
// Create a group for this universe.
|
||||
auto group = create_group(universes_group, fmt::format("universe {}", id_));
|
||||
|
||||
|
|
@ -364,20 +385,20 @@ DAGUniverse::to_hdf5(hid_t universes_group) const {
|
|||
|
||||
// Write other properties of the DAGMC Universe
|
||||
write_string(group, "filename", filename_, false);
|
||||
write_attribute(group, "auto_geom_ids", static_cast<int>(adjust_geometry_ids_));
|
||||
write_attribute(group, "auto_mat_ids", static_cast<int>(adjust_material_ids_));
|
||||
write_attribute(
|
||||
group, "auto_geom_ids", static_cast<int>(adjust_geometry_ids_));
|
||||
write_attribute(
|
||||
group, "auto_mat_ids", static_cast<int>(adjust_material_ids_));
|
||||
|
||||
close_group(group);
|
||||
}
|
||||
|
||||
bool
|
||||
DAGUniverse::uses_uwuw() const
|
||||
bool DAGUniverse::uses_uwuw() const
|
||||
{
|
||||
return !uwuw_->material_library.empty();
|
||||
}
|
||||
|
||||
std::string
|
||||
DAGUniverse::get_uwuw_materials_xml() const
|
||||
std::string DAGUniverse::get_uwuw_materials_xml() const
|
||||
{
|
||||
if (!uses_uwuw()) {
|
||||
throw std::runtime_error("This DAGMC Universe does not use UWUW materials");
|
||||
|
|
@ -389,18 +410,20 @@ DAGUniverse::get_uwuw_materials_xml() const
|
|||
ss << "<materials>\n";
|
||||
const auto& mat_lib = uwuw_->material_library;
|
||||
// write materials
|
||||
for (auto mat : mat_lib) { ss << mat.second->openmc("atom"); }
|
||||
for (auto mat : mat_lib) {
|
||||
ss << mat.second->openmc("atom");
|
||||
}
|
||||
// write footer
|
||||
ss << "</materials>";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void
|
||||
DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
|
||||
void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
|
||||
{
|
||||
if (!uses_uwuw()) {
|
||||
throw std::runtime_error("This DAGMC universe does not use UWUW materials.");
|
||||
throw std::runtime_error(
|
||||
"This DAGMC universe does not use UWUW materials.");
|
||||
}
|
||||
|
||||
std::string xml_str = get_uwuw_materials_xml();
|
||||
|
|
@ -410,9 +433,8 @@ DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
|
|||
mats_xml.close();
|
||||
}
|
||||
|
||||
void
|
||||
DAGUniverse::legacy_assign_material(std::string mat_string,
|
||||
std::unique_ptr<DAGCell>& c) const
|
||||
void DAGUniverse::legacy_assign_material(
|
||||
std::string mat_string, std::unique_ptr<DAGCell>& c) const
|
||||
{
|
||||
bool mat_found_by_name = false;
|
||||
// attempt to find a material with a matching name
|
||||
|
|
@ -425,10 +447,11 @@ DAGUniverse::legacy_assign_material(std::string mat_string,
|
|||
if (!mat_found_by_name) {
|
||||
mat_found_by_name = true;
|
||||
c->material_.push_back(m->id_);
|
||||
// report error if more than one material is found
|
||||
// report error if more than one material is found
|
||||
} else {
|
||||
fatal_error(fmt::format(
|
||||
"More than one material found with name '{}'. Please ensure materials "
|
||||
"More than one material found with name '{}'. Please ensure "
|
||||
"materials "
|
||||
"have unique names if using this property to assign materials.",
|
||||
mat_string));
|
||||
}
|
||||
|
|
@ -459,8 +482,8 @@ DAGUniverse::legacy_assign_material(std::string mat_string,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
DAGUniverse::read_uwuw_materials() {
|
||||
void DAGUniverse::read_uwuw_materials()
|
||||
{
|
||||
|
||||
int32_t next_material_id = 0;
|
||||
for (const auto& m : model::materials) {
|
||||
|
|
@ -470,7 +493,8 @@ DAGUniverse::read_uwuw_materials() {
|
|||
|
||||
uwuw_ = std::make_shared<UWUW>(filename_.c_str());
|
||||
const auto& mat_lib = uwuw_->material_library;
|
||||
if (mat_lib.size() == 0) return;
|
||||
if (mat_lib.size() == 0)
|
||||
return;
|
||||
|
||||
// if we're using automatic IDs, update the UWUW material metadata
|
||||
if (adjust_material_ids_) {
|
||||
|
|
@ -482,7 +506,9 @@ DAGUniverse::read_uwuw_materials() {
|
|||
std::stringstream ss;
|
||||
ss << "<?xml version=\"1.0\"?>\n";
|
||||
ss << "<materials>\n";
|
||||
for (auto mat : mat_lib) { ss << mat.second->openmc("atom"); }
|
||||
for (auto mat : mat_lib) {
|
||||
ss << mat.second->openmc("atom");
|
||||
}
|
||||
ss << "</materials>";
|
||||
std::string mat_xml_string = ss.str();
|
||||
|
||||
|
|
@ -503,24 +529,31 @@ DAGUniverse::read_uwuw_materials() {
|
|||
//==============================================================================
|
||||
|
||||
DAGCell::DAGCell(std::shared_ptr<moab::DagMC> dag_ptr, int32_t dag_idx)
|
||||
: Cell{}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx) {
|
||||
: Cell {}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx)
|
||||
{
|
||||
geom_type_ = GeometryType::DAG;
|
||||
simple_ = true;
|
||||
};
|
||||
|
||||
std::pair<double, int32_t>
|
||||
DAGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) const
|
||||
std::pair<double, int32_t> DAGCell::distance(
|
||||
Position r, Direction u, int32_t on_surface, Particle* p) const
|
||||
{
|
||||
Expects(p);
|
||||
// if we've changed direction or we're not on a surface,
|
||||
// reset the history and update last direction
|
||||
if (u != p->last_dir()) { p->last_dir() = u; p->history().reset(); }
|
||||
if (on_surface == 0) { p->history().reset(); }
|
||||
if (u != p->last_dir()) {
|
||||
p->last_dir() = u;
|
||||
p->history().reset();
|
||||
}
|
||||
if (on_surface == 0) {
|
||||
p->history().reset();
|
||||
}
|
||||
|
||||
const auto& univ = model::universes[p->coord(p->n_coord() - 1).universe];
|
||||
|
||||
DAGUniverse* dag_univ = static_cast<DAGUniverse*>(univ.get());
|
||||
if (!dag_univ) fatal_error("DAGMC call made for particle in a non-DAGMC universe");
|
||||
if (!dag_univ)
|
||||
fatal_error("DAGMC call made for particle in a non-DAGMC universe");
|
||||
|
||||
moab::ErrorCode rval;
|
||||
moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_);
|
||||
|
|
@ -532,21 +565,23 @@ DAGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) cons
|
|||
MB_CHK_ERR_CONT(rval);
|
||||
int surf_idx;
|
||||
if (hit_surf != 0) {
|
||||
surf_idx = dag_univ->surf_idx_offset_ + dagmc_ptr_->index_by_handle(hit_surf);
|
||||
surf_idx =
|
||||
dag_univ->surf_idx_offset_ + dagmc_ptr_->index_by_handle(hit_surf);
|
||||
} else {
|
||||
// indicate that particle is lost
|
||||
surf_idx = -1;
|
||||
dist = INFINITY;
|
||||
if (!dagmc_ptr_->is_implicit_complement(vol) || model::universe_map[dag_univ->id_] == model::root_universe) {
|
||||
p->mark_as_lost(fmt::format("No intersection found with DAGMC cell {}", id_));
|
||||
if (!dagmc_ptr_->is_implicit_complement(vol) ||
|
||||
model::universe_map[dag_univ->id_] == model::root_universe) {
|
||||
p->mark_as_lost(
|
||||
fmt::format("No intersection found with DAGMC cell {}", id_));
|
||||
}
|
||||
}
|
||||
|
||||
return {dist, surf_idx};
|
||||
}
|
||||
|
||||
bool
|
||||
DAGCell::contains(Position r, Direction u, int32_t on_surface) const
|
||||
bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const
|
||||
{
|
||||
moab::ErrorCode rval;
|
||||
moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_);
|
||||
|
|
@ -559,14 +594,12 @@ DAGCell::contains(Position r, Direction u, int32_t on_surface) const
|
|||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
DAGCell::to_hdf5_inner(hid_t group_id) const {
|
||||
void DAGCell::to_hdf5_inner(hid_t group_id) const
|
||||
{
|
||||
write_string(group_id, "geom_type", "dagmc", false);
|
||||
|
||||
}
|
||||
|
||||
BoundingBox
|
||||
DAGCell::bounding_box() const
|
||||
BoundingBox DAGCell::bounding_box() const
|
||||
{
|
||||
moab::ErrorCode rval;
|
||||
moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_);
|
||||
|
|
@ -581,19 +614,17 @@ DAGCell::bounding_box() const
|
|||
//==============================================================================
|
||||
|
||||
DAGSurface::DAGSurface(std::shared_ptr<moab::DagMC> dag_ptr, int32_t dag_idx)
|
||||
: Surface{}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx)
|
||||
: Surface {}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx)
|
||||
{
|
||||
geom_type_ = GeometryType::DAG;
|
||||
} // empty constructor
|
||||
|
||||
double
|
||||
DAGSurface::evaluate(Position r) const
|
||||
double DAGSurface::evaluate(Position r) const
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double
|
||||
DAGSurface::distance(Position r, Direction u, bool coincident) const
|
||||
double DAGSurface::distance(Position r, Direction u, bool coincident) const
|
||||
{
|
||||
moab::ErrorCode rval;
|
||||
moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_);
|
||||
|
|
@ -603,12 +634,12 @@ DAGSurface::distance(Position r, Direction u, bool coincident) const
|
|||
double dir[3] = {u.x, u.y, u.z};
|
||||
rval = dagmc_ptr_->ray_fire(surf, pnt, dir, hit_surf, dist, NULL, 0, 0);
|
||||
MB_CHK_ERR_CONT(rval);
|
||||
if (dist < 0.0) dist = INFTY;
|
||||
if (dist < 0.0)
|
||||
dist = INFTY;
|
||||
return dist;
|
||||
}
|
||||
|
||||
Direction
|
||||
DAGSurface::normal(Position r) const
|
||||
Direction DAGSurface::normal(Position r) const
|
||||
{
|
||||
moab::ErrorCode rval;
|
||||
moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_);
|
||||
|
|
@ -619,8 +650,7 @@ DAGSurface::normal(Position r) const
|
|||
return dir;
|
||||
}
|
||||
|
||||
Direction
|
||||
DAGSurface::reflect(Position r, Direction u, Particle* p) const
|
||||
Direction DAGSurface::reflect(Position r, Direction u, Particle* p) const
|
||||
{
|
||||
Expects(p);
|
||||
p->history().reset_to_last_intersection();
|
||||
|
|
@ -638,27 +668,32 @@ DAGSurface::reflect(Position r, Direction u, Particle* p) const
|
|||
// Non-member functions
|
||||
//==============================================================================
|
||||
|
||||
void read_dagmc_universes(pugi::xml_node node) {
|
||||
void read_dagmc_universes(pugi::xml_node node)
|
||||
{
|
||||
for (pugi::xml_node dag_node : node.children("dagmc_universe")) {
|
||||
model::universes.push_back(std::make_unique<DAGUniverse>(dag_node));
|
||||
model::universe_map[model::universes.back()->id_] = model::universes.size() - 1;
|
||||
model::universe_map[model::universes.back()->id_] =
|
||||
model::universes.size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void check_dagmc_root_univ() {
|
||||
void check_dagmc_root_univ()
|
||||
{
|
||||
const auto& ru = model::universes[model::root_universe];
|
||||
if (ru->geom_type() == GeometryType::DAG) {
|
||||
// if the root universe contains DAGMC geometry, warn the user
|
||||
// if it does not contain a graveyard volume
|
||||
auto dag_univ = dynamic_cast<DAGUniverse*>(ru.get());
|
||||
if (dag_univ && !dag_univ->has_graveyard()) {
|
||||
warning("No graveyard volume found in the DagMC model. "
|
||||
"This may result in lost particles and rapid simulation failure.");
|
||||
warning(
|
||||
"No graveyard volume found in the DagMC model. "
|
||||
"This may result in lost particles and rapid simulation failure.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t next_cell(DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed)
|
||||
int32_t next_cell(
|
||||
DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed)
|
||||
{
|
||||
moab::EntityHandle surf =
|
||||
surf_xed->dagmc_ptr()->entity_by_index(2, surf_xed->dag_index());
|
||||
|
|
@ -668,10 +703,10 @@ int32_t next_cell(DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed
|
|||
moab::EntityHandle new_vol;
|
||||
cur_cell->dagmc_ptr()->next_vol(surf, vol, new_vol);
|
||||
|
||||
return cur_cell->dagmc_ptr()->index_by_handle(new_vol) + dag_univ->cell_idx_offset_;
|
||||
return cur_cell->dagmc_ptr()->index_by_handle(new_vol) +
|
||||
dag_univ->cell_idx_offset_;
|
||||
}
|
||||
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@ Discrete::Discrete(pugi::xml_node node)
|
|||
auto params = get_node_array<double>(node, "parameters");
|
||||
|
||||
std::size_t n = params.size();
|
||||
std::copy(params.begin(), params.begin() + n/2, std::back_inserter(x_));
|
||||
std::copy(params.begin() + n/2, params.end(), std::back_inserter(p_));
|
||||
std::copy(params.begin(), params.begin() + n / 2, std::back_inserter(x_));
|
||||
std::copy(params.begin() + n / 2, params.end(), std::back_inserter(p_));
|
||||
|
||||
normalize();
|
||||
}
|
||||
|
||||
Discrete::Discrete(const double* x, const double* p, int n)
|
||||
: x_{x, x+n}, p_{p, p+n}
|
||||
: x_ {x, x + n}, p_ {p, p + n}
|
||||
{
|
||||
normalize();
|
||||
}
|
||||
|
|
@ -44,9 +44,10 @@ double Discrete::sample(uint64_t* seed) const
|
|||
double c = 0.0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
c += p_[i];
|
||||
if (xi < c) return x_[i];
|
||||
if (xi < c)
|
||||
return x_[i];
|
||||
}
|
||||
throw std::runtime_error{"Error when sampling probability mass function."};
|
||||
throw std::runtime_error {"Error when sampling probability mass function."};
|
||||
} else {
|
||||
return x_[0];
|
||||
}
|
||||
|
|
@ -79,7 +80,7 @@ Uniform::Uniform(pugi::xml_node node)
|
|||
|
||||
double Uniform::sample(uint64_t* seed) const
|
||||
{
|
||||
return a_ + prn(seed)*(b_ - a_);
|
||||
return a_ + prn(seed) * (b_ - a_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -121,7 +122,7 @@ double Watt::sample(uint64_t* seed) const
|
|||
//==============================================================================
|
||||
Normal::Normal(pugi::xml_node node)
|
||||
{
|
||||
auto params = get_node_array<double>(node,"parameters");
|
||||
auto params = get_node_array<double>(node, "parameters");
|
||||
if (params.size() != 2) {
|
||||
openmc::fatal_error("Normal energy distribution must have two "
|
||||
"parameters specified.");
|
||||
|
|
@ -141,7 +142,7 @@ double Normal::sample(uint64_t* seed) const
|
|||
//==============================================================================
|
||||
Muir::Muir(pugi::xml_node node)
|
||||
{
|
||||
auto params = get_node_array<double>(node,"parameters");
|
||||
auto params = get_node_array<double>(node, "parameters");
|
||||
if (params.size() != 3) {
|
||||
openmc::fatal_error("Muir energy distribution must have three "
|
||||
"parameters specified.");
|
||||
|
|
@ -170,7 +171,8 @@ Tabular::Tabular(pugi::xml_node node)
|
|||
} else if (temp == "linear-linear") {
|
||||
interp_ = Interpolation::lin_lin;
|
||||
} else {
|
||||
openmc::fatal_error("Unknown interpolation type for distribution: " + temp);
|
||||
openmc::fatal_error(
|
||||
"Unknown interpolation type for distribution: " + temp);
|
||||
}
|
||||
} else {
|
||||
interp_ = Interpolation::histogram;
|
||||
|
|
@ -184,13 +186,15 @@ Tabular::Tabular(pugi::xml_node node)
|
|||
init(x, p, n);
|
||||
}
|
||||
|
||||
Tabular::Tabular(const double* x, const double* p, int n, Interpolation interp, const double* c)
|
||||
: interp_{interp}
|
||||
Tabular::Tabular(const double* x, const double* p, int n, Interpolation interp,
|
||||
const double* c)
|
||||
: interp_ {interp}
|
||||
{
|
||||
init(x, p, n, c);
|
||||
}
|
||||
|
||||
void Tabular::init(const double* x, const double* p, std::size_t n, const double* c)
|
||||
void Tabular::init(
|
||||
const double* x, const double* p, std::size_t n, const double* c)
|
||||
{
|
||||
// Copy x/p arrays into vectors
|
||||
std::copy(x, x + n, std::back_inserter(x_));
|
||||
|
|
@ -211,17 +215,17 @@ void Tabular::init(const double* x, const double* p, std::size_t n, const double
|
|||
c_[0] = 0.0;
|
||||
for (int i = 1; i < n; ++i) {
|
||||
if (interp_ == Interpolation::histogram) {
|
||||
c_[i] = c_[i-1] + p_[i-1]*(x_[i] - x_[i-1]);
|
||||
c_[i] = c_[i - 1] + p_[i - 1] * (x_[i] - x_[i - 1]);
|
||||
} else if (interp_ == Interpolation::lin_lin) {
|
||||
c_[i] = c_[i-1] + 0.5*(p_[i-1] + p_[i]) * (x_[i] - x_[i-1]);
|
||||
c_[i] = c_[i - 1] + 0.5 * (p_[i - 1] + p_[i]) * (x_[i] - x_[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize density and distribution functions
|
||||
for (int i = 0; i < n; ++i) {
|
||||
p_[i] = p_[i]/c_[n-1];
|
||||
c_[i] = c_[i]/c_[n-1];
|
||||
p_[i] = p_[i] / c_[n - 1];
|
||||
c_[i] = c_[i] / c_[n - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,8 +239,9 @@ double Tabular::sample(uint64_t* seed) const
|
|||
int i;
|
||||
std::size_t n = c_.size();
|
||||
for (i = 0; i < n - 1; ++i) {
|
||||
if (c <= c_[i+1]) break;
|
||||
c_i = c_[i+1];
|
||||
if (c <= c_[i + 1])
|
||||
break;
|
||||
c_i = c_[i + 1];
|
||||
}
|
||||
|
||||
// Determine bounding PDF values
|
||||
|
|
@ -246,7 +251,7 @@ double Tabular::sample(uint64_t* seed) const
|
|||
if (interp_ == Interpolation::histogram) {
|
||||
// Histogram interpolation
|
||||
if (p_i > 0.0) {
|
||||
return x_i + (c - c_i)/p_i;
|
||||
return x_i + (c - c_i) / p_i;
|
||||
} else {
|
||||
return x_i;
|
||||
}
|
||||
|
|
@ -255,11 +260,13 @@ double Tabular::sample(uint64_t* seed) const
|
|||
double x_i1 = x_[i + 1];
|
||||
double p_i1 = p_[i + 1];
|
||||
|
||||
double m = (p_i1 - p_i)/(x_i1 - x_i);
|
||||
double m = (p_i1 - p_i) / (x_i1 - x_i);
|
||||
if (m == 0.0) {
|
||||
return x_i + (c - c_i)/p_i;
|
||||
return x_i + (c - c_i) / p_i;
|
||||
} else {
|
||||
return x_i + (std::sqrt(std::max(0.0, p_i*p_i + 2*m*(c - c_i))) - p_i)/m;
|
||||
return x_i +
|
||||
(std::sqrt(std::max(0.0, p_i * p_i + 2 * m * (c - c_i))) - p_i) /
|
||||
m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -273,11 +280,11 @@ double Equiprobable::sample(uint64_t* seed) const
|
|||
std::size_t n = x_.size();
|
||||
|
||||
double r = prn(seed);
|
||||
int i = std::floor((n - 1)*r);
|
||||
int i = std::floor((n - 1) * r);
|
||||
|
||||
double xl = x_[i];
|
||||
double xr = x_[i+i];
|
||||
return xl + ((n - 1)*r - i) * (xr - xl);
|
||||
double xr = x_[i + i];
|
||||
return xl + ((n - 1) * r - i) * (xr - xl);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -295,19 +302,19 @@ UPtrDist distribution_from_xml(pugi::xml_node node)
|
|||
// Allocate extension of Distribution
|
||||
UPtrDist dist;
|
||||
if (type == "uniform") {
|
||||
dist = UPtrDist{new Uniform(node)};
|
||||
dist = UPtrDist {new Uniform(node)};
|
||||
} else if (type == "maxwell") {
|
||||
dist = UPtrDist{new Maxwell(node)};
|
||||
dist = UPtrDist {new Maxwell(node)};
|
||||
} else if (type == "watt") {
|
||||
dist = UPtrDist{new Watt(node)};
|
||||
dist = UPtrDist {new Watt(node)};
|
||||
} else if (type == "normal") {
|
||||
dist = UPtrDist{new Normal(node)};
|
||||
dist = UPtrDist {new Normal(node)};
|
||||
} else if (type == "muir") {
|
||||
dist = UPtrDist{new Muir(node)};
|
||||
dist = UPtrDist {new Muir(node)};
|
||||
} else if (type == "discrete") {
|
||||
dist = UPtrDist{new Discrete(node)};
|
||||
dist = UPtrDist {new Discrete(node)};
|
||||
} else if (type == "tabular") {
|
||||
dist = UPtrDist{new Tabular(node)};
|
||||
dist = UPtrDist {new Tabular(node)};
|
||||
} else {
|
||||
openmc::fatal_error("Invalid distribution type: " + type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "openmc/distribution_angle.h"
|
||||
|
||||
#include <cmath> // for abs, copysign
|
||||
#include <cmath> // for abs, copysign
|
||||
|
||||
#include "xtensor/xarray.hpp"
|
||||
#include "xtensor/xview.hpp"
|
||||
|
|
@ -38,15 +38,15 @@ AngleDistribution::AngleDistribution(hid_t group)
|
|||
int j = offsets[i];
|
||||
int n;
|
||||
if (i < n_energy - 1) {
|
||||
n = offsets[i+1] - j;
|
||||
n = offsets[i + 1] - j;
|
||||
} else {
|
||||
n = temp.shape()[1] - j;
|
||||
}
|
||||
|
||||
// Create and initialize tabular distribution
|
||||
auto xs = xt::view(temp, 0, xt::range(j, j+n));
|
||||
auto ps = xt::view(temp, 1, xt::range(j, j+n));
|
||||
auto cs = xt::view(temp, 2, xt::range(j, j+n));
|
||||
auto xs = xt::view(temp, 0, xt::range(j, j + n));
|
||||
auto ps = xt::view(temp, 1, xt::range(j, j + n));
|
||||
auto cs = xt::view(temp, 2, xt::range(j, j + n));
|
||||
vector<double> x {xs.begin(), xs.end()};
|
||||
vector<double> p {ps.begin(), ps.end()};
|
||||
vector<double> c {cs.begin(), cs.end()};
|
||||
|
|
@ -55,8 +55,8 @@ AngleDistribution::AngleDistribution(hid_t group)
|
|||
// CDF values that were passed through to the HDF5 library. At a later
|
||||
// time, we can remove the CDF values from the HDF5 library and
|
||||
// reconstruct them using the PDF
|
||||
Tabular* mudist = new Tabular{x.data(), p.data(), n, int2interp(interp[i]),
|
||||
c.data()};
|
||||
Tabular* mudist =
|
||||
new Tabular {x.data(), p.data(), n, int2interp(interp[i]), c.data()};
|
||||
|
||||
distribution_.emplace_back(mudist);
|
||||
}
|
||||
|
|
@ -79,17 +79,19 @@ double AngleDistribution::sample(double E, uint64_t* seed) const
|
|||
r = 1.0;
|
||||
} else {
|
||||
i = lower_bound_index(energy_.begin(), energy_.end(), E);
|
||||
r = (E - energy_[i])/(energy_[i+1] - energy_[i]);
|
||||
r = (E - energy_[i]) / (energy_[i + 1] - energy_[i]);
|
||||
}
|
||||
|
||||
// Sample between the ith and (i+1)th bin
|
||||
if (r > prn(seed)) ++i;
|
||||
if (r > prn(seed))
|
||||
++i;
|
||||
|
||||
// Sample i-th distribution
|
||||
double mu = distribution_[i]->sample(seed);
|
||||
|
||||
// Make sure mu is in range [-1,1] and return
|
||||
if (std::abs(mu) > 1.0) mu = std::copysign(1.0, mu);
|
||||
if (std::abs(mu) > 1.0)
|
||||
mu = std::copysign(1.0, mu);
|
||||
return mu;
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue