-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunAll.py
129 lines (96 loc) · 4.77 KB
/
RunAll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from Sim import Sim
from ByVispy import ByVispy
from Test import Test
from PropSetup import PropSetup
from ResultEnvProcessing import ResultEnvProcessing
from SumProjection import SumProjection
from ChartMaker import ChartMaker
from tabulate import tabulate
import time
import os
class RunAll():
def __init__(self):
pass
@staticmethod
def normalize_process(propSetup: PropSetup):
# NORMALIZATION OF resultEnv
# normalize output [photon weight / bin] -> Relative fluence rate [1/cm^2]
photon_limits_list = propSetup.lightSource.photon_limits_list
photon_num = sum(photon_limits_list) # type: ignore
bins_per_1_cm = propSetup.config["bins_per_1_cm"] # [N/cm] # type: ignore
volume_per_bin = (1/bins_per_1_cm)**3
if propSetup.config["flag_save_result_env"]: # type: ignore
# TEST TO DELETE (inplace = False)
Test.Test_ResultEnvProcessing.are_2_variants_equal_resultEnv(propSetup, photon_num, volume_per_bin, propSetup.escaped_photons_weight)
# END OF TEST
propSetup.resultEnv = ResultEnvProcessing.normalize_resultEnv(propSetup, photon_num, volume_per_bin, propSetup.escaped_photons_weight, inplace=True)
# HERE NORMALIZATION ON propSetup.resultEnv INPLACE IS DONE
# NORMALIZATION OF resultRecords
if propSetup.config["flag_seve_result_records"]: # type: ignore
# TEST TO DELETE (inplace = False)
sh = propSetup.resultShape
borders = [0, sh[0], 0, sh[1], 0, sh[2]] # type: ignore
Test.Test_ResultEnvProcessing.are_2_variants_equal_resultRecords(propSetup, photon_num, volume_per_bin, borders, propSetup.escaped_photons_weight)
# END OF TEST
propSetup.resultRecords = ResultEnvProcessing.normalize_resultRecords(propSetup, photon_num, volume_per_bin, propSetup.escaped_photons_weight, inplace=True, print_debug=False)
# HERE NORMALIZATION ON propSetup.resultRecords INPLACE IS DONE
return propSetup
@staticmethod
def run():
"""
MAIN PHOTON SIMULATION
"""
# check list
# - LOAD_INSTEAD_OF_SIM
# - USE_TRIANGLED_PLANES_FROM_FILE
# - ["heatmap trans-normal", "heatmap min-max"]
# - do_connect_lines_list = [False]
# - photon limit in make
# - make env
# - save result records
# - flag_use_propenv_on_formulas
# if true, just load last saved results
LOAD_INSTEAD_OF_SIM = True
LOAD_INSTEAD_OF_SIM = False
# if False, new traingled planes to show in ByVispy will be calculated using data from propEnv.body array
USE_TRIANGLED_PLANES_FROM_FILE = False
USE_TRIANGLED_PLANES_FROM_FILE = True
# SIMULATION
sim = Sim(load_last_dump=LOAD_INSTEAD_OF_SIM)
if LOAD_INSTEAD_OF_SIM:
result_propSetup = sim.propSetup
print("simulation dump loaded")
else:
result_propSetup = sim.start_sim()
print("simulation calculation time:", sim.simulation_calculation_time)
print("boundary check calculation time:", sim.boundary_check_calculation_time)
# return
# NORMALIZATION
result_propSetup = RunAll.normalize_process(result_propSetup)
# used in every print .png and charts
color_scheme_list = ["threshold", "loop", "solid", "photonwise", "random", "rainbow", "min-max", "median", "trans-normal", "logarithmic", "heatmap min-max", "heatmap median", "heatmap trans-normal", "heatmap logarithmic"]
take_cs = color_scheme_list
take_cs.remove("photonwise")
take_cs = ["min-max", "heatmap min-max", "heatmap trans-normal"]
take_cs = ["heatmap trans-normal", "heatmap min-max"]
take_cs = ["heatmap logarithmic"]
take_cs = ["photonwise"]
do_connect_lines_list = [True, False]
do_connect_lines_list = [False]
do_connect_lines_list = [True]
# SHOW CHARTS + MAKE .PNG IMAGES
print()
for cl_loop in do_connect_lines_list:
for i in range(len(take_cs)):
cs_loop = take_cs[i]
print("({}) Run ChartMaker.show_all, color_scheme = {}".format(i, cs_loop))
ChartMaker.show_all(result_propSetup,
cs_loop,
cl_loop,
color_points_by_root = False,
color_arrows_by_root = False,
do_triangled_planes = False,
draw_planes_from_material_stack = False,
use_triangled_planes_from_file = USE_TRIANGLED_PLANES_FROM_FILE)
if __name__ == '__main__':
RunAll.run()