I want to obtain keff after each calculation easily. Does OpenMC have corresponding functions?

I now need to do structural optimization and need to calculate keff for many cases. Therefore, it is necessary to use some optimization schemes for iteration. I want to obtain keff after each calculation easily. Does OpenMC have corresponding functions? ps: When openMC outputs keff, it comes with a lot of information, which brings a certain amount of trouble.

You can access outputs through a statepoint:

run = model.run()

sp = openmc.StatePoint(run)
keff = sp.keff
print(keff)
>>> 0.937+/-0.006
print(type(keff))
>>> <class 'uncertainties.core.Variable'>

Is it what you are looking for ?

yes! Thank you.

model = openmc.model.Model(geometry, materials_file, settings, tallies)
run = model.run()
sp = openmc.StatePoint(run)
keff = sp.keff
print(keff.nominal_value)

Hello ,

Kindly support on how to increase the decimal places in keff = sp.keff to say 12 decimal places ?

Thank you

I don’t know how to do it, but I think the error of 1pcm is already small enough.