MCNP input files#

The complete API can be found at f4enix.input.MCNPinput.Input

Quick general overview#

# Import the input module
from f4enix.input.MCNPinput import Input

# Load the input file
inp_file = "ITER_1D"
inp = Input.from_input(inp_file)
/home/docs/checkouts/readthedocs.org/user_builds/f4enix/envs/developing/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
# Here are the main attributes of the input
print(inp.cells)
print(inp.surfs)
print(inp.materials)  # datacard class that have their own complete parser
print(inp.transformations)  # uncomplete parser (no transformations in this inp)
print(inp.other_data)  # treated as general data cards, no parser
{'1': <numjuggler.parser.Card object at 0x77dfd4fd7910>, '2': <numjuggler.parser.Card object at 0x77dfd4fd4100>, '3': <numjuggler.parser.Card object at 0x77dfd4fd7e50>, '4': <numjuggler.parser.Card object at 0x77df970e7100>, '5': <numjuggler.parser.Card object at 0x77df970e6ef0>, '6': <numjuggler.parser.Card object at 0x77df970e6f20>, '7': <numjuggler.parser.Card object at 0x77df970e6fb0>, '8': <numjuggler.parser.Card object at 0x77df970e7070>, '9': <numjuggler.parser.Card object at 0x77df970e70a0>, '10': <numjuggler.parser.Card object at 0x77df970e7160>, '11': <numjuggler.parser.Card object at 0x77df970e70d0>, '12': <numjuggler.parser.Card object at 0x77df970e7190>, '13': <numjuggler.parser.Card object at 0x77df970e71c0>, '14': <numjuggler.parser.Card object at 0x77df970e71f0>, '15': <numjuggler.parser.Card object at 0x77df970e7220>, '16': <numjuggler.parser.Card object at 0x77df970e7250>, '17': <numjuggler.parser.Card object at 0x77df970e7280>, '18': <numjuggler.parser.Card object at 0x77df970e72b0>, '19': <numjuggler.parser.Card object at 0x77df970e72e0>, '20': <numjuggler.parser.Card object at 0x77df970e7310>, '21': <numjuggler.parser.Card object at 0x77df970e7340>, '22': <numjuggler.parser.Card object at 0x77df970e7370>, '23': <numjuggler.parser.Card object at 0x77df970e73a0>, '24': <numjuggler.parser.Card object at 0x77df970e73d0>, '25': <numjuggler.parser.Card object at 0x77df970e7400>, '26': <numjuggler.parser.Card object at 0x77df970e7430>, '27': <numjuggler.parser.Card object at 0x77df970e7460>, '28': <numjuggler.parser.Card object at 0x77df970e7490>, '29': <numjuggler.parser.Card object at 0x77df970e74c0>, '30': <numjuggler.parser.Card object at 0x77df970e74f0>, '31': <numjuggler.parser.Card object at 0x77df970e7520>, '32': <numjuggler.parser.Card object at 0x77df970e7550>, '33': <numjuggler.parser.Card object at 0x77df970e7580>, '34': <numjuggler.parser.Card object at 0x77df970e75b0>, '35': <numjuggler.parser.Card object at 0x77df970e75e0>, '36': <numjuggler.parser.Card object at 0x77df970e7610>, '37': <numjuggler.parser.Card object at 0x77df970e7640>, '38': <numjuggler.parser.Card object at 0x77df970e7670>, '39': <numjuggler.parser.Card object at 0x77df970e76a0>, '40': <numjuggler.parser.Card object at 0x77df970e76d0>, '41': <numjuggler.parser.Card object at 0x77df970e7700>, '42': <numjuggler.parser.Card object at 0x77df970e7730>, '43': <numjuggler.parser.Card object at 0x77df970e7760>, '44': <numjuggler.parser.Card object at 0x77df970e7790>, '45': <numjuggler.parser.Card object at 0x77df970e77c0>, '46': <numjuggler.parser.Card object at 0x77df970e77f0>, '47': <numjuggler.parser.Card object at 0x77df970e7820>, '48': <numjuggler.parser.Card object at 0x77df970e7850>, '49': <numjuggler.parser.Card object at 0x77df970e7880>, '50': <numjuggler.parser.Card object at 0x77df970e78b0>, '51': <numjuggler.parser.Card object at 0x77df970e78e0>, '52': <numjuggler.parser.Card object at 0x77df970e7910>, '53': <numjuggler.parser.Card object at 0x77df970e7940>, '54': <numjuggler.parser.Card object at 0x77df970e7970>, '55': <numjuggler.parser.Card object at 0x77df970e79a0>, '56': <numjuggler.parser.Card object at 0x77df970e79d0>, '57': <numjuggler.parser.Card object at 0x77df970e7a00>, '58': <numjuggler.parser.Card object at 0x77df970e7a30>, '59': <numjuggler.parser.Card object at 0x77df970e7a60>, '60': <numjuggler.parser.Card object at 0x77df970e7a90>, '61': <numjuggler.parser.Card object at 0x77df970e7ac0>, '62': <numjuggler.parser.Card object at 0x77df970e7af0>, '63': <numjuggler.parser.Card object at 0x77df970e7b20>, '64': <numjuggler.parser.Card object at 0x77df970e7b50>, '65': <numjuggler.parser.Card object at 0x77df970e7b80>, '66': <numjuggler.parser.Card object at 0x77df970e7bb0>, '67': <numjuggler.parser.Card object at 0x77df970e7be0>, '68': <numjuggler.parser.Card object at 0x77df970e7c10>, '69': <numjuggler.parser.Card object at 0x77df970e7c40>, '70': <numjuggler.parser.Card object at 0x77df970e7c70>, '71': <numjuggler.parser.Card object at 0x77df970e7cd0>, '72': <numjuggler.parser.Card object at 0x77df970e7d00>, '73': <numjuggler.parser.Card object at 0x77df970e7d30>, '74': <numjuggler.parser.Card object at 0x77df970e7d60>, '75': <numjuggler.parser.Card object at 0x77df970e7d90>, '76': <numjuggler.parser.Card object at 0x77df970e7dc0>, '77': <numjuggler.parser.Card object at 0x77df970e7df0>, '78': <numjuggler.parser.Card object at 0x77df970e7e20>, '79': <numjuggler.parser.Card object at 0x77df970e7e50>, '80': <numjuggler.parser.Card object at 0x77df970e7e80>, '81': <numjuggler.parser.Card object at 0x77df970e7eb0>, '82': <numjuggler.parser.Card object at 0x77df970e7ee0>, '83': <numjuggler.parser.Card object at 0x77df970e7f10>, '84': <numjuggler.parser.Card object at 0x77df970e7f40>, '85': <numjuggler.parser.Card object at 0x77df970e7fa0>, '86': <numjuggler.parser.Card object at 0x77df970e7fd0>, '87': <numjuggler.parser.Card object at 0x77df9711c040>, '88': <numjuggler.parser.Card object at 0x77df9711c070>, '89': <numjuggler.parser.Card object at 0x77df9711c0a0>, '90': <numjuggler.parser.Card object at 0x77df9711c0d0>, '91': <numjuggler.parser.Card object at 0x77df9711c100>, '92': <numjuggler.parser.Card object at 0x77df9711c130>, '93': <numjuggler.parser.Card object at 0x77df9711c160>, '94': <numjuggler.parser.Card object at 0x77df9711c190>, '95': <numjuggler.parser.Card object at 0x77df9711c1c0>, '96': <numjuggler.parser.Card object at 0x77df9711c1f0>, '97': <numjuggler.parser.Card object at 0x77df9711c220>, '98': <numjuggler.parser.Card object at 0x77df9711c250>, '99': <numjuggler.parser.Card object at 0x77df9711c280>, '100': <numjuggler.parser.Card object at 0x77df9711c2b0>, '101': <numjuggler.parser.Card object at 0x77df9711c2e0>, '102': <numjuggler.parser.Card object at 0x77df9711c310>, '103': <numjuggler.parser.Card object at 0x77df9711c340>, '104': <numjuggler.parser.Card object at 0x77df9711c370>, '105': <numjuggler.parser.Card object at 0x77df9711c3a0>, '106': <numjuggler.parser.Card object at 0x77df9711c400>}
{'1': <numjuggler.parser.Card object at 0x77df9711c460>, '60': <numjuggler.parser.Card object at 0x77df9711c4c0>, '61': <numjuggler.parser.Card object at 0x77df9711c4f0>, '62': <numjuggler.parser.Card object at 0x77df9711c520>, '63': <numjuggler.parser.Card object at 0x77df9711c550>, '64': <numjuggler.parser.Card object at 0x77df9711c580>, '65': <numjuggler.parser.Card object at 0x77df9711c5b0>, '66': <numjuggler.parser.Card object at 0x77df9711c5e0>, '67': <numjuggler.parser.Card object at 0x77df9711c610>, '68': <numjuggler.parser.Card object at 0x77df9711c640>, '69': <numjuggler.parser.Card object at 0x77df9711c670>, '70': <numjuggler.parser.Card object at 0x77df9711c6a0>, '71': <numjuggler.parser.Card object at 0x77df9711c6d0>, '72': <numjuggler.parser.Card object at 0x77df9711c700>, '73': <numjuggler.parser.Card object at 0x77df9711c730>, '74': <numjuggler.parser.Card object at 0x77df9711c760>, '75': <numjuggler.parser.Card object at 0x77df9711c790>, '76': <numjuggler.parser.Card object at 0x77df9711c7c0>, '77': <numjuggler.parser.Card object at 0x77df9711c7f0>, '78': <numjuggler.parser.Card object at 0x77df9711c820>, '2': <numjuggler.parser.Card object at 0x77df9711c850>, '3': <numjuggler.parser.Card object at 0x77df9711c880>, '4': <numjuggler.parser.Card object at 0x77df9711c8b0>, '5': <numjuggler.parser.Card object at 0x77df9711c8e0>, '6': <numjuggler.parser.Card object at 0x77df9711c910>, '80': <numjuggler.parser.Card object at 0x77df9711c940>, '81': <numjuggler.parser.Card object at 0x77df9711c970>, '82': <numjuggler.parser.Card object at 0x77df9711c9a0>, '83': <numjuggler.parser.Card object at 0x77df9711c9d0>, '7': <numjuggler.parser.Card object at 0x77df9711ca00>, '8': <numjuggler.parser.Card object at 0x77df9711ca30>, '9': <numjuggler.parser.Card object at 0x77df9711ca60>, '10': <numjuggler.parser.Card object at 0x77df9711ca90>, '11': <numjuggler.parser.Card object at 0x77df9711cac0>, '12': <numjuggler.parser.Card object at 0x77df9711caf0>, '13': <numjuggler.parser.Card object at 0x77df9711cb20>, '14': <numjuggler.parser.Card object at 0x77df9711cb50>, '15': <numjuggler.parser.Card object at 0x77df9711cb80>, '16': <numjuggler.parser.Card object at 0x77df9711cbb0>, '17': <numjuggler.parser.Card object at 0x77df9711cbe0>, '18': <numjuggler.parser.Card object at 0x77df9711cc10>, '19': <numjuggler.parser.Card object at 0x77df9711cc40>, '20': <numjuggler.parser.Card object at 0x77df9711cc70>, '21': <numjuggler.parser.Card object at 0x77df9711cca0>, '22': <numjuggler.parser.Card object at 0x77df9711ccd0>, '23': <numjuggler.parser.Card object at 0x77df9711cd00>, '24': <numjuggler.parser.Card object at 0x77df9711cd30>, '25': <numjuggler.parser.Card object at 0x77df9711cd60>, '26': <numjuggler.parser.Card object at 0x77df9711cd90>, '27': <numjuggler.parser.Card object at 0x77df9711cdc0>, '28': <numjuggler.parser.Card object at 0x77df9711cdf0>, '29': <numjuggler.parser.Card object at 0x77df9711ce20>, '30': <numjuggler.parser.Card object at 0x77df9711ce50>, '31': <numjuggler.parser.Card object at 0x77df9711ce80>, '32': <numjuggler.parser.Card object at 0x77df9711ceb0>, '33': <numjuggler.parser.Card object at 0x77df9711cee0>, '34': <numjuggler.parser.Card object at 0x77df9711cf10>, '35': <numjuggler.parser.Card object at 0x77df9711cf40>, '36': <numjuggler.parser.Card object at 0x77df9711cf70>, '37': <numjuggler.parser.Card object at 0x77df9711cfa0>, '38': <numjuggler.parser.Card object at 0x77df9711cfd0>, '39': <numjuggler.parser.Card object at 0x77df9711d000>, '40': <numjuggler.parser.Card object at 0x77df9711d030>, '41': <numjuggler.parser.Card object at 0x77df9711d060>, '42': <numjuggler.parser.Card object at 0x77df9711d090>, '43': <numjuggler.parser.Card object at 0x77df9711d0c0>, '44': <numjuggler.parser.Card object at 0x77df9711d0f0>, '45': <numjuggler.parser.Card object at 0x77df9711d120>, '46': <numjuggler.parser.Card object at 0x77df9711d150>, '47': <numjuggler.parser.Card object at 0x77df9711d180>, '48': <numjuggler.parser.Card object at 0x77df9711d1b0>, '84': <numjuggler.parser.Card object at 0x77df9711d1e0>, '85': <numjuggler.parser.Card object at 0x77df9711d210>, '86': <numjuggler.parser.Card object at 0x77df9711d240>, '87': <numjuggler.parser.Card object at 0x77df9711d270>, '88': <numjuggler.parser.Card object at 0x77df9711d2a0>, '89': <numjuggler.parser.Card object at 0x77df9711d2d0>, '90': <numjuggler.parser.Card object at 0x77df9711d300>, '91': <numjuggler.parser.Card object at 0x77df9711d330>, '92': <numjuggler.parser.Card object at 0x77df9711d360>, '49': <numjuggler.parser.Card object at 0x77df9711d390>, '50': <numjuggler.parser.Card object at 0x77df9711d3c0>, '51': <numjuggler.parser.Card object at 0x77df9711d3f0>, '52': <numjuggler.parser.Card object at 0x77df9711d420>, '53': <numjuggler.parser.Card object at 0x77df9711d450>, '93': <numjuggler.parser.Card object at 0x77df9711d480>, '94': <numjuggler.parser.Card object at 0x77df9711d4b0>, '95': <numjuggler.parser.Card object at 0x77df9711d4e0>, '96': <numjuggler.parser.Card object at 0x77df9711d510>, '97': <numjuggler.parser.Card object at 0x77df9711d540>, '98': <numjuggler.parser.Card object at 0x77df9711d570>, '99': <numjuggler.parser.Card object at 0x77df9711d5a0>, '100': <numjuggler.parser.Card object at 0x77df9711d5d0>, '101': <numjuggler.parser.Card object at 0x77df9711d600>, '102': <numjuggler.parser.Card object at 0x77df9711d630>, '103': <numjuggler.parser.Card object at 0x77df9711d660>, '104': <numjuggler.parser.Card object at 0x77df9711d690>, '105': <numjuggler.parser.Card object at 0x77df9711d6c0>, '106': <numjuggler.parser.Card object at 0x77df9711d6f0>, '107': <numjuggler.parser.Card object at 0x77df9711d720>, '108': <numjuggler.parser.Card object at 0x77df9711d750>, '109': <numjuggler.parser.Card object at 0x77df9711d780>, '110': <numjuggler.parser.Card object at 0x77df9711d7b0>, '111': <numjuggler.parser.Card object at 0x77df9711d7e0>, '54': <numjuggler.parser.Card object at 0x77df9711d810>, '*55': <numjuggler.parser.Card object at 0x77df9711d840>, '*56': <numjuggler.parser.Card object at 0x77df9711d870>}
{'M1': <f4enix.input.materials.Material object at 0x77df93300730>, 'M2': <f4enix.input.materials.Material object at 0x77df93300880>, 'M3': <f4enix.input.materials.Material object at 0x77df93300eb0>, 'M4': <f4enix.input.materials.Material object at 0x77df93301060>, 'M5': <f4enix.input.materials.Material object at 0x77df933012d0>, 'M6': <f4enix.input.materials.Material object at 0x77df933015a0>, 'M7': <f4enix.input.materials.Material object at 0x77df93301930>, 'M8': <f4enix.input.materials.Material object at 0x77df93301e40>, 'M9': <f4enix.input.materials.Material object at 0x77df93301f30>, 'M10': <f4enix.input.materials.Material object at 0x77df933025c0>, 'M11': <f4enix.input.materials.Material object at 0x77df93325030>, 'M12': <f4enix.input.materials.Material object at 0x77df93326380>, 'M13': <f4enix.input.materials.Material object at 0x77df93342b30>, 'M14': <f4enix.input.materials.Material object at 0x77df933430a0>, 'M15': <f4enix.input.materials.Material object at 0x77df93361ed0>, 'M16': <f4enix.input.materials.Material object at 0x77df933620e0>, 'M17': <f4enix.input.materials.Material object at 0x77df933623b0>, 'M18': <f4enix.input.materials.Material object at 0x77df93362620>, 'M19': <f4enix.input.materials.Material object at 0x77df93362770>, 'M20': <f4enix.input.materials.Material object at 0x77df93362920>, 'M21': <f4enix.input.materials.Material object at 0x77df93362cb0>, 'M74': <f4enix.input.materials.Material object at 0x77df93385360>}
{}
{'SDEF': <numjuggler.parser.Card object at 0x77df9711e140>, 'SP1': <numjuggler.parser.Card object at 0x77df9711e1a0>, 'SI2': <numjuggler.parser.Card object at 0x77df9711e200>, 'SP2': <numjuggler.parser.Card object at 0x77df9711e230>, 'SI3': <numjuggler.parser.Card object at 0x77df9711e290>, 'SP3': <numjuggler.parser.Card object at 0x77df9711e2c0>, 'SI4': <numjuggler.parser.Card object at 0x77df9711e320>, 'SP4': <numjuggler.parser.Card object at 0x77df9711e350>, 'MODE': <numjuggler.parser.Card object at 0x77df9711e3b0>, 'PHYS:N': <numjuggler.parser.Card object at 0x77df9711e410>, 'CUT:N': <numjuggler.parser.Card object at 0x77df9711e470>, 'E4': <numjuggler.parser.Card object at 0x77df9711e4d0>, 'FC4': <numjuggler.parser.Card object at 0x77df9711e530>, 'F4': <numjuggler.parser.Card object at 0x77df9711e560>, 'FM4': <numjuggler.parser.Card object at 0x77df9711e590>, 'FC204': <numjuggler.parser.Card object at 0x77df9711e5f0>, 'F204': <numjuggler.parser.Card object at 0x77df9711e620>, 'FM204': <numjuggler.parser.Card object at 0x77df9711e650>, 'FC14': <numjuggler.parser.Card object at 0x77df9711e6b0>, 'F14': <numjuggler.parser.Card object at 0x77df9711e6e0>, 'FM14': <numjuggler.parser.Card object at 0x77df9711e710>, 'E14': <numjuggler.parser.Card object at 0x77df9711e740>, 'FQ14': <numjuggler.parser.Card object at 0x77df9711e770>, 'FC214': <numjuggler.parser.Card object at 0x77df9711e7d0>, 'F214': <numjuggler.parser.Card object at 0x77df9711e800>, 'FM214': <numjuggler.parser.Card object at 0x77df9711e830>, 'FC6': <numjuggler.parser.Card object at 0x77df9711e890>, 'F6': <numjuggler.parser.Card object at 0x77df9711e8c0>, 'FM6': <numjuggler.parser.Card object at 0x77df9711e8f0>, 'FC16': <numjuggler.parser.Card object at 0x77df9711e950>, 'F16': <numjuggler.parser.Card object at 0x77df9711e980>, 'FM16': <numjuggler.parser.Card object at 0x77df9711e9b0>, 'FC26': <numjuggler.parser.Card object at 0x77df9711ea10>, 'F26': <numjuggler.parser.Card object at 0x77df9711ea40>, 'FM26': <numjuggler.parser.Card object at 0x77df9711ea70>, 'FC24': <numjuggler.parser.Card object at 0x77df9711ead0>, 'F24': <numjuggler.parser.Card object at 0x77df9711eb00>, 'FM24': <numjuggler.parser.Card object at 0x77df9711eb30>, 'FC34': <numjuggler.parser.Card object at 0x77df9711eb90>, 'F34': <numjuggler.parser.Card object at 0x77df9711ebc0>, 'FM34': <numjuggler.parser.Card object at 0x77df9711ebf0>, 'FC44': <numjuggler.parser.Card object at 0x77df9711ec50>, 'F44': <numjuggler.parser.Card object at 0x77df9711ec80>, 'FM44': <numjuggler.parser.Card object at 0x77df9711ecb0>, 'FC54': <numjuggler.parser.Card object at 0x77df9711ed10>, 'F54': <numjuggler.parser.Card object at 0x77df9711ed40>, 'FM54': <numjuggler.parser.Card object at 0x77df9711ed70>, 'FC64': <numjuggler.parser.Card object at 0x77df9711edd0>, 'F64': <numjuggler.parser.Card object at 0x77df9711ee00>, 'FM64': <numjuggler.parser.Card object at 0x77df9711ee30>, 'FC74': <numjuggler.parser.Card object at 0x77df9711ee90>, 'F74': <numjuggler.parser.Card object at 0x77df9711eec0>, 'FM74': <numjuggler.parser.Card object at 0x77df9711eef0>, 'FC84': <numjuggler.parser.Card object at 0x77df9711ef50>, 'F84': <numjuggler.parser.Card object at 0x77df9711ef80>, 'FM84': <numjuggler.parser.Card object at 0x77df9711efb0>, 'FC94': <numjuggler.parser.Card object at 0x77df9711f010>, 'F94': <numjuggler.parser.Card object at 0x77df9711f040>, 'FM94': <numjuggler.parser.Card object at 0x77df9711f070>, 'FC104': <numjuggler.parser.Card object at 0x77df9711f0d0>, 'F104': <numjuggler.parser.Card object at 0x77df9711f100>, 'FM104': <numjuggler.parser.Card object at 0x77df9711f130>, 'FC114': <numjuggler.parser.Card object at 0x77df9711f190>, 'F114': <numjuggler.parser.Card object at 0x77df9711f1c0>, 'FM114': <numjuggler.parser.Card object at 0x77df9711f1f0>, 'FC124': <numjuggler.parser.Card object at 0x77df9711f250>, 'F124': <numjuggler.parser.Card object at 0x77df9711f280>, 'FM124': <numjuggler.parser.Card object at 0x77df9711f2b0>, 'FC134': <numjuggler.parser.Card object at 0x77df9711f310>, 'F134': <numjuggler.parser.Card object at 0x77df9711f340>, 'FM134': <numjuggler.parser.Card object at 0x77df9711f370>, 'FC144': <numjuggler.parser.Card object at 0x77df9711f3d0>, 'F144': <numjuggler.parser.Card object at 0x77df9711f400>, 'FM144': <numjuggler.parser.Card object at 0x77df9711f430>, 'FC154': <numjuggler.parser.Card object at 0x77df9711f490>, 'F154': <numjuggler.parser.Card object at 0x77df9711f4c0>, 'FM154': <numjuggler.parser.Card object at 0x77df9711f4f0>, 'FC164': <numjuggler.parser.Card object at 0x77df9711f550>, 'F164': <numjuggler.parser.Card object at 0x77df9711f580>, 'FM164': <numjuggler.parser.Card object at 0x77df9711f5b0>, 'FC174': <numjuggler.parser.Card object at 0x77df9711f610>, 'F174': <numjuggler.parser.Card object at 0x77df9711f640>, 'E174': <numjuggler.parser.Card object at 0x77df9711f670>, 'FM174': <numjuggler.parser.Card object at 0x77df9711f6a0>, 'FC1004': <numjuggler.parser.Card object at 0x77df9711f700>, 'FMESH1004': <numjuggler.parser.Card object at 0x77df9711f730>, 'FM1004': <numjuggler.parser.Card object at 0x77df9711f760>, 'FC1024': <numjuggler.parser.Card object at 0x77df9711f7c0>, 'FMESH1024': <numjuggler.parser.Card object at 0x77df9711f7f0>, 'FM1024': <numjuggler.parser.Card object at 0x77df9711f820>, 'PRINT': <numjuggler.parser.Card object at 0x77df9711f880>, 'RAND': <numjuggler.parser.Card object at 0x77df9711f8e0>, 'PRDMP': <numjuggler.parser.Card object at 0x77df9711f940>, 'NPS': <numjuggler.parser.Card object at 0x77df9711f970>}
# Get a specific card
print(inp.get_cells_by_id([2]))  # cell n.2
print(inp.get_surfs_by_id([1, 2]))  # surfaces n.1 and 2
print(inp.get_cells_by_matID("13"))  # cells to which material 13 is assigned
print(inp.get_materials_subset(["m2", "m3"]))  # materials M2 and M3
print(inp.get_data_cards("SDEF"))  # generic data cards
{'2': <numjuggler.parser.Card object at 0x77dfd4fd4100>}
{'1': <numjuggler.parser.Card object at 0x77df9711c460>, '2': <numjuggler.parser.Card object at 0x77df9711c850>}
{'2': <numjuggler.parser.Card object at 0x77df9711e2f0>, '3': <numjuggler.parser.Card object at 0x77df9711e7a0>, '4': <numjuggler.parser.Card object at 0x77df9711db40>, '5': <numjuggler.parser.Card object at 0x77df9711e170>, '6': <numjuggler.parser.Card object at 0x77df9711e260>, '7': <numjuggler.parser.Card object at 0x77df9711f160>, '8': <numjuggler.parser.Card object at 0x77df9711db10>, '9': <numjuggler.parser.Card object at 0x77df9711f460>, '10': <numjuggler.parser.Card object at 0x77df9711f790>, '11': <numjuggler.parser.Card object at 0x77df9711f6d0>, '12': <numjuggler.parser.Card object at 0x77df9711de70>, '13': <numjuggler.parser.Card object at 0x77df9711d8d0>, '14': <numjuggler.parser.Card object at 0x77df9711da50>, '15': <numjuggler.parser.Card object at 0x77df9711ef20>, '16': <numjuggler.parser.Card object at 0x77df9711ded0>, '17': <numjuggler.parser.Card object at 0x77df9711f910>, '18': <numjuggler.parser.Card object at 0x77df9711d8a0>, '19': <numjuggler.parser.Card object at 0x77df933854b0>, '20': <numjuggler.parser.Card object at 0x77df93385510>, '21': <numjuggler.parser.Card object at 0x77df93385570>, '86': <numjuggler.parser.Card object at 0x77df933855d0>, '87': <numjuggler.parser.Card object at 0x77df93385630>, '88': <numjuggler.parser.Card object at 0x77df93385690>, '89': <numjuggler.parser.Card object at 0x77df933856f0>, '90': <numjuggler.parser.Card object at 0x77df93385750>, '91': <numjuggler.parser.Card object at 0x77df933857b0>, '92': <numjuggler.parser.Card object at 0x77df93385810>, '93': <numjuggler.parser.Card object at 0x77df93385870>, '94': <numjuggler.parser.Card object at 0x77df933858d0>, '95': <numjuggler.parser.Card object at 0x77df93385930>, '96': <numjuggler.parser.Card object at 0x77df93385990>, '97': <numjuggler.parser.Card object at 0x77df933859f0>, '98': <numjuggler.parser.Card object at 0x77df93385a50>, '99': <numjuggler.parser.Card object at 0x77df93385ab0>, '100': <numjuggler.parser.Card object at 0x77df93385b10>, '101': <numjuggler.parser.Card object at 0x77df93385b70>, '102': <numjuggler.parser.Card object at 0x77df93385bd0>, '103': <numjuggler.parser.Card object at 0x77df93385c30>, '104': <numjuggler.parser.Card object at 0x77df93385c90>, '105': <numjuggler.parser.Card object at 0x77df93385cf0>}
{'M2': <f4enix.input.materials.Material object at 0x77df93300880>, 'M3': <f4enix.input.materials.Material object at 0x77df93300eb0>}
{'SDEF': <numjuggler.parser.Card object at 0x77df9711e140>}

Working with surfaces and cells#

A common example may be the need to modify some cells attributes based on an arbitrary logic. Here is an example where the density of cells is reduced by a factor depending on the material. If a constant factor has to be used, consider the Input.scale_densities() method

from copy import deepcopy
import tempfile  # To have a scratch directory for the example
import os

# It may be useful to preserve the original input
inp2 = deepcopy(inp)

# Set some density correction factors for specific materials
density_factors = {61: 1.1, 63: 10}

# Cycle on the cells dictionary
for idx_cell, cell in inp2.cells.items():
    # Change density based on material
    # mat = cell._get_value_by_type('mat')
    mat = cell.get_m()
    # get the density of the cell
    rho = cell.get_d()
    if mat in [61, 63]:
        cell.set_d(str(rho * density_factors[mat]))
    elif mat == 0:
        pass  # do not change density of void cells
    else:
        # scale all other densitites by a constant factor
        cell.set_d(str(rho * 0.5))

# Print the modified file
outfile = os.path.join(tempfile.gettempdir(), "new_input.i")
inp2.write(outfile)
print(outfile)
/tmp/new_input.i

This input parser is built on numjuggler, hence every card is a numjuggler.parser.Card. The recommended way to get and modify fields of these cards are to use the _get_value_by_type() and _set_value_by_type() methods, as in the example above. Since numjuggler is lacking extensive documentation, to understand which methods are available, the dir() method can be useful, while the values attributes should be used to verify the available values to get/modify.

