EGS Brachy
An egs++ user code for rapid brachytherapy calculations
Loading...
Searching...
No Matches
test.py
Go to the documentation of this file.
1"""
2A test that generates an IAEAphsp source with egs_brachy and then checks
3the IAEA file to make sure it was created correctly.
4"""
5
6import math
7import re
8
9import eb_tests.iaea_types as types
10from eb_tests.iaea import IAEAPhaseSpace
11from eb_tests.utils import read_csv_spectrum, values_close
12
13EGSINP = "phsp_score.egsinp"
14TIME_LIMIT_S_PER_MHZ = 10/2993. # s / MHz
15
16SOURCE_WEIGHTS = (1., 9.)
17MAX_E = (0.05, 0.025,)
18NHIST= 1000
19RM = 0.511
20
21EXPECTED = {
22 'num_e': NHIST*SOURCE_WEIGHTS[0]/sum(SOURCE_WEIGHTS),
23 'num_p': NHIST*SOURCE_WEIGHTS[1]/sum(SOURCE_WEIGHTS),
24 'max_energy': 0.05,
25 'num_orig': NHIST,
26}
27
28
29def compare_results(egslst, inp_name):
30
31 iaea_path = "%s.phsp%s" %(inp_name, IAEAPhaseSpace.phsp_ext)
32 phsp = IAEAPhaseSpace(iaea_path)
33 num_e = phsp.num_particles("electron")
34 num_p = phsp.num_particles("photon")
35 num_orig = phsp.num_orig_particles()
36 max_energy = phsp.maximum_energy() - RM
37
38 actual = {
39 'num_e': num_e,
40 'num_p': num_p,
41 'num_orig': num_orig,
42 'max_energy': max_energy
43 }
44
45 num_orig_equal = num_orig == NHIST
46 num_e_close = abs(EXPECTED['num_e']- num_e) < 10
47 num_p_close = abs(EXPECTED['num_p']- num_p) < 10
48 max_e_close = abs( max_energy - MAX_E[0]) < 0.0001
49
50 all_correct = num_e_close and num_p_close and max_e_close and num_orig_equal
51 return all_correct, actual, EXPECTED