EGS Brachy
An egs++ user code for rapid brachytherapy calculations
Loading...
Searching...
No Matches
test.py
Go to the documentation of this file.
1"""
2
3A test for comparing the total absolute photon counts on the surface of a
4source with the expected value. A uniform spectrum between 15keV-25keV in a
5near-vaccuum source is used so the expected spectrum can easily be calculated
6analytically.
7
8"""
9
10import math
11import re
12
13from eb_tests.utils import read_csv_spectrum, values_close
14
15EGSINP = "spec_absolute.egsinp"
16TIME_LIMIT_S_PER_MHZ = 6/2993. # s / MHz
17
18EMIN, EMAX = 0.015, 0.025
19
20def expected(e):
21 if EMIN <= e <= EMAX:
22 return 1./(EMAX-EMIN)
23 return 0
24
25def compare_results(egslst, inp_name):
26
27 energies, counts, uncs = read_csv_spectrum(inp_name+".surfcount.csv")
28
29 for e, c in zip(energies, counts):
30 exp = expected(e)
31 if not values_close(c, exp, 0.005):
32 return False, "Count at %f=%f" %(e, c), "Expected %f" % exp
33
34 return True, [], []