def __init__(self, name, nom_cap, yhv, ylv, ang_freq, hv_lead, lv_lead,
                 rel_u, **kwargs):
        """

        Two terminal-pair capacitor
        :param name: label to identify capacitor
        :param nom_cap: the main capacitor as a tuple of conductance and capacitance (just nominal value for now)
        :param yhv: additional admittance to screen at the HV terminal as a tuple of conductance and capacitance
        :param ylv: additional admittance to screen at the LV terminal as a tuple of conductance and capacitance
        :param ang_freq: angular frequency in radians per second
        :param hv_lead: LEAD object
        :param lv_lead: LEAD object
        :param rel_u a default 1% relative uncertainty in measured C, G values. Could offer a non-default option.
        :param kwargs: best_value= ideally the best calculated value as a ucomplex in the build up
        """
        self.relu = rel_u  #
        for arg in kwargs.keys():
            if arg == 'best_value':
                self.best_value = kwargs[arg]
        self.w = ang_freq
        self.label = name
        self.y13 = ucomplex(
            (nom_cap[0] + 1j * nom_cap[1] * self.w), (0, 0),
            label=self.label +
            ' nom_y13')  # treat y13 as exact for correction purposes
        self.y12 = ucomplex((yhv[0] + 1j * yhv[1] * self.w),
                            (yhv[0] * self.relu, yhv[1] * self.w * self.relu),
                            label=self.label + ' y12')
        self.y34 = ucomplex((ylv[0] + 1j * ylv[1] * self.w),
                            (ylv[0] * self.relu + ylv[1] * self.w * self.relu),
                            label=self.label + ' y34')
        self.hvlead = hv_lead
        self.lvlead = lv_lead
示例#2
0
 def dict_to_ucomplex(self, unc_dict):
     """
     Takes a dictionary created by ucomplex_to_dict and creates a GTC uncertain complex.
     :param unc_dict: dictionary of parts of a GTC uncertain complex.
     :return: GTC uncertain complex
     """
     return ucomplex(unc_dict['xreal'] + 1j * unc_dict['ximag'],
                     unc_dict['v'],
                     unc_dict['df'],
                     label=unc_dict['label'])
示例#3
0
 def json_to_ucomplex(self, unc_json):
     """
     Takes a json string created by ucomplex_to_json and creates a GTC uncertain complex.
     :param unc_json: json string of a dictionary of parts of a GTC uncertain complex.
     :return: GTC uncertain complex
     """
     unc_dict = loads(unc_json)
     return ucomplex(unc_dict['xreal'] + 1j * unc_dict['ximag'],
                     unc_dict['v'],
                     unc_dict['df'],
                     label=unc_dict['label'])
    def __init__(self, name, series_z, parallel_y, ang_freq, rel_u):
        """

        Pi transform of a cable
        :param name: label to identify cable
        :param series_z: series impedance as tuple of resistance (ohm) and inductance (H)
        :param parallel_y: admittance of cable as tuple of conductance (S) and capacitance (F)
        :param ang_freq: angular frequency in radians per second
        :param rel_u a default relative uncertainty in the L, R, C values (could be nuanced)
        """
        self.relu = rel_u
        self.w = ang_freq
        self.label = name
        self.z = ucomplex(
            (series_z[0] + 1j * series_z[1] * self.w),
            (series_z[0] * self.relu, series_z[1] * self.w * self.relu),
            label=name + ' z')
        self.y = ucomplex(
            (parallel_y[0] + 1j * parallel_y[1] * self.w),
            (parallel_y[0] * self.relu, parallel_y[1] * self.w * self.relu),
            label=name + ' y')
示例#5
0
    def get_ShuntByTrans(self, f, sName, sheet, transR, uncL, dofL):
        shuntraw = self.get_shuntraw(sName, sheet)
        shunt_r = ureal(shuntraw[0], shuntraw[0] * uncL[3] / 1000000, dofL[3],
                        "Shunt Resistance (R3 real)")
        shunt_i = ureal(f * 2 * math.pi * shuntraw[1] * 0.000001,
                        shuntraw[0] * uncL[4] / 1000000, dofL[4],
                        "Shunt Resistance (R3 imag)")

        ## shnt = complex(shuntraw[0], f*2*math.pi*shuntraw[1]*0.000001)  # cells O10 and P10 of PowerCalc worksheet
        ## Shunt = ucomplex(shnt,(shnt.real*uncL[3]/1000000, shnt.real*uncL[4]/1000000), dofL[3], "Shunt Resistance (R3)")
        Trans = ucomplex(
            complex(transR, 0), (transR * 2 / 1000000, 0), 6,
            "Shunt by Transformer Resistance (R3)"
        )  ######## ! zeros as placeholder for phase & uncertainty of Transformer ratio
        if transR > 1:
            return Shunt / Trans
        else:
            return shunt_r, shunt_i
    for l, u in budget(final_ratio.real, trim=0):
        print(l, u)

    ratio_cal.file_ratio(final_ratio)

    # temporary creation of most likely values for leads etc.
    # will make ucomplex for storage
    # p.90 of KJ Diary 2 has PC values
    # I:\MSL\Private\Electricity\Ongoing\Farad\CalcCap\Cap1997\BU29OC97.XLS has assumed lead values
    # these will do for now, but remeasuring them in future is obviously a good idea.
    angf = ratio_cal.w
    rel_u = 0.05  # nominal 5% error in component measurements
    # lead A
    aR = 6.5128e-2
    aL = 4.269e-7
    za = ucomplex((aR + 1j * angf * aL), (rel_u * aR, rel_u * angf * aL),
                  label='za')
    # print(za)
    aG = 5e-11
    aC = 6.4915e-11
    ya = ucomplex((aG + 1j * angf * aC), (rel_u * aG, rel_u * angf * aC),
                  label='ya')
    # print(ya)
    yR = 2.606e-2
    yL = 2.417e-7
    zinta = ucomplex((yR + 1j * angf * yL), (rel_u * yR, rel_u * angf * yL),
                     label='zinta')
    # print(zinta)
    gppp = 2.09e-10
    cppp = 6.0527e-12
    y3 = ucomplex((gppp + 1j * angf * cppp),
                  (rel_u * gppp, rel_u * angf * cppp),
示例#7
0
                     xfrm, no_lead, relu)
    es16 = CAPACITOR('ES16', (0.0, 5.0e-12), (6e-10, 1.85e-10), (0, 0), w,
                     xfrm, no_lead, relu)
    gr10 = CAPACITOR('GR10', (0.0, 10.0e-12), (0, 0), (0, 0), w, no_lead,
                     no_lead, relu)
    gr100 = CAPACITOR('GR100', (0.0, 100.0e-12), (0, 0), (0, 0), w, no_lead,
                      no_lead, relu)
    gr1000a = CAPACITOR('GR1000A', (0.0, 1000.0e-12), (0, 0), (0, 0), w, xfrm,
                        no_lead, relu)
    gr1000b = CAPACITOR('GR1000B', (0.0, 1000.0e-12), (0, 0), (0, 0), w, xfrm,
                        no_lead, relu)
    es13_16 = PARALLEL(es13, es16, hv1, no_lead)

    # For now the starting point is an NMIA value of AH11C1
    cert = ucomplex((1.9e-6 * 100e-12 * 1.5915e3 + 1j * w * 99.999586e-12),
                    (0.6e-6 * 100e-12 * 1.5915e3, 0.11e-6 / 2 * w * 100e-12),
                    50)
    ah11c1.set_best_value(cert)  # nominal value remains as 100 pF
    c1 = ah11c1.best_value - ah11c1.lead_correction(
    )  # measured C slightly larger than certificate value
    r4 = scale.balance_dict['r4']
    a1 = scale.cap_ratio(r4, c1, True)
    ah11a1.set_best_value(
        a1 + ah11a1.lead_correction())  # this is the value with no leads
    r5 = scale.balance_dict['r5']
    b1 = scale.cap_ratio(r5, c1, True)
    ah11b1.set_best_value(
        b1 + ah11b1.lead_correction())  # this is the value with no leads
    r6 = scale.balance_dict['r6']
    a2 = scale.cap_ratio(r6, c1, True)
    ah11a2.set_best_value(
示例#8
0
    print(first, type(first))
    print(second, type(second))
    print(third, type(third))
    print(fourth, type(fourth))

    # mylist = []
    # mylist.append(x1)
    # mylist.append(x2)
    # store.save_gtc_real(mylist, 'results2.csv')
    # last_results = store.read_gtc_real('results1.csv')
    # print(last_results)
    # print(repr(last_results[1]))

    # Look at uncertain complex
    print('\n', 'Complex games')
    c1 = ucomplex((23.01 + 3.2j), (1.1, 0.22), 22, label='c1')
    c2 = ucomplex((2 * pi + 1j * pi), (1.1, 0.22), 22, label='c1')
    c3 = c1 + c2
    c4 = c1 * c2
    c5 = c3 / c4
    c6 = ucomplex((5 - 1.4j), 0.1, 11, label='c6')
    print(repr(c1))
    print(repr(c2))
    print(repr(c3))
    print(repr(c4))
    print(repr(c5))
    print(repr(c6))
    print(c6.x)
    aaa = store.ucomplex_to_dict(c1)
    print('aaa ', aaa, type(aaa))
    bbb = store.dict_to_ucomplex(aaa)