# Generate\_single\_ww\_and\_apply.ipynb is not working with fission neutrons.Neutrons do not promot any further

**URL:** <https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688>\
**Category:** User Support\
**Created:** [August 14, 2024, 8:29pm UTC](https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688 "2024-08-14T20:29:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamiCodhen](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/samicodhen/32/2951_2.png) [@SamiCodhen](https://openmc.discourse.group/u/SamiCodhen)\
**Post date:** [August 14, 2024, 8:29pm UTC](https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688/1 "2024-08-14T20:29:00Z")

</div>

Greetings  
@pshriwise  
@Shimwell  
@paulromano  
@khurrum  
Does this works with fission neutrons too?

# Beam Tube Meshing

mesh\_bt = openmc.RegularMesh()  
mesh\_bt.lower\_left = [-363, -20, -(20+12.8)]  
mesh\_bt.upper\_right = [core\_width/2 ,+20, +(20-12.8)]  
mesh\_bt.dimension = [400,80,1]  
mesh\_bt\_filter = openmc.MeshFilter(mesh\_bt)

# Ploting total flux profile along beamtube

tally\_flux\_profile\_bt = openmc.Tally(name = ‘flux profile along beam tube’)  
tally\_flux\_profile\_bt.filters = [mesh\_bt\_filter]  
tally\_flux\_profile\_bt.scores = [‘flux’]

# Settings

settings = openmc.Settings()  
settings.particles = 10000  
settings.batches = 15  
settings.inactive = 5  
settings.source = source  
settings.geometry\_debug=False  
model = openmc.Model(geometry=geometry, materials=mat, settings=settings, tallies=tallies)  
model.run

# Constants

x,y=(400,80)

print(x,y)

# Define volume correctly

volume = (6 \* 7.711 \* 4 \* 8.1 \* 60)/(x\*y) # [cm^3]

V = volume # Volume [cm^3]

P = 9e6 # Power [J/sec]

Q = 3.2e-11 # Energy per fission [J/fission]

# Extract tallies

flux\_profile = sp.get\_tally(name=‘flux profile along beam tube’) # [#-cm/source]  
fission = sp.get\_tally(name=‘fission’)  
nu\_fission = sp.get\_tally(name=‘nu-fission’)

# Get mean values of tallies

flux\_mean = flux\_profile.mean.ravel()  
fission\_rate = fission.mean.ravel()  
neutrons\_per\_fission = nu\_fission.mean.ravel()

# Calculate nu (neutrons per fission) while avoiding division by zero

fission\_rate[fission\_rate == 0] = 1e-10 # Small value to prevent division by zero  
nu = neutrons\_per\_fission / fission\_rate

# Calculate k (neutron multiplication factor)

k = neutrons\_per\_fission

# Compute the neutron flux in normal units [neutrons/cm^2-sec]

Flux = flux\_mean \* P \* nu / (V \* Q \* k)

# Reshape Flux to match the original flux profile shape (6x4)

Flux\_reshaped = Flux.reshape(y,x)

# Plot the total neutron flux as a heatmap

plt.imshow(Flux\_reshaped, cmap=‘coolwarm’, origin=‘lower’)  
plt.colorbar(label=‘Neutron Flux [neutrons/cm^2-sec]’)  
plt.xlabel(‘X Position’)  
plt.ylabel(‘Y Position’)  
plt.suptitle(‘Without Weight Window’)  
plt.title(‘Total Neutron Flux Distribution’)  
plt.show()

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/3/3c0faca3f8c79fbf12d43735e980359aa0409355.png)

import openmc\_weight\_window\_generator

# this is a minimal package that adds some functionality to openmc, namely it adds:

# - openmc.StatePoint.generate\_wws which we use in this task

# - openmc.Model.generate\_wws\_magic\_method which we use in the next task

# this generates an openmc.WeightWindow object from the flux tally

weight\_windows = sp.generate\_wws(tally=flux\_profile)

#deletes the old output files

!rm summary.h5

!rm statepoint.\*.h5

model.settings.weight\_windows = weight\_windows

model.settings.max\_split = 1\_000\_000

model.run()

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/3/3c6a95e8dcbe3713e5f1af5b82411f7314b8e7ed.png)

---

<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:** [August 15, 2024, 5:49am UTC](https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688/2 "2024-08-15T05:49:55Z")

</div>

The micro python package called openmc\_weight\_window\_generator is depreciated and has been archived

I would suggest making use of inbuilt openmc.WeightWindowGenerator or openmc.lib.WeightWindows methods in OpenMC

Here are some examples

> **[neutronics-workshop/tasks/task\_14\_variance\_reduction at main ·...](https://github.com/fusion-energy/neutronics-workshop/tree/main/tasks/task_14_variance_reduction)**
>
> A workshop covering a range of fusion relevant analysis and simulations with OpenMC, DAGMC, Paramak and other open source fusion neutronics tools - fusion-energy/neutronics-workshop

---

<div class="post-metadata">

**Author:** ![SamiCodhen](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/samicodhen/32/2951_2.png) [@SamiCodhen](https://openmc.discourse.group/u/SamiCodhen)\
**Post date:** [August 15, 2024, 9:27am UTC](https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688/3 "2024-08-15T09:27:11Z")

</div>

@Shimwell  
These examples are for the fixed source.  
Do they work for ‘fission source’ ?  
I am using reactor core as a neutron source for Boron Neutron Capture Therapy.

---

<div class="post-metadata">

**Author:** ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)\
**Post date:** [August 15, 2024, 2:03pm UTC](https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688/4 "2024-08-15T14:03:00Z")

</div>

Hi @SamiCodhen,

good question! By ‘fission source’ do you mean running OpenMC in ‘eigenvalue’ mode?

I’ve never tried it, but weight windows should applicable in either case. As @Shimwell said, it’s probably best to use the built-in options that come with OpenMC.

It may be advantageous for you to break this simulation into two: one eigenvalue simulation to determine the behavior of the reactor and tally a source term exiting the reactor/entering the neutron beam port with a surface tally; and another, fixed-source calculation (with variance reduction) to determine the efficacy for BNCT. In this approach, some additional normalization of tally result would be required as each source particle in the fixed-source calculation is per source particle of the eigenvalue simulation. The advantage is that you only need to perform the eigenvalue simulation once, allowing you to iterate on the beam port/BNCT design more quickly.

Keep us posted!

-Patrick

---

<div class="post-metadata">

**Author:** ![SamiCodhen](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/samicodhen/32/2951_2.png) [@SamiCodhen](https://openmc.discourse.group/u/SamiCodhen)\
**Post date:** [August 16, 2024, 1:34pm UTC](https://openmc.discourse.group/t/generate-single-ww-and-apply-ipynb-is-not-working-with-fission-neutrons-neutrons-do-not-promot-any-further/4688/5 "2024-08-16T13:34:26Z")

</div>

Hello  
Dear @pshriwise  
Yes ! I am trying to run a single simulation in ‘eigenvalue mode’ to get the neutron flux at the far end of the beamtube with the help of’ ‘’ Weight Window’'.  
But I think ww doesn’t work in ‘eigenvalue mode’.  
@Shimwell  
Would to like to elaborate that how to apply tally to get the ‘’ source ‘’ for the ‘‘fixed\_source’’ mode and how to use it in that mode.