print(type(cell))
print(dir(cell))
cell.values
<class 'numjuggler.parser.Card'>
['_Card__cr', '_Card__d', '_Card__f', '_Card__i', '_Card__m', '_Card__st', '_Card__u', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slotnames__', '__str__', '__subclasshook__', '__weakref__', '_get_value_by_type', '_protect_nums', '_set_value_by_type', 'apply_map', 'card', 'cstrg', 'ctype', 'debug', 'dtype', 'geom_prefix', 'geom_suffix', 'get_d', 'get_f', 'get_geom', 'get_imp', 'get_input', 'get_m', 'get_refcells', 'get_u', 'get_values', 'hidden', 'input', 'lines', 'name', 'pos', 'print_debug', 'remove_fill', 'remove_spaces', 'set_d', 'template', 'values']
[(106, 'cel'),
 (0, 'mat'),
 ('', '#gpr'),
 (55, 'sur'),
 (54, 'sur'),
 (56, 'sur'),
 ('', '#gsu')]

Another useful feature is to check wether a range of ints is free or not. This can be done both for cell and surfaces indexes

print(inp2.check_range([1, 2], who="cell"))
print(inp2.check_range(range(1000, 1005), who="cell"))
print(inp2.check_range([1], who="surf"))
False
True
False

The following function finds the first free range of cell and surface ids of a give length.

print(
    "If we need to fit 500 new cells in the model they would start with cell: ",
    inp2.find_first_free_id_range(500),
)
print(
    "If we need to fit 3 models of 1000 new cells each they would start with cell: ",
    inp2.find_first_free_id_range(3 * 1000),
)
If we need to fit 500 new cells in the model they would start with cell:  112
If we need to fit 3 models of 1000 new cells each they would start with cell:  112

We can also visualize the used and free ranges of cell and surface ids with a plot. This helps to quickly identify large enough free ranges for adding new cells or surfaces.

fig, ax = inp2.explore_id_ranges_by_plot()
../../../_images/42fb2abf57edbb0572c2fee7fe5f0d6bdc78bcc171d63672604ada2b2f3ca39f.png

Special actions on cells#

In some cases it may be useful to delete all fill cards that are present in an input (for instance for plotting purposes).

This can be done thanks to an ad hoc method:

u_inp = Input.from_input("test_universe.i")
print("original cell")
print(u_inp.cells["1"].card())

u_inp.delete_fill_cards()
print("after deleting fill cards")
print(u_inp.cells["1"].card())
original cell
c
C Cells section
c Universe level 0
1 0 -1 imp:n=1 fill=125

after deleting fill cards
1 0 -1 imp:n=1     

Working with materials#

Replace a material#

It is possible to replace a material with another one (and another density) or set it to void. This can be done across the entire input or only in specific universes.

# It may be useful to preserve the original input
inp3 = deepcopy(inp)

print("original card:")
print(inp3.cells["2"].card())
# In this case replaces in the entire input
inp3.replace_material(10, "-1", 13)
print("modified card:")
print(inp3.cells["2"].card())
original card:
2     13  7.2058e-002  -55 56   1  -60   imp:n,p=8388608  

modified card:
2     10  -1  -55 56   1  -60   imp:n,p=8388608           

Get info on the material section of the input and switch fraction#

# For many operations on materials a libmanager is needed. For most application
# the default libmanager can be used, check the libmanager documentation for
# more details
from f4enix.input.libmanager import LibManager

libmanager = LibManager()

# Get a summary of the materials defined in the input
df_mat, df_submat = inp.materials.get_info(libmanager)
df_mat
Atom Fraction Mass Fraction
Material Submaterial Element
M1 1 H 2.162999e-02 -0.019046
2 C 1.892004e-02 -0.198524
3 N 2.059998e-03 -0.025207
4 O 2.705996e-02 -0.378226
5 Mg 1.190000e-03 -0.025268
... ... ... ... ...
M74 1 Si 8.157524e-06 -0.000020
Ta 6.330820e-07 -0.000010
Ti 2.392466e-06 -0.000010
Zr 1.255620e-06 -0.000010
W 6.220930e-02 -0.999565

161 rows × 2 columns

# here the fraction used in the MCNP input (i.e. either mass or atom) is used
df_submat
Fraction Sub-Material Fraction Material Fraction
Material Submaterial Element
M1 1 H 2.162999e-02 1.000000 0.256858
2 C 1.892004e-02 1.000000 0.224677
3 N 2.059998e-03 1.000000 0.024463
4 O 2.705996e-02 1.000000 0.321339
5 Al 3.930000e-03 0.299542 0.046669
... ... ... ... ... ...
M74 1 Si 8.157524e-06 0.000131 0.000131
Ta 6.330820e-07 0.000010 0.000010
Ti 2.392466e-06 0.000038 0.000038
W 6.220930e-02 0.996832 0.996832
Zr 1.255620e-06 0.000020 0.000020

161 rows × 3 columns

# switch from atom to mass fraction for all materials
inp2 = deepcopy(inp)

# MaterialSection is implemented as a Sequence, hence, it can be iterated
for material in inp2.materials:
    material.switch_fraction("mass", libmanager)

# verify the change, this time get also the different zaid contribution
df_mat, df_submat = inp2.materials.get_info(libmanager, zaids=True)
df_submat
Fraction Sub-Material Fraction Material Fraction
Material Submaterial Element
M1 1 H -0.019046 1.000000 0.019046
2 C -0.198524 1.000000 0.198524
3 N -0.025207 1.000000 0.025207
4 O -0.378226 1.000000 0.378226
5 Al -0.092636 0.294839 0.092636
... ... ... ... ... ...
M74 1 Si -0.000020 0.000020 0.000020
Ta -0.000010 0.000010 0.000010
Ti -0.000010 0.000010 0.000010
W -0.999565 0.999565 0.999565
Zr -0.000010 0.000010 0.000010

161 rows × 3 columns

# the zaids are print only in the df_mat when requested
df_mat
Atom Fraction Mass Fraction
Material Submaterial Element Isotope
M1 1 H H-1 [1001] 0.256828 -0.019042
H-2 [1002] 0.000030 -0.000004
2 C C-12 [6012] 0.222273 -0.196224
C-13 [6013] 0.002404 -0.002300
3 N N-14 [7014] 0.024374 -0.025109
... ... ... ... ... ...
M74 1 W W-180 [74180] 0.001196 -0.001174
W-182 [74182] 0.264161 -0.262157
W-183 [74183] 0.142647 -0.142344
W-184 [74184] 0.305429 -0.306448
W-186 [74186] 0.283399 -0.287442

506 rows × 2 columns

Translation of the material card to different libraries#

F4Enix allows to translate the materials contained into an input to different libraries. There are different ways to do that:

  • Translate all encountered zaids to a specified library

  • Provide a dictionary specifying which zaids needs to be translated to which libraries

  • Provide a dictionary specifying which original libraries should be converted to which ones.

Hereafter are some examples of all these methods

# --- Change library for all materials ---
inp2.translate("31c", libmanager)
print("All translated to 81c:")
print(inp2.materials["M8"].to_text())

# --- specify a library for every zaid ---
special_zaids = ["4009", "28061"]  # to be translated to specific library
non_special = []
for material in inp2.materials:
    for submaterial in material.submaterials:
        for zaid in submaterial.zaidList:
            zaid_str = zaid.element + zaid.isotope
            if zaid_str not in special_zaids:
                non_special.append(zaid_str)

inp2.translate({"80c": special_zaids, "31c": non_special}, libmanager)
print("\nSpecified library for each isotope:")
print(inp2.materials["M8"].to_text())

# --- specify different libraries depending on the original one ---
# this can be useful when D1S libraries only have to be changed for instance
libs = {"31c": "30c", "80c": "31c"}
inp2.translate(libs, libmanager)
print("\nDifferent libraries based on original one:")
print(inp2.materials["M8"].to_text())
All translated to 81c:
c -------------------------------------------------------------------
M8
c   Cu-Be-Ni:  t.a.d. = 8.6794e-002
      28058.31c       -1.337648E-2     $ Ni-58  WEIGHT(%) 2.0035 AB(%) 66.767
      28060.31c       -5.346947E-3     $ Ni-60  WEIGHT(%) 2.0035 AB(%) 26.688
      28061.31c       -2.697346E-4     $ Ni-61  WEIGHT(%) 2.0035 AB(%) 1.3463
      28062.31c       -7.802716E-4     $ Ni-62  WEIGHT(%) 2.0035 AB(%) 3.8946
      28064.31c       -2.612322E-4     $ Ni-64  WEIGHT(%) 2.0035 AB(%) 1.3039
      29063.31c       -6.676429E-1     $ Cu-63  WEIGHT(%) 97.496 AB(%) 68.479
      29065.31c       -3.073144E-1     $ Cu-65  WEIGHT(%) 97.496 AB(%) 31.521
       4009.31c       -5.008062E-3     $ Be-9   WEIGHT(%) 0.50081 AB(%) 100.0
	 plib=84p
Specified library for each isotope:
c -------------------------------------------------------------------
M8
c   Cu-Be-Ni:  t.a.d. = 8.6794e-002
      28058.31c       -1.337648E-2     $ Ni-58  WEIGHT(%) 2.0035 AB(%) 66.767
      28060.31c       -5.346947E-3     $ Ni-60  WEIGHT(%) 2.0035 AB(%) 26.688
      28061.80c       -2.697346E-4     $ Ni-61  WEIGHT(%) 2.0035 AB(%) 1.3463
      28062.31c       -7.802716E-4     $ Ni-62  WEIGHT(%) 2.0035 AB(%) 3.8946
      28064.31c       -2.612322E-4     $ Ni-64  WEIGHT(%) 2.0035 AB(%) 1.3039
      29063.31c       -6.676429E-1     $ Cu-63  WEIGHT(%) 97.496 AB(%) 68.479
      29065.31c       -3.073144E-1     $ Cu-65  WEIGHT(%) 97.496 AB(%) 31.521
       4009.80c       -5.008062E-3     $ Be-9   WEIGHT(%) 0.50081 AB(%) 100.0
	 plib=84p
Different libraries based on original one:
c -------------------------------------------------------------------
M8
c   Cu-Be-Ni:  t.a.d. = 8.6794e-002
      28058.30c       -1.337648E-2     $ Ni-58  WEIGHT(%) 2.0035 AB(%) 66.767
      28060.30c       -5.346947E-3     $ Ni-60  WEIGHT(%) 2.0035 AB(%) 26.688
      28061.31c       -2.697346E-4     $ Ni-61  WEIGHT(%) 2.0035 AB(%) 1.3463
      28062.30c       -7.802716E-4     $ Ni-62  WEIGHT(%) 2.0035 AB(%) 3.8946
      28064.30c       -2.612322E-4     $ Ni-64  WEIGHT(%) 2.0035 AB(%) 1.3039
      29063.30c       -6.676429E-1     $ Cu-63  WEIGHT(%) 97.496 AB(%) 68.479
      29065.30c       -3.073144E-1     $ Cu-65  WEIGHT(%) 97.496 AB(%) 31.521
       4009.31c       -5.008062E-3     $ Be-9   WEIGHT(%) 0.50081 AB(%) 100.0
	 plib=84p

A special mention should go to dosimetry libraries. Often the user does not wish to modify them during the tranlsation (which should happen only for “transport” libraries). For this reason, it is possible to specify a list of libraries that should be ignored by translation operations as an optional argument of the LibManager

from f4enix.input.materials import SubMaterial

newlibmanager = LibManager(dosimetry_lib=["21c"])
text = [
    "C Headers",
    "      28058.31c  1",
    "      28060.31c  1",
    "      28061.21c  1",
]
submat = SubMaterial.from_text(text)
submat.translate("00c", newlibmanager)
print(submat.to_text())
C Header
      28058.00c        1.000000E+0     $        WEIGHT(%)  AB(%)     
      28060.00c        1.000000E+0     $        WEIGHT(%)  AB(%)     
      28061.21c        1.000000E+0     $        WEIGHT(%)  AB(%)     

Generate new materials from existing ones#

# Generate a new material as a composition of existing ones
# The percentages are intended in mass if the fraction is to be expressed in
# mass or in atom otherwise. The new material is created as 'M1'
new_mat = inp2.materials.generate_material(
    ["m2", "m74"], [0.2, 0.8], "31c", libmanager, fractiontype="mass"
)
print(new_mat.to_text())
C Material: M2 Percentage: 20.0% (mass)
C Material: M74 Percentage: 80.0% (mass)
M1
c  -----------------------------------------------------------------
C           o-------------------------------------------------------o
c           |    Copper                                             |
c           |    t.a.d. =   8.29204E-02                        M2   |
C           o-------------------------------------------------------o
c
C M2, submaterial 1
      29063.31c       -1.369585E-1     $ Cu-63  WEIGHT(%) 100.0 AB(%) 68.479
      29065.31c       -6.304150E-2     $ Cu-65  WEIGHT(%) 100.0 AB(%) 31.521
c
C M74, submaterial 1
      13027.31c       -1.201453E-5     $ Al-27  WEIGHT(%) 0.0015018 AB(%) 100.0
       6012.31c       -2.349665E-5     $ C-12   WEIGHT(%) 0.0029715 AB(%) 98.842
       6013.31c       -2.753824E-7     $ C-13   WEIGHT(%) 0.0029715 AB(%) 1.1584
      20040.31c       -7.742686E-6     $ Ca-40  WEIGHT(%) 0.0010013 AB(%) 96.662
      20042.31c       -5.425701E-8     $ Ca-42  WEIGHT(%) 0.0010013 AB(%) 0.67736
      20043.31c       -1.159086E-8     $ Ca-43  WEIGHT(%) 0.0010013 AB(%) 0.1447
      20044.31c       -1.832560E-7     $ Ca-44  WEIGHT(%) 0.0010013 AB(%) 2.2878
      20046.31c      -3.673774E-10     $ Ca-46  WEIGHT(%) 0.0010013 AB(%) 0.0045864
      20048.31c       -1.792187E-8     $ Ca-48  WEIGHT(%) 0.0010013 AB(%) 0.22374
      27059.31c       -8.009724E-6     $ Co-59  WEIGHT(%) 0.0010012 AB(%) 100.0
      24050.31c       -3.342998E-7     $ Cr-50  WEIGHT(%) 0.0010012 AB(%) 4.1737
      24052.31c       -6.704119E-6     $ Cr-52  WEIGHT(%) 0.0010012 AB(%) 83.699
      24053.31c       -7.748249E-7     $ Cr-53  WEIGHT(%) 0.0010012 AB(%) 9.6735
      24054.31c       -1.965054E-7     $ Cr-54  WEIGHT(%) 0.0010012 AB(%) 2.4533
      29063.31c       -5.486584E-6     $ Cu-63  WEIGHT(%) 0.0010012 AB(%) 68.499
      29065.31c       -2.523103E-6     $ Cu-65  WEIGHT(%) 0.0010012 AB(%) 31.501
      26054.31c       -1.356578E-6     $ Fe-54  WEIGHT(%) 0.0030036 AB(%) 5.6456
      26056.31c       -2.208314E-5     $ Fe-56  WEIGHT(%) 0.0030036 AB(%) 91.902
      26057.31c       -5.191164E-7     $ Fe-57  WEIGHT(%) 0.0030036 AB(%) 2.1604
      26058.31c       -7.029536E-8     $ Fe-58  WEIGHT(%) 0.0030036 AB(%) 0.29254
       1001.31c       -4.003929E-6     $ H-1    WEIGHT(%) 0.00050061 AB(%) 99.977
       1002.31c      -9.203023E-10     $ H-2    WEIGHT(%) 0.00050061 AB(%) 0.02298
      19039.31c       -7.443313E-6     $ K-39   WEIGHT(%) 0.0010011 AB(%) 92.937
      19040.31c      -9.577965E-10     $ K-40   WEIGHT(%) 0.0010011 AB(%) 0.011959
      19041.31c       -5.647107E-7     $ K-41   WEIGHT(%) 0.0010011 AB(%) 7.051
      12024.31c       -3.121783E-6     $ Mg-24  WEIGHT(%) 0.00050061 AB(%) 77.95
      12025.31c       -4.117021E-7     $ Mg-25  WEIGHT(%) 0.00050061 AB(%) 10.28
      12026.31c       -4.713673E-7     $ Mg-26  WEIGHT(%) 0.00050061 AB(%) 11.77
      25055.31c       -4.004868E-6     $ Mn-55  WEIGHT(%) 0.00050061 AB(%) 100.0
      42092.31c       -1.138774E-5     $ Mo-92  WEIGHT(%) 0.010012 AB(%) 14.217
      42094.31c       -7.252501E-6     $ Mo-94  WEIGHT(%) 0.010012 AB(%) 9.0546
      42095.31c       -1.261515E-5     $ Mo-95  WEIGHT(%) 0.010012 AB(%) 15.75
      42096.31c       -1.335646E-5     $ Mo-96  WEIGHT(%) 0.010012 AB(%) 16.675
      42097.31c       -7.726974E-6     $ Mo-97  WEIGHT(%) 0.010012 AB(%) 9.647
      42098.31c       -1.972517E-5     $ Mo-98  WEIGHT(%) 0.010012 AB(%) 24.627
      42100.31c       -8.033012E-6     $ Mo-100 WEIGHT(%) 0.010012 AB(%) 10.029
       7014.31c       -7.978127E-6     $ N-14   WEIGHT(%) 0.0010013 AB(%) 99.602
       7015.31c       -3.188774E-8     $ N-15   WEIGHT(%) 0.0010013 AB(%) 0.3981
      11023.31c       -8.009689E-6     $ Na-23  WEIGHT(%) 0.0010012 AB(%) 100.0
      41093.31c       -8.009716E-6     $ Nb-93  WEIGHT(%) 0.0010012 AB(%) 100.0
      28058.31c       -1.076462E-5     $ Ni-58  WEIGHT(%) 0.0020024 AB(%) 67.198
      28060.31c       -4.289338E-6     $ Ni-60  WEIGHT(%) 0.0020024 AB(%) 26.776
      28061.31c       -1.895663E-7     $ Ni-61  WEIGHT(%) 0.0020024 AB(%) 1.1834
      28062.31c       -6.143145E-7     $ Ni-62  WEIGHT(%) 0.0020024 AB(%) 3.8348
      28064.31c       -1.614991E-7     $ Ni-64  WEIGHT(%) 0.0020024 AB(%) 1.0082
       8016.31c       -2.390572E-5     $ O-16   WEIGHT(%) 0.0029963 AB(%) 99.729
       8017.31c       -9.678044E-9     $ O-17   WEIGHT(%) 0.0029963 AB(%) 0.040375
       8018.31c       -5.528194E-8     $ O-18   WEIGHT(%) 0.0029963 AB(%) 0.23062
      15031.31c       -4.004808E-5     $ P-31   WEIGHT(%) 0.005006 AB(%) 100.0
      82204.31c       -1.088356E-7     $ Pb-204 WEIGHT(%) 0.0009872 AB(%) 1.3781
      82206.31c       -1.891913E-6     $ Pb-206 WEIGHT(%) 0.0009872 AB(%) 23.956
      82207.31c       -1.743340E-6     $ Pb-207 WEIGHT(%) 0.0009872 AB(%) 22.074
      82208.31c       -4.153525E-6     $ Pb-208 WEIGHT(%) 0.0009872 AB(%) 52.592
      16032.31c       -3.793265E-6     $ S-32   WEIGHT(%) 0.00050061 AB(%) 94.715
      16033.31c       -3.088613E-8     $ S-33   WEIGHT(%) 0.00050061 AB(%) 0.77121
      16034.31c       -1.803114E-7     $ S-34   WEIGHT(%) 0.00050061 AB(%) 4.5023
      16036.31c      -4.492321E-10     $ S-36   WEIGHT(%) 0.00050061 AB(%) 0.011217
      14028.31c       -1.471739E-5     $ Si-28  WEIGHT(%) 0.0020024 AB(%) 91.874
      14029.31c       -7.740048E-7     $ Si-29  WEIGHT(%) 0.0020024 AB(%) 4.8317
      14030.31c       -5.277873E-7     $ Si-30  WEIGHT(%) 0.0020024 AB(%) 3.2947
      73181.31c       -8.009681E-6     $ Ta-181 WEIGHT(%) 0.0010012 AB(%) 100.0
      22046.31c       -6.343764E-7     $ Ti-46  WEIGHT(%) 0.0010009 AB(%) 7.9226
      22047.31c       -5.845310E-7     $ Ti-47  WEIGHT(%) 0.0010009 AB(%) 7.3001
      22048.31c       -5.912271E-6     $ Ti-48  WEIGHT(%) 0.0010009 AB(%) 73.837
      22049.31c       -4.431130E-7     $ Ti-49  WEIGHT(%) 0.0010009 AB(%) 5.5339
      22050.31c       -4.329136E-7     $ Ti-50  WEIGHT(%) 0.0010009 AB(%) 5.4066
      40090.31c       -4.060946E-6     $ Zr-90  WEIGHT(%) 0.0010011 AB(%) 50.706
      40091.31c       -8.954570E-7     $ Zr-91  WEIGHT(%) 0.0010011 AB(%) 11.181
      40092.31c       -1.383769E-6     $ Zr-92  WEIGHT(%) 0.0010011 AB(%) 17.278
      40094.31c       -1.432863E-6     $ Zr-94  WEIGHT(%) 0.0010011 AB(%) 17.891
      40096.31c       -2.357623E-7     $ Zr-96  WEIGHT(%) 0.0010011 AB(%) 2.9438
      74180.31c       -9.392522E-4     $ W-180  WEIGHT(%) 99.957 AB(%) 0.11746
      74182.31c       -2.097256E-1     $ W-182  WEIGHT(%) 99.957 AB(%) 26.227
      74183.31c       -1.138753E-1     $ W-183  WEIGHT(%) 99.957 AB(%) 14.241
      74184.31c       -2.451585E-1     $ W-184  WEIGHT(%) 99.957 AB(%) 30.658
      74186.31c       -2.299535E-1     $ W-186  WEIGHT(%) 99.957 AB(%) 28.757

Generate a material from a list of zaids or elements#

it is also possible to generate a material from a list of zaids. If the “natural zaids” notation is used, the elements are expanded automatically as shown in the following example.

from f4enix.input.materials import Material
from f4enix.input.libmanager import LibManager

libman = LibManager()  # always needed when libraries are involved
zaids = [
    (1000, -4.7),
    (5000, -30.4),
    (6000, -28.3),
    (11000, -3.2),
    (16000, -33.1),
    (14000, -0.06),
    (26000, -0.08),
    (7000, -0.4),
]
newmat = Material.from_zaids(zaids, libman, "31c", "header of the material")
print(newmat.to_text())
C header of the material
M1
       1001.31c       -4.698638E+0     $ H-1    WEIGHT(%) 4.6887 AB(%) 99.971
       1002.31c       -1.361756E-3     $ H-2    WEIGHT(%) 4.6887 AB(%) 0.028974
       5010.31c       -5.531343E+0     $ B-10   WEIGHT(%) 30.327 AB(%) 18.195
       5011.31c       -2.486866E+1     $ B-11   WEIGHT(%) 30.327 AB(%) 81.805
       6012.31c       -2.797523E+1     $ C-12   WEIGHT(%) 28.232 AB(%) 98.852
       6013.31c       -3.247744E-1     $ C-13   WEIGHT(%) 28.232 AB(%) 1.1476
      11023.31c       -3.200000E+0     $ Na-23  WEIGHT(%) 3.1923 AB(%) 100.0
      16032.31c       -3.130391E+1     $ S-32   WEIGHT(%) 33.021 AB(%) 94.574
      16033.31c       -2.596888E-1     $ S-33   WEIGHT(%) 33.021 AB(%) 0.78456
      16034.31c       -1.530534E+0     $ S-34   WEIGHT(%) 33.021 AB(%) 4.624
      16036.31c       -5.866145E-3     $ S-36   WEIGHT(%) 33.021 AB(%) 0.017722
      14028.31c       -5.513970E-2     $ Si-28  WEIGHT(%) 0.059856 AB(%) 91.899
      14029.31c       -2.892181E-3     $ Si-29  WEIGHT(%) 0.059856 AB(%) 4.8203
      14030.31c       -1.968119E-3     $ Si-30  WEIGHT(%) 0.059856 AB(%) 3.2802
      26054.31c       -4.516447E-3     $ Fe-54  WEIGHT(%) 0.079808 AB(%) 5.6456
      26056.31c       -7.352122E-2     $ Fe-56  WEIGHT(%) 0.079808 AB(%) 91.902
      26057.31c       -1.728295E-3     $ Fe-57  WEIGHT(%) 0.079808 AB(%) 2.1604
      26058.31c       -2.340355E-4     $ Fe-58  WEIGHT(%) 0.079808 AB(%) 0.29254
       7014.31c       -3.983744E-1     $ N-14   WEIGHT(%) 0.39904 AB(%) 99.594
       7015.31c       -1.625644E-3     $ N-15   WEIGHT(%) 0.39904 AB(%) 0.40641

The elements/zaids to be added can be specified with the zaid number but also using their formula as shown below

zaids = [("1001", -100), ("B-0", -200), ("C-12", -50)]
newmat = Material.from_zaids(zaids, libman, "31c", "header of the material")
print(newmat.to_text())
C header of the material
M1
       1001.31c       -1.000000E+2     $ H-1    WEIGHT(%) 28.571 AB(%) 100.0
       5010.31c       -3.639041E+1     $ B-10   WEIGHT(%) 57.143 AB(%) 18.195
       5011.31c       -1.636096E+2     $ B-11   WEIGHT(%) 57.143 AB(%) 81.805
       6012.31c       -5.000000E+1     $ C-12   WEIGHT(%) 14.286 AB(%) 100.0

Renumbering and Merging#

A very common task when dealing with MCNP input is renumbering. The numjuggler capabilities have been restored also in F4Enix with the exception of renumbering materials

newinp = deepcopy(inp)

newinp.renumber(cells=100, surfs=120, translations=10, universes=10)
# when used like that, the keys of the dictionary will not be updated
print("keys are not modified by renumbering:")
print(newinp.cells.keys())
print("\n\n")
# it is recommeded then to operate the renumbering only at the end of the
# pre-processing
outfile = os.path.join(tempfile.gettempdir(), "renum.i")
newinp.write(outfile)

print("but the renumbering correctly happens when dumped:\n")
with open(outfile, "r") as infile:
    for i, line in enumerate(infile):
        print(line.strip("\n"))
        if i > 20:
            break
keys are not modified by renumbering:
dict_keys(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106'])



but the renumbering correctly happens when dumped:

ITER 1D
c  -use endfb8.0 with ljj builds of mcnp6
c 
c  mcnp6.mpi n=inp173 
c 
c        bohm edits
c             -added ebin to f14 photon flux tally
c 
c        Cells section:
101    0                -175 176 -121          imp:n,p=8388608
102     13  7.2058e-002  -175 176   121  -180   imp:n,p=8388608  
103     13  7.2058e-002  -175 176  180  -181   imp:n,p=8388608  
104     13  7.2058e-002  -175 176  181  -182   imp:n,p=4194304  
105     13  7.2058e-002  -175 176  182  -183   imp:n,p=4194304  
106     13  7.2058e-002  -175 176  183  -184   imp:n,p=2097152  
107     13  7.2058e-002  -175 176  184  -185   imp:n,p=2097152  
108     13  7.2058e-002  -175 176  185  -186   imp:n,p=1048576   
109     13  7.2058e-002  -175 176  186  -187   imp:n,p=1048576   
110    13  7.2058e-002  -175 176  187  -188   imp:n,p=524288 
111    13  7.2058e-002  -175 176  188  -189   imp:n,p=524288 
112    13  7.2058e-002  -175 176  189  -190   imp:n,p=262144  
113    13  7.2058e-002  -175 176  190  -191   imp:n,p=262144  
# keys can be updated if needed, it will cost a bit in term of performance
# this do not guarantee that all internal numjuggler parameters are also updated
newinp = deepcopy(inp)

# the renumber_all option can be useful
newinp.renumber(renum_all=1000, update_keys=True)
# when used like that, the keys of the dictionary will not be updated
print("now dict keys are also renumbered:")
print(newinp.cells.keys())
print("\n\n")
now dict keys are also renumbered:
dict_keys(['1001', '1002', '1003', '1004', '1005', '1006', '1007', '1008', '1009', '1010', '1011', '1012', '1013', '1014', '1015', '1016', '1017', '1018', '1019', '1020', '1021', '1022', '1023', '1024', '1025', '1026', '1027', '1028', '1029', '1030', '1031', '1032', '1033', '1034', '1035', '1036', '1037', '1038', '1039', '1040', '1041', '1042', '1043', '1044', '1045', '1046', '1047', '1048', '1049', '1050', '1051', '1052', '1053', '1054', '1055', '1056', '1057', '1058', '1059', '1060', '1061', '1062', '1063', '1064', '1065', '1066', '1067', '1068', '1069', '1070', '1071', '1072', '1073', '1074', '1075', '1076', '1077', '1078', '1079', '1080', '1081', '1082', '1083', '1084', '1085', '1086', '1087', '1088', '1089', '1090', '1091', '1092', '1093', '1094', '1095', '1096', '1097', '1098', '1099', '1100', '1101', '1102', '1103', '1104', '1105', '1106'])

The ability to renumber is often connected by the ability to merge two different mcnp inputs into a single one. A check is made to not duplicate the ID of cells, surfaces, materials or transformations. All other cards, if with duplicated ID, will be the ones of inp2 in the example below

# just for the sake of the example, the same but renumbered input is merged
inp1 = deepcopy(inp)
print(f"original cells: {len(inp1.cells)}, original surfs: {len(inp1.surfs)}")
inp2 = deepcopy(inp)

inp2.renumber(renum_all=1000, update_keys=True)
inp1.merge(inp2)
print(f"merged cells: {len(inp1.cells)}, original surfs: {len(inp1.surfs)}")
original cells: 106, original surfs: 107
merged cells: 212, original surfs: 214

Hash and Cut#

Sometimes it may be useful to cut certain cells with a surface or hash them with a cell.

# cut the cell with a surface
newinp = deepcopy(inp)
cell = newinp.cells["2"]
print(f"original cell:\n{cell.card()}")
Input.add_surface(cell, 3, inplace=True)
print(f"cell after cut:\n{cell.card()}")
original cell:
2     13  7.2058e-002  -55 56   1  -60   imp:n,p=8388608  

cell after cut:
2 13 7.2058e-002 ( -55 56 1 -60 ) 3 imp:n,p=8388608
# hash a cell with a surface
newinp = deepcopy(inp)
cell = newinp.cells["2"]
print(f"original cell:\n{cell.card()}")
Input.hash_cell(cell, 3, inplace=True)
print(f"cell after hash:\n{cell.card()}")

# it is also possible to hash multiple cells at once, this is always done inplace
print("multiple hashes:")
hashes = {1: [3, 4], 2: [6]}
newinp = deepcopy(inp)
newinp.hash_multiple_cells(hashes)
for id in [3, 4, 6]:
    print(newinp.cells[str(id)].card())
original cell:
2     13  7.2058e-002  -55 56   1  -60   imp:n,p=8388608  

cell after hash:
2 13 7.2058e-002 ( -55 56 1 -60 ) #3  imp:n,p=8388608

multiple hashes:
3 13 7.2058e-002 ( -55 56 60 -61 ) #1  imp:n,p=8388608
4 13 7.2058e-002 ( -55 56 61 -62 ) #1  imp:n,p=4194304

6 13 7.2058e-002 ( -55 56 63 -64 ) #2  imp:n,p=2097152

Working with tallies#

Get an implemented tallies summary#

When producing a report, it can be useful to have a summary of the tallies defined in the input

# Normal tallies
inp.get_tally_summary()
Particle Description Normalization Other multipliers
Tally
4 N Neutrons Flux (energy binned) [#/cm^2] 1.222e21 NaN
6 NP Total Nuclear Heating [W/g] 1.9577e8 NaN
14 P Photons Flux (energy binned) [#/cm^2] 1.222e21 NaN
16 N Neutron Heating [W/g] 1.9577e8 NaN
24 N Fe dpa/FPY 3.8566e8 [16, 444]
26 P Gamma Heating [W/g] 1.9577e8 NaN
34 N He in 316SS appm/FPY 3.8566e10 [11, (207:206)]
44 N H in 316SS appm/FPY 3.8566e10 [11, (203:204:205)]
54 N T in 316SS appm/FPY 3.8566e10 [11, 205]
64 N Cu dpa/FPY 3.8566e8 [2, 444]
74 N He in CuBeNi appm/FPY 3.8566e10 [8, (207:206)]
84 N H in CuBeNi appm/FPY 3.8566e10 [8, (203:204:205)]
94 N T in CuBeNi appm/FPY 3.8566e10 [8, 205]
104 N Ni dpa/FPY 3.8566e8 [17, 444]
114 N He in Inconel appm/FPY 3.8566e10 [12, (207:206)]
124 N H in Inconel appm/FPY 3.8566e10 [12, (203:204:205)]
134 N T in Inconel appm/FPY 3.8566e10 [12, 205]
144 N He in Be appm/FPY 3.8566e10 [9, (207:206)]
154 N H in Be appm/FPY 3.8566e10 [9, (203:204:205)]
164 N T in Be appm/FPY 3.8566e10 [9, 205]
174 N fast (E>0.1 MeV) fluence at magnet n/cm2/FPY 3.8566e28 NaN
204 N Total Neutron Flux [#/cm^2] 1.222e21 NaN
214 P Total Photons Flux [#/cm^2] 1.222e21 NaN
# FMESHES
inp.get_tally_summary(fmesh=True)
Particle Description Normalization Other multipliers
Tally
1004 N Neutron Flux [#/cc/s] 1.222e21 NaN
1024 P Photon Flux [#/cc/s] 1.222e21 NaN

Adding new tallies#

Tallies are not explicitly handled with ad hoc object in F4Enix for the moment but the numjuggler cards can be accessed through the Input.other_data dictionary. Nevertheless, a method is provided to conveniently add ‘F’ tallies to an existing input

import numpy as np

newinput = deepcopy(inp)
cells = range(100, 150)  # whatever array of integers
energies = np.linspace(1e4, 1e5, 100)  # whatever array of floats
newinput.add_F_tally(
    4,  # ID of the tally
    ["N", "P"],  # particles to be tallied
    cells,  # either cells or surfaces ints to tally
    energies=energies,  # energies to tally (optional)
    description="Test F4 tally",  # description of the tally
    add_SD=True,  # add SD card equal 1 for each bin
    add_total=True,  # add total to the cell or surface bin
    multiplier="1 -52 1",  # multiplier for the tally
)

# shortcut to print the result, writing the input to a file would give the same
# result
for idx, card in newinput.other_data.items():
    # Even if FC, SD, E and FM are connected to F4 they are still stored as
    # separate cards
    if idx in ["F4", "FC4", "SD4", "E4", "FM4"]:
        print(card.card())
E4
     1.0000e+04 1.0909e+04 1.1818e+04 1.2727e+04 1.3636e+04 1.4545e+04
     1.5455e+04 1.6364e+04 1.7273e+04 1.8182e+04 1.9091e+04 2.0000e+04
     2.0909e+04 2.1818e+04 2.2727e+04 2.3636e+04 2.4545e+04 2.5455e+04
     2.6364e+04 2.7273e+04 2.8182e+04 2.9091e+04 3.0000e+04 3.0909e+04
     3.1818e+04 3.2727e+04 3.3636e+04 3.4545e+04 3.5455e+04 3.6364e+04
     3.7273e+04 3.8182e+04 3.9091e+04 4.0000e+04 4.0909e+04 4.1818e+04
     4.2727e+04 4.3636e+04 4.4545e+04 4.5455e+04 4.6364e+04 4.7273e+04
     4.8182e+04 4.9091e+04 5.0000e+04 5.0909e+04 5.1818e+04 5.2727e+04
     5.3636e+04 5.4545e+04 5.5455e+04 5.6364e+04 5.7273e+04 5.8182e+04
     5.9091e+04 6.0000e+04 6.0909e+04 6.1818e+04 6.2727e+04 6.3636e+04
     6.4545e+04 6.5455e+04 6.6364e+04 6.7273e+04 6.8182e+04 6.9091e+04
     7.0000e+04 7.0909e+04 7.1818e+04 7.2727e+04 7.3636e+04 7.4545e+04
     7.5455e+04 7.6364e+04 7.7273e+04 7.8182e+04 7.9091e+04 8.0000e+04
     8.0909e+04 8.1818e+04 8.2727e+04 8.3636e+04 8.4545e+04 8.5455e+04
     8.6364e+04 8.7273e+04 8.8182e+04 8.9091e+04 9.0000e+04 9.0909e+04
     9.1818e+04 9.2727e+04 9.3636e+04 9.4545e+04 9.5455e+04 9.6364e+04
      9.7273e+04 9.8182e+04 9.9091e+04 1.0000e+05 

FC4 Test F4 tally

F4:N,P
     100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
     117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
      134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 T 

FM4 1 -52 1

SD4 1 50R

You can also add a more complex cell definition in the tally as a string:

newinput = deepcopy(inp)
cells = [
    "((1 2 3 4 5 6) < 10)",
    12,
    "(((1 2 3 4 5 6) 18) < 11)",
    19,
    20,
    "((1 2 3 4 5 11) < 20)",
]  # whatever array of integers
energies = np.linspace(1e4, 1e5, 100)  # whatever array of floats
newinput.add_F_tally(
    14,  # ID of the tally
    ["N"],  # particles to be tallied
    cells,  # either cells or surfaces ints to tally
    description="Test F14 tally",  # description of the tally
    add_SD=True,  # add SD card equal 1 for each bin
    add_total=True,  # add total to the cell or surface bin
    multiplier="1 -52 1",  # multiplier for the tally
)

# shortcut to print the result, writing the input to a file would give the same
# result
for idx, card in newinput.other_data.items():
    # Even if FC, SD, E and FM are connected to F4 they are still stored as
    # separate cards
    if idx in ["F14", "FC14", "SD14", "E14", "FM14"]:
        print(card.card())
FC14 Test F14 tally

F14:N
     ((1 2 3 4 5 6) < 10) 12 (((1 2 3 4 5 6) 18) < 11) 19 20 ((1 2 3 4 5
      11) < 20) T 

FM14 1 -52 1

e14 .1 1 5 10 20 t

SD14 1 6R

Extract a sub-input#

Another capability implemented in the MCNP inputs is the possibility to extract a minimum working MCNP input given a set of cells. All transformation cards, surfaces, universes and material cards related to these cells will also be extracted. Cell definitions using the # operator are also supported.

cells_to_extract = [34, 35, 36]
outfile = os.path.join(tempfile.gettempdir(), "extracted.i")
inp.extract_cells(cells_to_extract, outfile)

with open(outfile, "r") as infile:
    for line in infile:
        print(line.strip("\n"))
ITER 1D
34   7   1.0028e-001  -55 56  10 -11     imp:n,p=64
35   11  8.5299e-002  -55 56  11 -12     imp:n,p=32
36   7   1.0028e-001  -55 56  12 -13     imp:n,p=32

10   cz 447.9 
11   cz 451   
12   cz 455.2 
13   cz 458.2 
*55   pz  1000.0
*56   pz -1000.0

c ------------------------------------------------------------------
c           o-------------------------------------------------------o
C           |     S.S. 316L(N)-IG.....100 %                         |   
c           |                                                       | 
c           |     t.a.d.  = 8.5299e-002                       M11   |
C           o-------------------------------------------------------o
c
c
M11
       5010.31c        8.707160E-7     $        WEIGHT(%)  AB(%)     
       5011.31c        3.504740E-6     $        WEIGHT(%)  AB(%)     
c         6012.21c 7.08895E-05  $ C    (nat.)
       6012.31c        7.013100E-5     $        WEIGHT(%)  AB(%)     
       6013.31c        7.585180E-7     $        WEIGHT(%)  AB(%)     
c         7014.21c 2.36402E-04  $ N    (nat.)
       7014.31c        2.355410E-4     $        WEIGHT(%)  AB(%)     
       7015.31c        8.605030E-7     $        WEIGHT(%)  AB(%)     
c         8016.70c 5.89895E-06  $ O    (nat.)
       8016.31c        5.884620E-6     $        WEIGHT(%)  AB(%)     
       8017.31c        2.241600E-9     $        WEIGHT(%)  AB(%)     
       8018.31c        1.209280E-8     $        WEIGHT(%)  AB(%)     
      13027.31c        5.259500E-4     $        WEIGHT(%)  AB(%)     
      14028.31c        7.145600E-4     $        WEIGHT(%)  AB(%)     
      14029.31c        3.628300E-5     $        WEIGHT(%)  AB(%)     
      14030.31c        2.391800E-5     $        WEIGHT(%)  AB(%)     
      15031.31c        3.970720E-5     $        WEIGHT(%)  AB(%)     
c        16000.21c 1.47526E-05  $ S    (nat.)
      16032.31c        1.401790E-5     $        WEIGHT(%)  AB(%)     
      16033.31c        1.106450E-7     $        WEIGHT(%)  AB(%)     
      16034.31c        6.210840E-7     $        WEIGHT(%)  AB(%)     
      16036.31c        2.950520E-9     $        WEIGHT(%)  AB(%)     
c        19000.21c 6.04926E-07  $ K    (nat.)
      19039.31c        5.641540E-7     $        WEIGHT(%)  AB(%)     
      19040.31c       6.049260E-11     $        WEIGHT(%)  AB(%)     
      19041.31c        4.071150E-8     $        WEIGHT(%)  AB(%)     
      22046.31c        3.260400E-6     $        WEIGHT(%)  AB(%)     
      22047.31c        2.940200E-6     $        WEIGHT(%)  AB(%)     
      22048.31c        2.913400E-5     $        WEIGHT(%)  AB(%)     
      22049.31c        2.138000E-6     $        WEIGHT(%)  AB(%)     
      22050.31c        2.047100E-6     $        WEIGHT(%)  AB(%)     
c        23000.21c 3.71431E-06  $ V    (nat.)
      23050.31c        9.285780E-9     $        WEIGHT(%)  AB(%)     
      23051.31c        3.705020E-6     $        WEIGHT(%)  AB(%)     
      24050.31c        6.689300E-4     $        WEIGHT(%)  AB(%)     
      24052.31c        1.303600E-2     $        WEIGHT(%)  AB(%)     
      24053.31c        1.493400E-3     $        WEIGHT(%)  AB(%)     
      24054.31c        3.733600E-4     $        WEIGHT(%)  AB(%)     
      25055.31c        1.463750E-3     $        WEIGHT(%)  AB(%)     
      26054.31c        3.165200E-3     $        WEIGHT(%)  AB(%)     
      26056.31c        5.004400E-2     $        WEIGHT(%)  AB(%)     
      26057.31c        1.200600E-3     $        WEIGHT(%)  AB(%)     
      26058.31c        1.637200E-4     $        WEIGHT(%)  AB(%)     
      27059.31c        2.407970E-5     $        WEIGHT(%)  AB(%)     
      28058.31c        7.202200E-3     $        WEIGHT(%)  AB(%)     
      28060.31c        2.787300E-3     $        WEIGHT(%)  AB(%)     
      28061.31c        1.383000E-4     $        WEIGHT(%)  AB(%)     
      28062.31c        3.829800E-4     $        WEIGHT(%)  AB(%)     
      28064.31c        1.276600E-4     $        WEIGHT(%)  AB(%)     
      29063.31c        5.147510E-5     $        WEIGHT(%)  AB(%)     
      29065.31c        2.296460E-5     $        WEIGHT(%)  AB(%)     
c        40000.21c 1.03708E-06  $ Zr-nat.
      40090.31c        5.335780E-7     $        WEIGHT(%)  AB(%)     
      40091.31c        1.163600E-7     $        WEIGHT(%)  AB(%)     
      40092.31c        1.778590E-7     $        WEIGHT(%)  AB(%)     
      40094.31c        1.802450E-7     $        WEIGHT(%)  AB(%)     
      40096.31c        2.903820E-8     $        WEIGHT(%)  AB(%)     
      41093.31c        1.018300E-6     $        WEIGHT(%)  AB(%)     
      42092.31c        1.829400E-4     $        WEIGHT(%)  AB(%)     
      42094.31c        1.140300E-4     $        WEIGHT(%)  AB(%)     
      42095.31c        1.962500E-4     $        WEIGHT(%)  AB(%)     
      42096.31c        2.056200E-4     $        WEIGHT(%)  AB(%)     
      42097.31c        1.177300E-4     $        WEIGHT(%)  AB(%)     
      42098.31c        2.974600E-4     $        WEIGHT(%)  AB(%)     
      42100.31c        1.187100E-4     $        WEIGHT(%)  AB(%)     
c        50000.21c 7.96952E-07  $ Sn   (nat.)
      50112.31c        7.730430E-9     $        WEIGHT(%)  AB(%)     
      50114.31c        5.259880E-9     $        WEIGHT(%)  AB(%)     
      50115.31c        2.709640E-9     $        WEIGHT(%)  AB(%)     
      50116.31c        1.158770E-7     $        WEIGHT(%)  AB(%)     
      50117.31c        6.120590E-8     $        WEIGHT(%)  AB(%)     
      50118.31c        1.930220E-7     $        WEIGHT(%)  AB(%)     
      50119.31c        6.845820E-8     $        WEIGHT(%)  AB(%)     
      50120.31c        2.596470E-7     $        WEIGHT(%)  AB(%)     
      50122.31c        3.689890E-8     $        WEIGHT(%)  AB(%)     
      50124.31c        4.614350E-8     $        WEIGHT(%)  AB(%)     
      73181.31c        1.307090E-7     $        WEIGHT(%)  AB(%)     
      74180.31c       3.083810E-10     $        WEIGHT(%)  AB(%)     
      74182.31c        6.810080E-8     $        WEIGHT(%)  AB(%)     
      74183.31c        3.677440E-8     $        WEIGHT(%)  AB(%)     
      74184.31c        7.873990E-8     $        WEIGHT(%)  AB(%)     
      74186.31c        7.306060E-8     $        WEIGHT(%)  AB(%)     
      82204.31c        2.556720E-9     $        WEIGHT(%)  AB(%)     
      82206.31c        4.401210E-8     $        WEIGHT(%)  AB(%)     
      82207.31c        4.035970E-8     $        WEIGHT(%)  AB(%)     
      82208.31c        9.569450E-8     $        WEIGHT(%)  AB(%)     
      83209.31c        1.810820E-7     $        WEIGHT(%)  AB(%)     
	 plib=84p
c ------------------------------------------------------------------
C           o-------------------------------------------------------o
c           |    H2O                    
c           |                                                       |
c           |                                                       |
c           |    t.a.d. =   1.0028e-001                        M7   |
C           o-------------------------------------------------------o
c     
M7
       1001.31c        6.684830E-2     $        WEIGHT(%)  AB(%)     
       1002.31c        7.688440E-6     $        WEIGHT(%)  AB(%)     
c         8016.70c 3.34280E-02  $ O        (nat.)
       8016.31c        3.334680E-2     $        WEIGHT(%)  AB(%)     
       8017.31c        1.270260E-5     $        WEIGHT(%)  AB(%)     
       8018.31c        6.852740E-5     $        WEIGHT(%)  AB(%)     
	 plib=84p
c
c       o-----------------------------------------------------------------o
c       |               s o u r c e  d e s c r i p t i o n                |
c       o-----------------------------------------------------------------o
sdef  erg=d1  cel=51   x=d2 y=d3 z=d4   wgt=1
c
c    Source probability function for energy sampling:
c    Muir velocity Gaussian energy spectrum (DT fusion at 10 keV):
sp1   -6
c    Coordinates sampling (x,y,z):
si2    -1115.2  1115.2
sp2      0    1
c
si3    -1115.2  1115.2
sp3      0    1
c
si4    -1000.2  1000.2
sp4      0    1
c
c void
c   --------------------------------------------------------------
c               source for volume calculations
c sdef  erg=14.1 sur=57 nrm=-1 wgt=2.82743e+7
c   --------------------------------------------------------------
c 
mode    n p
c 
c phys:n  20 1e-8
c change phys card for mcnp6
phys:n  100 1e-8 $ change emax to default 100 MeV
c  phys:p  20 1
cut:n   j j -0.5 -0.25 j
c
c vol:n  106j
c  -----------------------------
C    TALLY ENERGY CARD VITAMIN-J 175-group structure                       
C                                            
E4    1.00001E-07 4.13994E-07 5.31579E-07 6.82560E-07 8.76425E-07
      1.12535E-06 1.44498E-06 1.85539E-06 2.38237E-06 3.05902E-06
      3.92786E-06 5.04348E-06 6.47595E-06 8.31529E-06 1.06770E-05
      1.37096E-05 1.76035E-05 2.26033E-05 2.90232E-05 3.72665E-05
      4.78512E-05 6.14421E-05 7.88932E-05 1.01301E-04 1.30073E-04
      1.67017E-04 2.14454E-04 2.75364E-04 3.53575E-04 4.53999E-04
      5.82947E-04 7.48518E-04 9.61117E-04 1.23410E-03 1.58461E-03
      2.03468E-03 2.24867E-03 2.48517E-03 2.61259E-03 2.74654E-03
      3.03539E-03 3.35463E-03 3.70744E-03 4.30742E-03 5.53084E-03
      7.10174E-03 9.11882E-03 1.05946E-02 1.17088E-02 1.50344E-02
      1.93045E-02 2.18749E-02 2.35786E-02 2.41755E-02 2.47875E-02
      2.60584E-02 2.70001E-02 2.85011E-02 3.18278E-02 3.43067E-02
      4.08677E-02 4.63092E-02 5.24752E-02 5.65622E-02 6.73795E-02
      7.20245E-02 7.94987E-02 8.25034E-02 8.65170E-02 9.80365E-02
      1.11090E-01 1.16786E-01 1.22773E-01 1.29068E-01 1.35686E-01
      1.42642E-01 1.49956E-01 1.57644E-01 1.65727E-01 1.74224E-01
      1.83156E-01 1.92547E-01 2.02419E-01 2.12797E-01 2.23708E-01
      2.35177E-01 2.47235E-01 2.73237E-01 2.87246E-01 2.94518E-01
      2.97211E-01 2.98491E-01 3.01974E-01 3.33733E-01 3.68832E-01
      3.87742E-01 4.07622E-01 4.50492E-01 4.97871E-01 5.23397E-01
      5.50232E-01 5.78443E-01 6.08101E-01 6.39279E-01 6.72055E-01
      7.06512E-01 7.42736E-01 7.80817E-01 8.20850E-01 8.62936E-01
      9.07180E-01 9.61672E-01 1.00259E+00 1.10803E+00 1.16484E+00
      1.22456E+00 1.28735E+00 1.35335E+00 1.42274E+00 1.49569E+00
      1.57237E+00 1.65299E+00 1.73774E+00 1.82684E+00 1.92050E+00
      2.01897E+00 2.12248E+00 2.23130E+00 2.30693E+00 2.34570E+00
      2.36533E+00 2.38513E+00 2.46597E+00 2.59240E+00 2.72532E+00
      2.86505E+00 3.01194E+00 3.16637E+00 3.32871E+00 3.67879E+00
      4.06570E+00 4.49329E+00 4.72367E+00 4.96585E+00 5.22046E+00
      5.48812E+00 5.76950E+00 6.06531E+00 6.37628E+00 6.59241E+00
      6.70320E+00 7.04688E+00 7.40818E+00 7.78801E+00 8.18731E+00
      8.60708E+00 9.04837E+00 9.51229E+00 1.00000E+01 1.05127E+01
      1.10517E+01 1.16183E+01 1.22140E+01 1.25232E+01 1.28403E+01
      1.34986E+01 1.38403E+01 1.41907E+01 1.45499E+01 1.49182E+01
      1.56831E+01 1.64872E+01 1.69046E+01 1.73325E+01 1.96403E+01
C 
c   --------------------------------------------------------------------
fc4  Neutrons Flux (energy binned) [#/cm^2]
f4:n
                 2 3  4  5  6  
                 7  8  9  10 11 
                 12 13 14 15 16 
                 17 18 19 20 21 
                 22 24 25 26 27 
                 28 29 30 31 33 
                 34 35 36 37 38 
                 39 40 41 42 43 
                 44 45 46 47 48 
                 49 53 54 55 56 
                 57 58 59 60 61 
                 62 63 64 65 66 
                 67 68 69 71 72 
                 73 74 75 76 77 
                 78 79 80 81 82 
                 83 85 86 87 88 
                 89 90 91 92 93 
                 94  95  96  97  98 
                 99  100 101 102 103
                 104 105
fm4   1.222e21
c      ----------------------------------           
c
fc204  Total Neutron Flux [#/cm^2]
f204:n
                 2 3  4  5  6  
                 7  8  9  10 11 
                 12 13 14 15 16 
                 17 18 19 20 21 
                 22 24 25 26 27 
                 28 29 30 31 33 
                 34 35 36 37 38 
                 39 40 41 42 43 
                 44 45 46 47 48 
                 49 53 54 55 56 
                 57 58 59 60 61 
                 62 63 64 65 66 
                 67 68 69 71 72 
                 73 74 75 76 77 
                 78 79 80 81 82 
                 83 85 86 87 88 
                 89 90 91 92 93 
                 94  95  96  97  98 
                 99  100 101 102 103
                 104 105
fm204   1.222e21
c      ----------------------------------           
c
fc14  Photons Flux (energy binned) [#/cm^2]
f14:p
                  2 3  4  5  6 
                  7  8  9  10 11
                  12 13 14 15 16
                  17 18 19 20 21
                  22 24 25 26 27
                  28 29 30 31 33
                  34 35 36 37 38
                  39 40 41 42 43
                  44 45 46 47 48
                  49 53 54 55 56
                  57 58 59 60 61
                  62 63 64 65 66
                  67 68 69 71 72
                  73 74 75 76 77
                  78 79 80 81 82
                  83 85 86 87 88
                  89 90 91 92 93
                  94  95  96  97  98 
                  99  100 101 102 103
                  104 105
fm14   1.222e21
e14 .1 1 5 10 20 t
fq14 f e $ change tally printout cell/surf down,ebins across top
c      ---------------------------------
c
fc214  Total Photons Flux [#/cm^2]
f214:p
                  2 3  4  5  6 
                  7  8  9  10 11
                  12 13 14 15 16
                  17 18 19 20 21
                  22 24 25 26 27
                  28 29 30 31 33
                  34 35 36 37 38
                  39 40 41 42 43
                  44 45 46 47 48
                  49 53 54 55 56
                  57 58 59 60 61
                  62 63 64 65 66
                  67 68 69 71 72
                  73 74 75 76 77
                  78 79 80 81 82
                  83 85 86 87 88
                  89 90 91 92 93
                  94  95  96  97  98 
                  99  100 101 102 103
                  104 105
fm214   1.222e21
c      ---------------------------------
c
fc6   Total Nuclear Heating [W/g]
f6:np
                  2 3  4  5  6 
                  7  8  9  10 11
                  12 13 14 15 16
                  17 18 19 20 21
                  22 24 25 26 27
                  28 29 30 31 33
                  34 35 36 37 38
                  39 40 41 42 43
                  44 45 46 47 48
                  49 53 54 55 56
                  57 58 59 60 61
                  62 63 64 65 66
                  67 68 69 71 72
                  73 74 75 76 77
                  78 79 80 81 82
                  83 85 86 87 88
                  89 90 91 92 93
                  94  95  96  97  98 
                  99  100 101 102 103
                  104 105
fm6   1.9577e8
c      -----------------------------
fc16   Neutron Heating [W/g]
f16:n
                 2 3  4  5  6 
                 7  8  9  10 11
                 12 13 14 15 16
                 17 18 19 20 21
                 22 24 25 26 27
                 28 29 30 31 33
                 34 35 36 37 38
                 39 40 41 42 43
                 44 45 46 47 48
                 49 53 54 55 56
                 57 58 59 60 61
                 62 63 64 65 66
                 67 68 69 71 72
                 73 74 75 76 77
                 78 79 80 81 82
                 83 85 86 87 88
                 89 90 91 92 93
                 94  95  96  97  98 
                 99  100 101 102 103
                 104 105
fm16   1.9577e8
c        --------------------------
fc26   Gamma Heating [W/g]
f26:p
                  2 3  4  5  6 
                  7  8  9  10 11
                  12 13 14 15 16
                  17 18 19 20 21
                  22 24 25 26 27
                  28 29 30 31 33
                  34 35 36 37 38
                  39 40 41 42 43
                  44 45 46 47 48
                  49 53 54 55 56
                  57 58 59 60 61
                  62 63 64 65 66
                  67 68 69 71 72
                  73 74 75 76 77
                  78 79 80 81 82
                  83 85 86 87 88
                  89 90 91 92 93
                  94  95  96  97  98 
                  99  100 101 102 103
                  104 105
fm26   1.9577e8
c    -------------------------------
fc24   Fe dpa/FPY
f24:n   47 
        45 43 41 39 37 35 33 
        26 30 29 28 27
        21
        55
        57 59 61 63 65 67 69
        72 73 74 75 76 77 78 79 80 81
        86
fm24   3.8566e8   16 444
c      ------------------------------
fc34   He in 316SS appm/FPY
f34:n   47
        45 43 41 39 37 35 33
        26 30 29 28 27
        21
        55
        57 59 61 63 65 67 69
        72 73 74 75 76 77 78 79 80 81
        86
fm34   3.8566e10   11 (207:206)
c   ----------------------------------
fc44   H in 316SS appm/FPY
f44:n   47
        45 43 41 39 37 35 33
        26 30 29 28 27
        21
        55
        57 59 61 63 65 67 69
        72 73 74 75 76 77 78 79 80 81
        86
fm44   3.8566e10   11  (203:204:205)
c   ----------------------------------
fc54   T in 316SS appm/FPY
f54:n   47
        45 43 41 39 37 35 33
        26 30 29 28 27
        21
        55
        57 59 61 63 65 67 69
        72 73 74 75 76 77 78 79 80 81
        86
fm54   3.8566e10   11 205
c     -------------------------------
fc64   Cu dpa/FPY
f64:n  48 21 54 86
fm64   3.8566e8   2 444
c      ------------------------------
fc74   He in CuBeNi appm/FPY
f74:n   48 21 54 86
fm74   3.8566e10   8 (207:206)
c   ----------------------------------
fc84   H in CuBeNi appm/FPY
f84:n   48 21 54 86
fm84   3.8566e10   8  (203:204:205)
c   ----------------------------------
fc94   T in CuBeNi appm/FPY
f94:n   48 21 54 86
fm94   3.8566e10   8 205
c    ________________________________
fc104   Ni dpa/FPY
f104:n  31 25 71 82
fm104   3.8566e8   17 444
c      ------------------------------
fc114   He in Inconel appm/FPY
f114:n   31 25 71 82
fm114   3.8566e10   12 (207:206)
c   ----------------------------------
fc124   H in Inconel appm/FPY
f124:n   31 25 71 82
fm124   3.8566e10   12  (203:204:205)
c   ----------------------------------
fc134   T in Inconel appm/FPY
f134:n   31 25 71 82
fm134   3.8566e10   12 205
c    ________________________________
fc144   He in Be appm/FPY
f144:n   49 53
fm144   3.8566e10   9 (207:206)
c   ----------------------------------
fc154   H in Be appm/FPY
f154:n   49 53
fm154   3.8566e10   9  (203:204:205)
c   ----------------------------------
fc164   T in Be appm/FPY
f164:n   49 53
fm164   3.8566e10   9 205
c    ________________________________
fc174   fast (E>0.1 MeV) fluence at magnet n/cm2/FPY
f174:n  21 86
e174    0.1 20
fm174   3.8566e28
c     ------------------------------
C
FC1004  Neutron Flux [#/cc/s]
FMESH1004:N GEOM=XYZ ORIGIN=-1300 -1300 -900
                    IMESH=1300   IINTS=130
                        JMESH=1300   JINTS=130
                        KMESH=900    KINTS= 90
FM1004   1.222e21
C
C
FC1024  Photon Flux [#/cc/s]
FMESH1024:P GEOM=XYZ ORIGIN=-1300 -1300 -900
                    IMESH=1300   IINTS=130
                        JMESH=1300   JINTS=130
                        KMESH=900    KINTS= 90
FM1024   1.222e21
C
print  110
c original nps,prdmp 
c BW added 110 above                   
c prdmp  100000 100000 1 1 100000
c BW changed above NDM from 1000000 to 500000       
c nps    500000  
C BW originally was 100000
c ctme   1000
c BW commented out line above =computer time cutoff
c 
rand gen=1 seed=19073486328213 $ change random number seed (default ends in 5)
c 
c nps 160e6             $ number of particles
prdmp j 16e6 1 1 $ write mctal,save only the last dump 
NPS 1e7 

The extract_universe method allows the creation of a new MCNP input with the selected universe. The universe keywords will be erased from the cell definitions.

inp_universes = Input.from_input("test_universe.i")
# both extract_universe() and extract_cells() also allow to renumber cards
# the arguments are the same as for the renumber() function
offset_dict = {"cells": 100, "surfs": 150}
outfile = os.path.join(tempfile.gettempdir(), "extracted_universe.i")
inp_universes.extract_universe(125, outfile, renumber_offsets=offset_dict)
with open(outfile, "r") as infile:
    for line in infile:
        print(line.strip("\n"))
Title
C
c Universe level 1
121 4 -1.0 -171 imp:n=1    
122 0      -172 imp:n=1    
399 0 #121 #122    imp:n=1    

171 SX 25 10
172 SX -25 10

M4
       2003.31c        2.460820E-8     $        WEIGHT(%)  AB(%)     
       2004.31c        1.836430E-2     $        WEIGHT(%)  AB(%)     
C Data cards section
sdef pos 0 0 0

Get info summaries on input cells#

It is possible to print a summary of the cells defined in the input that reports the material, density universe and filler

inp_universes.get_cells_summary()
material density universe filler
cell
1 0 0.0 NaN 125.0
21 4 -1.0 125.0 NaN
22 0 0.0 125.0 NaN
99 0 0.0 NaN NaN
299 0 0.0 125.0 NaN

Or even get a summary of the range of densities used for the different materials. All densities are converted to g/cc.

inp.get_densities_range()
Min density [g/cc] Max density [g/cc]
Material ID
1 1.900794 1.900794
7 0.999978 0.999978
8 8.875125 8.875125
11 7.856840 7.856840
12 8.284558 8.284558
13 5.944160 5.944160
14 3.446482 3.446482
15 5.114038 5.114038
74 1.820000 1.820000

Miscellaneous#

Deal with FENDL3.1d faulty isotopes#

FENDL3.1 has some faulty isotopes that produce negative heating. F4Enix conveniently stores these isotopes in a global variable for the user to easily translate them in another library

from f4enix.core.constants import FAULTY_ISOTOPES

newinp = deepcopy(inp)
# first of all collect all the zaids that are present in the input and not in
# the faulty isotopes
other_zaids = []
for material in newinp.materials:
    for submaterial in material.submaterials:
        for zaid in submaterial.zaidList:
            zaidnum = zaid.element + zaid.isotope
            if zaidnum not in FAULTY_ISOTOPES:
                other_zaids.append(zaidnum)
newinp.translate({"21c": FAULTY_ISOTOPES, "31c": other_zaids}, libmanager)

Prepare a void check#

You can prepare an input for a void check calculation: the function sets the mode to void, sets the input spherical surface as source and assigns the proper weigth to the source. It will run the NPS set by the user.

from numjuggler import parser

newinp = deepcopy(inp)

# Create a spherical surface for the void check
sphere = parser.Card(["12345 SO 100\n"], 4, -1)
sphere.get_values()

newinp.prepare_void_check(sphere, 1e6)

print(newinp.other_data["SDEF"].card())
SDEF PAR=N NRM=-1 SUR=12345 WGT=31415.926535897932 DIR=d1

Get formatted cell or surface id ranges#

from f4enix.input.MCNPinput import get_formatted_range

print(get_formatted_range([21, 22, 23] + list(range(25, 100))))
21 22 23 25 73I 99