Hi ,
I edited the code to learn the dose rate based on distance from an example. However, I couldn’t quite understand how to write this in this part of the code( dose_in_pSv = tally_result / (4 * math.pi * math.pow(?))
distances.append(?). Could you help me?
import numpy as np
import matplotlib.pyplot as plt
import openmc
import pandas as pd
##################### Materials ###################################
aluminium = openmc.Material()
aluminium.add_element(‘Al’, 1)
aluminium.temperature = 300
aluminium.set_density(‘g/cm3’, 2.7)
sodium_iodide = openmc.Material()
sodium_iodide.add_element(‘Na’, 1)
sodium_iodide.add_element(‘I’, 1)
sodium_iodide.temperature = 300
sodium_iodide.set_density(‘g/cm3’, 3.667)
oxide = openmc.Material()
oxide.add_nuclide(‘O16’, 0.4) # same as MCNP atom or weight fraction
oxide.add_element(‘Al’, 0.6)
oxide.temperature = 300
oxide.set_density(‘g/cm3’, 3.97)
iron = openmc.Material()
iron.add_element(‘Fe’, 1)
iron.temperature = 300
iron.set_density(‘g/cm3’, 7.874)
air = openmc.Material()
air.add_element(‘N’, 4)
air.add_nuclide(‘O16’, 1)
air.temperature = 300
air.set_density(‘g/cm3’, 0.000000000000000000001)
materials = openmc.Materials([aluminium, sodium_iodide, oxide, iron, air])
materials.cross_section=’…’
materials.export_to_xml()
materials = openmc.Materials()
materials += [aluminium, sodium_iodide, oxide, iron, air]
isinstance(materials, list)
##########################Geometry#######################################
a1 = openmc.ZCylinder(r=3.40)
a2 = openmc.ZCylinder(r=3.65)
a3 = openmc.ZCylinder(r=3.82)
z1 = openmc.ZPlane(z0=0.00)
z2 = openmc.ZPlane(z0=0.20)
z3 = openmc.ZPlane(z0=7.28)
z4 = openmc.ZPlane(z0=9.8)
s = openmc.Sphere(r=15, boundary_type=‘vacuum’)
crystal = openmc.Cell(name=“crystal”)
crystal.region = -a1 & -z3 & +z2
crystal.fill = sodium_iodide
oxide_layer = openmc.Cell(name=“oxyde”)
oxide_layer.region = +a1 & -a2 &-z3 & +z2
oxide_layer.fill = oxide
aluminium_casing = openmc.Cell()
aluminium_casing.region = +a2 & -a3 & -z4 & +z1
aluminium_casing.fill = aluminium
aluminium_window = openmc.Cell()
aluminium_window.region = -a2 & -z2 & +z1
aluminium_window.fill = aluminium
iron_back = openmc.Cell()
iron_back.region = -a2 & -z4 & +z3
iron_back.fill = iron
sourrounding = openmc.Cell()
sourrounding.region = -s & ~(-a3 & -z4 & +z1)
sourrounding.fill = air
cell_list = [crystal, oxide_layer, aluminium_casing, aluminium_window, iron_back, sourrounding]
universe = openmc.Universe(cells=cell_list)
universe.plot(width = (20.0,20.0),basis = ‘xz’)
geometry = openmc.Geometry(universe)
geometry.export_to_xml()
source = openmc.Source()
source.particle = ‘photon’
direction_array = np.array([0,0,1])
source.angle = openmc.stats.Monodirectional(direction_array)
source.energy = openmc.stats.Discrete([1.1732e6,1.3325e6], [0.5, 0.5])
settings = openmc.Settings()
settings.run_mode = ‘fixed source’
settings.source = source
settings.batches = 6
settings.particles = 100000
settings.export_to_xml()
energy_bins_p, dose_coeffs_p = openmc.data.dose_coefficients(
particle=‘photon’,
geometry=‘AP’
)
energy_function_filter_p = openmc.EnergyFunctionFilter(
energy_bins_p,
dose_coeffs_p
)
photon_particle_filter = openmc.ParticleFilter([“photon”])
tallies = openmc.Tallies()
surfaces_to_tally = [
a1,a2,a3,z1,z2,z3,z4
]
this loops adds tallies for each sphere surface
for surface_id, surface in zip(range(1,9), surfaces_to_tally):
surface_filter = openmc.SurfaceFilter(surface)
dose_tally = openmc.Tally(name=“dose_tally_on_surface_”+str(surface_id))
dose_tally.scores = [“current”]
dose_tally.filters = [
surface_filter,
photon_particle_filter,
energy_function_filter_p,
]
tallies.append(dose_tally)
for surface_id, surface in zip(range(1,9), surfaces_to_tally):
surface_filter = openmc.SurfaceFilter(surface)
dose_tally = openmc.Tally(name=“dose_tally_on_surface_”+str(surface_id))
dose_tally.scores = [“current”]
dose_tally.filters = [
surface_filter,
photon_particle_filter,
energy_function_filter_p,
]
tallies.append(dose_tally)
openmc.run()
import math
open the results file
sp = openmc.StatePoint(‘statepoint.6.h5’)
dose_rates_in_pSv = []
distances = []
access the tally using pandas dataframes
for surface_id, surface in zip(range(1,9), surfaces_to_tally):
tally = sp.get_tally(name=‘dose_tally_on_surface_’+str(surface_id))
df = tally.get_pandas_dataframe()
tally_result = df[‘mean’].sum()
tally_std_dev = df[‘std. dev.’].sum()
dose_in_pSv = tally_result / (4 * math.pi * math.pow(surface.z0, 2))
distances.append(surface.z0)
source_activity =33200 # in decays per second (Bq)
emission_rate = 2
gamma_per_second = source_activity * emission_rate
dose_rate_in_pSv = dose_in_pSv * gamma_per_second
dose_rates_in_pSv.append(dose_rate_in_pSv)
print results
print('The surface dose = ', dose_rates_in_pSv, ‘pSv per second’)
print('At distances = ', distances)