Dose rate-distance

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)

I have an example here which has does calculations from a point source on the surface of spheres with different distances from the source if that helps.

I believe this part of the code in your example is getting the surface area of the sphere, so r would be the radius of the sphere surface

dose_in_pSv = tally_result / (4 * math.pi * math.pow(r, 2))

I have a rectangular prism shaped detector and exactly what I want to do is put the source at different distances from the detector and calculate the dose based on the distance. However, I didn’t quite understand how to adapt this spherical surface example to my own example. I’m putting all the code I tried to write here(Gkcnr/rec_prisma detector at main · Gkcnr/Gkcnr · GitHub). Thank you in advance for your help.

Perhaps you can change the coordinates used in this line of your examples.

This currently places the source at x,y,z values of 0,0,0

source.space = openmc.stats.Point((0, 0, 0))

So if you wanted to move it by 10cm in the z direction then it would changed to

source.space = openmc.stats.Point((0, 0, 10))

when i move 10cm in z direction the code gives an error like this

RuntimeError: More than 95% of external source sites sampled were rejected. Please check your external source definition. pure virtual method called pure virtual method called pure virtual method called pure virtual method called pure virtual method called terminate called recursively terminate called without an active exception terminate called without an active exception terminate called recursively terminate called without an active exception

I wonder if it is being put outside of the universe. Perhaps it is also worth increasing the value of r on this line of your code to make the edge of the universe larger

Gkcnr/rec_prisma detector at main · Gkcnr/Gkcnr · GitHub
I edited my code again for my own work and this is the final version. I need to make changes here and the geometry is different here


This is how I make the measurements in the laboratory. First of all, I want to calculate the dose rate of the state without shielding in front of it.

@paulromano is it possible for you to give me an opinion on my question when you are available.I am attaching the final version of my code here Gkcnr/rec_prisma detector at main · Gkcnr/Gkcnr · GitHub

Hey, if you have this 95% rejection problem, it’s because your source is not inside the geometry. Geometry in OpenMC works like this: if a particle is outside of the region you have defined, it is immediately killed. It appears that your geometry only include a definition of the detector; is that right?

What you need to do in OpenMC (and in any Monte Carlo radiation simulator, more or less), is define the entire geometry in which particles can move. This has to fully encompass your source, and even obstacles which can reflect photons (although this effect is somewhat minor for photons).

So, you need to define a prism in a box. You could alternatively just make a huge sphere, and put the prism-shaped detector inside of that. You would fill the sphere with air, and the detector volume with CsI.

Lastly, this problem is not really one that you need OpenMC to get an answer with. You should be able to calculate the photons captured by the detector at various distances by calculating the solid angle covered by the detector with respect to the location of the source, and making some assumption about the average thickness the photons will travel in the detector. I recommend taking a look at the book “Radiation Shielding” by Shultis if you don’t know how to do this.

1 Like