Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] fixed dep matrix reader for serpent V 2.2.1 #512

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 18 additions & 3 deletions src/serpentTools/parsers/depmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class DepmtxReader(BaseReader, SparseReaderMixin):
----------
deltaT: float
Length of depletion interval
flx: float
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer to have the full variable name just to be more explicit. And it should be typed as optional float, right? Since for older versions of serpent that don't output this data, users should expect it to not always be a float.

Homogenized flux
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about this not existing for versions of Serpent less than 2.2.1

n0: :class:`numpy.ndarray`
Vector of original isotopics
zai: :class:`numpy.ndarray`
Expand All @@ -60,6 +62,7 @@ def __init__(self, filePath, sparse=None):
BaseReader.__init__(self, filePath, 'depmtx')
SparseReaderMixin.__init__(self, sparse)
self.deltaT = None
self.flx = None
self.n0 = None
self.n1 = None
self.zai = None
Expand Down Expand Up @@ -92,9 +95,16 @@ def _read(self):
with open(self.filePath) as stream:
line = stream.readline()
self.deltaT = float(line.split()[-1][:-1])
line = stream.readline()

if "flx" in line:
self.flx = float(line.split()[-1][:-1])
line = stream.readline()

if "zeros" in line:
line = stream.readline()
Comment on lines +104 to +105
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the zero line added? If that's also new that's one thing but I'm pretty sure this line existed in earlier versions of Serpent.

Related to the removal of the zero line down below?


# process initial isotopics
line = stream.readline()
match = self._getMatch(line, NDENS_REGEX, 'n0 vector')
line = _parseIsoBlock(stream, tempN0, match, line, NDENS_REGEX)
numIso = len(tempN0)
Expand All @@ -104,7 +114,9 @@ def _read(self):

self.n1 = empty_like(self.n0)
self.zai = empty_like(self.n0, dtype=int)


if "zeros" in line:
line = stream.readline()
Comment on lines -107 to +119
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on why removing the zeros line read

match = self._getMatch(line, ZAI_REGEX, 'zai vector')
line = _parseIsoBlock(stream, self.zai, match, line, ZAI_REGEX)

Expand All @@ -115,7 +127,10 @@ def _read(self):
line = self.__processSparseMatrix(stream, matrixSize)
else:
line = self.__processDenseMatrix(stream, matrixSize)


if "zeros" in line:
line = stream.readline()

Comment on lines -118 to +133
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on the removal of the zeros line read

match = self._getMatch(line, NDENS_REGEX, 'n1 vector')
_parseIsoBlock(stream, self.n1, match, line, NDENS_REGEX)

Expand Down
Loading