Commit 413f4b39 authored by Zinour Charifoulline's avatar Zinour Charifoulline
Browse files

Contributor

parent b04aee4d
Pipeline #2471346 passed with stage
in 19 seconds
__version__ = "1.5.54"
__version__ = "1.5.55"
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI2.f1 HWC Test in an RQ Circuit</center></h1>
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rq/RQ.png" width=75%>
source: Test Procedure and Acceptance Criteria for the 13 kA Quadrupole (RQD-RQF) Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874714">https://edms.cern.ch/document/874714</a> (Please follow this link for the latest version)
%% Cell type:markdown id: tags:
# Analysis Assumptions
- We consider standard analysis scenarios, i.e., all signals can be queried. If a signal is missing, an analysis can raise a warning and continue or an error and abort the analysis.
- It is recommended to execute each cell one after another. However, since the signals are queried prior to analysis, any order of execution is allowed. In case an analysis cell is aborted, the following ones may not be executed (e.g. I\_MEAS not present).
# Plot Convention
- Scales are labeled with signal name followed by a comma and a unit in square brackets, e.g., I_MEAS, [A].
- If a reference signal is present, it is represented with a dashed line.
- If the main current is present, its axis is on the left. Remaining signals are attached to the axis on the right. The legend of these signals is located on the lower left and upper right, respectively.
- The grid comes from the left axis.
- The title contains timestamp, circuit name, and signal name allowing to re-access the signal.
- The plots assigned to the left scale have colors: blue (C0) and orange (C1). Plots presented on the right have colors red (C2) and green (C3).
- Each plot has an individual time-synchronization mentioned explicitly in the description.
- If an axis has a single signal, then the color of the label matches the signal's color. Otherwise, the label color is black.
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/11)'); import pandas as pd
print('Loading (2/11)'); import sys
print('Loading (3/11)'); from IPython.display import display, Javascript, clear_output, HTML
# Internal libraries
print('Loading (4/11)'); import lhcsmapi
print('Loading (5/11)'); from lhcsmapi.Time import Time
print('Loading (6/11)'); from lhcsmapi.Timer import Timer
print('Loading (7/11)'); from lhcsmapi.analysis.RqCircuitQuery import RqCircuitQuery
print('Loading (8/11)'); from lhcsmapi.analysis.RqCircuitAnalysis import RqCircuitAnalysis
print('Loading (9/11)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (10/11)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
print('Loading (11/11)'); from lhcsmapi.analysis.expert_input import get_expert_decision
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
print('Analysis performed by %s' % HwcSearchModuleMediator.get_user())
```
%% Cell type:markdown id: tags:
# 1. User Input
1. Copy code from AccTesting and paste into an empty cell below
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/swan-manual-acctesting-integration.png">
- If you only want to test the notebook only for the copy&paste feature (without opening the AccTesting), please copy and execute the code below
```
hwc_test = 'PLI2.f1'
circuit_name = 'RQD.A12'
campaign = 'HWC_2014'
t_start = '2015-01-17 21:52:03.746'
t_end = '2015-01-17 22:04:52.451'
```
2. To analyze a historical test with a browser GUI, copy and execute the following code in the cell below
```
circuit_type = 'RQ'
hwc_test = 'PLI2.f1'
hwcb = HwcSearchModuleMediator(circuit_type=circuit_type, hwc_test=hwc_test, hwc_summary_path='/eos/project/l/lhcsm/hwc/HWC_Summary.csv')
```
- After opening the browser GUI, choose a circuit name in order to display HWC test with, campaign name as well as start and end time
%% Cell type:code id: tags:
``` python
hwc_test = 'PLI2.f1'
circuit_name = 'RQD.A45'
campaign= 'Recommissioning post LS2'
t_start = '2021-04-07 20:44:14.437000000'
t_end = '2021-04-07 20:55:41.364000000'
```
%% Cell type:code id: tags:
``` python
print('hwc_test = \'%s\'\ncircuit_name = \'%s\'\ncampaign = \'%s\'\nt_start = \'%s\'\nt_end = \'%s\'' % (hwc_test, circuit_name, campaign, t_start, t_end))
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:skip_output
``` python
circuit_type = 'RQ'
if 'hwcb' in locals():
circuit_name = hwcb.get_circuit_name()
t_start = Time.to_unix_timestamp(hwcb.get_start_time())
t_end = Time.to_unix_timestamp(hwcb.get_end_time())
t_start_ref = Time.to_unix_timestamp(hwcb.get_ref_start_time())
t_end_ref = Time.to_unix_timestamp(hwcb.get_ref_end_time())
is_automatic = hwcb.is_automatic_mode()
else:
t_start = Time.to_unix_timestamp(t_start)
t_end = Time.to_unix_timestamp(t_end)
t_start_ref, t_end_ref = HwcSearchModuleMediator.get_last_ref_start_end_time('/eos/project/l/lhcsm/hwc/HWC_Summary.csv', circuit_name, hwc_test, Time.to_string_short(t_start))
t_start_ref, t_end_ref = Time.to_unix_timestamp(t_start_ref), Time.to_unix_timestamp(t_end_ref)
is_automatic = False
circuit_names = [circuit_name if 'RQD' in circuit_name else circuit_name.replace('F', 'D'),
circuit_name if 'RQF' in circuit_name else circuit_name.replace('D', 'F')]
rqd_query = RqCircuitQuery(circuit_type, circuit_names[0], max_executions=28)
rqf_query = RqCircuitQuery(circuit_type, circuit_names[1], max_executions=19)
with Timer():
# PC
source_timestamp_df = rqd_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc_rqd = source_timestamp_df.at[0, 'timestamp']
source_timestamp_df = rqf_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc_rqf = source_timestamp_df.at[0, 'timestamp']
i_meas_rqd_df, i_a_rqd_df, i_earth_rqd_df, i_earth_pcnt_rqd_df, i_ref_rqd_df = rqd_query.query_pc_pm(timestamp_fgc_rqd, timestamp_fgc_rqd, signal_names=['I_MEAS', 'I_A', 'IEARTH', 'I_EARTH_PCNT', 'I_REF'])
i_meas_rqf_df, i_a_rqf_df, i_earth_rqf_df, i_earth_pcnt_rqf_df, i_ref_rqf_df = rqf_query.query_pc_pm(timestamp_fgc_rqf, timestamp_fgc_rqf, signal_names=['I_MEAS', 'I_A', 'IEARTH', 'I_EARTH_PCNT', 'I_REF'])
source_timestamp_pc_rqd_ref_df = rqd_query.find_source_timestamp_pc(t_start_ref, t_end_ref)
timestamp_fgc_ref_rqd = source_timestamp_pc_rqd_ref_df.at[0, 'timestamp']
source_timestamp_pc_rqf_ref_df = rqf_query.find_source_timestamp_pc(t_start_ref, t_end_ref)
timestamp_fgc_ref_rqf = source_timestamp_pc_rqf_ref_df.at[0, 'timestamp']
i_meas_ref_rqd_df, i_earth_rqd_ref_df, i_earth_pcnt_rqd_ref_df = rqd_query.query_pc_pm(timestamp_fgc_ref_rqd, timestamp_fgc_ref_rqd, signal_names=['I_MEAS', 'IEARTH', 'I_EARTH_PCNT'])
i_meas_ref_rqf_df, i_earth_rqf_ref_df, i_earth_pcnt_rqf_ref_df = rqf_query.query_pc_pm(timestamp_fgc_ref_rqf, timestamp_fgc_ref_rqf, signal_names=['I_MEAS', 'IEARTH', 'I_EARTH_PCNT'])
# PIC
timestamp_pic_rqd = rqd_query.find_timestamp_pic(timestamp_fgc_rqd, spark=spark)
timestamp_pic_rqf = rqf_query.find_timestamp_pic(timestamp_fgc_rqf, spark=spark)
# EE
source_timestamp_ee_rqd_df = rqd_query.find_source_timestamp_ee(timestamp_fgc_rqd)
timestamp_ee_rqd = source_timestamp_ee_rqd_df.loc[0, 'timestamp']
u_dump_res_rqd_df = rqd_query.query_ee_u_dump_res_pm(timestamp_ee_rqd, timestamp_fgc_rqd, system='EE', signal_names=['U_DUMP_RES'])[0]
source_timestamp_ee_rqf_df = rqf_query.find_source_timestamp_ee(timestamp_fgc_rqf)
timestamp_ee_rqf = source_timestamp_ee_rqf_df.loc[0, 'timestamp']
u_dump_res_rqf_df = rqf_query.query_ee_u_dump_res_pm(timestamp_ee_rqf, timestamp_fgc_rqf, system='EE', signal_names=['U_DUMP_RES'])[0]
t_res_0_rqd_df = rqd_query.query_ee_t_res_pm(source_timestamp_ee_rqd_df.loc[0, 'timestamp'], timestamp_fgc_rqd, system='EE', signal_names=['T_RES'])[0]
if len(source_timestamp_ee_rqd_df) > 1:
t_res_1_rqd_df = rqd_query.query_ee_t_res_pm(source_timestamp_ee_rqd_df.loc[1, 'timestamp'], timestamp_fgc_rqd, system='EE', signal_names=['T_RES'])[0]
else:
t_res_1_rqd_df = pd.DataFrame(columns=['T_RES'])
t_res_0_rqf_df = rqf_query.query_ee_t_res_pm(source_timestamp_ee_rqf_df.loc[0, 'timestamp'], timestamp_fgc_rqf, system='EE', signal_names=['T_RES'])[0]
if len(source_timestamp_ee_rqf_df) > 1:
t_res_1_rqf_df = rqf_query.query_ee_t_res_pm(source_timestamp_ee_rqf_df.loc[1, 'timestamp'], timestamp_fgc_rqf, system='EE', signal_names=['T_RES'])[0]
else:
t_res_1_rqf_df = pd.DataFrame(columns=['T_RES'])
# EE - REF
source_timestamp_ee_rqd_ref_df = rqd_query.find_source_timestamp_ee(timestamp_fgc_ref_rqd)
source_timestamp_ee_rqf_ref_df = rqf_query.find_source_timestamp_ee(timestamp_fgc_ref_rqf)
t_res_0_rqd_ref_df = rqd_query.query_ee_t_res_pm(source_timestamp_ee_rqd_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref_rqd, system='EE', signal_names=['T_RES'])[0]
if len(source_timestamp_ee_rqd_ref_df) > 1:
t_res_1_rqd_ref_df = rqd_query.query_ee_t_res_pm(source_timestamp_ee_rqd_ref_df.loc[1, 'timestamp'], timestamp_fgc_ref_rqd, system='EE', signal_names=['T_RES'])[0]
else:
t_res_1_rqd_ref_df = pd.DataFrame(columns=['T_RES'])
t_res_0_rqf_ref_df = rqf_query.query_ee_t_res_pm(source_timestamp_ee_rqf_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref_rqf, system='EE', signal_names=['T_RES'])[0]
if len(source_timestamp_ee_rqf_ref_df) > 1:
t_res_1_rqf_ref_df = rqf_query.query_ee_t_res_pm(source_timestamp_ee_rqf_ref_df.loc[1, 'timestamp'], timestamp_fgc_ref_rqf, system='EE', signal_names=['T_RES'])[0]
else:
t_res_1_rqf_ref_df = pd.DataFrame(columns=['T_RES'])
# iQPS
source_timestamp_qds_rq_df = rqd_query.find_source_timestamp_qds(timestamp_fgc_rqd, duration=[(10, 's'), (200, 's')])
if Time.to_unix_timestamp(timestamp_fgc_rqd) > 1577833200000000000:
iqps_analog_0_dfs = rqd_query.query_iqps_analog_pm(source_timestamp_qds_rq_df, signal_names=['U_QS0_INT_A', 'U_QS0_EXT_A'])
iqps_analog_1_dfs = rqd_query.query_iqps_analog_pm(source_timestamp_qds_rq_df, signal_names=['U_QS1_INT_A', 'U_QS1_EXT_A'])
iqps_analog_dfs = rqd_query.query_iqps_analog_pm(source_timestamp_qds_rq_df, signal_names=['U_QS0_INT_A', 'U_QS0_EXT_A'])
iqps_digital_dfs = rqd_query.query_iqps_analog_pm(source_timestamp_qds_rq_df, signal_names=['ST_NOLATCH_BR_EXT_A', 'ST_NOLATCH_BR_INT_A', 'ST_NOTRIG_BR_EXT_A', 'ST_NOTRIG_BR_INT_A'])
else:
iqps_analog_dfs = rqd_query.query_iqps_analog_pm(source_timestamp_qds_rq_df, signal_names=['U_QS0_EXT', 'U_QS0_INT', 'U_1_EXT', 'U_2_EXT', 'U_1_INT', 'U_2_INT'])
iqps_digital_dfs = rqd_query.query_iqps_analog_pm(source_timestamp_qds_rq_df, signal_names=['ST_MAGNET_OK', 'ST_MAGNET_OK_INT', 'ST_NQD0_EXT', 'ST_NQD0_INT'])
# nQPS
source_timestamp_nqps_rqd_df = rqd_query.find_source_timestamp_nqps(timestamp_fgc_rqd)
source_timestamp_nqps_rqf_df = rqf_query.find_source_timestamp_nqps(timestamp_fgc_rqf)
u_nqps_rqd_dfs = rqd_query.query_nqps_voltage_pm(source_timestamp_qds_rq_df)
u_nqps_rqf_dfs = rqf_query.query_nqps_voltage_pm(source_timestamp_qds_rq_df)
# Results table
results_table = rqd_query.create_report_analysis_template(source_timestamp_qds_rq_df, source_timestamp_nqps_rqd_df, min(timestamp_fgc_rqd, timestamp_fgc_rqf), min(timestamp_pic_rqd, timestamp_pic_rqf), '../__init__.py', i_meas_rqd_df, i_meas_rqf_df, HwcSearchModuleMediator.get_user())
# QH
source_timestamp_qh_rq_df = rqd_query.find_source_timestamp_qh(timestamp_fgc_rqd, duration=[(10, 's'), (200, 's')])
i_hds_rq_dfs = rqd_query.query_qh_pm(source_timestamp_qh_rq_df, signal_names='I_HDS')
u_hds_rq_dfs = rqd_query.query_qh_pm(source_timestamp_qh_rq_df, signal_names='U_HDS')
i_hds_rq_ref_dfs = rqd_query.query_qh_pm(source_timestamp_qh_rq_df, signal_names='I_HDS', is_ref=True)
u_hds_rq_ref_dfs = rqd_query.query_qh_pm(source_timestamp_qh_rq_df, signal_names='U_HDS', is_ref=True)
# DIODE LEADS
i_meas_u_diode_u_ref_rqd_pm_dfs = rqd_query.query_current_voltage_diode_leads_pm(timestamp_fgc_rqd, source_timestamp_qds_rq_df)
i_meas_u_diode_rqd_nxcals_dfs = rqd_query.query_current_voltage_diode_leads_nxcals(source_timestamp_qds_rq_df, spark=spark)
i_meas_u_diode_u_ref_rqf_pm_dfs = rqf_query.query_current_voltage_diode_leads_pm(timestamp_fgc_rqf, source_timestamp_qds_rq_df)
i_meas_u_diode_rqf_nxcals_dfs = rqf_query.query_current_voltage_diode_leads_nxcals(source_timestamp_qds_rq_df, spark=spark)
# DFB
source_timestamp_leads_rqd_df = rqd_query.find_timestamp_leads(timestamp_fgc_rqd)
u_hts_rqd_dfs = rqd_query.query_leads(timestamp_fgc_rqd, source_timestamp_leads_rqd_df, signal_names=['U_HTS'], spark=spark)
u_res_rqd_dfs = rqd_query.query_leads(timestamp_fgc_rqd, source_timestamp_leads_rqd_df, signal_names=['U_RES'], spark=spark)
source_timestamp_leads_rqf_df = rqf_query.find_timestamp_leads(timestamp_fgc_rqf)
u_hts_rqf_dfs = rqf_query.query_leads(timestamp_fgc_rqf, source_timestamp_leads_rqf_df, signal_names=['U_HTS'], spark=spark)
u_res_rqf_dfs = rqf_query.query_leads(timestamp_fgc_rqf, source_timestamp_leads_rqf_df, signal_names=['U_RES'], spark=spark)
# U_DIODE
u_diode_rqd_dfs = rqd_query.query_voltage_nxcals('DIODE_RQD', 'U_DIODE_RQD', timestamp_fgc_rqd, spark=spark)
u_diode_rqf_dfs = rqf_query.query_voltage_nxcals('DIODE_RQF', 'U_DIODE_RQF', timestamp_fgc_rqf, spark=spark)
# U_EARTH
u_earth_rqd_dfs = rqd_query.query_voltage_nxcals('VF_RQD', 'U_EARTH_RQD', timestamp_fgc_rqd, spark=spark)
u_earth_rqf_dfs = rqf_query.query_voltage_nxcals('VF_RQF', 'U_EARTH_RQF', timestamp_fgc_rqf, spark=spark)
rq_analysis = RqCircuitAnalysis(circuit_type, results_table, is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Circuit Parameters Table
%% Cell type:code id: tags:
``` python
rq_analysis.display_parameters_table(circuit_names[0])
```
%% Cell type:markdown id: tags:
# 4. Timestamps
## 4.1. FPA
Table below provides timestamps ordered achronologically and represents the sequence of events that occurred in the analyzed circuit: PIC_RQD, PIC_RQF, iQPS, nQPS, FGC_RQD, FGC_RQF, EE_RQD, EE_RQF and optionally LEADS_RQD and LEADS_RQF, provided they exist. Note that for iQPS and nQPS only the first timestamp is reported. Tables with all iQPS and NQPS timestamps are presented in the section dedicated to magnet and quench protection analysis. The table also contains time difference in milliseconds from the first event and from the FGC event.
In short, the following criteria should be kept:
- The PC timestamp (51_self) is QPS time stamp +/-20 ms.
- Time stamp difference between FGC and EE: 100±15 ms
- The PC timestamp (51_self) is QPS time stamp +/-40 ms.
- Time stamp delay between PIC and EE: 100±15 ms
If one or more of these conditions are not fulfilled, then an in-depth analysis has to be performed by the QPS team.
%% Cell type:code id: tags:
``` python
timestamp_dct = {'FGC_RQD': timestamp_fgc_rqd, 'FGC_RQF': timestamp_fgc_rqf,
'PIC_RQD': timestamp_pic_rqd, 'PIC_RQF': timestamp_pic_rqf,
'EE_RQD': source_timestamp_ee_rqd_df, 'EE_RQF': source_timestamp_ee_rqf_df,
'iQPS': source_timestamp_qds_rq_df, 'nQPS': source_timestamp_nqps_rqd_df,
'LEADS_RQD': source_timestamp_leads_rqd_df, 'LEADS_RQF': source_timestamp_leads_rqf_df}
rq_analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
## 4.2. Reference
Table below contains reference timestamps of signals used for comparison to the analyzed FPA. The reference comes as the last PNO.b3 HWC test with activation of EE systems and no magnets quenching.
%% Cell type:code id: tags:
``` python
timestamp_ref_dct = {'FGC_RQD': timestamp_fgc_ref_rqd, 'FGC_RQF': timestamp_fgc_ref_rqf,
'EE_RQD_first': source_timestamp_ee_rqd_ref_df.loc[0, 'timestamp'], 'EE_RQD_second': source_timestamp_ee_rqd_ref_df.loc[1, 'timestamp'],
'EE_RQF_first': source_timestamp_ee_rqd_ref_df.loc[0, 'timestamp'], 'EE_RQF_second': source_timestamp_ee_rqd_ref_df.loc[1, 'timestamp']}
rq_analysis.create_ref_timestamp_table(timestamp_ref_dct)
```
%% Cell type:markdown id: tags:
# 5. PIC
## 5.1. Analysis of the PIC Timestamp
*CRITERIA*:
- Check iff the the difference between RQD and RQF PIC timestamps is less than 1 ms. If yes, then a warning is displayed.
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_pic([timestamp_pic_rqd, timestamp_pic_rqf])
```
%% Cell type:markdown id: tags:
# 6. Power Converter
## 6.1. Analysis of the Power Converter Main Current
This analysis module displays the main current of the power converter (I_MEAS), and for comparison, a reference I_MEAS (PNO.b3).
*ANALYSIS*:
- The evolution of the characteristic time $\tau$ of an exponential decay $f(t)$ is obtained as
\begin{equation}
-\frac{f(t)}{\partial_t f(t)} = -\frac{f_0 e^{-t/\tilde{\tau}}}{\partial_t (f_0 e^{-t/\tilde{\tau}})} = -\frac{f_0 e^{-t/\tilde{\tau}}}{-f_0/\tilde{\tau} e^{-t/\tilde{\tau}}}=-\frac{1}{-1/\tau}=\tau
\end{equation}
Naturally, this formula only applies to exponential decayed characterised by a time constant. Nonetheless, for pseudo-exponential decays, this formula gives a notion of the change of the characteristic time $\tilde{\tau}$. For a circuit we compute the time-varying characteristic time as
\begin{equation}
\tilde{\tau} = \frac{\partial \text{I_MEAS}}{\partial_t}
\end{equation}
*CRITERIA*
- Check if the characteristic time of the pseudo-exponential I_MEAS decay from t=1 to 100 s is 25 s< Tau < 35 s
*GRAPHS* (one for each circuit):
- The main power converter current (reference and actual) on the left axis, I_MEAS
- The characteristic pseudo time constant calculated for the main current (reference and actual) on the right axis, -I_MEAS/dI_MEAS
The actual characteristic pseudo time constant contains discrete steps, which indicate a quenching magnet (decreasing L, increasing R); note that for the reference one the steps are not present (no quench).
- Timing of PIC abort, FGC timestamps, the maximum currents, and the characteristic times are reported next to the graph.
- t = 0 s corresponds to the respective (actual and reference) FGC timestamps.
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_i_meas_pc(circuit_names[0], timestamp_fgc_rqd, timestamp_fgc_ref_rqd, timestamp_pic_rqd, i_meas_rqd_df, i_meas_ref_rqd_df)
rq_analysis.calculate_current_miits(i_meas_rqd_df, t_quench=0, col_name='MIITS_RQD')
rq_analysis.calculate_quench_current(i_meas_rqd_df, t_quench=0, col_name='I_Q_RQD')
rq_analysis.calculate_current_slope(i_meas_rqd_df, col_name=['Ramp rate RQD', 'Plateau duration RQD'])
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_i_meas_pc(circuit_names[1], timestamp_fgc_rqf, timestamp_fgc_ref_rqf, timestamp_pic_rqf, i_meas_rqf_df, i_meas_ref_rqf_df)
rq_analysis.calculate_current_miits(i_meas_rqf_df, t_quench=0, col_name='MIITS_RQF')
rq_analysis.calculate_quench_current(i_meas_rqf_df, t_quench=0, col_name='I_Q_RQF')
rq_analysis.calculate_current_slope(i_meas_rqf_df, col_name=['Ramp rate RQF', 'Plateau duration RQF'])
```
%% Cell type:markdown id: tags:
## 6.2. Analysis of the Power Converter Earth Current
*GRAPHS (one for each circuit)*:
t = 0 s corresponds to respective (actual and reference) FGC PM timestamps
First plot (absolute scale, zoom for t = [-0.1, 0.3])
- The main power converter current on the left axis, I_A
- Actual and reference earth current on the right axis, IEARTH
Second plot (percentage scale, for t > 3 s)
- The main power converter current on the left axis, I_MEAS
- Actual and reference earth current on the right axis, I_EARTH_PCNT
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_i_earth_pc(circuit_names[0], timestamp_fgc_rqd, i_a_rqd_df, i_earth_rqd_df, i_earth_rqd_ref_df)
rq_analysis.calculate_max_i_earth_pc(i_earth_rqd_df, col_name='I_Earth_max_RQD')
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_i_earth_pc(circuit_names[1], timestamp_fgc_rqf, i_a_rqf_df, i_earth_rqf_df, i_earth_rqf_ref_df)
rq_analysis.calculate_max_i_earth_pc(i_earth_rqf_df, col_name='I_Earth_max_RQF')
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_i_earth_pcnt_pc(circuit_names[0], timestamp_fgc_rqd, i_meas_rqd_df, i_meas_ref_rqd_df, i_earth_pcnt_rqd_df, i_earth_pcnt_rqd_ref_df)
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_i_earth_pcnt_pc(circuit_names[1], timestamp_fgc_rqf, i_meas_rqf_df, i_meas_ref_rqf_df, i_earth_pcnt_rqf_df, i_earth_pcnt_rqf_ref_df)
```
%% Cell type:markdown id: tags:
# 7. Energy Extraction System
## 7.1. Analysis of the Energy Extraction Voltage
*CRITERIA*:
- Check if the characteristic time of the pseudo-exponential U_DUMP_RES decay from t=2 to 100 s is 25 s< Tau < 35 s
- Check if the timestamp difference between FGC and EE is 100±15 ms
*GRAPHS* (one for each circuit):
t = 0 s corresponds to the PM timestamp of the FGC
First plot (global view):
- the power converter converter current on the left axis, I_MEAS
- the two energy extraction voltages on the right, U_DUMP_RES
Second plot (triggering view):
- the power converter current on the left axis, I_MEAS
- the power converter reference current on the left axis, STATUS.I_REF (should stop at the moment of the FGC PM timestamp)
- the energy extraction voltage on the right axis, U_DUMP_RES
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_char_time_u_dump_res_ee(circuit_names[0], timestamp_fgc_rqd, u_dump_res_rqd_df, i_meas_rqd_df)
rq_analysis.results_table['U_EE_max_RQD'] = u_dump_res_rqd_df.max()[0]
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_char_time_u_dump_res_ee(circuit_names[1], timestamp_fgc_rqf, u_dump_res_rqf_df, i_meas_rqf_df)
rq_analysis.results_table['U_EE_max_RQF'] = u_dump_res_rqf_df.max()[0]
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_delay_time_u_dump_res_ee(circuit_names[0], timestamp_fgc_rqd, timestamp_pic_rqd, timestamp_ee_rqd, i_a_rqd_df, i_ref_rqd_df, u_dump_res_rqd_df)
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_delay_time_u_dump_res_ee(circuit_names[1], timestamp_fgc_rqf, timestamp_pic_rqf, timestamp_ee_rqf, i_a_rqf_df, i_ref_rqf_df, u_dump_res_rqf_df)
```
%% Cell type:markdown id: tags:
## 7.2. Analysis of the Energy Extraction Temperature
*CRITERIA*:
- Check if each temperature profile is +/-25 K w.r.t. the reference temperature profile
*GRAPHS*:
- Temperature signals on the left axis, T
- A reference signal with an acceptable signal range is also presented on the left axis
- t = 0 s corresponds to PM timestamps of each temperature PM entry
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_ee_temp(circuit_names[0], timestamp_ee_rqd, [t_res_0_rqd_df, t_res_1_rqd_df], [t_res_0_rqd_ref_df, t_res_1_rqd_ref_df], abs_margin=25, scaling=1)
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_ee_temp(circuit_names[1], timestamp_ee_rqf, [t_res_0_rqf_df, t_res_1_rqf_df], [t_res_0_rqf_ref_df, t_res_1_rqf_ref_df], abs_margin=25, scaling=1)
```
%% Cell type:code id: tags:
``` python
if not is_automatic:
rq_analysis.results_table['EE analysis RQD'] = input('EE analysis RQD comment: ')
```
%% Cell type:code id: tags:
``` python
if not is_automatic:
rq_analysis.results_table['EE analysis RQF'] = input('EE analysis RQF comment: ')
```
%% Cell type:markdown id: tags:
# 8. Quench Protection System
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rq/RQ_QPS_Signals.png" width=75%>
source: Test Procedure and Acceptance Criteria for the 13 kA Quadrupole (RQD-RQF) Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874714/5.1">https://edms.cern.ch/document/874714/5.1</a>
%% Cell type:markdown id: tags:
## 8.1. Plot of Voltage Across All Magnets (U_DIODE_RQx)
*GRAPHS* (one for each circuit):
t = 0 s corresponds to the PM timestamp of the FGC
First plot (global)
- the power converter current on the left axis, I_MEAS
- diode voltage on the right axis, U_DIODE_RQx
Second plot (zoom)
- the power converter current on the left axis, I_MEAS
- diode voltage on the right axis, U_DIODE_RQx
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_u_diode_nqps(circuit_names[0], timestamp_fgc_rqd, i_meas_rqd_df, u_diode_rqd_dfs, 'U_DIODE_RQD', system='DIODE_RQD')
```
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rq_analysis.analyze_u_diode_nqps(circuit_names[1], timestamp_fgc_rqf, i_meas_rqf_df, u_diode_rqf_dfs, 'U_DIODE_RQF', system='DIODE_RQF')
```
%% Cell type:markdown id: tags:
## 8.2. Analysis of Quenched Magnets by QDS - PM
*QUERY*:
- PM for quench detection signals for 1 s before and 400 s after the FGC PM timestamp; if a quench detection signal is present, it means that a magnet quenched. Since there are two QPS boards (so called boards A and B), there are twice as many PM entries as quenched magnets.
*ANALYSIS*:
- calculates the current at which a quench occured by finding the timestamp of the current dataframe (i_meas_df) closest to the quench time and the curresponding value of current
- compute the time difference (in seconds) from the first quench - dt_quench
%% Cell type:code id: tags:
``` python
rq_analysis.results_table[['Circuit Name', 'Position', 'Date (FGC)', 'Time (FGC)', 'I_Q_MQD', 'I_Q_MQF']]
```
%% Cell type:markdown id: tags:
## 8.3. Analysis of Quench Detection Voltage and Logic Signals for Quenched Magnets
If a quadrupole magnet naturally quenches the QPS system (old or iQPS) records a PM file. This file containts the data from the two quench detectors for RQD and RQF (called INT and EXT). The aperture which quenches first defines the common PM time stamp. The PM data is however recorded by two individual boards. Since there is only one common heater circuit for both apertures, the non-quenching aperture will also be warmed up by the heaters and will quench. This heater induced quench which comes some time after the primary quench which triggered the PM is recorded by its quench detector when it is reaching the 100mV. Since the system has only one absolute time stamp (the one of the primary quench) the secondary, heater induced, quench appears in the PM at the same time as the primary quench despite the fact that it happens later in time. This behaviour is a feature of the system which is foreseen to be fixed in LS2 with the new quadrupole quench detection system.
In the following analysis one can see the typical shape of U_QS0 signals (up to LS2). Both reach 100 mV at the same time due to the synchronisation of the data. The non-quenching aperture typically has a spike some 40 ms earlier (due to QH firing) and a faster voltage rise (due to QH induced quench). The quenching aperture has a typical 5-6 V/s slope at nominal current.
*ANALYSIS*:
Determine aperture with a quenched magnet
1. Find a diode signal which is the first to reach 1 V
2. Take a circuit name (RQD/RQF) from the diode signal name
3. With the circuit name and the magnet name, get the aperture (INT/EXT)
4. With the aperture name, choose an appropriate U_QS0 signal and use for du_dt calculation
- if |U_QS0| $\geq$ 100 mV, then find the start time of a quench, t_start_quench, as the moment at which |U_QS0| is 10 mV greater than its initial value. Otherwise, the start time of a quench is set to 0 s
- Find U_QS0 value, u_start_quench, at the moment of quench start as u_start_quench = U_QS0(t=t_start_quench)
- The slope of the quench detection signals is calculated as du_dt = (u_ST_NQD0 - u_start_quench) / (t_st_nqd0 - t_start_quench)
*GRAPHS*:
t = 0 s corresponds to the PM timestamp of the QDS
Upper left (iQPS analog signals)
- the quench detection voltage on the left axis, U_QS0_INT, U_QS0_EXT
- the green box denotes an envelope of the +/- 100 mV quench detection threshold
- the orange box denotes an envelope of the rise of the quench signal from its start until reaching the threshold
Lower left (iQPS digital signals)
- the quench detection voltage on the left axis, ST_MAGNET_OK, ST_MAGNET_OK_INT, ST_NQD0_INT, ST_NQD0_EXT
Upper right (nQPS analog signals)
For PM signals (raw view)
- the diode voltages used by the nQPS crate for quench detection on the left axis, U_DIODE_RQx and U_REF_N1
Lower right (nQPS analog signals)
For PM signals (zoomed view)
- the diode voltages used by the nQPS crate for quench detection on the left axis, U_DIODE_RQx and U_REF_N1
%% Cell type:code id: tags:
``` python
%matplotlib inline
if Time.to_unix_timestamp(timestamp_fgc_rqd) > 1577833200000000000:
rq_analysis.analyze_qds_run3(source_timestamp_qds_rq_df.rename(columns={'source':'magnet', 'timestamp':'timestamp_iqps'}), circuit_names, iqps_analog_0_dfs, iqps_digital_dfs, u_nqps_rqd_dfs, u_nqps_rqf_dfs)
rq_analysis.analyze_qds_run3(source_timestamp_qds_rq_df.rename(columns={'source':'magnet', 'timestamp':'timestamp_iqps'}), circuit_names, iqps_analog_1_dfs, iqps_digital_dfs, u_nqps_rqd_dfs, u_nqps_rqf_dfs)
rq_analysis.analyze_qds_run3(source_timestamp_qds_rq_df, circuit_names, iqps_analog_dfs, iqps_digital_dfs, u_nqps_rqd_dfs, u_nqps_rqf_dfs)
else:
rq_analysis.analyze_qds(source_timestamp_qds_rq_df, circuit_names, iqps_analog_dfs, iqps_digital_dfs, u_nqps_rqd_dfs, u_nqps_rqf_dfs)
rq_analysis.results_table[['Circuit Name', 'Position', 'Delta_t(iQPS-PIC)','I_Q_RQD', 'I_Q_RQF', 'Delta_t(nQPS_RQD-PIC)', 'QDS trigger origin', 'dU_iQPS/dt_RQD', 'dU_iQPS/dt_RQF']]
```
%% Cell type:markdown id: tags:
## 8.4. Analysis of Quench Heater Discharges
*CRITERIA*:
- check if all characteristic times of the pseudo-exponential voltage decays calculated with the 'charge' approach is +/- 3 ms from the reference ones
- check if the initial voltage should be between 810 V and 1020 V
- check if the final voltage should be between 0 V and 10 V
*GRAPHS*:
- the queried and filtered quench heater voltage on the left axis (actual signal continuous, reference dashed), U_HDS
- t = 0 s corresponds to the start of the pseudo-exponential decay
%% Cell type:code id: tags:
``` python
%matplotlib inline
if Time.to_unix_timestamp(timestamp_fgc_rqd) > 1577833200000000000:
rq_analysis.analyze_qh_voltage_current(source_timestamp_qh_rq_df, u_hds_rq_dfs, i_hds_rq_dfs, u_hds_rq_ref_dfs, i_hds_rq_ref_dfs)
else:
rq_analysis.analyze_qh(source_timestamp_qds_rq_df, circuit_type, u_hds_rq_dfs, u_hds_rq_ref_dfs)
rq_analysis.results_table[['Circuit Name', 'Position', 'Date (FGC)', 'Time (FGC)', 'I_Q_MQD', 'I_Q_MQF', 'QH analysis']]