-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add call to the OpenMC Depletion Solver #13
Conversation
Add state variable definition and default. Add mention to phase 1 of DRE, but not sure it is any meaningful functionality. Tests all pass
New functions to get the index of a materials commodity name, recipe name, or preference based on the material's object ID. These functions exist in cycamore:Reactor, but were previously overlooked
add an if loop to only get the material if its commodity name is in the spent materials dictionary. Call the get_commods function instead of just looping of the commodity names list. 3 tests failing, two of which concern the resources
The loop for the recipes was creating a bid for each possiblespent fuel recipe, which is unphysical. Each spent fuel assembly will only have one composition. Instead, get the index of the commodity name in fuel_outcommods and matches to the recipe at the same index of fuel_outrecipes. Enforces the need for users to have consistent ordering in their input file
Had to manually call each step of the Depletion.run_depletion because it just would not work if I tried to call that method directly
- name: Setup Conda | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniforge-variant: Mambaforge | ||
miniforge-version: latest | ||
activate-environment: openmcyclus-env | ||
environment-file: environment.yml | ||
use-mamba: true | ||
|
||
- name: Conda config | ||
run: | | ||
conda config --env --set pip_interop_enabled True | ||
|
||
- name: Update Environment | ||
run: | | ||
mamba env update -n openmcyclus-env -f environment.yml | ||
|
||
- name: Install pytest | ||
run: conda install -y pytest | ||
|
||
- name: Build OpenMC | ||
run: | | ||
mamba install openmc | ||
conda install -y python=3.7 cyclus cycamore | ||
HDF5_DIR=$CONDA_PREFIX && pip install h5py | ||
|
||
- name: OpenMC dependencies | ||
run: | | ||
sudo apt -y update | ||
sudo apt install -y libhdf5-dev | ||
|
||
- name: Download OpenMC | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: openmc-dev/openmc | ||
path: openmc | ||
submodules: recursive | ||
|
||
- name: Build OpenMC from source | ||
run: | | ||
run: build-openmc.sh | ||
|
||
|
||
- name: Install OpenMC cross section library | ||
run: echo "OPENMC_CROSS_SECTIONS=cross_sections.xml" >> $GITHUB_ENV |
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.
Have you tested this workflow yet? If not, you could merge into your fork's main branch to test it
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.
It looks like right now there is a syntax error in the ci scripts, so I will fix that. But because of a seg fault when importing OpenMC into a cyclus script (See issue #12), there isn't much point in running the integration tests in a CI environment, because they will all fail due to the seg fault. I can make sure that the environment builds and the unit tests pass, but that's the best I can do until Issue #12 is resolved.
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.
Oh yes sorry for not reading your PR comments properly
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.
All good. It's important to have the CI as functional as possible. I'll fix the syntax error int he CI on this branch, but do the bulk of the CI changes/maintenance on another branch to keep this PR from getting too big.
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.
Mostly LGTM, I saw Sun Myung's comment so I won't approve quite yet, I had some minor README comments, package comments, and some stuff on the tests.
pytest --ignore tests/unit_tests | ||
pytest | ||
|
||
FWAk8hnxPUNDeep! |
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.
What does this mean?
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'm not sure how that ended up there. I must have accidentally copied whatever was in my clipboard into the file. It's been removed!
### Install OpenMCyclus | ||
To install this archetype library run ``pip install .``. | ||
To run tests: ``pytest`` from the main directory. | ||
|
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.
### Testing | |
In progress. |
Should there be a testing subsubsection?
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.
All it would contain would be the sentence about running pytest
.
assert all(quantities == [10]*6) | ||
assert len(tbl) == 9 | ||
assert all(times == [0,0,0,2,2,5,5,8,8]) | ||
assert all(quantities == [10]*9) |
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.
assert all(quantities == [10]*9) | |
assert all(quantities == [10]*len(tbl)) |
Would it reduce the chance for errors if you add times later if you changed it to this? For test_resources too?
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 part of the code is testing what's in the output database. So your code suggestion is just testing if all of the entries in the table are of value 10, not specifically if there are 9 occurrences of value 10 in the table. I suppose that by testing for [10]*9
that's also checking that there are 9 values in the table, same as l.124. but I'm okay with being redundant in my testing.
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 didn't run anything but I looked through your code. Here are my review comments.
<model_path>/home/abachmann/openmcyclus/tests/</model_path> | ||
<chain_file>chain_endfb71_pwr.xml</chain_file> |
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.
Can this be a relative path? It won't work on other people's computers.
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.
Maybe? I'll play around with it. Can we make this an issue so that this doesn't hold up the merging of this PR?
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.
Sure that's okay
for commod_index, commod in enumerate(self.fuel_outcommods): | ||
reqs = requests[commod] | ||
print("time:", self.context.time, "reqs:", reqs) | ||
if len(reqs) == 0: | ||
continue | ||
elif (got_mats == False): | ||
all_mats = self.peek_spent() | ||
|
||
if len(all_mats) == 0: | ||
tot_qty = 0 | ||
continue | ||
mats = [all_mats[commod]] | ||
if commod in all_mats: | ||
mats = [all_mats[commod]] | ||
|
||
else: | ||
mats = [] | ||
print("time:", self.context.time, "mats to trade matching request commod:", mats) | ||
if len(mats) == 0: | ||
continue | ||
for ii in range(len(self.fuel_outrecipes)): | ||
recipe_comp = self.context.get_recipe(self.fuel_outrecipes[ii]) | ||
for req in reqs: | ||
tot_bid = 0 | ||
for jj in range(len(mats)): | ||
tot_bid += mats[jj].quantity | ||
qty = min(req.target.quantity, self.spent_fuel.quantity) | ||
mat = ts.Material.create_untracked(qty, recipe_comp) | ||
continue | ||
|
||
recipe_comp = self.context.get_recipe(self.fuel_outrecipes[commod_index]) | ||
|
||
for req in reqs: | ||
tot_bid = 0 | ||
for jj in range(len(mats)): | ||
tot_bid += mats[jj].quantity | ||
qty = min(req.target.quantity, self.assem_size) | ||
mat = ts.Material.create_untracked(qty, recipe_comp) | ||
for kk in range(self.spent_fuel.count): |
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.
Nice refactoring. You may wanna update your for-loop index names.
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.
In what way? How would you suggest updating the index names?
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.
Renaming jj
and kk
as ii
and jj
. But leaving it as is is fine too
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.
LGTM! @nsryan2 go ahead and merge if you approve too.
This PR adds new functionality to the DepleteReactor archetype:
transmute
methodThe CI fails because importing openmc into the archetype (i.e.
import openmc
) causes a segmentation fault. The seg fault is after the simulation runs and writes the results to the output file and is trying to close python imports (I think). So it all still mostly runs, and I have manually compared the results of the output database to the expected values in the test suite. An issue (#12) has been created to help resolve the seg fault.