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

Serpent Interface Upgrade #2290

Merged
merged 29 commits into from
Apr 4, 2024
Merged

Serpent Interface Upgrade #2290

merged 29 commits into from
Apr 4, 2024

Conversation

alfoa
Copy link
Collaborator

@alfoa alfoa commented Mar 27, 2024


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

Closes #2289

What are the significant changes in functionality due to this change request?

This merge request is aimed to upgrade and make the SERPENT interface fully functional and flexible.

  • Addition of support for eigen/criticality calculations (not only burnup)
  • Usage of open source tool (serpentTools: https://serpent-tools.readthedocs.io/en/master/index.html) to parse results from serpent. The serpentTools library is not installed if a user does not invoke the serpent interface.
  • Utility Function to create RAVEN variable groups has been rewritten to leverage Serpent output parser directly (if a modification of the parser is performed, the script is able to get it directly)
  • Addition of embedded reactivity calculation
  • Support of multiple output files (Result files, Detector outputs, Depletion outputs, Micro XS reader)
  • Bumat support has been disabled since Serpent is removing (deprecated) such output format and all the info are already contained in the Depletion output (*dep.m format)
  • Consistency checks in the input files (if an output is requested, the flags in the input are checked accordingly)

For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in XML block, the node <internalParallel> to True.
  • 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

@alfoa alfoa requested a review from wangcj05 March 27, 2024 15:53
alfoa added 3 commits March 27, 2024 10:13
…test machine centos8 (since by default it stills uses python 2 for initial installation of plugins
Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

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

@alfoa I have several general comments for you to consider.

self._fileTypesToRead = ['ResultsReader'] # container of file types to read
# in case of burnup calc, the interface can compute the time at which FOMs (e.g. keff) crosses
# a target. For example (default), we can compute the time (burnDays) at which absKeff crosses 1.0
self.EOLtarget = {'absKeff':1.0}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I kind do not like the naming here, but I do not have a better suggestion here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe eolTarget?

Copy link
Collaborator Author

@alfoa alfoa Apr 2, 2024

Choose a reason for hiding this comment

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

yeah. EOL is the acronym for "End Of Life". I changed it following your suggestion above.

Comment on lines +77 to +78
#if 'set mdep' not in data:
# raise Exception("MicroXSReader file type has been requested but no 'mdep' flag has been set in the input file!")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to keep these lines?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I would like to keep those lines because are "ready" to be used once a "defect" in serpentTools is addressed

Comment on lines +81 to +87
#if 'set his' not in data:
# raise Exception("HistoryReader file type has been requested but no 'his' flag has been set in the input file!")
#else:
# optionSet = data.split('set his')[1].strip()
# if not optionSet.startswith('1'):
# raise Exception("HistoryReader file type has been requested but 'set his' flag is not set to '1'!")

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to keep these lines?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I would like to keep those lines because are "ready" to be used once a "defect" in serpentTools is addressed

Comment on lines +127 to +130
#elif ft == 'HistoryReader':
# results.update(self._historyReader(nSteps))
#elif ft == 'MicroXSReader':
# results.update(self._microXSReader(nSteps))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to keep these lines?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I would like to keep those lines because are "ready" to be used once a "defect" in serpentTools is addressed

@ Out, None
"""
if 'keff' in k.lower() and k.lower() != 'anakeff':
rho_sigma, rhoLog_sigma = None, None
Copy link
Collaborator

Choose a reason for hiding this comment

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

camelBack for these variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

rho, rhoLog = (v[0] - 1) / v[0], np.log(v[0])
if v.shape[0] > 1:
# we have sigma
rho_sigma, rhoLog_sigma = (v[1] / v[0]) * rho, (v[1] / v[0]) * rhoLog
Copy link
Collaborator

Choose a reason for hiding this comment

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

camelBack for these variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,62 @@

Copy link
Collaborator

Choose a reason for hiding this comment

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

please add copyright info

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

Comment on lines 1093 to 1096
try:
sigmaAdjusted = calculations['sigma'][list(needed[metric]['targets'])]/np.sqrt(calculations['equivalentSamples'][list(needed[metric]['targets'])])
except:
sigmaAdjusted = calculations['sigma'][list(needed[metric]['targets'])]/np.sqrt(self.sampleSize)
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 put the error type in the "except"? it seems to me these changes may not be the right fix for the issue. I guess equivalentSamples may not computed for certain cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the error type. What the right fix you have in mind?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess maybe we need to figure why equivalentSamples is not calculated in certain case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The equivalentSamples is not computed when self.pbPresent is False.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we need to assign uniform weight in this case, reset self.pbPressent, and raise a warning for user.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you guys do it in another MR? It is not really related to this MR. I can revert the fix if you want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

definitely, you do not need to revert the changes. By the way, I have already approved your PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wonderful.
Thanks a lot!!!

Comment on lines +550 to +572
def importOrInstall(package):
"""
Method to import or install (if not found) a library named "package"
@ In, package, str, the package name to import
@ Out, pckImport, module, the imported module

NOTE: This method should be used only by developers
since it silently install packages
if not found
"""
pckImport = None
try:
pckImport = __import__(package)
except ImportError:
print("( ) "+UreturnPrintTag('UTILS')+": "+UreturnPrintPostTag('Message') + " -> Python package "+package+"not found. Trying to install it via pip!")
import subprocess
s = subprocess.getstatusoutput("python -m pip install " + package)
if int(s[0]) == 0:
print("( ) "+ UreturnPrintTag('UTILS')+": "+ UreturnPrintPostTag('Message') + " -> Installation succeded!")
pckImport = __import__(package)
else:
print("( ) " + UreturnPrintTag('UTILS')+ ": " + UreturnPrintPostTag('Message') + " -> Installation failed with error: " + s[1] )
return pckImport
Copy link
Collaborator

Choose a reason for hiding this comment

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

As stated, this method should be used only by developers. Can you add the package through RAVEN dependencies file? You may use optional attribute if you do not want to force to install it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. And also modified the test to check for that library (if not found, the tests should be skipped)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wangcj05 I don't remember. Are the "optional" libraries installed in any machine? (If not, the serpent regression tests are never run)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We do have one unix machine to test optional, however, for your situation, the library serpentTools is not installed. It seems something is wrong with the scripts/library_handler.py, the optional library is not added to pip for some reason. I would suggest you update the script to handle the pip with optional.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the problem is located in the following lines, the addOptional is set to False when using pip within conda.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems that serpentTools is now installed.

Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

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

changes are good.

Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

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

changes are good.

@moosebuild
Copy link

Job Test qsubs sawtooth on a5b2cd7 : invalidated by @wangcj05

very slow in removing packages

@alfoa alfoa added the RAVENv3.0 label Apr 3, 2024
@moosebuild
Copy link

Job Test qsubs sawtooth on a5b2cd7 : invalidated by @wangcj05

library issue

@wangcj05
Copy link
Collaborator

wangcj05 commented Apr 4, 2024

checklist passed. PR can be merged.

@wangcj05 wangcj05 merged commit ad44499 into devel Apr 4, 2024
12 checks passed
@wangcj05 wangcj05 deleted the alfoa/serpentModifications branch April 4, 2024 14:57
@alfoa
Copy link
Collaborator Author

alfoa commented Apr 4, 2024

@wangcj05 Thanks a lot!!!

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

Successfully merging this pull request may close these issues.

[TASK] Serpent interface should be upgraded to process criticality calcs too (not only burnup)
3 participants