Hi,
I am new to OpenMC and am trying to run a simulation to track the number of backscatter neutrons that appear on a detector.
I have a DT neutron source at the origin, to the left is the material from which back scatter neutrons are generated, and far to the right is the detector.
currently the simulation traks the 14 MeV DT neutrons at the detector., but nothing else. Do i need to clarify that a scattering is taking place in the code? Do i do this with the use of openmc.mgxs.ScatterXS?
Here is the code:
##########libraries###########
import openmc
import numpy as np
import math
import sys
import matplotlib.pyplot as plt
from openmc_plasma_source import FusionPointSource
#######################
#############Materials###########
air = openmc.Material(name=‘air’)
air.add_element(‘N’, .788903, ‘ao’)
air.add_nuclide(‘O16’, .211097, ‘ao’)
air.set_density(‘atom/b-cm’, 4.614e-5)
C6D6 = openmc.Material(name=“C6D6”)
C6D6.add_nuclide(‘C0’, 6)
C6D6.add_nuclide(‘H2’, 6)
C6D6.set_density(‘g/cm3’, 0.95)
materials = openmc.Materials()
materials.cross_sections=r"/g1/hdd/jomar/cross_sections.xml"
materials.append(air)
materials.append(C6D6)
isinstance(materials, list)
materials.export_to_xml()
!cat materials.xml
####################
#############geometry##############
detector = openmc.Sphere(x0=1340, y0=0,z0=0, r=10,boundary_type=‘transmission’)
NIV = openmc.XCone(x0=-9, y0=0, z0=0, r2=-1 / np.tan(16)**2,boundary_type=‘transmission’)
innerBound = openmc.Sphere(x0=0, y0=0,z0=0, r=1400,boundary_type=‘transmission’)
outerBound = openmc.Sphere(x0=0, y0=0,z0=0, r=1410,boundary_type=‘vacuum’)
cellDetect = openmc.Cell(name=‘Detector’)
cellDetect.fill = air
cellDetect.region = -detector
cellNIV = openmc.Cell(name=‘NIV’)
cellNIV.fill = C6D6
cellNIV.region = -NIV
cellSpace = openmc.Cell(name=‘air’)
cellSpace.region = -innerBound & +detector & +NIV
cellVoid = openmc.Cell(name=‘void’)
cellVoid.region = -outerBound & +innerBound
univ = openmc.Universe(cells=[cellDetect, cellNIV, cellSpace, cellVoid])
geometry = openmc.Geometry(root=univ)
geometry.export_to_xml(‘geometry.xml’)
###############################
####################Settings/Source############
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])
source.particle = ‘neutron’
settings = openmc.Settings()
settings.run_mode = ‘fixed source’
settings.source = source
#settings.batches = 100
#settings.inactive = 10
#settings.particles = 10000
settings.particles = 1500000
settings.batches = 150
settings.generations_per_batch = 1
settings.inactive = 0
settings.export_to_xml()
!cat settings.xml
########################
##################tallies############
tallies = openmc.Tallies()
neutron_particle_filter = openmc.ParticleFilter(‘neutron’)
cell_filter = openmc.CellFilter(cellDetect)
energy_filter = openmc.EnergyFilter.from_group_structure(‘VITAMIN-J-42’)
detect_surface_spectra_tally = openmc.Tally(name=‘detect_surface_spectra_tally’)
detect_surface_spectra_tally.scores = [‘flux’]
detect_surface_spectra_tally.filters = [cell_filter, neutron_particle_filter, energy_filter]
tallies.append(detect_surface_spectra_tally)
tallies.export_to_xml()
!cat tallies.xml
##################
###################run code############
model = openmc.model.Model(geometry, materials, settings, tallies)
!rm *.h5
results_filename = model.run()
##########################
##############results#############
results = openmc.StatePoint(results_filename)
bin_boundaries = energy_filter.lethargy_bin_width
tally = results.get_tally(name=‘detect_surface_spectra_tally’)
print(tally)
tally.mean.shape = (1,len(bin_boundaries))
values = np.array(tally.mean)
flux = values[0]
print(values)
print(flux)
normalised_flux = flux / (bin_boundaries)
E = energy_filter.values[:-1]
E = energy_filter.values[1:len(energy_filter.values)]
plt.figure()
plt.semilogy(E, normalised_flux)
plt.xlabel(“Energies (eV)”)
plt.ylabel(“Flux (Arbitrary Units)”)
plt.show()
###################