mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Filter material from (#2750)
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com> Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
910d1df1c9
commit
a3695c784e
12 changed files with 99 additions and 10 deletions
|
|
@ -406,6 +406,7 @@ list(APPEND libopenmc_SOURCES
|
|||
src/tallies/filter_energyfunc.cpp
|
||||
src/tallies/filter_legendre.cpp
|
||||
src/tallies/filter_material.cpp
|
||||
src/tallies/filter_materialfrom.cpp
|
||||
src/tallies/filter_mesh.cpp
|
||||
src/tallies/filter_meshsurface.cpp
|
||||
src/tallies/filter_mu.cpp
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ Constructing Tallies
|
|||
openmc.Filter
|
||||
openmc.UniverseFilter
|
||||
openmc.MaterialFilter
|
||||
openmc.MaterialFromFilter
|
||||
openmc.CellFilter
|
||||
openmc.CellFromFilter
|
||||
openmc.CellBornFilter
|
||||
|
|
|
|||
|
|
@ -435,6 +435,7 @@ public:
|
|||
int& material() { return material_; }
|
||||
const int& material() const { return material_; }
|
||||
int& material_last() { return material_last_; }
|
||||
const int& material_last() const { return material_last_; }
|
||||
|
||||
BoundaryInfo& boundary() { return boundary_; }
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ enum class FilterType {
|
|||
ENERGY_OUT,
|
||||
LEGENDRE,
|
||||
MATERIAL,
|
||||
MATERIALFROM,
|
||||
MESH,
|
||||
MESH_SURFACE,
|
||||
MU,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
void set_materials(gsl::span<const int32_t> materials);
|
||||
|
||||
private:
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
|
|
|
|||
29
include/openmc/tallies/filter_materialfrom.h
Normal file
29
include/openmc/tallies/filter_materialfrom.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_MATERIALFROM_H
|
||||
#define OPENMC_TALLIES_FILTER_MATERIALFROM_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "openmc/tallies/filter_material.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
//! Specifies which material particles exit when crossing a surface.
|
||||
//==============================================================================
|
||||
|
||||
class MaterialFromFilter : public MaterialFilter {
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
std::string type_str() const override { return "materialfrom"; }
|
||||
FilterType type() const override { return FilterType::MATERIALFROM; }
|
||||
|
||||
void get_all_bins(const Particle& p, TallyEstimator estimator,
|
||||
FilterMatch& match) const override;
|
||||
|
||||
std::string text_label(int bin) const override;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_TALLIES_FILTER_MATERIALFROM_H
|
||||
|
|
@ -22,7 +22,7 @@ from ._xml import get_text
|
|||
_FILTER_TYPES = (
|
||||
'universe', 'material', 'cell', 'cellborn', 'surface', 'mesh', 'energy',
|
||||
'energyout', 'mu', 'polar', 'azimuthal', 'distribcell', 'delayedgroup',
|
||||
'energyfunction', 'cellfrom', 'legendre', 'spatiallegendre',
|
||||
'energyfunction', 'cellfrom', 'materialfrom', 'legendre', 'spatiallegendre',
|
||||
'sphericalharmonics', 'zernike', 'zernikeradial', 'particle', 'cellinstance',
|
||||
'collision', 'time'
|
||||
)
|
||||
|
|
@ -451,7 +451,7 @@ class UniverseFilter(WithIDFilter):
|
|||
Parameters
|
||||
----------
|
||||
bins : openmc.UniverseBase, int, or iterable thereof
|
||||
The Universes to tally. Either openmc.UniverseBase objects or their
|
||||
The Universes to tally. Either :class:`openmc.UniverseBase` objects or their
|
||||
Integral ID numbers can be used.
|
||||
filter_id : int
|
||||
Unique identifier for the filter
|
||||
|
|
@ -475,7 +475,31 @@ class MaterialFilter(WithIDFilter):
|
|||
Parameters
|
||||
----------
|
||||
bins : openmc.Material, Integral, or iterable thereof
|
||||
The Materials to tally. Either openmc.Material objects or their
|
||||
The material(s) to tally. Either :class:`openmc.Material` objects or their
|
||||
Integral ID numbers can be used.
|
||||
filter_id : int
|
||||
Unique identifier for the filter
|
||||
|
||||
Attributes
|
||||
----------
|
||||
bins : Iterable of Integral
|
||||
openmc.Material IDs.
|
||||
id : int
|
||||
Unique identifier for the filter
|
||||
num_bins : Integral
|
||||
The number of filter bins
|
||||
|
||||
"""
|
||||
expected_type = Material
|
||||
|
||||
|
||||
class MaterialFromFilter(WithIDFilter):
|
||||
"""Bins tally event locations based on the Material they occurred in.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
bins : openmc.Material, Integral, or iterable thereof
|
||||
The material(s) to tally. Either :class:`openmc.Material` objects or their
|
||||
Integral ID numbers can be used.
|
||||
filter_id : int
|
||||
Unique identifier for the filter
|
||||
|
|
@ -499,7 +523,7 @@ class CellFilter(WithIDFilter):
|
|||
Parameters
|
||||
----------
|
||||
bins : openmc.Cell, int, or iterable thereof
|
||||
The cells to tally. Either openmc.Cell objects or their ID numbers can
|
||||
The cells to tally. Either :class:`openmc.Cell` objects or their ID numbers can
|
||||
be used.
|
||||
filter_id : int
|
||||
Unique identifier for the filter
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ __all__ = [
|
|||
'Filter', 'AzimuthalFilter', 'CellFilter', 'CellbornFilter', 'CellfromFilter',
|
||||
'CellInstanceFilter', 'CollisionFilter', 'DistribcellFilter', 'DelayedGroupFilter',
|
||||
'EnergyFilter', 'EnergyoutFilter', 'EnergyFunctionFilter', 'LegendreFilter',
|
||||
'MaterialFilter', 'MeshFilter', 'MeshSurfaceFilter', 'MuFilter', 'ParticleFilter',
|
||||
'MaterialFilter', 'MaterialFromFilter', 'MeshFilter', 'MeshSurfaceFilter', 'MuFilter', 'ParticleFilter',
|
||||
'PolarFilter', 'SphericalHarmonicsFilter', 'SpatialLegendreFilter', 'SurfaceFilter',
|
||||
'UniverseFilter', 'ZernikeFilter', 'ZernikeRadialFilter', 'filters'
|
||||
]
|
||||
|
|
@ -342,6 +342,10 @@ class MaterialFilter(Filter):
|
|||
_dll.openmc_material_filter_set_bins(self._index, n, bins)
|
||||
|
||||
|
||||
class MaterialFromFilter(Filter):
|
||||
filter_type = 'materialfrom'
|
||||
|
||||
|
||||
class MeshFilter(Filter):
|
||||
filter_type = 'mesh'
|
||||
|
||||
|
|
@ -501,6 +505,7 @@ _FILTER_TYPE_MAP = {
|
|||
'energyfunction': EnergyFunctionFilter,
|
||||
'legendre': LegendreFilter,
|
||||
'material': MaterialFilter,
|
||||
'materialfrom': MaterialFromFilter,
|
||||
'mesh': MeshFilter,
|
||||
'meshsurface': MeshSurfaceFilter,
|
||||
'mu': MuFilter,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "openmc/tallies/filter_energyfunc.h"
|
||||
#include "openmc/tallies/filter_legendre.h"
|
||||
#include "openmc/tallies/filter_material.h"
|
||||
#include "openmc/tallies/filter_materialfrom.h"
|
||||
#include "openmc/tallies/filter_mesh.h"
|
||||
#include "openmc/tallies/filter_meshsurface.h"
|
||||
#include "openmc/tallies/filter_mu.h"
|
||||
|
|
@ -121,6 +122,8 @@ Filter* Filter::create(const std::string& type, int32_t id)
|
|||
return Filter::create<LegendreFilter>(id);
|
||||
} else if (type == "material") {
|
||||
return Filter::create<MaterialFilter>(id);
|
||||
} else if (type == "materialfrom") {
|
||||
return Filter::create<MaterialFromFilter>(id);
|
||||
} else if (type == "mesh") {
|
||||
return Filter::create<MeshFilter>(id);
|
||||
} else if (type == "meshsurface") {
|
||||
|
|
|
|||
24
src/tallies/filter_materialfrom.cpp
Normal file
24
src/tallies/filter_materialfrom.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "openmc/tallies/filter_materialfrom.h"
|
||||
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/material.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
void MaterialFromFilter::get_all_bins(
|
||||
const Particle& p, TallyEstimator estimator, FilterMatch& match) const
|
||||
{
|
||||
auto search = map_.find(p.material_last());
|
||||
if (search != map_.end()) {
|
||||
match.bins_.push_back(search->second);
|
||||
match.weights_.push_back(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
std::string MaterialFromFilter::text_label(int bin) const
|
||||
{
|
||||
return "Material from " +
|
||||
std::to_string(model::materials[materials_[bin]]->id_);
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
<filter id="4" type="surface">
|
||||
<bins>1</bins>
|
||||
</filter>
|
||||
<filter id="7" type="cellfrom">
|
||||
<filter id="7" type="materialfrom">
|
||||
<bins>2</bins>
|
||||
</filter>
|
||||
<filter id="8" type="cell">
|
||||
|
|
|
|||
|
|
@ -106,19 +106,19 @@ class SurfaceTallyTestHarness(PyAPITestHarness):
|
|||
|
||||
# Create partial current tallies from water to fuel
|
||||
# Filters
|
||||
cell_from_filter = openmc.CellFromFilter(water)
|
||||
mat_from_filter = openmc.MaterialFromFilter(borated_water)
|
||||
cell_filter = openmc.CellFilter(fuel)
|
||||
|
||||
# Cell to cell filters for partial current
|
||||
cell_to_cell_tally = openmc.Tally(name=str('water_to_fuel_1'))
|
||||
cell_to_cell_tally.filters = [cell_from_filter, cell_filter, \
|
||||
cell_to_cell_tally.filters = [mat_from_filter, cell_filter, \
|
||||
energy_filter, polar_filter, azimuthal_filter]
|
||||
cell_to_cell_tally.scores = ['current']
|
||||
tallies_file.append(cell_to_cell_tally)
|
||||
|
||||
# Cell from + surface filters for partial current
|
||||
cell_to_cell_tally = openmc.Tally(name=str('water_to_fuel_2'))
|
||||
cell_to_cell_tally.filters = [cell_from_filter, surface_filter, \
|
||||
cell_to_cell_tally.filters = [mat_from_filter, surface_filter, \
|
||||
energy_filter, polar_filter, azimuthal_filter]
|
||||
cell_to_cell_tally.scores = ['current']
|
||||
tallies_file.append(cell_to_cell_tally)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue