Created
August 4, 2022 03:23
-
-
Save paulromano/4c9b82d42d28c1e51c1a45de3d48b64d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "4c247d71", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import openmc.deplete\n", | |
"import networkx as nx\n", | |
"import matplotlib.pyplot as plt" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "6fceaca8", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"chain = openmc.deplete.Chain.from_xml('/home/romano/openmc-data/depletion/chain_endfb71_pwr.xml')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"id": "36ed7b9a", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Create directed graph based on reactions/decays\n", | |
"dg = nx.DiGraph()\n", | |
"for nuc in chain.nuclides:\n", | |
" for mode in nuc.decay_modes:\n", | |
" if mode.target is not None:\n", | |
" dg.add_edge(nuc.name, mode.target)\n", | |
" \n", | |
" \"\"\"\n", | |
" for rx in nuc.reactions:\n", | |
" if rx.target is not None:\n", | |
" dg.add_edge(nuc.name, mode.target)\n", | |
" \n", | |
" if nuc.yield_data is not None:\n", | |
" for product in nuc.yield_data.products:\n", | |
" dg.add_edge(nuc.name, product)\n", | |
" \"\"\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"id": "edc56fb5", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'Sb135', 'Sb136', 'Sb137', 'Sb138', 'Sn136', 'Sn137', 'Te135', 'Te136'}" | |
] | |
}, | |
"execution_count": 42, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# Get ancestors of a given nuclide\n", | |
"nx.ancestors(dg, \"I135\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "572f03d3", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment