-
Notifications
You must be signed in to change notification settings - Fork 1
/
003_recalc_and_plotonly_one_cell.py
128 lines (96 loc) · 4.51 KB
/
003_recalc_and_plotonly_one_cell.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
import numpy as np
import LHCMeasurementTools.TimberManager as tm
from GasFlowHLCalculator.calibration_config import calibration_config
from GasFlowHLCalculator.calibration import Calibration, CalibrationManager
from GasFlowHLCalculator.h5_storage import H5_storage
from GasFlowHLCalculator import heatload_recalc as hlr
cal_manager = CalibrationManager(calibration_config=calibration_config)
with_P_drop = True
compute_instrumented = True
filln = 6737
# filln = 6966
# filln = 6967
circuit = 'QRLAB_23L2_QBS947.POSST' # Missing P4 (same result as logginh)
#circuit = 'QRLAB_15L2_QBS943.POSST' # Missing T1 (same result as logging)
#circuit = 'QRLAB_27L4_QBS943.POSST' # Missing P1 (result different from logging)
circuit = 'QRLAB_31L2_QBS943.POSST' # Instrumented cell
circuit = 'QRLAA_13L5_QBS943.POSST' # Instrumented cell
circuit = 'QRLAA_13R4_QBS947.POSST' # Instrumented cell
circuit = 'QRLAA_33L5_QBS947.POSST' # Instrumented cell
h5_storage = H5_storage(h5_dir = '/eos/user/l/lhcecld/heatload_data_storage/')
if compute_instrumented:
obraw = h5_storage.load_special_data_file(filln=filln)
else:
obraw = h5_storage.load_data_file(filln=filln)
calibration = cal_manager.get_calibration(obraw.timestamps[0])
cell_calib = calibration.get_circuit(circuit)
T1 = obraw.dictionary[cell_calib['T1']]
T3 = obraw.dictionary[cell_calib['T3']]
P1 = obraw.dictionary[cell_calib['P1']]
P4 = obraw.dictionary[cell_calib['P4']]
CV= obraw.dictionary[cell_calib['CV']]
EH = obraw.dictionary[cell_calib['EH']]
# T2 = obraw.dictionary[cell_calib['T2']]
Q_bs, other = hlr.compute_heat_load(P1, T1, T3, P4, CV, EH,
Qs_calib=cell_calib['Qs_calib'],
Kv_calib=cell_calib['Kv_calib'],
R_calib=cell_calib['R_calib'],
cell_length=cell_calib['length'],
n_channels=cell_calib['n_channels_tot'],
channel_radius=cell_calib['channel_radius'],
channel_roughness=cell_calib['roughness'],
with_P_drop=with_P_drop, N_iter_max=100, scale_correction=0.3,
iter_toll=1e-3)
if compute_instrumented:
from GasFlowHLCalculator.instrumented_cells_config import instrumented_cells_config
instrum_cell_config = instrumented_cells_config[circuit]
(n_channels_circuits, magnet_lengths_circuits, in_sensor_names_circuits,
out_sensor_names_circuits) = \
hlr.extract_info_from_instrum_config_dict(
config_dict=instrum_cell_config)
T_out_magnets_circuits = [[obraw.dictionary[vv] for vv in
out_sensor_names_circuits[ii]] for ii in [0, 1]]
T_in_magnets_circuits = [[obraw.dictionary[vv] for vv in
in_sensor_names_circuits[ii]] for ii in [0, 1]]
Qbs_magnets_circuits, other_instr = hlr.compute_heat_loads_instrumented_cell(
mass_flow = other['mass_flow'], P1=P1,
T_in_magnets_circuits=T_in_magnets_circuits,
T_out_magnets_circuits=T_out_magnets_circuits,
magnet_lengths_circuits=magnet_lengths_circuits,
n_channels_circuits=n_channels_circuits,
channel_radius=cell_calib['channel_radius'],
channel_roughness=cell_calib['roughness'],
dp_toll = 0.001, N_iter_max=200)
magnet_beam_circuits = [instrum_cell_config['circuit_%s_beam'%cc]
for cc in ['A', 'B']]
dict_output = hlr.build_instrumented_hl_dict(
config_dict=instrum_cell_config, circuit=circuit,
Qbs_magnets_circuits=Qbs_magnets_circuits)
# Some plots
import matplotlib.pyplot as plt
plt.close('all')
t_h = (obraw.timestamps - obraw.timestamps[0])/3600.
figtot = plt.figure(100)
axtot = figtot.add_subplot(111)
axtot.plot(t_h, Q_bs, color = 'black', label="Total")
axlist = [axtot]
if compute_instrumented:
for i_mag, name_mag in enumerate(instrum_cell_config['magnet_names']):
fig = plt.figure(i_mag+1)
ax = fig.add_subplot(111, sharex=axtot, sharey=axtot)
nn = circuit.replace('.POSST', '_%s.POSST'%name_mag)
nnb1 = circuit.replace('.POSST', '_%sB1.POSST'%name_mag)
nnb2 = circuit.replace('.POSST', '_%sB2.POSST'%name_mag)
ax.plot(t_h, dict_output[nn], color='k', label='Total')
ax.plot(t_h, dict_output[nnb1], color='b', label='B1')
ax.plot(t_h, dict_output[nnb2], color='r', label='B2')
fig.suptitle(circuit + ' - ' +name_mag)
axtot.plot(t_h, dict_output[nn], label=name_mag)
axlist.append(ax)
for aa in axlist:
aa.legend(loc='best')
aa.set_xlabel('t [h]')
aa.set_ylabel('Heat load [W]')
aa.grid(True, linestyle='--', alpha=.5)
figtot.suptitle(circuit)
plt.show()