def coreZgtc(self, excite, frequency): """ 'excite' is the excitation level in % returns a complex impedance based on empirical fits...this works wit ureal for x """ x = excite inductance = (self.a1*GTC.log(x)+self.a2*x+self.a3)*1e-3 resistance = self.a4*GTC.log(x)+self.a5*x**2+self.a6/GTC.sqrt(x) return resistance + 1j*2*math.pi*frequency*inductance
def Calculate_Wr(temp_C): # constants for temperature range -259.3467 C to 0 C A = [ -2.13534729, #A0 3.18324720, #A1 -1.80143597, #A2 0.71727204, #A3 0.50344027, #A4 -0.61899395, #A5 -0.05332322, #A6 0.28021362, #A7 0.10715224, #A8 -0.29302865, #A9 0.04459872, #A10 0.11868632, #A11 -0.05248134 ] #A12 # constants for temperature range 0 C to 961.78 C C = [ 2.78157254, #C0 1.64650916, #C1 -0.13714390, #C2 -0.00649767, #C3 -0.00234444, #C4 0.00511868, #C5 0.00187982, #C6 -0.00204472, #C7 -0.00046122, #C8 0.00045724 ] #C9 temp_K = Conv_celsius2kelvin(float(temp_C)) Wr = 1 if (temp_C >= -259.3467) and (temp_C < 0): for i in range(13): if i == 0: sum = A[0] else: sum = sum + A[i] * GTC.pow( (GTC.log(temp_K / 273.16) + 1.5) / 1.5, i) Wr = GTC.exp(sum) elif (temp_C >= 0) and (temp_C <= 961.78): for i in range(10): if i == 0: sum = C[0] else: sum = sum + C[i] * GTC.pow((temp_K - 754.15) / 481, i) Wr = sum else: print("temperature out of range") print("Wr({})={}".format(temp_C, Wr)) return Wr
def calculate_Wr_unc(temp_C, verbose=False): """ Function calculate reference function Wr for temperature t with uncertainty as a urealtype :param temp_C: :param verbose: :return: """ # constants for temperature range -259.3467 C to 0 C A = [ -2.13534729, # A0 3.18324720, # A1 -1.80143597, # A2 0.71727204, # A3 0.50344027, # A4 -0.61899395, # A5 -0.05332322, # A6 0.28021362, # A7 0.10715224, # A8 -0.29302865, # A9 0.04459872, # A10 0.11868632, # A11 -0.05248134 ] # A12 # constants for temperature range 0 C to 961.78 C C = [ 2.78157254, # C0 1.64650916, # C1 -0.13714390, # C2 -0.00649767, # C3 -0.00234444, # C4 0.00511868, # C5 0.00187982, # C6 -0.00204472, # C7 -0.00046122, # C8 0.00045724 ] # C9 temp_C = float2GTC(temp_C) temp_K = conv_celsius2kelvin(temp_C) Wr = 1 if (temp_C.x >= -259.3467) and (temp_C.x < 0): for i in range(13): if i == 0: sum = A[0] else: sum = sum + A[i] * GTC.pow( (GTC.log(temp_K / 273.16) + 1.5) / 1.5, i) Wr = GTC.exp(sum) elif (temp_C.x >= 0) and (temp_C.x <= 961.78): for i in range(10): if i == 0: sum = C[0] else: sum = sum + C[i] * GTC.pow((temp_K - 754.15) / 481, i) Wr = sum else: print("temperature out of range") if verbose: print("Wr({}, unc std:{})={}, unc std:{}".format( temp_C.x, temp_C.u, Wr.x, Wr.u)) return Wr
if __name__ == "__main__": #use fitted impedance coefficients to define behviour of core impedance this_core = [11.7204144319303, -0.0273771774408702, 29.7364068940134, 3.90272331971033, 0.000243735060998679, 5.8544055409592] this_CT = CT(this_core) #should look at GTC output when model inputs have uncertainty from the fits a1 = GTC.ureal(11.7204144319303,0.346683597109428,34,label ='a1',dependent = True) a2 = GTC.ureal(-0.0273771774408702,0.0136282110753501,34,label ='a2',dependent = True) a3 = GTC.ureal(29.7364068940134,0.695696459888704,34,label ='a3',dependent = True) GTC.set_correlation(-0.826126693986887, a1, a2) GTC.set_correlation(-0.881067593505553, a1, a3) GTC.set_correlation(0.551078899199967, a2, a3) a4 = GTC.ureal(3.90272331971033,0.0859519946028212,34,label ='a4',dependent = True) a5 = GTC.ureal(0.000243735060998679,0.0000527749402101903,34,label ='a5',dependent = True) a6 = GTC.ureal(5.8544055409592,0.501146466659668,34,label ='a6',dependent = True) GTC.set_correlation(-0.679730943215757, a4, a5) GTC.set_correlation(-0.562016044432279, a4, a6) GTC.set_correlation(0.303221134084321, a5, a6) this_core_gtc = [a1,a2,a3,a4,a5,a6] this_CT_gtc = CT(this_core_gtc) print GTC.log(a1) x = GTC.ureal(100,1) answer = this_CT_gtc.coreZgtc(x, 50) error = repr(answer.real) print error burden = GTC.ucomplex((0.186 + 0.12j),(0.0001,0.0001)) print(this_CT.burdenZgtc(burden, 5.0))