Esempio n. 1
0
 def calc_uncertainty(self):
     # 计算一元线性回归的不确定度
     num_u_b = self.data['num_b'] * sqrt((1 / (self.data['num_r'] ** 2) - 1) / (8 - 2))
     self.data['num_u_b'] = num_u_b
     # 计算直径D的不确定度
     num_ua_D = Method.a_uncertainty(self.data['list_D'])
     num_ub_D = 0.03 / sqrt(3) /1000
     num_u_D = sqrt(num_ua_D ** 2 + num_ub_D ** 2)
     self.data.update({"num_ua_D":num_ua_D, "num_ub_D":num_ub_D, "num_u_D":num_u_D})
     # 电阻率不确定度的合成
     num_u_rho_rho = sqrt((num_u_D / self.data['num_D']) ** 2 + (num_u_b / self.data['num_b']) ** 2)
     num_rho = self.data['num_rho']
     num_u_rho = num_u_rho_rho * num_rho
     self.data.update({"num_u_rho_rho": num_u_rho_rho, "num_u_rho": num_u_rho})
     # 输出带不确定度的最终结果: 不确定度保留一位有效数字, 物理量结果与不确定度首位有效数字对齐
     self.data['final_1'] = Method.final_expression(self.data['num_rho'], self.data['num_u_rho'])
     # 单电桥测电阻
     # 灵敏度分析
     num_S = self.data['num_delta_n'] / self.data['num_delta_R_3']
     num_delta_lmd = 0.2 / num_S
     num_u_lmd = num_delta_lmd / sqrt(3)
     self.data.update({"num_S": num_S, "num_delta_lmd":num_delta_lmd, "num_u_lmd":num_u_lmd})
     # 仪器误差
     num_delta_yi = InstrumentError.dc_bridge(self.data['num_a_pct'], self.data['num_R_3'],self.data['num_R_0'])
     num_u_yi = num_delta_yi / sqrt(3)
     num_u_R_x = sqrt(num_u_yi ** 2 + num_u_lmd ** 2)
     self.data.update({"num_delta_yi": num_delta_yi, "num_u_yi": num_u_yi, "num_u_R_x": num_u_R_x})
     # 输出带不确定度的最终结果: 不确定度保留一位有效数字, 物理量结果与不确定度首位有效数字对齐
     self.data['final_2'] = Method.final_expression(self.data['num_R_3'], self.data['num_u_R_x'])
     print(self.data['final_2'])
Esempio n. 2
0
 def calc_uncertainty_detail(data_list, result_list):
     sunc = Simplified()
     uncertain_data = {}
     ua_10delta_x = Method.a_uncertainty(result_list['diff_10delta_x'])
     ub_10delta_x = sunc.micrometer / sqrt(3)
     u_10delta_x = sqrt(ua_10delta_x**2 + ub_10delta_x**2)
     u_delta_x = u_10delta_x / 10
     ub_S = sqrt((sunc.steel_ruler / 10 / sqrt(3))**2 +
                 (data_list['delta_s'] / sqrt(3))**2)
     ub_b = sqrt((sunc.micrometer / sqrt(3))**2 +
                 (data_list['delta_b_b'] * result_list['b'] / sqrt(3))**2)
     ub_b1 = sqrt((sunc.micrometer / sqrt(3))**2 +
                  (data_list['delta_b_b'] * result_list['b1'] / sqrt(3))**2)
     u_lbd_lbd = sqrt((u_delta_x / result_list['delta_x'])**2 +
                      (ub_b / result_list['b'] / 2)**2 +
                      (ub_b1 / result_list['b1'] / 2)**2 + 2 *
                      ((ub_S / (result_list['S'] + result_list['S1']))**2))
     u_lbd = u_lbd_lbd * result_list['result_lambda']
     final_lbd = Method.final_expression(result_list['result_lambda'],
                                         u_lbd)
     uncertain_data['ua_10delta_x'] = ua_10delta_x
     uncertain_data['ub_10delta_x'] = ub_10delta_x
     uncertain_data['u_10delta_x'] = u_10delta_x
     uncertain_data['u_delta_x'] = u_delta_x
     uncertain_data['u_S'] = ub_S
     uncertain_data['u_b'] = ub_b
     uncertain_data['u_b1'] = ub_b1
     uncertain_data['u_lbd_lbd'] = u_lbd_lbd
     uncertain_data['u_lbd'] = u_lbd
     uncertain_data['final'] = final_lbd
     return uncertain_data
Esempio n. 3
0
 def calc_uncertainty_d(self):
     # 计算光程差d的a,b及总不确定度
     Ua_2xita1 = Method.a_uncertainty(
         self.data['list_d_2xita1'])  # 这里容易写错,一定要用原始数据的数组
     Ub_2xita1 = 1.679e-4
     U_xita1 = sqrt(Ub_2xita1**2 + Ua_2xita1**2) / 2
     Ud1 = abs(self.data['d1'] * U_xita1 /
               tan(self.data['d_xita1_average']))
     Ub_2xita2 = 1.679e-4
     Ud2 = abs(self.data['d2'] * Ub_2xita2 /
               (2 * tan(3.14 * self.data['d_2xita2'] / 360)))
     self.uncertainty.update({
         "Ua_2xita1": Ua_2xita1,
         "Ub_2xita1": Ub_2xita1,
         "Ua_xita1": Ua_2xita1 / 2,
         "Ub_xita1": Ub_2xita1 / 2,
         "U_xita1": U_xita1,
         "Ud1": Ud1,
         "Ub_2xita2": Ub_2xita2,
         "Ub_xita2": Ub_2xita2 / 2,
         "Ud2": Ud2
     })
     d1 = self.data['d1']
     d2 = self.data['d2']
     d_av = (d1 / (Ud1**2) + d2 / (Ud2**2)) / (1 / (Ud1**2) + 1 / (Ud2**2))
     Ud_av = sqrt((Ud1**2) * (Ud2**2) / (Ud1**2) + (Ud2**2))
     self.uncertainty.update({"d_av": d_av, "Ud_av": Ud_av})
     self.data['final1'] = Method.final_expression(d_av, Ud_av)
Esempio n. 4
0
 def calc_uncertainty3(self):
     # 计算顶角A的a,b及总不确定度
     ua_delta = Method.a_uncertainty(
         self.data['list_delta'])  # 这里容易写错,一定要用原始数据的数组
     ub_delta = (1 / 60) / sqrt(3)
     u_delta = sqrt(ua_delta**2 + ub_delta**2)
     self.data.update({
         "ua_delta": ua_delta,
         "ub_delta": ub_delta,
         "u_delta": u_delta
     })
     part_1 = -1 / sin(self.data['aver_A'] / 180 * pi) - sin(
         self.data['aver_delta'] / 180 * pi) * cos(
             self.data['aver_A'] / 180 * pi) / (sin(
                 self.data['aver_A'] / 180 * pi)**2)
     part_4 = (cos(self.data['aver_A'] / 180 * pi) +
               sin(self.data['aver_delta'] / 180 * pi)) / sin(
                   self.data['aver_A'] / 180 * pi)
     n_delta = cos(
         self.data['aver_delta'] / 180 * pi) * part_4 / self.data['n2']
     n_A = part_1 * part_4 / self.data['n2']
     u_n2 = sqrt((n_delta * u_delta / 180 * pi)**2 +
                 (n_A * self.data['u_A'] / 180 * pi)**2)
     self.data['u_n2'] = u_n2
     self.data['final_n2'] = Method.final_expression(self.data['n2'], u_n2)
Esempio n. 5
0
 def calc_uncertainty1(self):
     # 计算顶角A的a,b及总不确定度
     ua_A = Method.a_uncertainty(self.data['list_A'])  # 这里容易写错,一定要用原始数据的数组
     ub_A = (1 / 60) / sqrt(3) / 2
     u_A = sqrt(ua_A**2 + ub_A**2)
     self.data.update({"ua_A": ua_A, "ub_A": ub_A, "u_A": u_A})
     self.data['final_A'] = Method.final_expression(self.data['aver_A'],
                                                    u_A)
 def calc_uncertainty(self):
     num_sum = 0
     for i in range(0, 8):
         num_sum += (self.data['list_Y'][i] -
                     self.data['list_X'][i] * self.data['num_a'])**2
     num_u_A = sqrt(num_sum / (48 * 21))
     num_u_E = num_u_A * self.data['num_para']
     num_eta = abs(self.data['num_E'] - 70 * 1e9) / (70 * 1e9) * 100
     self.data['num_u_A'] = num_u_A
     self.data['num_u_E'] = num_u_E
     self.data['num_eta'] = num_eta
     self.data['final'] = Method.final_expression(
         self.data['num_E'] / 1e9, self.data['num_u_E'] / 1e9)
Esempio n. 7
0
 def calc_uncertainty(self):
     b = self.data['b']
     n = len(self.data['arr_D'])
     r = self.data['r']
     lbd = self.data['lambda'] * 1e-6
     ua_b = b * sqrt((1 / (n - 2)) * ((1 / (r ** 2)) - 1))
     ub_b = 0.005 / sqrt(3)
     u_b = sqrt(ua_b ** 2 + ub_b ** 2)
     u_R = u_b / (4 * lbd)
     R = self.data['R']
     res, unc, pwr = Method.final_expression(R, u_R)
     self.uncertainty['ua_b'] = ua_b
     self.uncertainty['ub_b'] = ub_b
     self.uncertainty['u_b'] = u_b
     self.uncertainty['u_R'] = u_R
     self.data['final'] = "(%.0f ± %.0f)e%d" % (res, unc, int(pwr))
     pass
Esempio n. 8
0
 def calc_uncertainty(self):
     # 计算光程差d的a,b及总不确定度
     ua_d = Method.a_uncertainty(self.data['list_d'])  # 这里容易写错,一定要用原始数据的数组
     ub_d = 0.00005 / sqrt(3)
     u_d = sqrt(ua_d**2 + ub_d**2)
     self.uncertainty.update({"ua_d": ua_d, "ub_d": ub_d, "u_d": u_d})
     # 计算圈数N的不确定度
     N = self.data['N']
     u_N = 1 / sqrt(3)
     self.uncertainty['u_N'] = u_N
     d, N = self.data['d'], self.data['N']
     # 波长的不确定度合成
     u_lbd_lbd = sqrt((u_d / d)**2 + (u_N / N)**2)
     lbd = self.data['lbd']
     u_lbd = u_lbd_lbd * lbd
     self.uncertainty.update({"u_lbd_lbd": u_lbd_lbd, "u_lbd": u_lbd})
     # 输出带不确定度的最终结果: 不确定度保留一位有效数字, 物理量结果与不确定度首位有效数字对齐
     self.data['final'] = Method.final_expression(lbd, u_lbd)
Esempio n. 9
0
 def calc_uncertainty2(self):
     # 计算顶角A的a,b及总不确定度
     ua_delta_m = Method.a_uncertainty(
         self.data['list_delta_m'])  # 这里容易写错,一定要用原始数据的数组
     ub_delta_m = (1 / 60) / sqrt(3)
     u_delta_m = sqrt(ua_delta_m**2 + ub_delta_m**2)
     self.data.update({
         "ua_delta_m": ua_delta_m,
         "ub_delta_m": ub_delta_m,
         "u_delta_m": u_delta_m
     })
     part_1 = cos((self.data['aver_delta_m'] / 180 * pi +
                   self.data['aver_A'] / 180 * pi) / 2)
     part_4 = sin(self.data['aver_A'] / 180 * pi / 2)
     n_delta_m = 0.5 * part_1 / part_4
     n_A = -sin(self.data['aver_delta_m'] / 180 * pi / 2) / 2 / (part_4**2)
     u_n1 = sqrt((n_delta_m * u_delta_m / 180 * pi)**2 +
                 (n_A * self.data['u_A'] / 180 * pi)**2)
     self.data['u_n1'] = u_n1
     self.data['final_n1'] = Method.final_expression(self.data['n1'], u_n1)
Esempio n. 10
0
    def calc_uncertainty_Rh(self):
        Ua_2xita1_r = Method.a_uncertainty(
            self.data['list_r_2xita1'])  # 这里容易写错,一定要用原始数据的数组
        Ub_2xita1_r = 1.679e-4
        Ua_xita1_r = Ua_2xita1_r / 2
        Ub_xita1_r = Ub_2xita1_r / 2
        U_xita1_r = sqrt(Ub_xita1_r**2 + Ua_xita1_r**2)
        self.uncertainty.update({
            "Ua_xita1_r": Ua_xita1_r,
            "Ub_xita1_r": Ub_xita1_r,
            "U_xita1_r": U_xita1_r,
            "Ua_2xita1_r": Ua_2xita1_r,
            "Ub_2xita1_r": Ub_2xita1_r
        })
        U_r_RH = self.data['r_RH'] * sqrt(
            (self.uncertainty['Ud_av'] / self.uncertainty['d_av'])**2 +
            (U_xita1_r / tan(self.data['r_xita1_average'])**2))
        self.uncertainty.update({"U_r_RH": U_r_RH})
        self.data['final2_r'] = Method.final_expression(
            self.data['r_RH'] * 1e6, U_r_RH * 1e4)

        Ua_2xita1_b = Method.a_uncertainty(
            self.data['list_b_2xita1'])  # 这里容易写错,一定要用原始数据的数组
        Ub_2xita1_b = 1.679e-4
        Ua_xita1_b = Ua_2xita1_b / 2
        Ub_xita1_b = Ub_2xita1_b / 2
        U_xita1_b = sqrt(Ub_xita1_b**2 + Ua_xita1_b**2)
        self.uncertainty.update({
            "Ua_xita1_b": Ua_xita1_b,
            "Ub_xita1_b": Ub_xita1_b,
            "U_xita1_b": U_xita1_b,
            "Ua_2xita1_b": Ua_2xita1_b,
            "Ub_2xita1_b": Ub_2xita1_b
        })
        U_b_RH = self.data['b_RH'] * sqrt(
            (self.uncertainty['Ud_av'] / self.uncertainty['d_av'])**2 +
            (U_xita1_b / tan(self.data['b_xita1_average'])**2))
        self.uncertainty.update({"U_b_RH": U_b_RH})
        self.data['final2_b'] = Method.final_expression(
            self.data['b_RH'] * 1e6, U_b_RH * 1e4)

        Ua_2xita1_p = Method.a_uncertainty(
            self.data['list_p_2xita1'])  # 这里容易写错,一定要用原始数据的数组
        Ub_2xita1_p = 1.679e-4
        Ua_xita1_p = Ua_2xita1_p / 2
        Ub_xita1_p = Ub_2xita1_p / 2
        U_xita1_p = sqrt(Ub_xita1_p**2 + Ua_xita1_p**2)
        self.uncertainty.update({
            "Ua_xita1_p": Ua_xita1_p,
            "Ub_xita1_p": Ub_xita1_p,
            "U_xita1_p": U_xita1_p,
            "Ua_2xita1_p": Ua_2xita1_p,
            "Ub_2xita1_p": Ub_2xita1_p
        })
        U_p_RH = self.data['p_RH'] * sqrt(
            (self.uncertainty['Ud_av'] / self.uncertainty['d_av'])**2 +
            (U_xita1_p / tan(self.data['p_xita1_average'])**2))
        self.uncertainty.update({"U_p_RH": U_p_RH})
        self.data['final2_p'] = Method.final_expression(
            self.data['p_RH'] * 1e6, U_p_RH * 1e4)

        RH = (self.simple_Rh(self.data['r_RH'], U_r_RH) +
              self.simple_Rh(self.data['b_RH'], U_b_RH) +
              self.simple_Rh(self.data['p_RH'], U_p_RH)) / ((1 / U_r_RH**2) +
                                                            (1 / U_b_RH**2) +
                                                            (1 / U_p_RH**2))
        self.data['RH'] = RH
        U_RH = sqrt(1 / ((1 / U_r_RH**2) + (1 / U_b_RH**2) + (1 / U_p_RH**2)))
        self.data['U_RH'] = U_RH
        self.data['final2'] = Method.final_expression(RH * 1e6, U_RH * 1e4)