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

# Python Meshtal Class Fails for mct < 0 on PRDMP Card #5

Open
gonsie2 opened this issue Oct 11, 2023 · 0 comments
Open

# Python Meshtal Class Fails for mct < 0 on PRDMP Card #5

gonsie2 opened this issue Oct 11, 2023 · 0 comments

Comments

@gonsie2
Copy link

gonsie2 commented Oct 11, 2023

Python Meshtal Class Fails for mct < 0 on PRDMP Card

I'm performing validation of MCNP6.3 and thus have disabled printing of run-specific information in my output files. I'm using the mct option on the PRDMP card (mct = -1 or -2). Though the MCNP6.3 manual only mentions the disabled printing for MCTAL and output files, run-specific information is also removed from MESHTAL files. For example,

mcnp   version 6     ld=02/20/18  probid =  10/11/23 13:51:15 
 MY TITLE
 Number of histories used for normalizing tallies =         10000.00

 Mesh Tally Number         4
 ...

becomes

 MY TITLE
 Number of histories used for normalizing tallies =         10000.00

 Mesh Tally Number         4
 ...

When I try to read these MESHTAL files using the Meshtal class within MCNPTools' Python bindings, I get a generic RuntimeError: McnpToolsException. Re-enabling printing of run-specific info fixes the issue. I haven't had the same issue with the MctalTally and MctalKcode classes, so it appears to be limited to the Meshtal class.

I have very limited knowledge of C++, but I think the issue is in the source code for file Meshtal.cpp, lines 31-43 (and repeated on lines 422-434?):

  // read the header line
  cjsoft::stringops::getline(m_handle,line);
  std::vector<std::string> spline;
  cjsoft::stringops::tokenize<std::vector<std::string>,cjsoft::stringops::StringTrim>(line,spline);

  if( spline.size() == 8 ) {
    m_code = spline[0];
    m_version = spline[2];
    m_probid = spline[6] + " " + spline[7];
  }
  else {
    throw McnpToolsException("file " + fname + " does not look like an MCNP meshtal file");
  }

It looks like the code expects to find 8 substrings which make up the run-specific information in the header line. If not found, it throws an exception. In pseudocode, it seems like the fix would be:

read header line

if (header line starts with 'mcnp'): \\ Follow existing logic
	split line into substrings
	assign values to run-specific variables
	load next line

else if (header line starts with space): \\ Comment line seems to always start with space, even if blank
	assign blank values to run-specific variables
	\\ already on comment line, so don't load next line

else:
	throw exception

process comment line...
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

No branches or pull requests

1 participant