# DPA calculation

**URL:** https://openmc.discourse.group/t/dpa-calculation/4028
**Category:** Development
**Created:** [March 10, 2024, 2:39pm UTC](https://openmc.discourse.group/t/dpa-calculation/4028 "2024-03-10T14:39:49Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [March 10, 2024, 2:39pm UTC](https://openmc.discourse.group/t/dpa-calculation/4028/1 "2024-03-10T14:39:49Z")

</div>

I am trying to calculate DPA values for mix materials using openmc. However, in my case I want to use energy vs flux values rather than the fixed DT source (not as in example it is taken 14MeV for Fe case). Can you please guide me how to implement the same in openmc.

Thanks for your help and regards

Anil

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [March 10, 2024, 7:24pm UTC](https://openmc.discourse.group/t/dpa-calculation/4028/2 "2024-03-10T19:24:14Z")

</div>

Hi @aktyagiprl

I’m not sure if this works or gives the right answers but @nuclearbae and myself have been trying to get reactions from flux spectra working to provide inventory code capabilities. More details on our efforts over [here](https://github.com/fusion-energy/neutronics-workshop/issues/257)

For this code you would need to either make the one line change shown in [this PR](https://github.com/openmc-dev/openmc/pull/2903) on your local version of openmc or make use of this PR branch directly.

```python
import openmc
import openmc.deplete

# you might want to change these to use specific xml files to use particular decay data or transport cross sections
# the chain file was downloaded with
# pip install openmc_data
# download_endf_chain -r b8.0
openmc.config['chain_file'] = '/home/j/chain-endf-b8.0.xml'
# openmc.config['cross_sections'] = 'cross_sections.xml'

# makes a simple material from Silver
my_material = openmc.Material() 
my_material.add_element('Fe', 1, percent_type='ao')
my_material.set_density('g/cm3', 7)
materials = openmc.Materials([my_material])

# this is the precalculated neutron spectra in units of n/cm2
flux_in_each_group=[0.1]*709

micro_xs = openmc.deplete.MicroXS.from_multigroup_flux(
    energies='CCFE-709', # different group structures are available, see this file for others https://github.com/openmc-dev/openmc/blob/develop/openmc/mgxs/ __init__.py
    multigroup_flux=flux_in_each_group,
    temperature=294, # endf 8.0 has ['1200K', '2500K', '250K', '294K', '600K', '900K']
    chain_file= openmc.config['chain_file'],
    nuclides=my_material.get_nuclides(),
    reactions=['damage-energy']
)

print(micro_xs.reactions)
print(micro_xs.nuclides)
print(micro_xs.data)

```

Then to convert from damage energy to DPA there are a few methods. [This example has a clear guide for two popular methods](https://github.com/fusion-energy/neutronics-workshop/blob/main/tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb) many thanks to @Oliverator for improving the DPA example.

---

<div class="post-metadata">

### Author: ![Oliverator](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/oliverator/32/3132_2.png) [@Oliverator](https://openmc.discourse.group/u/Oliverator)
#### Post date: [March 11, 2024, 11:15am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/3 "2024-03-11T11:15:40Z")

</div>

Hi @aktyagiprl,

I understand that you want to define your own source from an histogram where you have different values of flux for each bin of energy. In OpenMC you can do so very easily but you first need to normalise the dataset by dividing each flux by the total flux and the energy bin width.

Then you can define your source as

`my_source.energy = openmc.stats.Tabular(energy_bins, normalised_flux, interpolation='histogram')`

@paulromano explains it very well [here](https://openmc.discourse.group/t/source-energy-distribution-for-neutron-of-different-energy-group/477).

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [March 12, 2024, 8:41am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/4 "2024-03-12T08:41:31Z")

</div>

Dear Dr. @Shimwell I get the following error related to MicroXS

> > > micro\_xs = openmc.deplete.MicroXS.from\_multigroup\_flux(  
> > > … energies=‘CCFE-709’,  
> > > … multigroup\_flux=flux\_in\_each\_group,  
> > > … temperature=294,  
> > > … chain\_file= openmc.config[‘chain\_file’],  
> > > … nuclides=my\_material.get\_nuclides(),  
> > > … reactions=[‘damage-energy’]  
> > > … )  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > AttributeError: type object ‘MicroXS’ has no attribute ‘from\_multigroup\_flux’

Can you please suggest to solve this?

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [March 12, 2024, 9:49am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/5 "2024-03-12T09:49:56Z")

</div>

You would need to use the branch mentioned in the previous reply. This branch has the one line change for damage-eneregy but also it is based on the current develop branch so it includes the recently added class method from\_multigroup\_flux

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [March 13, 2024, 7:04am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/6 "2024-03-13T07:04:28Z")

</div>

I have openmc installed in conda environment (openmc-env) and have made the changes as suggested by you in the following file by adding \_valid\_rxns.append(‘damage-energy’)

/home/solps/anaconda2/envs/openmc-env/pkgs/openmc-0.13.3-dagmc\_mpi\_openmpi\_py310h956dc85\_100/lib/python3.10/site-packages/openmc/deplete/microxs.py

however getting same error. Is the change made at correct location? can you please suggest.

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [March 13, 2024, 7:42am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/7 "2024-03-13T07:42:19Z")

</div>

You also need the changes from the develop branch.

Here are the instructions for installing from source , you would need to checkout the PR branch as well with the git checkout command.

[https://docs.openmc.org/en/latest/quickinstall.html#installing-from-source-on-ubuntu](https://docs.openmc.org/en/latest/quickinstall.html#installing-from-source-on-ubuntu)

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [March 15, 2024, 6:26am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/8 "2024-03-15T06:26:52Z")

</div>

Hi @Oliverator,  
thanks yes what you have suggested, I want to use this definition in the calculation. Thanks to you and @Shimwell I am now trying to compare things with some benchmark case.

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [March 20, 2024, 6:10am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/9 "2024-03-20T06:10:54Z")

</div>

Dear Dr. @Shimwell,

I could get the damage-energy data for the Fe isotpes. However, this is one value (mean). can I extract the energy and cross-section data for each isotope. For example for energies CCFE-709 I should have 709 values of cross-section.  
Also I have used energies in 100 group structure, does the openmc.deplete method regroup the cross-section data for these energies. Jupyter-notebook code is below

# example from Dr. Shimwel

import openmc  
import openmc.deplete  
import numpy as np  
openmc.config[‘chain\_file’] = ‘/home/solps/OPENMC/CROSS\_SECTIONS/chain-endf-b8.0.xml’  
openmc.config[‘cross\_sections’] = ‘/home/solps/OPENMC/CROSS\_SECTIONS/endfb-viii.0-hdf5/cross\_sections.xml’

# Fe as material

my\_material = openmc.Material()  
my\_material.add\_element(‘Fe’, 1, percent\_type=‘ao’)  
my\_material.set\_density(‘g/cm3’, 7)  
materials = openmc.Materials([my\_material])  
precalculated neutron spectra in units of n/cm2  
flux\_in\_each\_group=[0.01]\*100

# using 100 energy group structure

micro\_xs = openmc.deplete.MicroXS.from\_multigroup\_flux(  
energies= np.array([1.000E-10, 1.000E-09, 1.000E-08, 2.300E-08, 5.000E-08, 7.600E-08, 1.150E-07, 1.700E-07,  
2.550E-07, 3.800E-07, 5.500E-07, 8.400E-07, 1.275E-06, 1.900E-06, 2.800E-06, 4.250E-06,  
6.300E-06, 9.200E-06, 1.350E-05, 2.100E-05, 3.000E-05, 4.500E-05, 6.900E-05, 1.000E-04,  
1.350E-04, 1.700E-04, 2.200E-04, 2.800E-04, 3.600E-04, 4.500E-04, 5.750E-04, 7.600E-04,  
9.600E-04, 1.275E-03, 1.600E-03, 2.000E-03, 2.700E-03, 3.400E-03, 4.500E-03, 5.500E-03,  
7.200E-03, 9.200E-03, 1.200E-02, 1.500E-02, 1.900E-02, 2.550E-02, 3.200E-02, 4.000E-02,  
5.250E-02, 6.600E-02, 8.800E-02, 1.100E-01, 1.350E-01, 1.600E-01, 1.900E-01, 2.200E-01,  
2.550E-01, 2.900E-01, 3.200E-01, 3.600E-01, 4.000E-01, 4.500E-01, 5.000E-01, 5.500E-01,  
6.000E-01, 6.600E-01, 7.200E-01, 7.800E-01, 8.400E-01, 9.200E-01, 1.000E+00, 1.200E+00,  
1.400E+00, 1.600E+00, 1.800E+00, 2.000E+00, 2.300E+00, 2.600E+00, 2.900E+00, 3.300E+00,  
3.700E+00, 4.100E+00, 4.500E+00, 5.000E+00, 5.500E+00, 6.000E+00, 6.700E+00, 7.400E+00,  
8.200E+00, 9.000E+00, 1.000E+01, 1.100E+01, 1.200E+01, 1.300E+01, 1.400E+01, 1.500E+01,  
1.600E+01, 1.700E+01, 1.800E+01, 1.900E+01, 2.000E+01]),  
multigroup\_flux=flux\_in\_each\_group,  
temperature=294, # endf 8.0 has [‘1200K’, ‘2500K’, ‘250K’, ‘294K’, ‘600K’, ‘900K’]  
chain\_file= openmc.config[‘chain\_file’],  
nuclides=my\_material.get\_nuclides(),  
reactions=[‘damage-energy’]  
)  
print(micro\_xs.reactions)  
print(micro\_xs.data)

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [March 20, 2024, 12:59pm UTC](https://openmc.discourse.group/t/dpa-calculation/4028/10 "2024-03-20T12:59:07Z")

</div>

I don’t think the code is setup to give a break down of DPA per energy bin. But you could loop through each energy bin each time call openmc.deplete.MicroXS.from\_multigroup\_flux with a list that contains single enery bin value and a list that contains a single flux value. Not very efficient but this is all I can think of given that you want DPA from a flux without particle transport. The openmc.deplete.MicroXS.from\_multigroup\_flux collapses the values so the DPA per bin is not available. Perhaps a multiplication of the cross section plot and the flux values should could also relative amounts.

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [March 21, 2024, 4:30am UTC](https://openmc.discourse.group/t/dpa-calculation/4028/11 "2024-03-21T04:30:11Z")

</div>

OK thanks I shall try that.

---

<div class="post-metadata">

### Author: ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)
#### Post date: [April 24, 2024, 7:18pm UTC](https://openmc.discourse.group/t/dpa-calculation/4028/12 "2024-04-24T19:18:46Z")

</div>

That PR i mented has been merged in

> <https://github.com/openmc-dev/openmc/pull/2903#pullrequestreview-2020593789>
>
> \# Description
> 
> This PR attempts to add \`\`\`damage-energy\`\`\` to the reactions av…ailable for MicroXS. This would help with \[this forum\](https://openmc.discourse.group/t/dpa-calculation/4028) post where a user requested the ability to get DPA from a flux spectrum.
> 
> Fixes # (issue)
> \[forum issue\](https://openmc.discourse.group/t/dpa-calculation/4028)
> 
> \# Checklist
> 
> \- \[x\] I have performed a self-review of my own code
> \- \[x\] I have followed the \[style guidelines\](https://docs.openmc.org/en/latest/devguide/styleguide.html#python) for Python source files (if applicable)
