# Plotting flux spectrum after depletion in openmc

**URL:** <https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383>\
**Category:** User Support\
**Created:** [June 12, 2024, 12:01pm UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383 "2024-06-12T12:01:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfelectron](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pfelectron](https://openmc.discourse.group/u/pfelectron)\
**Post date:** [June 12, 2024, 12:01pm UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383/1 "2024-06-12T12:01:26Z")

</div>

Here is how I can view the neutron flux at the output. There is an application in Jupyter notebook that is made like this. @paulromano @Shimwell @pshriwise

```auto
sp_path = model.run(output=False)

```

How can I change this for the following integrator?

```auto
# Instantiate a Settings object, set all runtime parameters, and export to XML
settings = openmc.Settings()
settings.batches = 500
settings.inactive = 20
settings.particles = 500

# Create an initial uniform spatial source distribution over fissionable zones
settings.source = openmc.source.Source(space=openmc.stats.Point())

tally = dict()
tally['heating'] = openmc.Tally(name="heating")
tally['heating'].scores.append('heating-local')
e_min, e_max = 1e-5, 20e6
groups = 500
energies = np.logspace(log10(e_min), log10(e_max), groups + 1)
energy_filter = openmc.EnergyFilter(energies)
particle_filter = openmc.ParticleFilter(['neutron'])
cell_filter = openmc.MaterialFilter([uo2])
tally['flux']= openmc.Tally(name="flux")
tally['flux'].filters = [energy_filter, particle_filter] 
tally['flux'].scores = ['flux']
mesh = openmc.RegularMesh()
mesh.dimension = [500, 500, 1]
mesh.lower_left = [-100, -100, 50]
mesh.upper_right = [100, 100, 200]
mesh_filter = openmc.MeshFilter(mesh)
tally['mesh'] = openmc.Tally(name="Mesh")
tally['mesh'].scores = ['flux','absorption','fission']
tally['mesh'].filters = [mesh_filter]
tally['mesh'].filters.append(particle_filter)
tallies = openmc.Tallies(tally.values())

###############################################################################
# Initialize and run depletion calculation
###############################################################################

with open('/depletion/serpent_fissq.json', 'r') as f:
    serpent_fission_q = json.load(f)

model = openmc.Model(geometry=geom, settings=settings, tallies=tallies)
model.export_to_xml()
chain_file = '/depletion-comparison/data/depletion/chain.xml'
op = openmc.deplete.Operator(model, chain_file,
    fission_q=serpent_fission_q,
    fission_yield_mode="average")

# cumulative steps in MWd/kg
burnup_cum = np.array([0.1, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.5, 15.0, 17.5, 20.0, 22.5, 25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0])
burnup = np.diff(burnup_cum, prepend=0.0)
power = 131040  

integrator = openmc.deplete.PredictorIntegrator(op, burnup, power, timestep_units='MWd/kg')
integrator.integrate()

```

---

<div class="post-metadata">

**Author:** ![wahidluthfi](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/wahidluthfi/32/3375_2.png) [@wahidluthfi](https://openmc.discourse.group/u/wahidluthfi)\
**Post date:** [June 14, 2024, 10:49pm UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383/2 "2024-06-14T22:49:37Z")

</div>

hi prof electron, the specified tally will be reported on the statepoint file of each depletion steps, so to read your tally output like from the second depletion steps, you could read your statepoint\_n2.h5, and so on. so as long as your tally has been added to the model for your transport operator being used at the integrator, then it will be good.  
model = openmc.Model(geometry, materials, settings, tallies)  
op = openmc.deplete.Operator(model, …  
you can try it with small particle history just to make sure that everything is as you want.

---

<div class="post-metadata">

**Author:** ![jiangjiang](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiangjiang/32/3483_2.png) [@jiangjiang](https://openmc.discourse.group/u/jiangjiang)\
**Post date:** [May 12, 2025, 2:06am UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383/3 "2025-05-12T02:06:34Z")

</div>

Hi, sorry to disturb you. I tryed add the tally into my model, but the ‘_statepoint\_nx.h5_’ didn’t exest after whole 500 cycles calculation. There are still ‘_openmc\_simulation\_nx.h5_’ and ‘_statepoin.500.h5_’ only.

my code was:  
_model = openmc.Model(geometry=geom, settings=settings, tallies=tallies\_file)_  
_operator = openmc.deplete.CoupledOperator(model, ‘/home/ads/vir-jiang/openmc/chain\_endfb80\_sfr.xml’)_

---

<div class="post-metadata">

**Author:** ![jiangjiang](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiangjiang/32/3483_2.png) [@jiangjiang](https://openmc.discourse.group/u/jiangjiang)\
**Post date:** [May 12, 2025, 3:24am UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383/4 "2025-05-12T03:24:13Z")

</div>

maybe I should add the materials=xx to the model? 🧐

---

<div class="post-metadata">

**Author:** ![wahidluthfi](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/wahidluthfi/32/3375_2.png) [@wahidluthfi](https://openmc.discourse.group/u/wahidluthfi)\
**Post date:** [May 13, 2025, 11:37pm UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383/5 "2025-05-13T23:37:20Z")

</div>

Hi Jiang  
Sorry for the confusion, yes, the openmc statepoint file for each depletion (burnup) step was named openmc\_simulation\_nx.h5. So it’s not statepoint\_nx.h5. I just want to said that the statepoint file was produced for each step with its unique name so you can use it later.  
About adding materials to the openmc.model, I think it wasn’t necessary because openmc model will regenerate the material.xml file later.  
Hope it helps you

---

<div class="post-metadata">

**Author:** ![jiangjiang](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiangjiang/32/3483_2.png) [@jiangjiang](https://openmc.discourse.group/u/jiangjiang)\
**Post date:** [May 14, 2025, 8:10am UTC](https://openmc.discourse.group/t/plotting-flux-spectrum-after-depletion-in-openmc/4383/6 "2025-05-14T08:10:11Z")

</div>

Thanks a lot. 😉  
Yes, it’s not the reason of “material”, I type "_**sp1 = openmc.StatePoint(‘openmc\_simulation\_n1.h5’)**_ " and it worked.
