Toggle Function IUPAC 2009/2013 data ( NATURAL_ABUNDANCE)

Hi everyone,

My desired PR correction is to toggled changing the default Isotopic compositions between IUPAC-2009 and IUPAC-2013. This toggle should be selectable in the API interface and then steer the API to which abundance data to use.

The IUPAC-2013 data should use IUPAC-2013 column 9 and when column 9 is an interval it should use the mean of the given interval NOT the value from IUPAC-2013 column 6. This data differs from what is currently in OpenMC main.

I am sure that IUPAC-2013 will be the default data.

Here is what I have so far with my brain storming on how to accomplish this and want a second opinion on it.

Explanation of my code: I am trying to make a python api function for the material.xml creation of Material.version(). I then place this into the material.xml file. Then this is read by the C++ code materials.cpp and materials.h . My dilemma is how to get the version material.cpp object variable to the and what is the order by which the code is read. I don’t want just to cython a variable over if the is already compiled without the version variable not implemented yet.


Insert following at line 114
NATURAL_ABUNDANCE_2009 = {…} //Hard coded data like for NATURAL_ABUNDANCE


Replace the following at line 113

def init(self, material_id=None, name=‘’, temperature=None, version=2013):

Insert the following at line 127
self._version = version

Instert following at line 236

def version(self) → Optional[int]:
return self._version

Insert following at line 269

def version(self, version: Optional[int]):
if version is 2009:
cv.check_type(‘version for Material ID=“{}”’.format(self._id), version, int)
self._version = version
self._version = 2013

Insert following at line 1337

if self.version is 2013:
    element.set("version", str(self.version))


Insert the following at line 164

//! Get the version of the abundance data
//! \return version of the abundance data
int version() const { return version_; }

//! Set the version of the abundance data
//! \param[in] version version of the abundance data
void set_version(int version) { version_ = version; }

Insert the following at line 212

//verions for abundance data
int version_;


Insert the following at line 119

if (check_for_node(material_node, “version”)) {
this->set_version(std::stoi(get_node_value(material_node, “version”)));

Insert the following at line 375

mat->version_ = version_;

Your suggestions and thoughts are most appreciated.

1 Like

FYI for others, please read the background to this development in issue:


1 Like

Here is the update to what I have concluded to do to fix my original code:


version_value = os.getenv(“IUPAC_VERSION”)
if not version_value:
version_value = ‘2013’

if version_value == ‘2009’:
elif version_value == ‘2013’:
print(“The value you entered is not either IUPAC 2013 or 2009, defaulted to IUPAC 2013”)

Python API

import os
Set the environment variable
os.environ[“IUPAC_VERSION”] = “2009” # or “2013”, whatever you want

import sys
import subprocess
import openmc
import os
import csv
import matplotlib.pyplot as plt
import numpy as np

Create materials
materials = openmc.Materials()

Create concrete material
water = openmc.Material()
water.add_element(‘H’, 2)
water.add_element(‘O’, 1)
water.set_density(‘g/cm3’, 0.9998395)

I have found that trying to make a xml input is counter productive due to the file being compiled during the import openmc portion. In order to pass a variable to the before import openmc, I made an environment variable.

Thanks @jmau for this proposal. For anyone that missed it, there is now a pull request open: