Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/usersguide/random_ray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ Supported scores:
- total
- fission
- nu-fission
- kappa-fission
- events

Supported Estimators:
Expand Down
1 change: 1 addition & 0 deletions include/openmc/random_ray/flat_source_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class FlatSourceDomain {
vector<double> nu_sigma_f_;
vector<double> sigma_f_;
vector<double> chi_;
vector<double> kappa_fission_;

// 3D arrays stored in 1D representing values for all materials x energy
// groups x energy groups
Expand Down
6 changes: 4 additions & 2 deletions openmc/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,12 +1729,14 @@ def _auto_generate_mgxs_lib(
if correction == 'P0':
mgxs_lib.mgxs_types = [
'nu-transport', 'absorption', 'nu-fission', 'fission',
'consistent nu-scatter matrix', 'multiplicity matrix', 'chi'
'consistent nu-scatter matrix', 'multiplicity matrix', 'chi',
'kappa-fission'
]
elif correction is None:
mgxs_lib.mgxs_types = [
'total', 'absorption', 'nu-fission', 'fission',
'consistent nu-scatter matrix', 'multiplicity matrix', 'chi'
'consistent nu-scatter matrix', 'multiplicity matrix', 'chi',
'kappa-fission'
]

# Specify a "material" domain type for the cross section tally filters
Expand Down
14 changes: 12 additions & 2 deletions src/random_ray/flat_source_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,15 @@ void FlatSourceDomain::random_ray_tally()
score = 1.0;
break;

case SCORE_KAPPA_FISSION:
score = flux * volume * kappa_fission_[material * negroups_ + g] *
density_mult;
break;

default:
fatal_error("Invalid score specified in tallies.xml. Only flux, "
"total, fission, nu-fission, and events are supported in "
"random ray mode.");
"total, fission, nu-fission, kappa-fission, and events "
"are supported in random ray mode.");
break;
}
// Apply score to the appropriate tally bin
Expand Down Expand Up @@ -1165,6 +1170,10 @@ void FlatSourceDomain::flatten_xs()
}
chi_.push_back(chi);

double kappa_fission =
m.get_xs(MgxsType::KAPPA_FISSION, g_out, NULL, NULL, NULL, t, a);
kappa_fission_.push_back(kappa_fission);

