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

Update to use OpenMC v0.14.0, update documentation #19

Merged
merged 83 commits into from
Jun 13, 2024

Conversation

abachma2
Copy link
Collaborator

@abachma2 abachma2 commented Apr 23, 2024

This PR does some updates to the archetype library to be compatible with OpenMC v0.14.0. A full list of changes in this PR (it suffers from scope creep unfortunately):

  • Updating DepleteReactor archetype to now accept thermal power (instead of just using the power_cap parameter for depletion) and flux (required input for OpenMC IndependentOperator
  • Remove the procedure to check for previous core composition -- this was a quick implementation that should really be thought through more for better implementation.
  • Update methods in Depletion class to be compatible with OpenMC v0.14.0, and associated tests
  • Running integration tests only on PR, and not actually running the tests (we know they fail because of issue Importing OpenMC causes a seg fault #12)
  • Add unit tests for the openmcyclus.Depletion class to CI (with help from @ceserz2)
  • Add .gitignore for repo
  • Improve documentation, which includes updating the README (change format from md to rst), adding a CHANGELOG, and CONTRIBUTING guidelines
  • Updating examples/micro_xs.csv to format used in OpenMC v0.14.0
  • Updating inputs in examples directory to include the new parameters added to DepleteReactor
  • Add comparison/materials.xml and comparison/chain_endfb71_pwr.xml for better reproduction of running the benchmark directory
  • Update the comparison/OpenMC.ipynb for OpenMC v0.14.0

@abachma2 abachma2 added the Type:Test Is related to software testing. Failing tests, necessary new tests, test frameworks, etc. label Apr 23, 2024
Copy link
Contributor

@yardasol yardasol left a comment

Choose a reason for hiding this comment

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

Hi @abachma2,

I can tell you put a lot of work into this. Nice job. My comments are below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider bundling these changes into the existing test-openmcyclus workflow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you referring to the build process? Or the tests themselves? I was planning on streamlining the build process in a different PR so this one didn't get too big.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do plan to have another PR later on for checking if the CHANGELOG is updated. I'm not sure if that's what you were referring to here.

CHANGELOG.rst Outdated Show resolved Hide resolved
CONTRIBUTING.rst Outdated Show resolved Hide resolved
CONTRIBUTING.rst Outdated Show resolved Hide resolved
CONTRIBUTING.rst Outdated Show resolved Hide resolved
README.rst Outdated
Comment on lines 35 to 43
~ $ conda install -y gxx_linux-64 gcc_linux-64 cmake make git glib libxml2 libxmlpp-4.0 liblapack pkg-config coincbc boost-cpp hdf5 sqlite pcre setuptools pytest pytables pandas jinja2 cython websockets pprintpp pip mamba

~ $ mamba install -y openmc=0.14.0 scipy=1.11

~ $ git clone https://github.com/cyclus/cyclus.git

~ $ cd cyclus

~/cyclus $ python install.py
Copy link
Contributor

Choose a reason for hiding this comment

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

If people try to run these commands there will be errors. I get what you're going for, trying to emulate what the terminal would look like. Just something to consider.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean? These are the commands I put into my terminal. Is it because of the ~ $ formatting? I'm trying to show some of the directory structure for being inside the cyclus directory to install it. Do you have any suggestions for how it might be clearer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I am referring to the ~ $ formatting. If your intention is more to show how these commands would be in a terminal rather than have users copy and paste them, then this is fine.

@@ -165,16 +162,15 @@ def get_spent_comps(self, material_ids, path):
list of the compositions from the OpenMC model
'''
results = od.Results(path + "depletion_results.h5")
nuclides = od.MicroXS.from_csv(path+"micro_xs.csv").nuclides
Copy link
Contributor

Choose a reason for hiding this comment

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

Why load in the MicroXS object again? Why not just use self.micro_xs.nuclides?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I don't actually initialize that object with the class. That might be a cleaner way to do this though. I don't have strong feelings either way. I think initially I was thinking that you wouldn't always need that, but it also might be good to initialize the materials with the class as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm giving this a shot (initializing the cross sections and materials with the class) see the changes in commit c1d7d2 and let me know what you think.

openmcyclus/depletion.py Show resolved Hide resolved
Comment on lines +89 to +90
assert spent_comps[0][922350000] == 10.650004036820036
assert spent_comps[0][942390000] == 0.22663550016678385
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be more robust to have a reference_depletion_results.h5 that you load in and compare against the spent comps. Not sure if it's that simple with Cyclus.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's probably a cleaner way to do, and more regression style.

openmcyclus/DepleteReactor.py Show resolved Hide resolved
Initializing these objects with the class removes extra calls to
the files, and removes the need for the methods to create the
objects. Still need to test out with Cyclus integration, but
unit tests pass
@abachma2 abachma2 mentioned this pull request May 2, 2024
@abachma2 abachma2 requested a review from yardasol May 6, 2024 15:43
Copy link
Contributor

@yardasol yardasol left a comment

Choose a reason for hiding this comment

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

Hi @abachma2,
Good work on these changes. My other comments are below. I think this is getting pretty close, so I'm going to tentatively approve.

openmcyclus/depletion.py Outdated Show resolved Hide resolved
Comment on lines 37 to 53
def read_materials(self, path):
'''
Read in the materials file for OpenMC

Parameters:
-----------
path: str
path to the materials.xml file
self.microxs = od.MicroXS.from_csv(str(path + "micro_xs.csv"))
self.materials = openmc.Materials().from_xml(str(path + "/materials.xml"))

Returns:
---------
materials: openmc.Material object
Materials for OpenMC
'''
materials = openmc.Materials()
materials = materials.from_xml(str(path + "/materials.xml"))
return materials
Copy link
Contributor

Choose a reason for hiding this comment

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

Good change. This was a lot for just two lines of code.

Comment on lines 50 to 51
self.microxs = od.MicroXS.from_csv(str(path + "micro_xs.csv"))
self.materials = openmc.Materials().from_xml(str(path + "/materials.xml"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

These objects are already initialized in the enter_notify method
of the DepleteReactor, and initializing them in the Depletion
class doesn't work when running the archetype. This method
requires more Depletion class method inputs, but it all
runs
@abachma2
Copy link
Collaborator Author

abachma2 commented May 6, 2024

So it turns out that initializing the micro_xs and materials objects in the Depletion class doesn't work so well when running this in Cyclus (I could have sworn this was working a week or two ago). So I updated things to initialize these objects with the DepleteReactor class, and use them as inputs to methods in the Depletion class. The model_path attribute of the DepleteReactor class is read in as an input to the Depletion class to prevent having to re-input that information. The tests should be updated to incorporate these changes.

@abachma2 abachma2 requested a review from yardasol May 6, 2024 20:59
THe new version of these codes (v1.6) is now live in
conda, and it'll be easier to install them using this method.
@abachma2
Copy link
Collaborator Author

Bumping this for review if anyone is available right now.

Copy link
Contributor

@yardasol yardasol left a comment

Choose a reason for hiding this comment

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

Hi @abachma2. Good job as always. I have a few more suggestions for you. Apologies for the long wait on this.

openmcyclus/DepleteReactor.py Outdated Show resolved Hide resolved
Comment on lines +630 to 631
# ss = str(len(assemblies)) + " assemblies"
# self.record("TRANSMUTE", ss)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing these if they are not going to be used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any instances of the record method are intended to be there, but I need to dig into the cyclus python API for writing to the database some to make sure it all works as it should/does in the c++ api

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain the purpose of having this method present in the code but commented out? Is there still something you are debugging? Or does it need to be there commented out to work properly?

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 self.record method writes information to the database, and in this case trying to record when different reactor-related events occur. When I was working on this archetype, I noticed that it this method wasn't working as expected, likely because of how the Cyclus python API implements it. So I commented it out to prevent it from hindering other development work on the archetype. I didn't remove it, because I do want this functionality in the code, but it's not crucial. I will make an issue about getting this working to make sure it doesn't get forgotten.

openmcyclus/depletion.py Outdated Show resolved Hide resolved
README.rst Show resolved Hide resolved
openmcyclus/depletion.py Outdated Show resolved Hide resolved
tests/unit_tests/test_depletion.py Outdated Show resolved Hide resolved
@abachma2 abachma2 requested a review from yardasol May 30, 2024 14:40
@abachma2
Copy link
Collaborator Author

Thanks for the feedback @yardasol! It should all be addressed now.

Copy link
Contributor

@yardasol yardasol left a comment

Choose a reason for hiding this comment

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

Hi @abachma2,
Good work here. Just a couple more fixes and we should be g2g.

openmcyclus/DepleteReactor.py Outdated Show resolved Hide resolved
Comment on lines +630 to 631
# ss = str(len(assemblies)) + " assemblies"
# self.record("TRANSMUTE", ss)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain the purpose of having this method present in the code but commented out? Is there still something you are debugging? Or does it need to be there commented out to work properly?

openmcyclus/depletion.py Outdated Show resolved Hide resolved
openmcyclus/depletion.py Outdated Show resolved Hide resolved
tests/unit_tests/test_depletion.py Outdated Show resolved Hide resolved
tests/unit_tests/test_depletion.py Outdated Show resolved Hide resolved
@abachma2 abachma2 requested a review from yardasol June 5, 2024 18:41
Copy link
Contributor

@yardasol yardasol left a comment

Choose a reason for hiding this comment

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

Great job @abachma2! Sorry this PR took so long to review.

@abachma2
Copy link
Collaborator Author

Thanks for the approval @yardasol. Are we waiting on something else for this to be merged?

@yardasol yardasol merged commit 1ad3ae1 into arfc:main Jun 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comp:Build This issue has to do with the build system of the code/doc (makefiles, cmake, install errors) Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Comp:Input This issue has to do with the input component of the code or document. (input parameters, prep) Difficulty:2-Challenging This issue may be complex or require specialized skills. Priority:2-Normal This work is important and should be completed ASAP. Type:Docs Is related to API documentation, website content, etc. Type:Test Is related to software testing. Failing tests, necessary new tests, test frameworks, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants