-
Notifications
You must be signed in to change notification settings - Fork 519
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
added material.from_library method #2105
base: develop
Are you sure you want to change the base?
added material.from_library method #2105
Conversation
@shimwell I really like this! My first bit of feedback is that I think having a single json file for each library may be clearer and I think the method should be a class method on the |
Thanks for the feedback @eepeterson I've moved the method to a classmethod as suggested. The python example from the first comment now changes to >>>import openmc
>>>m1 = openmc.Material.from_library(name='Sodium Oxide', library='pnnl_v2')
>>>m1
Material
ID = 1
Name =
Temperature = None
Density = 2.27 [g/cc]
S(a,b) Tables
Nuclides
O16 = 0.332523 [ao]
O17 = 0.0001266665 [ao]
O18 = 0.0006833327 [ao]
Na23 = 0.666667 [ao] |
@eepeterson I've refactored the PR to use a single files for each library as suggested 👍 . I guess this will be handy when adding private material libraries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @shimwell! One question I have is how the JSON file is being generated. I see that in the material compendium in many cases they have elemental compositions, but in the JSON file we have nuclides explicitly. This will create problems if the data library being used doesn't have a particular nuclide. For example, Anthracene uses C12 and C13, which won't work with ENDF/B-VII.1 and earlier. Is it possible to switch over to using elemental compositions when available?
@shimwell Also looks like you have a conflict on material.py |
@paulromano and @shimwell I have been thinking about this a little lately and I think this might warrant just a little more structure to do robustly, namely a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first round of small comments
Co-authored-by: Ethan Peterson <ethan.peterson@mit.edu>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a little refactoring here so that we can use external libraries as well based on an environment variable
Co-authored-by: Ethan Peterson <ethan.peterson@mit.edu>
@shimwell I think we need to move the library file to |
Thanks Ethan. I've created the folder, renamed the file and moved it in there. I've also added it to the package data in setup.py. Hoping the tests pass this time 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really handy capability. I spent a good chunk of time translating material definitions from the PNNL compendium by hand when learning to use MCNP. Thanks @shimwell and @eepeterson for working on this!
Just a few small thoughts/comments from me.
I came across a little error that the CI didn't catch. Perhaps because we use when using So I've added an |
I have left this PR for a while as the plan was to refactor the materials class so that is accepts elements then come back to this PR. However I have an alternative suggestions. How about we remove the basically just retaining part of this PR so that users can load in their own material library. This idea was inspired by @mwart-cfs who has a use case I had not considered. For QA purposes they prefer no material libraries to be initially loaded into the code but want the ability to add user libraries. Further details here |
I don’t quite see how not including widely used libraries within OpenMC directly helps with QA exactly and to me it doesn’t make sense for something like the PNNL compendium to exist within every users custom libraries. Since properly including elements in material specifications does require significant refactoring, maybe it is worth implementing a temporary way of including user libraries, but im not sure. |
How about we break this PR into two parts. Part 1, just the frame work to allow users to load in their own custom libraries (xml files) Part 2, after the material refactor add in the PNNL compendium so that it is distributed with openmc package and available as a default loaded in library |
I think this might be worth another go as the materials compendium is now downloadable in json format https://compendium.cwmd.pnnl.gov/ |
Also there is now a Pyne materials package that creates pyne materials from the compendium. Nice work by @ahnaf-tahmid-chowdhury |
I think this is a deprecated approach. The more |
If an organizational user doesn't want to use the libraries due to QA, they can just exclude that from the scope of their QA program. |
Hi all,
This PR attempts to add the ability to add material composition and density from a predefined collection / library.
This PR follows on from this discussion where adding materials from the PNNL library of predefined materials was discussed.
Adding a PNNL_v1 material database has previously be performed by PyNe and more recently by ATTILA. I've also done something similar before in the neutronics-material-maker package.
One of the differences to existing implementations and this PR is that we have revision version 2 (released in 2021) of the PNNL compendium released in here instead of the first revision (released in 2011)
I think this method for this implementation is quite concise due to expanding the dictionary into keyword arguments with
**
. The implementation is also extendable as the JSON file can support multiple libraries if PNNL_v3 gets release or there is a need to add another material compendium.I've also added a simple test to the test_material.py unit test but the usage is simple