openmc.lib.run_in_memory

openmc.lib.run_in_memory(**kwargs)[source]

Provides context manager for calling OpenMC shared library functions.

This function is intended to be used in a ‘with’ statement and ensures that OpenMC is properly initialized/finalized. At the completion of the ‘with’ block, all memory that was allocated during the block is freed. For example:

with openmc.lib.run_in_memory():
    for i in range(n_iters):
        openmc.lib.reset()
        do_stuff()
        openmc.lib.run()
Parameters

**kwargs – All keyword arguments are passed to init().