Code:
%%
import openmc
import numpy as np
import time
import neutronics_material_maker as nmm
NOTE - CHANGE CROSS SECTION PATH TO YOURS
openmc.config[‘cross_sections’] = ‘../../Libraries/endfb-viii.0-hdf5/cross_sections.xml’
%%
print(openmc.version)
%%
MATERIAL DEFINITONS
concrete_name = ‘Concrete, Regulatory Concrete (developed for U.S. NRC)’
air_mat = nmm.Material.from_library(‘Air (dry, near sea level)’).openmc_material
concrete_mat = nmm.Material.from_library(concrete_name).openmc_material
tissue_mat = nmm.Material.from_library(‘Tissue, Testis (ICRU)’).openmc_material
all_materials = openmc.Materials([concrete_mat,
tissue_mat])
%%
GEOMETRY
adding bounding box/universe
universe_machine = openmc.Universe()
bounding_surface = openmc.model.RectangularParallelepiped(xmin=-100, xmax=100,
ymin=-100, ymax=100,
zmin=-100, zmax=1000,
boundary_type = ‘vacuum’)
room_region = -bounding_surface
room_cell = openmc.Cell(region=room_region,
cell_id=100)
universe_machine.add_cells([room_cell])
Surface
concrete_thickness = 25 ## cm
test_human_radius = 10 ## cm
concrete_start = openmc.ZPlane(z0=100,
surface_id = 1000)
concrete_end = openmc.ZPlane(z0=concrete_start.z0 + concrete_thickness,
surface_id = 1001)
test_human = openmc.YCylinder(x0=0,
z0=concrete_end.z0+test_human_radius,
r=test_human_radius,
surface_id=1002)
Regions
concrete_region = (+concrete_start &
-concrete_end &
-bounding_surface)
test_human_region = (-test_human &
-bounding_surface)
Cells
concrete_cell = openmc.Cell(region = concrete_region,
cell_id = 200,
name = ‘Concrete Slab ala Shake Shack’)
concrete_cell.fill = concrete_mat
universe_machine.add_cells([concrete_cell])
room_region &= ~concrete_region
test_human_cell = openmc.Cell(region = test_human_region,
cell_id = 201,
name = ‘Test Human ala RadMan’)
test_human_cell.fill = tissue_mat
universe_machine.add_cells([test_human_cell])
room_region &= ~test_human_region
Define full geometry
full_geometry = openmc.Geometry(root = universe_machine,
merge_surfaces=True,
surface_precision=1)
full_geometry.root_universe.plot(basis = ‘xz’,
width=(250,1400),
origin= (0,0,400),
pixels=(700,700),
color_by = ‘cell’)
%%
Setting up the source
source_name = ‘DD’
point_source = openmc.IndependentSource()
point_source.particle = ‘neutron’
if source_name == ‘DD’:
point_source.energy = openmc.stats.Discrete([2.45e6],[1])
elif source_name == ‘DT’:
point_source.energy = openmc.stats.Discrete([14.1e6],[1])
else:
print(‘Invalid Source’)
point_source.angle = openmc.stats.Isotropic()
point_source.space = openmc.stats.Point(xyz=(0,0,0))
point_source.strength = 1
%%
Setting up dose within a cell
energy_bins_n, dose_coeffs_n = openmc.data.dose_coefficients(
particle=“neutron”, geometry=“AP”
)
energy_function_filter_n = openmc.EnergyFunctionFilter(energy_bins_n, dose_coeffs_n, interpolation=‘cubic’)
#energy_function_filter_n.interpolation = “cubic” # cubic interpolation is recommended by ICRP
neutron_particle_filter = openmc.ParticleFilter(“neutron”)
cell_filter = openmc.CellFilter(test_human_cell)
dose_cell_tally = openmc.Tally(name=“neutron_dose_on_cell”)
note that the EnergyFunctionFilter is included as a filter
dose_cell_tally.filters = [
cell_filter,
neutron_particle_filter,
energy_function_filter_n,
]
dose_cell_tally.scores = [“flux”]
my_tallies = openmc.Tallies([dose_cell_tally])
%%
Simulation Settings
new_settings = openmc.Settings()
new_settings.run_mode = “fixed source”
new_settings.particles = int(1e4)
new_settings.batches = 3
new_settings.output = {‘tallies’:False,
‘path’:‘Data/’,
‘summary’:False}
new_settings.electron_treatment = ‘led’
new_settings.photon_transport = True
new_settings.source = point_source
new_settings.seed = int(time.time())
model = openmc.Model(full_geometry,
all_materials,
new_settings,
my_tallies)
model.geometry.merge_surfaces = True
model.export_to_xml()
%%
start_time = time.time()
!rm s*.h5
model.run()
end_time = time.time()
# mv
print((end_time - start_time)/60)
%%
with openmc.StatePoint(‘Data/statepoint.3.h5’) as statepoint:
neutron_tally_result = statepoint.get_tally(
name="neutron_dose_on_cell"
).mean.flatten()[0]
neutron_tally_error = statepoint.get_tally(
name="neutron_dose_on_cell"
).std_dev.flatten()[0]
print(neutron_tally_result)
print(neutron_tally_error)
neutrons_per_second = 1e8 # units of neutrons per second
tally.mean is in units of pSv-cm3/source neutron
this multiplication changes units to neutron to pSv-cm3/second
total_dose = neutron_tally_result * neutrons_per_second
converts from pSv-cm3/second to pSv/second
total_dose = total_dose / (np.pitest_human_radiustest_human_radius*200)
converts from (pico) pSv/second to (milli) mSv/second
total_dose = total_dose * 1e-9
converts from (milli) mSv/second to (milli) mSv/year
total_dose = total_dose * 60 * 60 * 24 * 365
tally.mean is in units of pSv-cm3/source neutron
this multiplication changes units to neutron to pSv-cm3/second
total_dose_error = neutron_tally_error * neutrons_per_second
converts from pSv-cm3/second to pSv/second
total_dose_error = total_dose_error / (np.pitest_human_radiustest_human_radius*200)
converts from (pico) pSv/second to (milli) mSv/second
total_dose_error = total_dose_error * 1e-9
converts from (milli) mSv/second to (milli) mSv/year
total_dose_error = total_dose_error * 60 * 60 * 24 * 365
print(f’{total_dose} +/- {total_dose_error}')