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 to ensure initialized/escaping source/escaping geometry energy tallies
4are consistent with previously calculated values.
5
6"""
7
8import math
9import os
10import re
11
12from eb_tests.utils import values_close
13
14EGSINP = "source_energies.egsinp"
15TIME_LIMIT_S_PER_MHZ = 2/2993. # s / MHz
16
17expected_results = {
18 'initialized': 1135.1,
19 'escaping_source': 898.8,
20 'escaping_geom': 702.01,
21}
22
23
24def compare_results(egslst, inp_name):
25
26
27 actual_results = {
28 "initialized": float(re.findall("Total Energy Initialized\s*:(.*?) MeV", egslst,re.S)[0]),
29 "escaping_source": float(re.findall("Total Energy Escaping Sources\s*:(.*?) MeV", egslst,re.S)[0]),
30 "escaping_geom": float(re.findall("Total Energy Escaping Geometry\s*:(.*?) MeV", egslst,re.S)[0]),
31 }
32
33 all_good = True
34 for etype, expected in list(expected_results.items()):
35 actual = actual_results[etype]
36 if not values_close(actual, expected, max_percent_diff=0.01):
37 all_good = False
38
39
40 return all_good, actual_results, expected_results