openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Adding atomic mass management in C++ API

Open bam241 opened this issue 2 years ago • 9 comments

Description

This adds a simple API to read store and access, atomic masses. This is merrily a transposition of the existing version in the Python API. see data.py

This should be a step toward resolving of #2756.

I still have few questions:

  • shall we bind this to the Python solution (to avoid duplicates) ?
  • I have added reading and storing of the binding energy and mass excess. As there is no use now for those, shall we skip reading them and storing them ?
  • Where else could this be useful and leveraged ? For the plotter when no cross section are provided ?
  • do you have any advice on formatting and naming ?
  • any obvious place where this should be documented ?
  • any things I may have forgotten ?

Checklist

  • [x] I have performed a self-review of my own code
  • [x] I have run clang-format (version 15) on any C++ source files (if applicable)
  • [ ] I have made corresponding changes to the documentation (if applicable)
  • [x] I have added tests that prove my fix is effective or that my feature works (if applicable)

This work is sponsored by First Light Fusion.

bam241 avatar Dec 31 '23 12:12 bam241

I understand this is not yet ready. I am looking for feedback to make this mergeable.

bam241 avatar Dec 31 '23 12:12 bam241

I have tested this locally, it seems to be working. The only thing I didn't figure out is how to point to mass_1.mas20.txt proper path. right now it is located in openmc/data/ because it is used in the Python API. Not sure how to get that path from the cpp API, and/or if I should...

bam241 avatar Jan 01 '24 12:01 bam241

thx for the review @gridley, much appreciated.

I think I have addressed most/all you comments :)

bam241 avatar Jan 06 '24 14:01 bam241

now it is failing where I expect it to,

I need access to the mass_1.mas20.txt, and I don't know where to put it to guaranty it, to where to access it from

bam241 avatar Jan 11 '24 15:01 bam241

mass_1.mas20.txt

Not sure either but perhaps the values from the txt file can just be in the same cpp file that needs the data?

shimwell avatar Jan 11 '24 15:01 shimwell

the file exist in the Python API, I am wondering if there is a place where it can live and both API could access it

bam241 avatar Jan 11 '24 15:01 bam241

The problem is mass_1.mas20.txt is already present in the Python source, and installed in the Python package.

I don't know what is best:

  • include all the mass data in a include file as done in constant.h
  • find a way to link to the file somehow.

if we decide to do an include file, shall we add a script to generate it ? generate it on build ?

@paulromano @pshriwise do you have any opinion about this ?

bam241 avatar Jan 13 '24 10:01 bam241

Hi Baptiste, I was having some issues with with Abundances (different values in the Python API compared to what is used in MCNP) https://github.com/openmc-dev/openmc/issues/2423 https://github.com/openmc-dev/openmc/pull/2586 https://github.com/openmc-dev/openmc/pull/2585

I think it would be ideal for both of these files, atomic masses and atomic abundances to be in external files that are linked in. So there are defaults, but the user can select to read-in a user selected database. It would be best if the Python API and C++ API could do this.

yrrepy avatar Apr 09 '24 18:04 yrrepy

The need for this PR and following PR #2105 appear again in my new job. It would be great to have a materials collection like PNNL in openmc as it appears to be a common need across a few different organisation that I've seen using using openmc

shimwell avatar Jul 30 '24 16:07 shimwell