fixes per request of @paulromano: fixing test scratch files vice using .gitignore, minor typo in docs, and some otherwise small code cleanups

This commit is contained in:
Adam G Nelson 2018-05-01 19:17:21 -04:00
parent 1d2ebb71f8
commit b61c67a12c
8 changed files with 39 additions and 64 deletions

3
.gitignore vendored
View file

@ -100,6 +100,3 @@ examples/jupyter/plots
.python-version
.coverage
htmlcov
# Test data
tests/xsdir

View file

@ -24,7 +24,7 @@ function (:math:`f` in the above equation) should be used. The regions of phase
space are generally called *filters* and the scoring functions are simply
called *scores*.
The only cases when *filters* do not correspond directly with the regions of
The only cases when filters do not correspond directly with the regions of
phase space are when expansion functions are applied in the integrand, such as
for Legendre expansions of the scattering kernel.

View file

@ -1925,7 +1925,7 @@ class MGXS(metaclass=ABCMeta):
# Add the Legendre bin to the column if it exists
if 'legendre' in df:
columns += ['legendre']
columns.append('legendre')
# If user requested micro cross sections, divide out the atom densities
if xs_type == 'micro':

View file

@ -391,8 +391,7 @@ class Tally(IDManagerMixin):
'nu-scatter-p', 'scatter-y', 'nu-scatter-y',
'flux-y', 'total-y']:
if score.startswith(deprecated):
msg = score.strip() + ' is deprecated and should no ' \
'longer be used.'
msg = score.strip() + ' is no longer supported.'
raise ValueError(msg)
scores[i] = score.strip()

View file

@ -459,8 +459,6 @@ contains
! Find the number of macroscopic and nuclide data in this material
num_nuclides = 0
num_macros = 0
k = 1
n = 1
do j = 1, m % n_nuclides
if (nuclides_MG(m % nuclide(j)) % obj % awr /= MACROSCOPIC_AWR) then
num_nuclides = num_nuclides + 1

View file

@ -1199,8 +1199,9 @@ contains
!#########################################################################
! Expand score if necessary and add to tally results.
call expand_and_score(p, t, score_index, filter_index, score_bin, &
score, i)
!$omp atomic
t % results(RESULT_VALUE, score_index, filter_index) = &
t % results(RESULT_VALUE, score_index, filter_index) + score
end do SCORE_LOOP
end subroutine score_general_ce
@ -1982,36 +1983,15 @@ contains
!#########################################################################
! Expand score if necessary and add to tally results.
call expand_and_score(p, t, score_index, filter_index, score_bin, &
score, i)
!$omp atomic
t % results(RESULT_VALUE, score_index, filter_index) = &
t % results(RESULT_VALUE, score_index, filter_index) + score
end do SCORE_LOOP
nullify(matxs, nucxs)
end subroutine score_general_mg
!===============================================================================
! EXPAND_AND_SCORE takes a previously determined score value and adjusts it
! if necessary (for functional expansion weighting), and then adds the resultant
! value to the tally results array.
!===============================================================================
subroutine expand_and_score(p, t, score_index, filter_index, score_bin, &
score, i)
type(Particle), intent(in) :: p
type(TallyObject), intent(inout) :: t
integer, intent(inout) :: score_index
integer, intent(in) :: filter_index ! for % results
integer, intent(in) :: score_bin ! score of concern
real(8), intent(inout) :: score ! data to score
integer, intent(inout) :: i ! Working index
!$omp atomic
t % results(RESULT_VALUE, score_index, filter_index) = &
t % results(RESULT_VALUE, score_index, filter_index) + score
end subroutine expand_and_score
!===============================================================================
! SCORE_ALL_NUCLIDES tallies individual nuclide reaction rates specifically when
! the user requests <nuclides>all</nuclides>.
@ -2961,8 +2941,10 @@ contains
score_index = q
! Expand score if necessary and add to tally results.
call expand_and_score(p, t, score_index, filter_index, score_bin, &
score, k)
!$omp atomic
t % results(RESULT_VALUE, score_index, filter_index) = &
t % results(RESULT_VALUE, score_index, filter_index) + score
end do SCORE_LOOP
! ======================================================================

View file

@ -18,12 +18,12 @@ def test_tallies():
azimuthal_bins = (-3.14159, -1.8850, -0.6283, 0.6283, 1.8850, 3.14159)
azimuthal_filter = AzimuthalFilter(azimuthal_bins)
azimuthal_tally1 = Tally(tally_id=1)
azimuthal_tally1 = Tally()
azimuthal_tally1.filters = [azimuthal_filter]
azimuthal_tally1.scores = ['flux']
azimuthal_tally1.estimator = 'tracklength'
azimuthal_tally2 = Tally(tally_id=2)
azimuthal_tally2 = Tally()
azimuthal_tally2.filters = [azimuthal_filter]
azimuthal_tally2.scores = ['flux']
azimuthal_tally2.estimator = 'analog'
@ -33,38 +33,38 @@ def test_tallies():
mesh_2x2.upper_right = [182.07, 182.07]
mesh_2x2.dimension = [2, 2]
mesh_filter = MeshFilter(mesh_2x2)
azimuthal_tally3 = Tally(tally_id=3)
azimuthal_tally3 = Tally()
azimuthal_tally3.filters = [azimuthal_filter, mesh_filter]
azimuthal_tally3.scores = ['flux']
azimuthal_tally3.estimator = 'tracklength'
cellborn_tally = Tally(tally_id=4)
cellborn_tally = Tally()
cellborn_tally.filters = [
CellbornFilter((model.geometry.get_all_cells()[10],
model.geometry.get_all_cells()[21],
22, 23))] # Test both Cell objects and ids
cellborn_tally.scores = ['total']
dg_tally = Tally(tally_id=5)
dg_tally = Tally()
dg_tally.filters = [DelayedGroupFilter((1, 2, 3, 4, 5, 6))]
dg_tally.scores = ['delayed-nu-fission']
four_groups = (0.0, 0.253, 1.0e3, 1.0e6, 20.0e6)
energy_filter = EnergyFilter(four_groups)
energy_tally = Tally(tally_id=6)
energy_tally = Tally()
energy_tally.filters = [energy_filter]
energy_tally.scores = ['total']
energyout_filter = EnergyoutFilter(four_groups)
energyout_tally = Tally(tally_id=7)
energyout_tally = Tally()
energyout_tally.filters = [energyout_filter]
energyout_tally.scores = ['scatter']
transfer_tally = Tally(tally_id=8)
transfer_tally = Tally()
transfer_tally.filters = [energy_filter, energyout_filter]
transfer_tally.scores = ['scatter', 'nu-fission']
material_tally = Tally(tally_id=9)
material_tally = Tally()
material_tally.filters = [
MaterialFilter((model.geometry.get_materials_by_name('UOX fuel')[0],
model.geometry.get_materials_by_name('Zircaloy')[0],
@ -73,56 +73,56 @@ def test_tallies():
mu_bins = (-1.0, -0.5, 0.0, 0.5, 1.0)
mu_filter = MuFilter(mu_bins)
mu_tally1 = Tally(tally_id=10)
mu_tally1 = Tally()
mu_tally1.filters = [mu_filter]
mu_tally1.scores = ['scatter', 'nu-scatter']
print('mu_tally1', mu_tally1.id)
mu_tally2 = Tally(tally_id=11)
mu_tally2 = Tally()
mu_tally2.filters = [mu_filter, mesh_filter]
mu_tally2.scores = ['scatter', 'nu-scatter']
polar_bins = (0.0, 0.6283, 1.2566, 1.8850, 2.5132, 3.14159)
polar_filter = PolarFilter(polar_bins)
polar_tally1 = Tally(tally_id=12)
polar_tally1 = Tally()
polar_tally1.filters = [polar_filter]
polar_tally1.scores = ['flux']
polar_tally1.estimator = 'tracklength'
polar_tally2 = Tally(tally_id=13)
polar_tally2 = Tally()
polar_tally2.filters = [polar_filter]
polar_tally2.scores = ['flux']
polar_tally2.estimator = 'analog'
polar_tally3 = Tally(tally_id=14)
polar_tally3 = Tally()
polar_tally3.filters = [polar_filter, mesh_filter]
polar_tally3.scores = ['flux']
polar_tally3.estimator = 'tracklength'
legendre_filter = LegendreFilter(order=4)
legendre_tally = Tally(tally_id=15)
legendre_tally = Tally()
legendre_tally.filters = [legendre_filter]
legendre_tally.scores = ['scatter', 'nu-scatter']
legendre_tally.estimatir = 'analog'
print('legendre_tally', mu_tally1.id)
harmonics_filter = SphericalHarmonicsFilter(order=4)
harmonics_tally = Tally(tally_id=16)
harmonics_tally = Tally()
harmonics_tally.filters = [harmonics_filter]
harmonics_tally.scores = ['scatter', 'nu-scatter', 'flux', 'total']
harmonics_tally.estimatir = 'analog'
harmonics_tally2 = Tally(tally_id=17)
harmonics_tally2 = Tally()
harmonics_tally2.filters = [harmonics_filter]
harmonics_tally2.scores = ['flux', 'total']
harmonics_tally2.estimatir = 'collision'
harmonics_tally3 = Tally(tally_id=18)
harmonics_tally3 = Tally()
harmonics_tally3.filters = [harmonics_filter]
harmonics_tally3.scores = ['flux', 'total']
harmonics_tally3.estimatir = 'tracklength'
universe_tally = Tally(tally_id=19)
universe_tally = Tally()
universe_tally.filters = [
UniverseFilter((model.geometry.get_all_universes()[1],
model.geometry.get_all_universes()[2],
@ -132,8 +132,7 @@ def test_tallies():
cell_filter = CellFilter((model.geometry.get_all_cells()[10],
model.geometry.get_all_cells()[21],
22, 23, 60)) # Test both Cell objects and ids
score_tallies = [Tally(tally_id=20), Tally(tally_id=21),
Tally(tally_id=22)]
score_tallies = [Tally(), Tally(), Tally()]
for t in score_tallies:
t.filters = [cell_filter]
t.scores = ['absorption', 'delayed-nu-fission', 'events', 'fission',
@ -146,7 +145,7 @@ def test_tallies():
score_tallies[2].estimator = 'collision'
cell_filter2 = CellFilter((21, 22, 23, 27, 28, 29, 60))
flux_tallies = [Tally(tally_id=23 + i) for i in range(3)]
flux_tallies = [Tally() for i in range(3)]
for t in flux_tallies:
t.filters = [cell_filter2]
t.scores = ['flux']
@ -154,7 +153,7 @@ def test_tallies():
flux_tallies[1].estimator = 'analog'
flux_tallies[2].estimator = 'collision'
total_tallies = [Tally(tally_id=26 + i) for i in range(3)]
total_tallies = [Tally() for i in range(3)]
for t in total_tallies:
t.filters = [cell_filter]
t.scores = ['total']
@ -163,7 +162,7 @@ def test_tallies():
total_tallies[1].estimator = 'analog'
total_tallies[2].estimator = 'collision'
all_nuclide_tallies = [Tally(tally_id=29 + i) for i in range(4)]
all_nuclide_tallies = [Tally() for i in range(4)]
for t in all_nuclide_tallies:
t.filters = [cell_filter]
t.estimator = 'tracklength'

View file

@ -345,10 +345,10 @@ def test_nbody(tmpdir, h2):
assert nbody1.q_value == nbody2.q_value
def test_ace_convert(tmpdir):
def test_ace_convert(run_in_tmpdir):
filename = os.path.join(_ENDF_DATA, 'neutrons', 'n-001_H_001.endf')
ace_ascii = str(tmpdir.join('ace_ascii'))
ace_binary = str(tmpdir.join('ace_binary'))
ace_ascii = 'ace_ascii'
ace_binary = 'ace_binary'
openmc.data.njoy.make_ace(filename, ace=ace_ascii)
# Convert to binary