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

Fix multi-commodity transactions, add preferences #10

Merged
merged 15 commits into from
Jun 6, 2023

Conversation

abachma2
Copy link
Collaborator

@abachma2 abachma2 commented Apr 6, 2023

This PR has two primary additions:

  • Input commodity preferences are added (new feature)
  • Transaction issues are fixed when multiple commodities are requested (a bug fix, for a bug discovered while adding the feature)

Test and test-related files have been updated to test the new functionality and ensure the bug is fixed. There are two tests that are failing because of a bug with resource IDs for the spent fuel. This bug (Issue #9) will be fixed in a later PR. The 2 tests regarding transactions are both passing, and those are the tests for the feature and bug fix in this PR.

@abachma2 abachma2 self-assigned this Apr 6, 2023
@abachma2 abachma2 requested review from yardasol and nsryan2 April 6, 2023 16:30
@abachma2 abachma2 added Comp:Build This issue has to do with the build system of the code/doc (makefiles, cmake, install errors) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:2-Normal This work is important and should be completed ASAP. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Bug Something is wrong or broken. This issue or PR is related to a bug in code. Type:Feature New feature or feature request labels Apr 6, 2023
@yardasol
Copy link
Contributor

@abachma2 is this ready for review or still in progress?

@abachma2
Copy link
Collaborator Author

Yes. This is ready for review.

@abachma2 abachma2 requested a review from LukeSeifert April 25, 2023 20:35
Copy link
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

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

Overall looks good, I think there are some minor changes you can make which could polish things up.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Comment on lines 117 to 120
<!--entry>
<number>1</number>
<prototype>TwoReactor</prototype>
</entry-->
Copy link
Contributor

Choose a reason for hiding this comment

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

How come this is commented out?

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 am benchmarking a lot of the functionality against the Cycamore Reactor archetype, so this was an easy way for me to switch between running the simulation with the OpenMCyclus and Cycamore archetypes. I will remove this section because I ended up creating another file that runs with the Cycamore archetype, so this is no longer needed.

Comment on lines 63 to 82
refuel_time = ts.Int(
doc = "Time steps for refueling",
tooltip="Time steps for refueling",
uilabel="refueltime",
default = 0
)

n_assem_core = ts.Int(
doc = "Number of assemblies in a core",
tooltip = "Number of assemblies in a core",
uilabel = "n_assem_core",
default=0
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Spacing is inconsistent throughout this section, minor issue. Consider using autopep8 to fix it, but not necessary change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do!

print("time:", self.context.time, "tick")
if self.retired():
print("time:", self.context.time, "retired")
# self.record("RETIRED", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment

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 comments for the self.record method are intended to be eventual functionality to record to the database when certain things happen, such as starting a new cycle or retiring a reactor.

openmcyclus/DepleteReactor.py Outdated Show resolved Hide resolved
openmcyclus/DepleteReactor.py Outdated Show resolved Hide resolved
openmcyclus/DepleteReactor.py Outdated Show resolved Hide resolved
tests/integration_tests/test_depletereactor.py Outdated Show resolved Hide resolved
tests/integration_tests/test_depletereactor.py Outdated Show resolved Hide resolved
@abachma2
Copy link
Collaborator Author

Thanks for the review @LukeSeifert. I'll work on making the documentation better. I have made some of the other changes requested.

@abachma2
Copy link
Collaborator Author

abachma2 commented May 2, 2023

I have found a bug in the feature added through this PR. The requested material is based more on their ordering in the input file than the defined preferences. This results in errors in how much of the material is accepted if there is not enough to meet a full request. I am working on fixing this bug.

@abachma2
Copy link
Collaborator Author

abachma2 commented May 30, 2023

I have updated the doc strings to be more comprehensive. I have also updated the bug for the preferences described in the previous comment. The bug was because of a lack of feature in the Python API in cyclus, so that has been added in. 4/6 tests are passing locally, with the two resources tests not passing. This is already documented in issue #9.

@abachma2 abachma2 requested a review from LukeSeifert May 30, 2023 18:38
@abachma2 abachma2 requested review from smpark7 and ZoeRichter May 31, 2023 13:37
Copy link
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

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

Very good changes! Overall I just saw some print statements that I thought could use more detail in the output, but it's up to you if you think adding that detail makes sense or not. Let me know if you would like me to go ahead and merge.

for ii in range(len(trades)):
print("time:", self.context.time, "number of trades:", len(trades))
print(trades[ii])
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding more detail (such as print(f'Trade {ii}: {trades[ii]}') or something similar) so the information is easier to read

commodity = trades[ii].request.commodity
mat = mats[commodity].pop(-1)
responses[trades[ii]] = mat
self.resource_indexes.pop(mat.obj_id)
self.push_spent(mats)
print(responses)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding more detail here as well

'''
n_load = min(len(responses), self.n_assem_core - self.core.count)
print("time:", self.context.time, "responses:", responses)
# min(len(responses), self.n_assem_core - self.core.count)
Copy link
Contributor

Choose a reason for hiding this comment

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

Removable?

for trade in responses:
print(trade.request.commodity, trade.request.preference, trade.amt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding more detail to this print statement

@abachma2
Copy link
Collaborator Author

abachma2 commented Jun 5, 2023

Thanks for the review. Those print statements were meant for debugging for development and aren't needed in the final version. I'll remove them.

@abachma2 abachma2 requested a review from LukeSeifert June 5, 2023 21:26
@abachma2
Copy link
Collaborator Author

abachma2 commented Jun 5, 2023

The extra print statements have been removed and pep8 formatting has been enforced.

@LukeSeifert LukeSeifert merged commit 730eea8 into arfc:main Jun 6, 2023
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) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:2-Normal This work is important and should be completed ASAP. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Bug Something is wrong or broken. This issue or PR is related to a bug in code. Type:Feature New feature or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants