Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Support pre-evaluated data in Chain.from_endf by drewejohnson · Pull Request #1452 · openmc-dev/openmc · GitHub
Skip to content

Support pre-evaluated data in Chain.from_endf - #1452

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals
Jan 28, 2020
Merged

Support pre-evaluated data in Chain.from_endf#1452
paulromano merged 2 commits into
openmc-dev:developfrom
drewejohnson:chain-from-evals

Conversation

@drewejohnson

@drewejohnsondrewejohnson commented Jan 15, 2020

Copy link
Copy Markdown
Contributor

Companion to the from_endf method, but acts on instances of Evaluation, Decay, and FissionProductYields objects. The from_endf method reads the appropriate files and passes the instances off to from_evaluation for internal processing.

This is the first part in what I hope will be a two PR process allowing users to create equivalent depletion chains to what Serpent uses. I'm working on a hackscript know that will come up later after some more development. The goal is that the script will produce the evaluations by reading the .dec and .nfy files that usually ship with Serpent, and then create chain using from_evaluations

Edit

The from_evaluations method has been removed. Instead, users can pass pre-evaluated Decay, FissionProductYields and/orEvaluation instances in place of file names

@paulromanopaulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the enhancement @drewejohnson. In other places in the Python API, we have from_endf methods take either a str or an Evaluation instance (for example, look at IncidentNeutron.from_endf). To be consistent I think the best thing here would be to have a single from_endf method that takes either a list of str of a list of Evaluation. Would you be up for making that change?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

No problem @paulromano. I'll have that up shortly. Also, would the script for making an equivalent Serpent depletion chain be a good candidate for the scripts directory? Or something like the data repository?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

So it turns out that the Decay objects created from the decay file have some negative uncertainties in some of the discrete spectrum values. This causes the conversion to ufloat to fail. Specifically, I'm getting failures for cobalt 55 at

iflen(values) ==12:
di['k_shell_conversion'] =ufloat(*values[8:10])
di['l_shell_conversion'] =ufloat(*values[10:12])

This means that, at least for the Serpent decay file, we won't be able to pass Evaluations, as Decay(evaluation) fails.

I put together a MinimalDecay object that just contains information needed for depletion: half life, name, decay modes, and average decay energies. We can do some duck typing and pass in this object that has the information the chain method needs. With this, I can make this equivalent Chain.

I don't think changing how the Decay objects store data is worthwhile, but also having two decay-like classes could make refactoring and future changes tricky. Would love to hear your thoughts and suggestions

@paulromano

Copy link
Copy Markdown
Contributor

@drewejohnson I'm generally trying to move those types of scripts over to the data repo, so feel free to put a PR there.

For the decay file that runs into trouble, which library is it from? I probably wouldn't be a huge fan of having a separate decay class to maintain. Perhaps we can just do a check for negative uncertainties, print a warning, and set them to zero?

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

I'll put in a PR for my script in the data repo once we get this sorted. Otherwise the script may fail due to these reasons.

The cobalt 55 evaluation comes from 2005/2006 BNL distributions. I've provided the header below

 27-Co- 55 BNL EVAL-NOV05 A.A. Sonzogni (from ENSDF)
/ENSDF/ DIST-DEC06
----ENDF/B-VII MATERIAL 540
-----RADIOACTIVE DECAY DATA
------ENDF-6 FORMAT
*********************** Begin Description ***********************
** ENDF/B-VII RADIOACTIVE DECAY DATA FILE **
** Produced at the BNL from the ENSDF database **
** Authors: NSDD **
** Translated into ENDF format by A.A. Sonzogni, November 2005 **
*****************************************************************

One Decay class is surely best, agree. For the checks, what do you think about having some function in openmc.checkvalue that takes a value and uncertainty, and performs some checks? We could either set negative uncertainties to zero, or the absolute value. With some warnings. I think some of the library generation scripts make similar warnings anyway.

@paulromano

Copy link
Copy Markdown
Contributor

Ok, so that Co55 decay file is from ENDF/B-VII.0. The one negative uncertainty is the only one that appears in the whole VII.0 library. In light of that, one possible alternative (we have done this in other places), is to have the processing/conversion script make a one-off modification of the offending evaluation and leave the main code in tact:

# Get evaluationsevals=openmc.data.endf.get_evaluations('endfb70')
# Fix negative uncertainty in Co55co55= [xforxinevalsifx.gnd_name='Co55'][0]
sec=co55.section[8, 457]
co55.section[8, 457] =sec[:762] +' 0'+sec[764:]
# Continue processingforxinevals:
dec=openmc.data.Decay(x)
...

For what it's worth, I consider it a feature that things fail when the data is clearly wrong (rather than letting it silently pass). I can't tell you how many evaluation bugs I've reported to ENDF and JEFF because of this behavior.

@drewejohnson

Copy link
Copy Markdown
ContributorAuthor

Agree, catching these errors is useful. I guess if / when control over these uncertainties is added (set zero, set absolute, etc.) some options for warning / error control would be nice. But that is for a later PR.

For this, I will re-work the Chain implementation to string file names or Evaluation instances. This should play well with the conversion script.

Thanks for looking into the ENDF data! 💯

@drewejohnsondrewejohnson changed the title Provide openmc.deplete.Chain.from_evaluationsSupport pre-evaluated data in Chain.from_endfJan 24, 2020
Comment threadopenmc/deplete/chain.py Outdated
@paulromano
paulromano merged commit a1f71c1 into openmc-dev:developJan 28, 2020
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for iterating on this @drewejohnson.

@drewejohnson
drewejohnson deleted the chain-from-evals branch January 28, 2020 22:33
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drewejohnson@paulromano