for (int g_in = 0; g_in < negroups_; g_in++) {
double sigma_s =
m.get_xs(MgxsType::NU_SCATTER, g_in, &g_out, NULL, NULL, t, a);
Expand All @@ -1180,6 +1189,7 @@ void FlatSourceDomain::flatten_xs()
nu_sigma_f_.push_back(0);
sigma_f_.push_back(0);
chi_.push_back(0);
kappa_fission_.push_back(0);
for (int g_in = 0; g_in < negroups_; g_in++) {
sigma_s_.push_back(0);
}
Expand Down
5 changes: 3 additions & 2 deletions src/random_ray/random_ray_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ void validate_random_ray_inputs()
case SCORE_FISSION:
case SCORE_NU_FISSION:
case SCORE_EVENTS:
case SCORE_KAPPA_FISSION:
break;
default:
fatal_error(
"Invalid score specified. Only flux, total, fission, nu-fission, and "
"event scores are supported in random ray mode.");
"Invalid score specified. Only flux, total, fission, nu-fission, "
"kappa-fission, and event scores are supported in random ray mode.");
}
}

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version='1.0' encoding='utf-8'?>
<model>
<materials>
<cross_sections>mgxs.h5</cross_sections>
<material id="1" name="UO2__2_4__" depletable="true">
<density value="1.0" units="macro"/>
<macroscopic name="UO2__2_4__"/>
</material>
<material id="2" name="Zircaloy">
<density value="1.0" units="macro"/>
<macroscopic name="Zircaloy"/>
</material>
<material id="3" name="Hot_borated_water">
<density value="1.0" units="macro"/>
<macroscopic name="Hot_borated_water"/>
</material>
</materials>
<geometry>
<cell id="1" name="Fuel" material="1" region="-1" universe="0"/>
<cell id="2" name="Cladding" material="2" region="1 -2" universe="0"/>
<cell id="3" name="Water" material="3" region="2 3 -4 5 -6" universe="0"/>
<surface id="1" name="Fuel OR" type="z-cylinder" coeffs="0 0 0.39218"/>
<surface id="2" name="Clad OR" type="z-cylinder" coeffs="0 0 0.4572"/>
<surface id="3" name="left" type="x-plane" boundary="reflective" coeffs="-0.63"/>
<surface id="4" name="right" type="x-plane" boundary="reflective" coeffs="0.63"/>
<surface id="5" name="bottom" type="y-plane" boundary="reflective" coeffs="-0.63"/>
<surface id="6" name="top" type="y-plane" boundary="reflective" coeffs="0.63"/>
</geometry>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>100</particles>
<batches>10</batches>
<inactive>5</inactive>
<source type="independent" strength="1.0" particle="neutron">
<space type="box">
<parameters>-0.63 -0.63 -1 0.63 0.63 1</parameters>
</space>
<constraints>
<fissionable>true</fissionable>
</constraints>
</source>
<energy_mode>multi-group</energy_mode>
<random_ray>
<source type="independent" strength="1.0" particle="neutron">
<space type="box">
<parameters>-0.63 -0.63 -1.0 0.63 0.63 1.0</parameters>
</space>
</source>
<distance_inactive>30.0</distance_inactive>
<distance_active>150.0</distance_active>
<source_region_meshes>
<mesh id="1">
<domain id="0" type="universe"/>
</mesh>
</source_region_meshes>
<source_shape>linear</source_shape>
</random_ray>
<mesh id="1">
<dimension>2 2</dimension>
<lower_left>-0.63 -0.63</lower_left>
<upper_right>0.63 0.63</upper_right>
</mesh>
</settings>
<tallies>
<filter id="61" type="material">
<bins>1</bins>
</filter>
<tally id="193" name="KF Tally">
<filters>61</filters>
<scores>kappa-fission</scores>
</tally>
</tallies>
</model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
k-combined:
7.479770E-01 1.624548E-02
tally 1:
2.965503E+08
1.762157E+16
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version='1.0' encoding='utf-8'?>
<model>
<materials>
<cross_sections>mgxs.h5</cross_sections>
<material id="1" name="UO2__2_4__" depletable="true">
<density value="1.0" units="macro"/>
<macroscopic name="UO2__2_4__"/>
</material>
<material id="2" name="Zircaloy">
<density value="1.0" units="macro"/>
<macroscopic name="Zircaloy"/>
</material>
<material id="3" name="Hot_borated_water">
<density value="1.0" units="macro"/>
<macroscopic name="Hot_borated_water"/>
</material>
</materials>
<geometry>
<cell id="1" name="Fuel" material="1" region="-1" universe="0"/>
<cell id="2" name="Cladding" material="2" region="1 -2" universe="0"/>
<cell id="3" name="Water" material="3" region="2 3 -4 5 -6" universe="0"/>
<surface id="1" name="Fuel OR" type="z-cylinder" coeffs="0 0 0.39218"/>
<surface id="2" name="Clad OR" type="z-cylinder" coeffs="0 0 0.4572"/>
<surface id="3" name="left" type="x-plane" boundary="reflective" coeffs="-0.63"/>
<surface id="4" name="right" type="x-plane" boundary="reflective" coeffs="0.63"/>
<surface id="5" name="bottom" type="y-plane" boundary="reflective" coeffs="-0.63"/>
<surface id="6" name="top" type="y-plane" boundary="reflective" coeffs="0.63"/>
</geometry>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>100</particles>
<batches>10</batches>
<inactive>5</inactive>
<source type="independent" strength="1.0" particle="neutron">
<space type="box">
<parameters>-0.63 -0.63 -1 0.63 0.63 1</parameters>
</space>
<constraints>
<fissionable>true</fissionable>
</constraints>
</source>
<energy_mode>multi-group</energy_mode>
<random_ray>
<source type="independent" strength="1.0" particle="neutron">
<space type="box">
<parameters>-0.63 -0.63 -1.0 0.63 0.63 1.0</parameters>
</space>
</source>
<distance_inactive>30.0</distance_inactive>
<distance_active>150.0</distance_active>
<source_region_meshes>
<mesh id="1">
<domain id="0" type="universe"/>
</mesh>
</source_region_meshes>
<source_shape>linear</source_shape>
</random_ray>
<mesh id="1">
<dimension>2 2</dimension>
<lower_left>-0.63 -0.63</lower_left>
<upper_right>0.63 0.63</upper_right>
</mesh>
</settings>
<tallies>
<filter id="97" type="material">
<bins>1</bins>
</filter>
<tally id="203" name="KF Tally">
<filters>97</filters>
<scores>kappa-fission</scores>
</tally>
</tallies>
</model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
k-combined:
7.372542E-01 6.967831E-03
tally 1:
2.909255E+08
1.693395E+16
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version='1.0' encoding='utf-8'?>
<model>
<materials>
<cross_sections>mgxs.h5</cross_sections>
<material id="1" name="UO2__2_4__" depletable="true">
<density value="1.0" units="macro"/>
<macroscopic name="UO2__2_4__"/>
</material>
<material id="2" name="Zircaloy">
<density value="1.0" units="macro"/>
<macroscopic name="Zircaloy"/>
</material>
<material id="3" name="Hot_borated_water">
<density value="1.0" units="macro"/>
<macroscopic name="Hot_borated_water"/>
</material>
</materials>
<geometry>
<cell id="1" name="Fuel" material="1" region="-1" universe="0"/>
<cell id="2" name="Cladding" material="2" region="1 -2" universe="0"/>
<cell id="3" name="Water" material="3" region="2 3 -4 5 -6" universe="0"/>
<surface id="1" name="Fuel OR" type="z-cylinder" coeffs="0 0 0.39218"/>
<surface id="2" name="Clad OR" type="z-cylinder" coeffs="0 0 0.4572"/>
<surface id="3" name="left" type="x-plane" boundary="reflective" coeffs="-0.63"/>
<surface id="4" name="right" type="x-plane" boundary="reflective" coeffs="0.63"/>
<surface id="5" name="bottom" type="y-plane" boundary="reflective" coeffs="-0.63"/>
<surface id="6" name="top" type="y-plane" boundary="reflective" coeffs="0.63"/>
</geometry>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>100</particles>
<batches>10</batches>
<inactive>5</inactive>
<source type="independent" strength="1.0" particle="neutron">
<space type="box">
<parameters>-0.63 -0.63 -1 0.63 0.63 1</parameters>
</space>
<constraints>
<fissionable>true</fissionable>
</constraints>
</source>
<energy_mode>multi-group</energy_mode>
<random_ray>
<source type="independent" strength="1.0" particle="neutron">
<space type="box">
<parameters>-0.63 -0.63 -1.0 0.63 0.63 1.0</parameters>
</space>
</source>
<distance_inactive>30.0</distance_inactive>
<distance_active>150.0</distance_active>
<source_region_meshes>
<mesh id="1">
<domain id="0" type="universe"/>
</mesh>
</source_region_meshes>
<source_shape>linear</source_shape>
</random_ray>
<mesh id="1">
<dimension>2 2</dimension>
<lower_left>-0.63 -0.63</lower_left>
<upper_right>0.63 0.63</upper_right>
</mesh>
</settings>
<tallies>
<filter id="97" type="material">
<bins>1</bins>
</filter>
<tally id="203" name="KF Tally">
<filters>97</filters>
<scores>kappa-fission</scores>
</tally>
</tallies>
</model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
k-combined:
6.413334E-01 2.083132E-02
tally 1:
2.541463E+08
1.297259E+16
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os

import openmc
from openmc.examples import pwr_pin_cell
from openmc import RegularMesh
from openmc.utility_funcs import change_directory
import pytest

from tests.testing_harness import TolerantPyAPITestHarness


class MGXSTestHarness(TolerantPyAPITestHarness):
def _cleanup(self):
super()._cleanup()
f = 'mgxs.h5'
if os.path.exists(f):
os.remove(f)


@pytest.mark.parametrize("method", ["material_wise", "stochastic_slab", "infinite_medium"])
def test_random_ray_auto_convert(method):
with change_directory(method):
openmc.reset_auto_ids()

# Start with a normal continuous energy model
model = pwr_pin_cell()

# Convert to a multi-group model
model.convert_to_multigroup(
method=method, groups='CASMO-2', nparticles=100,
overwrite_mgxs_library=False, mgxs_path="mgxs.h5"
)

# Convert to a random ray model
model.convert_to_random_ray()

# Set the number of particles
model.settings.particles = 100

# Overlay a basic 2x2 mesh
n = 2
mesh = RegularMesh()
mesh.dimension = (n, n)
bbox = model.geometry.bounding_box
mesh.lower_left = (bbox.lower_left[0], bbox.lower_left[1])
mesh.upper_right = (bbox.upper_right[0], bbox.upper_right[1])
model.settings.random_ray['source_region_meshes'] = [
(mesh, [model.geometry.root_universe])]

# Set the source shape to linear
model.settings.random_ray['source_shape'] = 'linear'

# Set a material tally
t = openmc.Tally(name = 'KF Tally')
t.filters = [openmc.MaterialFilter(bins=1)]
t.scores = ['kappa-fission']
model.tallies.append(t)

harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()
Loading