mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Merge pull request #2154 from shimwell/adding_log_width_bins_to_energy_filter
added bin_log_width to EnergyFilter() to help with plotting
This commit is contained in:
commit
90608665b7
2 changed files with 21 additions and 0 deletions
|
|
@ -1324,6 +1324,18 @@ class EnergyFilter(RealFilter):
|
|||
cv.check_greater_than('filter value', v0, 0., equality=True)
|
||||
cv.check_greater_than('filter value', v1, 0., equality=True)
|
||||
|
||||
@property
|
||||
def lethargy_bin_width(self):
|
||||
"""Calculates the base 10 log width of energy bins which is useful when
|
||||
plotting the normalized flux.
|
||||
|
||||
Returns
|
||||
-------
|
||||
numpy.array
|
||||
Array of bin widths
|
||||
"""
|
||||
return np.log10(self.bins[:, 1]/self.bins[:, 0])
|
||||
|
||||
@classmethod
|
||||
def from_group_structure(cls, group_structure):
|
||||
"""Construct an EnergyFilter instance from a standard group structure.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
import numpy as np
|
||||
import openmc
|
||||
from pytest import fixture, approx
|
||||
|
|
@ -246,3 +247,11 @@ def test_energy():
|
|||
f = openmc.EnergyFilter.from_group_structure('CCFE-709')
|
||||
assert f.bins.shape == (709, 2)
|
||||
assert len(f.values) == 710
|
||||
|
||||
|
||||
def test_lethargy_bin_width():
|
||||
f = openmc.EnergyFilter.from_group_structure('VITAMIN-J-175')
|
||||
assert len(f.lethargy_bin_width) == 175
|
||||
energy_bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175']
|
||||
assert f.lethargy_bin_width[0] == math.log10(energy_bins[1]/energy_bins[0])
|
||||
assert f.lethargy_bin_width[-1] == math.log10(energy_bins[-1]/energy_bins[-2])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue