Added XML Schema chain validation functionality #3629
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Depletion chain validation could be useful for users who want to provide a custom chain file. Additionally, the validation step could be applied before OpenMC parses the file, thus avoiding unnecessary computation in the event of an invalid chain.
A validation procedure based on the definition of an XML Schema is proposed. This schema is written in XSD 1.1, drawing inspiration from the validation method implemented in the
Chainclass. Version 1.1 enables straightforward testing of the XML file, in this case by checking the sum of branching ratios and fission yields.Furthermore, the schema checks the file structure according to the information provided in the OpenMC documentation.
Feedback on the schema's structure could help to ensure greater adherence to OpenMC requirements. Currently, the schema uses a threshold when checking for yield normalisation. The degree of precision with which the normalisation is preserved depends on the number of fission product (FP) considered when building the chain. This means that some simplified chains may not pass the test if too many FPs have been discarded. For this reason, fine-tuning of the threshold may be necessary based on current requirements.
The proposed modifications require an additional package, xmlschemas.
This is necessary to ensure compatibility with XSD 1.1.
Another version of the schema based on version 1.0 can be implemented. In this case, no additional packages are required; however, it will not be possible to check normalisations directly with the schema.
One possible solution would be to make the XML Schema package optional while providing both schema versions. This would allow users who do not want to use the additional package to still apply a basic validation procedure through the schema.
Since the modifications only concern the chain.py file and the test suites, no clang-format check has been performed. As the documentation does not currently mention any form of chain validation, I would like to wait for feedback before making any changes to it.
Fixes # 3585
Checklist