Skip to content

fix: skip extra header lines in depmtx reader (Serpent 2.2.3+) - #538

Closed
steps-re wants to merge 1 commit into
CORE-GATECH-GROUP:mainfrom
steps-re:fix/depmtx-extra-header-lines
Closed

steps-re wants to merge 1 commit into
CORE-GATECH-GROUP:mainfrom
steps-re:fix/depmtx-extra-header-lines

Conversation

@steps-re

@steps-re steps-re commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Serpent 2.2.3 with set depmtx 1 writes additional scalar and matrix declaration lines between the time header and the N0 isotope data, for example:

t = 4.32E4;
flx =  2;             ← new in Serpent 2.2.3
N0 = zeros(74, 1);    ← new in Serpent 2.2.3
N0(  1, 1) =  1.17E-07; % lost
...

The current reader immediately tries to match the line after t = ... as an N0 entry and raises:

SerpentToolsException: Depmtx reader failed to match n0 vector from ...:
flx =  2;

Fix

In DepmtxReader._read, advance past any lines that do not match NDENS_REGEX before starting to parse the N0 block. The change is backward-compatible: files without extra lines are parsed identically.

Test

Added test_depmtx_extra_header_lines which prepends flx and N0 = zeros declarations to the existing depmtx_ref.m fixture and verifies the parsed arrays exactly match the unmodified reference reader.

Fixes #533

Signed-off-by: Mike German mike@stepsventures.com

Serpent 2.2.3 with ``set depmtx 1`` writes additional scalar and matrix
declaration lines (e.g. ``flx = 2;``, ``N0 = zeros(n, 1);``) between the
time header and the first N0 isotope entry.  The reader raised a
``SerpentToolsException`` when it hit these unrecognized lines.

Add a loop in ``DepmtxReader._read`` that advances past any lines which do
not match ``NDENS_REGEX`` before starting to parse the N0 block.  The fix
is backward-compatible: files without extra lines are parsed identically.

Add a regression test that prepends ``flx`` and ``N0 = zeros`` lines to
the existing ``depmtx_ref.m`` fixture and verifies the parsed arrays match
the reference reader output exactly.

Fixes CORE-GATECH-GROUP#533

Signed-off-by: Mike German <mike@stepsventures.com>
@drewejohnson

Copy link
Copy Markdown
Collaborator

Can you consider closing this PR in favor of #534? That one has been in the works for a while.

Then we can split #539 to just focus on the burn steps

@steps-re

Copy link
Copy Markdown
Contributor Author

makes sense, #534 has this covered and has been in flight longer. closing in favor of it.

#539 is now split down to just the burn-step fix, so the two no longer overlap on depmatrix.py.

@steps-re steps-re closed this Aug 12, 2026
@drewejohnson

Copy link
Copy Markdown
Collaborator

thank you 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG in depmtx reader

2 participants