3A test of the egs_brachy Monte Carlo volume correction routines. The volume of
4phantom voxels overlapped by sources and other phantoms are calculated by
5egs_brachy and compared with analytical values.
14TIME_LIMIT_S_PER_MHZ = 1 / 2993.
17 "source_volume": 4/3.*math.pi*0.1**3,
18 "bounding_shape_volume": 4/3.*math.pi*0.11**3,
19 "extra_bounding_shape_vol": 8**3,
20 "box_reg_0": 10**3 - 6**3,
21 "phantom_reg_0": 6*6*3 - 0.5*(4./3*math.pi*1**3),
22 "phantom_reg_1": 6*6*3 - 0.5*(4./3*math.pi*1**3),
23 "sph_phantom_reg_0": 4/3.*math.pi*(0.3**3 - 0.1**3),
24 "sph_phantom_reg_1": 4./3*math.pi*(1**3 - 0.3**3)
30 return same_sign
and abs(math.log( a ) - math.log(b)) <= eps
34 """Read voxel values for the phanton named 'phant' and
35 return the region volumes for that phantom"""
37 path =
"%s.%s.voxels" % (inp_name, phant)
39 dialect = csv.Sniffer().sniff(f.read(1024))
41 reader = csv.reader(f, dialect)
45 reg_vols.append((float(row[1]), float(row[2])))
53 phant_vols =
read_vols(
"phantom", inp_name)
54 sph_phant_vols =
read_vols(
"sph_phantom", inp_name)
56 vsource = float(re.findall(
"Volume of Source\s*=\s*(.*)\s*cm", egslst, re.IGNORECASE)[0])
57 bounding_vols = list(map(float, re.findall(
"Bounding shape volume\s*=\s*(.*)\s*cm", egslst, re.IGNORECASE)))
60 "source_volume": vsource,
61 "bounding_shape_volume": bounding_vols[0],
62 "extra_bounding_shape_vol": bounding_vols[1],
63 "box_reg_0": box_vols[0][0],
64 "phantom_reg_0": phant_vols[0][0],
65 "phantom_reg_1": phant_vols[1][0],
66 "sph_phantom_reg_0": sph_phant_vols[0][0],
67 "sph_phantom_reg_1": sph_phant_vols[1][0],
71 for k,v
in list(expected_volumes.items()):
73 print((
"Vol comparison failed for %s: Actual=%E Expected=%E" % (k, actual[k], v)))
76 return all_close, actual, expected_volumes
approx_equal(a, b, eps=0.001)
read_vols(phant, inp_name)
compare_results(egslst, inp_name)