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

**URL:** <https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812>\
**Category:** User Support\
**Created:** [January 10, 2024, 1:15pm UTC](https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812 "2024-01-10T13:15:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junren\_Hou-THU](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@Junren\_Hou-THU](https://openmc.discourse.group/u/Junren_Hou-THU)\
**Post date:** [January 10, 2024, 1:15pm UTC](https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812/1 "2024-01-10T13:15:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pferney](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@pferney](https://openmc.discourse.group/u/pferney)\
**Post date:** [January 10, 2024, 3:57pm UTC](https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812/2 "2024-01-10T15:57:04Z")

</div>

You can access outputs through a statepoint:

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![Junren\_Hou-THU](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@Junren\_Hou-THU](https://openmc.discourse.group/u/Junren_Hou-THU)\
**Post date:** [January 11, 2024, 12:53am UTC](https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812/3 "2024-01-11T00:53:00Z")

</div>

yes! Thank you.

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

```

---

<div class="post-metadata">

**Author:** ![ebeaboa1](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@ebeaboa1](https://openmc.discourse.group/u/ebeaboa1)\
**Post date:** [January 22, 2024, 8:01pm UTC](https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812/4 "2024-01-22T20:01:40Z")

</div>

Hello ,

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

Thank you

---

<div class="post-metadata">

**Author:** ![Junren\_Hou-THU](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@Junren\_Hou-THU](https://openmc.discourse.group/u/Junren_Hou-THU)\
**Post date:** [September 5, 2024, 8:39am UTC](https://openmc.discourse.group/t/i-want-to-obtain-keff-after-each-calculation-easily-does-openmc-have-corresponding-functions/3812/5 "2024-09-05T08:39:44Z")

</div>

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