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

Montepy is_atomic_fraction does not work as expected #597

Closed
AlphonseM91 opened this issue Dec 2, 2024 · 5 comments · Fixed by #598
Closed

Montepy is_atomic_fraction does not work as expected #597

AlphonseM91 opened this issue Dec 2, 2024 · 5 comments · Fixed by #598
Assignees
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". critical An issue that seriously limits user adoption or hampers current use.

Comments

@AlphonseM91
Copy link

AlphonseM91 commented Dec 2, 2024

Describe the bug

When montepy.data_inputs.material.is_atomic_fraction is set to False and I add a new material component and then write the output file, the fraction is positive (thus set to atomic fraction).

To Reproduce

A short code snippet of what you have ran.

zaid='1001.70c'
iso = montepy.data_inputs.isotope.Isotope(zaid)
mat = montepy.data_inputs.material_component.MaterialComponent(iso, 0.2)
# my MCNP_problem
print(pb.materials[99].is_atomic_fraction) --> True
# Then add a new material_component
pb.materials[99].material_components[iso]=mat
pb.write_to_file(output_path)

Then my output file has previous material components with negative fraction (i.e weight fraction) and the one I just added is positive. I find no way to write it with a minus sign before.

MCNP input file snippet

My M99 Material with the hydrogen i just added.

M99     12024.70c -0.4818 12025.70c -0.0610 12026.70c -0.0672 &
        8016.60C -0.39   $ MgO
1001.70c 0.2 

Version

  • MontePy 0.5.2
  • MCNP 6.1.0

Additional context

I know this should be fixed in MontePy 1.0 but I'd like to know if there is a quick fix I could do because I really need to be able to configure my Materials cards. Thank you!

@AlphonseM91 AlphonseM91 added the bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". label Dec 2, 2024
@MicahGale MicahGale added the critical An issue that seriously limits user adoption or hampers current use. label Dec 2, 2024
@MicahGale
Copy link
Collaborator

MicahGale commented Dec 2, 2024

Just to clarify did your material definition start out as?

M99     12024.70c -0.4818 12025.70c -0.0610 12026.70c -0.0672 &
        8016.60C -0.39   $ MgO

So good news: this is tested for and is currently working for the 1.0.0a1 candidate branch: mat_redesign. So a quick fix you could do right now is to switch to that branch, but that's very unstable as its feature development branch. I'm hoping to get an alpha release out within a month.

Bad news this is a bad bug that wouldn't have a quick and easy work around for the user. I can get a patch for 0.5.3 maybe in a week or longer that would be a stop gap measure.

So a few options:

  1. expedite a 1.0.0 alpha release where the whole material interface changes (for the better)
  2. expedite a patch for this which would require a lot of script rewriting for you to adapt to 1.0.0 in a month or so.
  3. I write you a hacky script that manually modifies the syntax tree and circumvents the material object mostly.

Do you have a preference?

@MicahGale MicahGale self-assigned this Dec 2, 2024
@MicahGale
Copy link
Collaborator

Also I believe you are saying is_atom_fraction is incorrect? Re-reading 5.6.1 of the 6.3 manual positive is atom fraction, and weight fraction is negative. The double negatives are hard to track.

@MicahGale MicahGale linked a pull request Dec 2, 2024 that will close this issue
7 tasks
MicahGale added a commit that referenced this issue Dec 2, 2024
@MicahGale
Copy link
Collaborator

As an update. This problem seemed actually pretty easy to solve. See the PR, next week we might be able to get this reviewed and merged.

@AlphonseM91
Copy link
Author

Hi, thank you for your work. I have a technical issue that make me unable to install the code, so I couldn't test it. Maybe I'll wait the merge and it would work.

Also I believe you are saying is_atom_fraction is incorrect? Re-reading 5.6.1 of the 6.3 manual positive is atom fraction, and weight fraction is negative. The double negatives are hard to track.

Actually I was not saying that is_atom_fraction is incorrect : it is correct reading the input, but when it comes to writing it's wrong.

@MicahGale
Copy link
Collaborator

@AlphonseM91 this bug fix has been shipped to pypi: https://pypi.org/project/montepy/. You can get it with pip install --upgrade montepy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". critical An issue that seriously limits user adoption or hampers current use.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants