mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Ruff comments on code (#2696)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
d765bd031f
commit
9b7b33c7fa
12 changed files with 10 additions and 50 deletions
|
|
@ -1308,9 +1308,6 @@ class CMFDRun:
|
|||
Whether or not to run an adjoint calculation
|
||||
|
||||
"""
|
||||
# Check for physical adjoint
|
||||
physical_adjoint = adjoint and self._adjoint_type == 'physical'
|
||||
|
||||
# Start timer for build
|
||||
time_start_buildcmfd = time.time()
|
||||
|
||||
|
|
@ -1432,9 +1429,6 @@ class CMFDRun:
|
|||
# indices of the actual problem so that cmfd_flux can be multiplied by
|
||||
# nfissxs
|
||||
|
||||
# Calculate volume
|
||||
vol = np.prod(self._hxyz, axis=3)
|
||||
|
||||
# Reshape phi by number of groups
|
||||
phi = self._phi.reshape((n, ng))
|
||||
|
||||
|
|
@ -2148,7 +2142,6 @@ class CMFDRun:
|
|||
is_accel = self._coremap != _CMFD_NOACCEL
|
||||
# Logical for determining whether a zero flux "albedo" b.c. should be
|
||||
# applied
|
||||
is_zero_flux_alb = abs(self._albedo - _ZERO_FLUX) < _TINY_BIT
|
||||
x_inds, y_inds, z_inds = np.indices((nx, ny, nz))
|
||||
|
||||
# Define slice equivalent to is_accel[0,:,:]
|
||||
|
|
@ -2725,8 +2718,6 @@ class CMFDRun:
|
|||
|
||||
# Define flux in each cell
|
||||
cell_flux = self._flux / dxdydz
|
||||
# Extract indices of coremap that are accelerated
|
||||
is_accel = self._coremap != _CMFD_NOACCEL
|
||||
|
||||
# Define dhat at left surface for all mesh cells on left boundary
|
||||
boundary = self._first_x_accel
|
||||
|
|
|
|||
|
|
@ -235,7 +235,6 @@ class AngleDistribution(EqualityMixin):
|
|||
items = get_cont_record(file_obj)
|
||||
li = items[2]
|
||||
nk = items[4]
|
||||
center_of_mass = (items[3] == 2)
|
||||
|
||||
# Check for obsolete energy transformation matrix. If present, just skip
|
||||
# it and keep reading
|
||||
|
|
@ -259,7 +258,6 @@ class AngleDistribution(EqualityMixin):
|
|||
mu = []
|
||||
for i in range(n_energy):
|
||||
items, al = get_list_record(file_obj)
|
||||
temperature = items[0]
|
||||
energy[i] = items[1]
|
||||
coefficients = np.asarray([1.0] + al)
|
||||
mu.append(Legendre(coefficients))
|
||||
|
|
@ -273,7 +271,6 @@ class AngleDistribution(EqualityMixin):
|
|||
mu = []
|
||||
for i in range(n_energy):
|
||||
params, f = get_tab1_record(file_obj)
|
||||
temperature = params[0]
|
||||
energy[i] = params[1]
|
||||
if f.n_regions > 1:
|
||||
raise NotImplementedError('Angular distribution with multiple '
|
||||
|
|
@ -289,7 +286,6 @@ class AngleDistribution(EqualityMixin):
|
|||
mu = []
|
||||
for i in range(n_energy_legendre):
|
||||
items, al = get_list_record(file_obj)
|
||||
temperature = items[0]
|
||||
energy_legendre[i] = items[1]
|
||||
coefficients = np.asarray([1.0] + al)
|
||||
mu.append(Legendre(coefficients))
|
||||
|
|
@ -300,7 +296,6 @@ class AngleDistribution(EqualityMixin):
|
|||
energy_tabulated = np.zeros(n_energy_tabulated)
|
||||
for i in range(n_energy_tabulated):
|
||||
params, f = get_tab1_record(file_obj)
|
||||
temperature = params[0]
|
||||
energy_tabulated[i] = params[1]
|
||||
if f.n_regions > 1:
|
||||
raise NotImplementedError('Angular distribution with multiple '
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ def _get_products(ev, mt):
|
|||
|
||||
za = int(params[0])
|
||||
awr = params[1]
|
||||
lip = params[2]
|
||||
law = params[3]
|
||||
|
||||
if za == 0:
|
||||
|
|
|
|||
|
|
@ -93,9 +93,8 @@ class Resonances:
|
|||
n_isotope = items[4] # Number of isotopes
|
||||
|
||||
ranges = []
|
||||
for iso in range(n_isotope):
|
||||
for _ in range(n_isotope):
|
||||
items = get_cont_record(file_obj)
|
||||
abundance = items[1]
|
||||
fission_widths = (items[3] == 1) # fission widths are given?
|
||||
n_ranges = items[4] # number of resonance energy ranges
|
||||
|
||||
|
|
@ -424,14 +423,12 @@ class MultiLevelBreitWigner(ResonanceRange):
|
|||
# Determine penetration and shift corresponding to resonance energy
|
||||
k = wave_number(A, E)
|
||||
rho = k*self.channel_radius[l](E)
|
||||
rhohat = k*self.scattering_radius[l](E)
|
||||
p[i], s[i] = penetration_shift(l, rho)
|
||||
|
||||
# Determine penetration at modified energy for competitive reaction
|
||||
if gx > 0:
|
||||
Ex = E + self.q_value[l]*(A + 1)/A
|
||||
rho = k*self.channel_radius[l](Ex)
|
||||
rhohat = k*self.scattering_radius[l](Ex)
|
||||
px[i], sx[i] = penetration_shift(l, rho)
|
||||
else:
|
||||
px[i] = sx[i] = 0.0
|
||||
|
|
@ -680,7 +677,6 @@ class ReichMoore(ResonanceRange):
|
|||
# Determine penetration and shift corresponding to resonance energy
|
||||
k = wave_number(A, E)
|
||||
rho = k*self.channel_radius[l](E)
|
||||
rhohat = k*self.scattering_radius[l](E)
|
||||
p[i], s[i] = penetration_shift(l, rho)
|
||||
|
||||
df['p'] = p
|
||||
|
|
|
|||
|
|
@ -93,10 +93,8 @@ class ResonanceCovariances(Resonances):
|
|||
n_isotope = items[4] # Number of isotopes
|
||||
|
||||
ranges = []
|
||||
for iso in range(n_isotope):
|
||||
for _ in range(n_isotope):
|
||||
items = endf.get_cont_record(file_obj)
|
||||
abundance = items[1]
|
||||
fission_widths = (items[3] == 1) # Flag for fission widths
|
||||
n_ranges = items[4] # Number of resonance energy ranges
|
||||
|
||||
for j in range(n_ranges):
|
||||
|
|
@ -378,7 +376,6 @@ class MultiLevelBreitWignerCovariance(ResonanceCovarianceRange):
|
|||
|
||||
# Other scatter radius parameters
|
||||
items = endf.get_cont_record(file_obj)
|
||||
target_spin = items[0]
|
||||
lcomp = items[3] # Flag for compatibility 0, 1, 2 - 2 is compact form
|
||||
nls = items[4] # number of l-values
|
||||
|
||||
|
|
@ -387,8 +384,6 @@ class MultiLevelBreitWignerCovariance(ResonanceCovarianceRange):
|
|||
items = endf.get_cont_record(file_obj)
|
||||
# Number of short range type resonance covariances
|
||||
num_short_range = items[4]
|
||||
# Number of long range type resonance covariances
|
||||
num_long_range = items[5]
|
||||
|
||||
# Read resonance widths, J values, etc
|
||||
records = []
|
||||
|
|
@ -421,7 +416,6 @@ class MultiLevelBreitWignerCovariance(ResonanceCovarianceRange):
|
|||
# compact correlations
|
||||
elif lcomp == 2:
|
||||
items, values = endf.get_list_record(file_obj)
|
||||
mean = items
|
||||
num_res = items[5]
|
||||
energy = values[0::12]
|
||||
spin = values[1::12]
|
||||
|
|
@ -613,20 +607,14 @@ class ReichMooreCovariance(ResonanceCovarianceRange):
|
|||
|
||||
# Other scatter radius parameters
|
||||
items = endf.get_cont_record(file_obj)
|
||||
target_spin = items[0]
|
||||
lcomp = items[3] # Flag for compatibility 0, 1, 2 - 2 is compact form
|
||||
nls = items[4] # Number of l-values
|
||||
|
||||
# Build covariance matrix for General Resolved Resonance Formats
|
||||
if lcomp == 1:
|
||||
items = endf.get_cont_record(file_obj)
|
||||
# Number of short range type resonance covariances
|
||||
num_short_range = items[4]
|
||||
# Number of long range type resonance covariances
|
||||
num_long_range = items[5]
|
||||
# Read resonance widths, J values, etc
|
||||
channel_radius = {}
|
||||
scattering_radius = {}
|
||||
records = []
|
||||
for i in range(num_short_range):
|
||||
items, values = endf.get_list_record(file_obj)
|
||||
|
|
|
|||
|
|
@ -594,7 +594,6 @@ class ConstantFissionYieldHelper(FissionYieldHelper):
|
|||
self._constant_yields[name] = yield_data
|
||||
continue
|
||||
# Specific energy not found, use closest energy
|
||||
distances = [abs(energy - ene) for ene in nuc.yield_energies]
|
||||
min_E = min(nuc.yield_energies, key=lambda e: abs(e - energy))
|
||||
self._constant_yields[name] = nuc.yield_data[min_E]
|
||||
|
||||
|
|
|
|||
|
|
@ -1222,8 +1222,8 @@ class RealFilter(Filter):
|
|||
def get_bin_index(self, filter_bin):
|
||||
i = np.where(self.bins[:, 1] == filter_bin[1])[0]
|
||||
if len(i) == 0:
|
||||
msg = (f'Unable to get the bin index for Filter since '
|
||||
'"{filter_bin}" is not one of the bins')
|
||||
msg = ('Unable to get the bin index for Filter since '
|
||||
f'"{filter_bin}" is not one of the bins')
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
return i[0]
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ class MDGXS(MGXS):
|
|||
group_edges = self.energy_groups.group_edges
|
||||
energy_filter = openmc.EnergyFilter(group_edges)
|
||||
|
||||
if self.delayed_groups != None:
|
||||
if self.delayed_groups is not None:
|
||||
delayed_filter = openmc.DelayedGroupFilter(self.delayed_groups)
|
||||
filters = [[energy_filter], [delayed_filter, energy_filter]]
|
||||
else:
|
||||
|
|
@ -1884,9 +1884,6 @@ class DecayRate(MDGXS):
|
|||
@property
|
||||
def filters(self):
|
||||
|
||||
# Create the non-domain specific Filters for the Tallies
|
||||
group_edges = self.energy_groups.group_edges
|
||||
|
||||
if self.delayed_groups is not None:
|
||||
delayed_filter = openmc.DelayedGroupFilter(self.delayed_groups)
|
||||
filters = [[delayed_filter], [delayed_filter]]
|
||||
|
|
|
|||
|
|
@ -499,8 +499,6 @@ class Model:
|
|||
warnings.warn("remove_surfs kwarg will be deprecated soon, please "
|
||||
"set the Geometry.merge_surfaces attribute instead.")
|
||||
self.geometry.merge_surfaces = True
|
||||
# Can be used to modify tallies in case any surfaces are redundant
|
||||
redundant_surfaces = self.geometry.remove_redundant_surfaces()
|
||||
|
||||
# provide a memo to track which meshes have been written
|
||||
mesh_memo = set()
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ class CylinderSector(CompositeSurface):
|
|||
**kwargs):
|
||||
|
||||
if r2 <= r1:
|
||||
raise ValueError(f'r2 must be greater than r1.')
|
||||
raise ValueError('r2 must be greater than r1.')
|
||||
|
||||
if theta2 <= theta1:
|
||||
raise ValueError(f'theta2 must be greater than theta1.')
|
||||
raise ValueError('theta2 must be greater than theta1.')
|
||||
|
||||
phi1 = pi / 180 * theta1
|
||||
phi2 = pi / 180 * theta2
|
||||
|
|
@ -204,7 +204,7 @@ class CylinderSector(CompositeSurface):
|
|||
offset.
|
||||
"""
|
||||
if theta >= 360. or theta <= 0:
|
||||
raise ValueError(f'theta must be less than 360 and greater than 0.')
|
||||
raise ValueError('theta must be less than 360 and greater than 0.')
|
||||
|
||||
theta1 = alpha
|
||||
theta2 = alpha + theta
|
||||
|
|
@ -288,10 +288,10 @@ class IsogonalOctagon(CompositeSurface):
|
|||
|
||||
# Side lengths
|
||||
if r2 > r1 * sqrt(2):
|
||||
raise ValueError(f'r2 is greater than sqrt(2) * r1. Octagon' +
|
||||
raise ValueError('r2 is greater than sqrt(2) * r1. Octagon' +
|
||||
' may be erroneous.')
|
||||
if r1 > r2 * sqrt(2):
|
||||
raise ValueError(f'r1 is greater than sqrt(2) * r2. Octagon' +
|
||||
raise ValueError('r1 is greater than sqrt(2) * r2. Octagon' +
|
||||
' may be erroneous.')
|
||||
|
||||
L_basis_ax = (r2 * sqrt(2) - r1)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import typing # imported separately as py3.8 requires typing.Iterable
|
||||
from collections.abc import Iterable, Mapping, MutableSequence
|
||||
from enum import Enum
|
||||
import itertools
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from __future__ import annotations
|
||||
from collections.abc import Iterable
|
||||
from numbers import Real, Integral
|
||||
from typing import Iterable, List, Optional, Dict, Sequence
|
||||
import warnings
|
||||
|
|
@ -481,7 +480,6 @@ def wwinp_to_wws(path: PathLike) -> List[WeightWindows]:
|
|||
# read file type, time-dependence, number of
|
||||
# particles, mesh type and problem identifier
|
||||
_if, iv, ni, nr = [int(x) for x in header[:4]]
|
||||
probid = header[4] if len(header) > 4 else ""
|
||||
|
||||
# header value checks
|
||||
if _if != 1:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue