def calc(self): ''' Calculates the posCoG of the outer wing tank. The cog of the fuel tank will be assumed to be constant for all filling levels. ''' xRoot = self.parent.aircraft.wing.xRoot.getValue() cRoot = self.parent.aircraft.wing.cRoot.getValue() sweep = self.parent.aircraft.wing.phiLE.getValue() tr = self.parent.aircraft.wing.taperRatio.getValue() halfSpan = self.parent.aircraft.wing.span.getValue() / 2. yBegin = 0.59 * halfSpan yEnd = 0.84 * halfSpan cBegin = calc_chord(cRoot, halfSpan, tr, yBegin) xBegin = xRoot + cmath.tan(sweep * cmath.pi / 180.) * yBegin cEnd = calc_chord(cRoot, halfSpan, tr, yEnd) xEnd = xRoot + cmath.tan(sweep * cmath.pi / 180.) * yEnd dy = yEnd - yBegin cog = calc_trapezoidCenterOfArea(xBegin, yBegin, cBegin, xEnd, cEnd, dy) return self.setValueCalc(cog[0]) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calcChortAtEta(self, eta, phiLE, phiTE, cRoot, etaKink, span, yFuselage): """ todo:: This is a copy of the function in flap.py maybe need to shift this somewhere else """ # if eta lies at the fuselage than return cRoot if eta <= yFuselage / span / 2.: return cRoot # elif eta lies in the inboard section return cRoot minus the bit lost due to leading edge sweep angle elif eta <= etaKink: l = span / 2.*eta - yFuselage cFront = l / tan(((90 - phiLE)) * rad) return cRoot - cFront # elif eta lies in the outboard section return cRoot minus the bit lost due to leading edge sweep angle + the bit gained due to the trailingedge angle elif eta > etaKink and eta < 1.: l1 = span / 2.*eta - yFuselage l2 = span / 2.*eta - span / 2.* etaKink cFront = l1 / tan(((90 - phiLE) * rad)) cBack = l2 / tan(((90 - phiTE) * rad)) return cRoot - cFront + cBack else: self.log.warning('VAMPzero CHORD: Calculation of chord at eta location called for invalid eta: %s' % str(eta)) raise ValueError
def calc(self): ''' Calculates the coordinates of the vertical tailplane center of gravity location :Source: Civil Jet Aircraft Design, L.R. Jenkinson and P. Simpkin and D. Rhodes, Butterworth Heinemann, 1999, p. 148 ''' span = self.parent.span.getValue() cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() phiTE = self.parent.phiTE.getValue() xRoot = self.parent.xRoot.getValue() cMAC = self.parent.cMAC.getValue() yMAC = self.parent.yMAC.getValue() bCG = span * 0.55 / 2. # Spanwise Location of the CoG cCG = cRoot - bCG * tan(phiLE * rad) + bCG * tan(phiTE * rad) #Calculate absolute Position of Wing Root from cMAC, yMAC and Pos xRoot = xRoot - (0.25 * cMAC + yMAC * tan(phiLE * rad)) #Calculated the X Location of the center of Gravity xCG = xRoot + tan(phiTE * rad) * bCG + 0.42 * cCG return self.setValueCalc(xCG) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calc(self): ''' Calculates the coordinates of the wings center of gravity location Calculation Formula for a swept wing is taken *Frontspar will be estimated to be at 25% of the chord *Rearspar will be estimated to be at 70% of the chord :Source: Civil Jet Aircraft Design, L.R. Jenkinson and P. Simpkin and D. Rhodes, Butterworth Heinemann, 1999, p. 148 ''' b = self.parent.span.getValue() cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() phiTE = self.parent.phiTE.getValue() xMAC = self.parent.xMAC.getValue() yMAC = self.parent.yMAC.getValue() bCG = b * 0.35 / 2. #Spanwise Location of the CoG cCG = cRoot - bCG * tan(phiLE * rad) + bCG * tan(phiTE * rad) #Calculate absolute Position of Wing Root from cMAC, yMAC and Pos # take the x position of the MAC # add the x distance to the chord of the cog 'tan(phiLE * rad) * (bCG - yMAC)' # add the distance to the front spar point '(0.25 * cCG)' # the center of gravity is at 70% of the distance between the front (0.25) and rear (0.7) spar '0.7 * (0.7 - 0.25) * cCG' xCG = xMAC + tan(phiLE * rad) * (bCG - yMAC) + 0.25 * cCG + (0.7 - 0.25) * cCG * 0.7 return self.setValueCalc(xCG) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calcFuselageMount(self): ''' Calculates the Z-location of the engine for the fuselage mounted engines from the engines diameter and the fuselage diameter. Takes into account a free angle of 12.5 deg in the x direction and 6deg in y direction ''' dEngine = self.parent.aircraft.engine.dEngine.getValue() lEngine = self.parent.aircraft.engine.lEngine.getValue() xEngine = self.parent.aircraft.engine.xEngine.getValue() yEngine = self.parent.aircraft.engine.yEngine.getValue() xLandingGear = self.parent.aircraft.landingGear.xLandingGear.getValue() yLandingGear = self.parent.aircraft.landingGear.yLandingGear.getValue() zLandingGear = self.parent.aircraft.landingGear.zLandingGear.getValue() # Estimate position in terms of x-axis deltaX = abs(xLandingGear-xEngine-lEngine*0.66) deltaZinX = tan(12.5*rad)*deltaX #Estimate position in y-axis deltaY = abs(yLandingGear-yEngine) deltaZinY = tan(6.*rad)*deltaY try: deltaZ = max(deltaZinX, deltaZinY) except: deltaZ = max(deltaZinX.real, deltaZinY.real) return self.setValueCalc(zLandingGear + deltaZ + 0.5* dEngine)
def oneArgFuncEval(function, value): # Evaluates functions that take a complex number input if function == "sin": return cmath.sin(value) elif function == "cos": return cmath.cos(value) elif function == "tan": return cmath.tan(value) elif function == "asin": return cmath.asin(value) elif function == "acos": return cmath.acos(value) elif function == "atan": return cmath.atan(value) elif function == "csc": return 1.0 / cmath.sin(value) elif function == "sec": return 1.0 / cmath.cos(value) elif function == "cot": return 1.0 / cmath.tan(value) elif function == "ln": return cmath.log(value) elif function == "sqr": return cmath.sqrt(value) elif function == "abs": return cmath.sqrt((value.real ** 2) + (value.imag ** 2)) elif function == "exp": return cmath.exp(value) if function == "sinh": return cmath.sinh(value) elif function == "cosh": return cmath.cosh(value) elif function == "tanh": return cmath.tanh(value) elif function == "asinh": return cmath.asinh(value) elif function == "acosh": return cmath.acosh(value) elif function == "atanh": return cmath.atanh(value) elif function == "ceil": return math.ceil(value.real) + complex(0, 1) * math.ceil(value.imag) elif function == "floor": return math.floor(value.real) + complex(0, 1) * math.floor(value.imag) elif function == "trunc": return math.trunc(value.real) + complex(0, 1) * math.trunc(value.imag) elif function == "fac": if value.imag == 0 and value < 0 and value.real == int(value.real): return "Error: The factorial function is not defined on the negative integers." return gamma(value + 1) elif function == "log": return cmath.log10(value)
def calc(self): ''' Calculates the horizontail tail's mean aerodynamic chord's x Location (tip) :Source: Simple Geometry based on phi and dihedral ''' yMAC = self.parent.yMAC.getValue() phi = self.parent.phiLE.getValue() dihedral = self.parent.dihedral.getValue() xRoot = self.parent.xRoot.getValue() return self.setValueCalc(xRoot + tan(phi * rad) * yMAC + tan(dihedral * rad) * yMAC) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def cdigamma(z) : """Digamma function with complex arguments""" z = complex(z) g = __lanczos_gamma c = __lanczos_coefficients zz = z if z.real < 0.5 : zz = 1 -z n=0. d=0. for k in range(len(c)-1,0,-1): dz =1./(zz+(k+1)-2); dd =c[k] * dz d = d + dd n = n - dd * dz d = d + c[0] gg = zz + g - 0.5 f = cm.log(gg) + (n/d - g/gg) if z.real<0.5 : f -= pi / cm.tan( pi * z) return f
def calcWingMount(self): ''' Calculates the Z-location of the engine from the engines diameter and the wing position. It is assumed that the engine is located underneath the wing. The calculation follows the picture from Stanfords online course, but does apply some simplifications: * As location x/c is choosen to be -0.1; h/c is taken for the easy curve and therefore should be ~ -0.09 * The end of the outer flow is chosen to be at 0.65% of overall engine length * As no curvature information for the nacelle is available h is parallel to the engine axis * values are relative to the leading edge of the wing :Source: http://adg.stanford.edu/aa241/propulsion/engineplacement.html ''' span = self.parent.aircraft.wing.span.getValue() eta = self.parent.aircraft.wing.etaEngine.getValue() phiLE = self.parent.aircraft.wing.phiLE.getValue() phiTE = self.parent.aircraft.wing.phiTE.getValue() cRoot = self.parent.aircraft.wing.cRoot.getValue() etaKink = self.parent.aircraft.wing.etaKink.getValue() yFuselage = self.parent.aircraft.wing.yFuselage.getValue() hOverC = -0.09 c = self.calcChortAtEta(eta, phiLE, phiTE, cRoot, etaKink, span, yFuselage) zRoot = self.parent.aircraft.wing.zRoot.getValue() dihedral = self.parent.aircraft.wing.dihedral.getValue() yEngine = self.parent.yEngine.getValue() dEngine = self.parent.dEngine.getValue() dZ = zRoot - dEngine / 2. + tan(dihedral * rad) * yEngine + hOverC * c return self.setValueCalc(dZ)
def cpacsExport(self, CPACSObj): ''' this methods exports all parameters nested in the component. Nested Components will be called as well. cpacsPath must be filled :Author: Jonas Jepsen :param CPACSObj: the CPACS object holding the data for export ''' # self.LoD.setValue(1) # level of detail [0,1] if self.location.getValue(): xRoot = self.xRoot.getValue() zRoot = self.zRoot.getValue() else: vtp_span = self.aircraft.vtp.span.getValue() vtp_phiLE = (self.aircraft.vtp.phiLE.getValue())*pi/180. xRoot = tan(vtp_phiLE)*vtp_span try: xRoot = xRoot.real except: pass zRoot = vtp_span createHTP(CPACSObj, self.id, xRoot, zRoot, self.airfoilr.tc.getValue(), self.airfoilt.tc.getValue(), self.cRoot.getValue(), self.cTip.getValue(), self.span.getValue(), self.phiLE.getValue(), self.dihedral.getValue(), self.LoD.getValue(), self.location.getValue()) super(wing, self).cpacsExport(CPACSObj)
def calc(self): ''' Calculates the z-position of the landing gear with respect to the required lift off angle (LoA) for a rotation without tail strike. This angle is estimated by a value of 12.5 degrees. Includes a minimum ground clearance criterion of 1m below the fuselage :Author: Patrick Goden ''' ltail = self.parent.aircraft.fuselage.ltail.getValue() lfus = self.parent.aircraft.fuselage.lfus.getValue() dfus = self.parent.aircraft.fuselage.dfus.getValue() xLG = self.parent.xLandingGear.getValue() LoA = 12.5 #[deg],assumption zLG = dfus/2. + (lfus - ltail - xLG) * tan(LoA*rad) try: if zLG.real < dfus.real/2.+1.: zLG = dfus/2.+1. except: pass return self.setValueCalc(-zLG)
def calc(self): ''' Calculates the leading edge postion of the strut tip from the wing geometry The calculation places the strut tip near the front spar of the wing. Hence, it should benefit aerostatic and maybe aeroelastic behavior as it helps the wing to wash out. :Source: Discussion at DLR-LY ''' xRoot_wing = self.parent.aircraft.wing.xRoot.getValue() cRoot_wing = self.parent.aircraft.wing.cRoot.getValue() phiLE_wing = self.parent.aircraft.wing.phiLE.getValue() span_wing = self.parent.aircraft.wing.span.getValue() cRoot = self.parent.cRoot.getValue() etaStrut = self.parent.etaStrut.getValue() depth = self.parent.depth.getValue() dfus = self.parent.aircraft.fuselage.dfus.getValue() # Go to the root position of the wing. # Move outwards along the leading edge # The front spar of the wing and and front spar of the strut shall meet # The front spar of the wing is always located at 10% of the root chord of the wing behind the leading edge # The strut spar is located at 30% of the profile as this is the location of the highest thickness. if 0.1 * cRoot_wing < 0.3 *cRoot: self.log.warn('VAMPzero STRUT: The leading edge of the strut exceeds the leading edge of the wing!') self.log.warn('VAMPzero STRUT: Decrease strut depth or adept spar positions.') loc = xRoot_wing + tan(phiLE_wing*rad) * span_wing/2. * (etaStrut-dfus/span_wing) + 0.1 * cRoot_wing - 0.3 *cRoot return self.setValueCalc(loc)
def calc(self): ''' Calculates the time for the descent segment :Source: adapted from DLR-LY-IL Performance Tool, J. Fuchte, 2011 ''' #T is the indice for top, b for bottom! altT = self.parent.atmosphere.hCR.getValue() altB = self.parent.atmosphere.hFL1500.getValue() sigmaT = self.parent.atmosphere.sigmaCR.getValue() sigmaB = self.parent.atmosphere.sigmaFL1500.getValue() IAS = self.parent.IASDESCENT.getValue() gamma = self.parent.gammaDESCENT.getValue() tasT = IAS * sigmaT tasB = IAS * sigmaB if sin(gamma * rad) != 0. and (tasT + tasB / 2.) != 0.: time = (altT - altB) * tan((90 - gamma) * rad) / ((tasT + tasB / 2.)) return self.setValueCalc(time) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calc(self): ''' Calculates the x-position of the landing gear with respekt to the eta- and xsi-coordinate of the wing. ''' span = self.parent.aircraft.wing.span.getValue() xRoot = self.parent.aircraft.wing.xRoot.getValue() cRoot = self.parent.aircraft.wing.cRoot.getValue() cTip = self.parent.aircraft.wing.cTip.getValue() phiLE = self.parent.aircraft.wing.phiLE.getValue() etaLG = self.parent.eta.getValue() xsiLG = self.parent.xsi.getValue() xLG = xRoot + span/2 * tan(phiLE*rad) * etaLG + xsiLG * (span/2 * tan(phiLE*rad) * (1-etaLG) + cTip - (span/2 * tan(phiLE*rad) + cTip - cRoot) * (1-etaLG)) return self.setValueCalc(xLG) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def test_tan_cc (self): src_data = [complex(i,i+1) for i in range(-5, 5, 2)] expected_result = tuple(cmath.tan(i) for i in src_data) src = gr.vector_source_c(src_data) op = gr.transcendental('tan', 'complex_float') snk = gr.vector_sink_c() self.tb.connect(src, op, snk) self.tb.run() result = snk.data() self.assertComplexTuplesAlmostEqual(expected_result, result, places=5)
def tan(*args, **kw): arg0 = args[0] if isinstance(arg0, (int, float, long)): return _math.tan(*args,**kw) elif isinstance(arg0, complex): return _cmath.tan(*args,**kw) elif isinstance(arg0, _sympy.Basic): return _sympy.tan(*args,**kw) else: return _numpy.tan(*args,**kw)
def calc(self): ''' Calculates the vertical tailplane's x location (MAC) ''' yMAC = self.parent.yMAC.getValue() phi = self.parent.phiLE.getValue() xRoot = self.parent.xRoot.getValue() return self.setValueCalc(xRoot + tan(phi * rad) * yMAC ) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def test_complex_functions(): for x in (list(range(10)) + list(range(-10,0))): for y in (list(range(10)) + list(range(-10,0))): z = complex(x, y)/4.3 + 0.01j assert exp(mpc(z)).ae(cmath.exp(z)) assert log(mpc(z)).ae(cmath.log(z)) assert cos(mpc(z)).ae(cmath.cos(z)) assert sin(mpc(z)).ae(cmath.sin(z)) assert tan(mpc(z)).ae(cmath.tan(z)) assert sinh(mpc(z)).ae(cmath.sinh(z)) assert cosh(mpc(z)).ae(cmath.cosh(z)) assert tanh(mpc(z)).ae(cmath.tanh(z))
def _n_Ztotal(self, Omega, j0, c10): fc = self.fc z_step = 1.0/self.channels phi = [-j - 1j*Omega for j in j0] psi = cmath.sqrt(-1j*Omega/fc.express["nD_d"]) nlJfix = fc.express["lJfix"]/fc.express["j_ref"] lbmupsi = self.fc.express["nl_d"]*self.fc.express["mu"]*psi sqrtphi = [cmath.sqrt(phii) for phii in phi] sinsqrtphi = [cmath.sin(s) for s in sqrtphi] sinlbmupsi = cmath.sin(lbmupsi) coslbmupsi = cmath.cos(lbmupsi) tanlbmupsi = cmath.tan(lbmupsi) y_v = [0.0]*(self.channels + 1) def function_rhs_ch(k): # all expressions below found in maxima: ABcommon = fc.express["nD_d"]*fc.express["mu"]*sinsqrtphi[k]*sqrtphi[k]*psi/(j0[k]*sinsqrtphi[k]*sqrtphi[k]*sinlbmupsi + c10[k]*fc.express["nD_d"]*fc.express["mu"]*phi[k]*psi*coslbmupsi) A = c10[k]*phi[k]*ABcommon B = -j0[k]*ABcommon/coslbmupsi+fc.express["nD_d"]*fc.express["mu"]*psi*tanlbmupsi return (A/nlJfix, (B - 1j*fc.express["xi2epsilon2"]*Omega)/nlJfix) c11peta = [0.0]*(self.channels + 1) # TODO: upload maxima script # found in maxima: c11peta[0] = (sinsqrtphi[0]*sqrtphi[0]*c10[0]*phi[0])/(j0[0]*sinsqrtphi[0]*sqrtphi[0] + c10[0]*fc.express["nD_d"]*fc.express["mu"]*phi[0]*psi/tanlbmupsi) Zloc = [0.0]*(self.channels + 1) # found in maxima: denominator = sinsqrtphi[0]*sqrtphi[0]*((c10[0]*phi[0])/(c11peta[0]*j0[0]) - 1.0) if denominator == 0.0: denominator = eff_zero Zloc[0] = -1.0 / denominator + self._n_Zccl(j0[0], sqrtphi[0]) invZtotal = 1.0/Zloc[0] for i in xrange(1, self.channels + 1): if self.num_method == 1: # Runge--Kutta method y_v[i] = RK_step(function_rhs_ch, (i-1)*2, y_v[i-1], z_step) ii = i*2 else: # finite-difference method coef = function_rhs_ch(i) y_v[i] = (y_v[i-1] + coef[0]*z_step)/(1.0 - z_step*coef[1]) ii = i # all expressions below found in maxima: c11peta[i] = y_v[i]/coslbmupsi - (sinsqrtphi[ii]*sqrtphi[ii]*(y_v[i]*j0[ii]/coslbmupsi - c10[ii]*phi[ii]))/(j0[ii]*sinsqrtphi[ii]*sqrtphi[ii] + c10[ii]*fc.express["nD_d"]*fc.express["mu"]*phi[ii]*psi/tanlbmupsi) denominator = sinsqrtphi[ii]*sqrtphi[ii]*((c10[ii]*phi[ii])/(c11peta[i]*j0[ii]) - 1.0) if denominator == 0.0: denominator = eff_zero Zloc[i] = -1.0 / denominator + self._n_Zccl(j0[ii], sqrtphi[ii]) invZtotal += 1.0/Zloc[i] invZtotal = invZtotal*z_step - (1.0/Zloc[0]+1.0/Zloc[-1])*z_step/2.0 self.y_v = y_v self.Zloc_v = Zloc return 1.0/invZtotal
def calc(self): """ Calculates the trailing edge sweep angle from leading edge angle, semispan and root and tip Chord """ cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() cTip = self.parent.cTip.getValue() b2 = self.parent.span.getValue() / 2.0 x1 = (tan(phiLE * rad) * b2 + cTip) - cRoot return self.setValueCalc(atan(x1 / b2) / rad)
def calc(self): ''' Calculates the value for the x Position of the tip section @Source: boeh_da @Discipline: Geometry/CPACS @Method: Parameter ''' span = self.parent.span.getValue() xRoot = self.parent.xRoot.getValue() phiLE = self.parent.phiLE.getValue() return self.setValueCalc(xRoot + span / 2. * tan(phiLE * rad))
def calcAirbus(self): ''' Calculates the aspectRatio from the wings quarterchord sweep High aspectRatio and high sweep can lead to tip stall :Source: Entwurfskolloquium, T. Engelbrecht, Airbus FPO, 2009, p. 8 :Source: changed values via Civil Jet Aircraft Design, L.R. Jenkinson and P. Simpkin and D. Rhodes, Butterworth Heinemann, 1999, database ''' self.setDeviation(0.1599) # needs to be set by the calc method when called for later use (deviation depends on the calc method) phi25 = self.parent.phi25.getValue() return self.setValueCalc(4.14 / (0.86 * tan(phi25 * rad)))
def calcTtail(self): ''' Calculates the X position of the horizontal tail from the xTip location of VTP ''' xRootVTP = self.parent.aircraft.vtp.xRoot.getValue() phiLEVTP = self.parent.aircraft.vtp.phiLE.getValue() spanVTP = self.parent.aircraft.vtp.span.getValue() return self.setValueCalc((xRootVTP + spanVTP * tan(phiLEVTP * pi / 180.) )) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def tan(self,command_position,args): try: if type(self.stack[command_position+1])==complex: value=cmath.tan(self.stack[command_position+1]) else: value=math.tan(self.stack[command_position+1]) self.stack.pop(command_position+1) self.stack[command_position]=value return command_position except: self.statstrings.append("Bad tangent attempted, ignoring command") self.error=True self.stack.pop(command_position) return command_position
def calc(self): ''' @Source: Dorbath p. 34 @Discipline: Geometry/CPACS @Method: Parameter ''' dihedral = self.parent.dihedral.getValue() yFuselage = self.parent.yFuselage.getValue() zFuselage = self.parent.zFuselage.getValue() span = self.parent.span.getValue() / 2. return self.setValueCalc(tan(dihedral * rad) * (span - yFuselage) + zFuselage) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calc(self): ''' Calculates the coordinates of the horizontal tailplane's center of gravity location :Source: Civil Jet Aircraft Design, L.R. Jenkinson and P. Simpkin and D. Rhodes, Butterworth Heinemann, 1999, p. 148 ''' span = self.parent.span.getValue() cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() phiTE = self.parent.phiTE.getValue() xRoot = self.parent.xRoot.getValue() bCG = span * 0.38 / 2. # Spanwise Location of the CoG cCG = cRoot - bCG * tan(phiLE * rad) + bCG * tan(phiTE * rad) #Calculated the X Location of the center of Gravity xCG = xRoot + tan(phiTE * rad) * bCG + 0.42 * cCG return self.setValueCalc(xCG) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calc(self): ''' Calculates the trailing edge sweep angle from leading edge angle, semispan and root and tip Chord ''' cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() cTip = self.parent.cTip.getValue() b2 = self.parent.span.getValue() x1 = (tan(phiLE * rad) * b2 + cTip) - cRoot return self.setValueCalc(90. - atan(b2 / x1) / rad) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def tan(x): """ Return the tangent of x, in radians. """ if isinstance(x,ADF): ad_funcs = list(map(to_auto_diff,[x])) x = ad_funcs[0].x ######################################## # Nominal value of the constructed ADF: f = tan(x) ######################################## variables = ad_funcs[0]._get_variables(ad_funcs) if not variables or isinstance(f, bool): return f ######################################## # Calculation of the derivatives with respect to the arguments # of f (ad_funcs): lc_wrt_args = [1./(cos(x))**2] qc_wrt_args = [2*sin(x)/(cos(x))**3] cp_wrt_args = 0.0 ######################################## # Calculation of the derivative of f with respect to all the # variables (Variable) involved. lc_wrt_vars,qc_wrt_vars,cp_wrt_vars = _apply_chain_rule( ad_funcs,variables,lc_wrt_args,qc_wrt_args, cp_wrt_args) # The function now returns an ADF object: return ADF(f, lc_wrt_vars, qc_wrt_vars, cp_wrt_vars) else: # try: # pythonic: fails gracefully when x is not an array-like object # return [tan(xi) for xi in x] # except TypeError: if x.imag: return cmath.tan(x) else: return math.tan(x.real)
def calc(self): ''' Calculates the leading edge sweep from quarter sweep, aspect ratio and taper ratio :Source: Aircraft Design: A Conceptual Approach, D. P. Raymer, AIAA Education Series, 1992, Second Edition, p.48 ''' self.setDeviation(0.0335) # needs to be set by the calc method when called for later use (deviation depends on the calc method) aspectRatio = self.parent.aspectRatio.getValue() phi25 = self.parent.phi25.getValue() taperRatio = self.parent.taperRatio.getValue() return self.setValueCalc(atan(tan(phi25 * rad) + ((1 - taperRatio) / (aspectRatio * (1 + taperRatio)))) / rad) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calc(self): """ :Source: Patrick Goden, Technische Universitaet Hamburg Harburg, Master Thesis :Source: FAR 25.335: Design airspeeds, FAR 25.253 High-speed characteristics) """ aspectRatioHPT = self.parent.aspectRatio.getValue() phi50HTP = self.parent.phi50.getValue() machCR = self.parent.aircraft.machCR.getValue() delta_MMO = 0.05 # margin to Maximum Operating Mach Number (MMO) may not less than 0.05 machCR_MMO = machCR + delta_MMO CLalphaHTP = (2 * pi * aspectRatioHPT) / ( 2 + (aspectRatioHPT ** 2 * (tan(phi50HTP * pi / 180) ** 2 + 1 - machCR_MMO ** 2) + 4) ** 0.5 ) return self.setValueCalc(CLalphaHTP)
def __new__(cls, argument): if isinstance(argument, (RealValue, Zero)): return FloatValue(math.tan(float(argument))) if isinstance(argument, (ComplexValue)): return ComplexValue(cmath.tan(complex(argument))) return MathFunction.__new__(cls)
def area(self): angle = radians(180 / 5) return self.size * self.size * 5 / (4 * tan(angle))
def p_expression_cot(t): 'expression : COT expression' t[0] = 1/cmath.tan(t[2])
def svgEndStyle(): """Finish group of styled svg items.""" svgTag('g', -1) # Actual output code total_size = 2*(scale+margin) svgHeader(total_size,total_size) svgStyle('fill="none" stroke="black" stroke-dasharray="2,4"') svgTag('circle cx="%d" cy="%d" r="%s"' % (scale+margin,scale+margin,scale)) svgEndStyle() svgStyle('fill="none" stroke="blue"') def circulate(pos): theta = 2*pi*pos/len(chords) x = int(abs(scale+margin+scale*cos(theta))) y = int(abs(scale+margin+scale*sin(theta))) return x,y for chord in firstpos.keys(): px,py = circulate(firstpos[chord]) qx,qy = circulate(lastpos[chord]) b = 0 if firstpos[chord] <= 0.25 * len(chords) and lastpos[chord] >= 0.75* len(chords): b = 1 r = int(abs(scale*tan(pi*(firstpos[chord]-lastpos[chord])/len(chords)))) svgTag('path d="M%d,%d A%d,%d 0 0,%d %d,%d"' % (px,py,r,r,b,qx,qy)) svgEndStyle() svgTrailer()
def execute_pcode(z, code, const_tab): MAX_STACK: int32 = 1024 stack = np.empty(MAX_STACK, dtype=complex64) sp: int32 = 0 pc: int32 = 0 cc: int8 = code[pc] zero: complex64 = 0 + 0j while cc != SEND: if cc == SPUSHC: stack[sp] = const_tab[code[pc + 1]] sp += 1 pc += 1 elif cc == SPUSHZ: stack[sp] = z sp += 1 elif cc == SADD: sp -= 2 stack[sp] += stack[sp + 1] sp += 1 elif cc == SSUB: sp -= 2 stack[sp] -= stack[sp + 1] sp += 1 elif cc == SMUL: sp -= 2 stack[sp] *= stack[sp + 1] sp += 1 elif cc == SDIV: sp -= 2 stack[sp] = stack[sp] / stack[ sp + 1] if stack[sp + 1] != zero and isfinite( stack[sp + 1]) and isfinite(stack[sp]) else zero sp += 1 elif cc == SPOW: sp -= 2 stack[sp] = stack[sp]**stack[sp + 1] sp += 1 elif cc == SNEG: stack[sp - 1] = -stack[sp - 1] elif cc == SSIN: stack[sp - 1] = sin(stack[sp - 1]) elif cc == SCOS: stack[sp - 1] = cos(stack[sp - 1]) elif cc == STAN: stack[sp - 1] = tan(stack[sp - 1]) elif cc == SASIN: stack[sp - 1] = asin(stack[sp - 1]) elif cc == SACOS: stack[sp - 1] = acos(stack[sp - 1]) elif cc == SATAN: stack[sp - 1] = atan(stack[sp - 1]) elif cc == SLOG: stack[sp - 1] = log(stack[sp - 1]) if stack[sp - 1] != zero else zero elif cc == SEXP: stack[sp - 1] = exp(stack[sp - 1]) pc += 1 cc = code[pc] return stack[0]
width = 7.0 frames = 100 for frame in range(frames): img = Image.new('RGB', (3 * size / 2, size), "black") # create a new black image pixels = img.load() # create the pixel map gamma = 0.5 - (0.5 * math.cos(frame * 3 * math.pi / frames)) for i in range(img.size[0]): # for every pixel: for j in range(img.size[1]): x = 1.5 * ((width * i / img.size[0]) - (width / 2)) y = (width * j / img.size[1]) - (width / 4) z = y + (1.0j * x) if frame < frames / 3: z = (gamma * cmath.tan(z)) + ((1 - gamma) * z) elif frame < 2 * frames / 3: z = (gamma * cmath.tan(z)) + ((1 - gamma) * cmath.exp(z)) else: z = (gamma * z) + ((1 - gamma) * cmath.exp(z)) H = 0.5 + (cmath.phase(z) / (2 * math.pi)) S = math.pow(np.abs(math.sin(2 * math.pi * np.abs(z))), 0.5) V = math.pow( np.abs( math.sin(z.real * 2 * math.pi) * math.sin(z.imag * 2 * math.pi)), 0.25) color = list(colorsys.hsv_to_rgb(H, S, V)) for k in range(3): color[k] = int(255 * color[k]) pixels[i, j] = tuple(color) # set the colour accordingly
def tan(x): if is_complex(x): return cmath.tan(x) return math.tan(x)
Power and Log Functions The cmath() module provides some useful functions for logarithmic and power operations. """ c = 1+2j print('e^c = ', cmath.exp(c)) print('log2(c) = ', cmath.log(c,2)) print('log10(c) = ', cmath.log10(c)) print('sqrt(c) = ', cmath.sqrt(c)) """ Trigonometric Functions """ c = 2+4j print('arc sine value:\n ', cmath.asin(c)) print('arc cosine value:\n ', cmath.acos(c)) print('arc tangent value:\n ', cmath.atan(c)) print('sine value:\n ', cmath.sin(c)) print('cosine value:\n ', cmath.cos(c)) print('tangent value:\n ', cmath.tan(c)) """ Hyperbolic Functions """ c = 2+4j print('Inverse hyperbolic sine value: \n', cmath.asinh(c)) print('Inverse hyperbolic cosine value: \n', cmath.acosh(c)) print('Inverse hyperbolic tangent value: \n', cmath.atanh(c)) print('Inverse sine value: \n', cmath.sinh(c)) print('Inverse cosine value: \n', cmath.cosh(c)) print('Inverse tangent value: \n', cmath.tanh(c))
# power and log functions c = 2 + 2j print('e^c =', cmath.exp(c)) print('log2(c) =', cmath.log(c, 2)) print('log10(c) =', cmath.log10(c)) print('sqrt(c) =', cmath.sqrt(c)) # trigonometric functions c = 2 + 2j print('arc sine =', cmath.asin(c)) print('arc cosine =', cmath.acos(c)) print('arc tangent =', cmath.atan(c)) print('sine =', cmath.sin(c)) print('cosine =', cmath.cos(c)) print('tangent =', cmath.tan(c)) # hyperbolic functions c = 2 + 2j print('inverse hyperbolic sine =', cmath.asinh(c)) print('inverse hyperbolic cosine =', cmath.acosh(c)) print('inverse hyperbolic tangent =', cmath.atanh(c)) print('hyperbolic sine =', cmath.sinh(c)) print('hyperbolic cosine =', cmath.cosh(c)) print('hyperbolic tangent =', cmath.tanh(c)) # classification functions print(cmath.isfinite(2 + 2j)) # True print(cmath.isfinite(cmath.inf + 2j)) # False
a = 1 + 1j #Be sure to have a coefficient in front of 'j'! b = complex(2,2) #Defines a complex number '2 + 2i' #Addition, subtraction, multiplication and division works without cmath real_coefficient = a.real complex_coefficient = a.imag polar_angle = cmath.phase(a) polar_radius = abs(a) rectangular_to_polar = cmath.polar(a) polar_to_rectangular = cmath.rect(1, math.pi) e_to_the_a = cmath.exp(a) #Takes 'e' to the power of 'a' square_root = cmath.sqrt(a) logarithm = cmath.log(a,b) #Logarithm of 'a' with base 'n' natural_logarithm = cmath.log(a) #Leaving out the 'n' makes this a natural logarithm log10 = cmath.log10(a) #Logarithm base 10 sine = cmath.sin(a) cosine = cmath.cos(a) tangent = cmath.tan(a) arcsine = cmath.asin(a) arccosine = cmath.acos(a) arctangent = cmath.atan(a) check_for_infinite_value = cmath.isinf(a)
def tan_usecase(x): return cmath.tan(x)
def TAN(df, price='Close'): """ Tangent Returns: list of floats = jhta.TAN(df, price='Close') """ return [cmath.tan(df[price][i]).real for i in range(len(df[price]))]
def tan(self): comp_value = cmath.tan(self.comp_value) secSquared = (2 / (cmath.cos(2 * self.comp_value)) + 1) comp_unc = self.comp_unc * secSquared # if y = tan^2(x) than U(y) = -U(x)sec^2(x) return Ucom(comp_value, comp_unc, self.name, self.dep)
assert abs(radians(30) - x) < 1e-14 assert abs(pi() - math.pi) < 1e-14 assert abs(atan2(sqrt(mpq(3, 4)), mpq(1, 2)) - radians(60)) < 1e-20 assert abs(atan2(sqrt(mpq(3, 4)), -mpq(1, 2)) - radians(120)) < 1e-20 assert abs(atan2(-sqrt(mpq(3, 4)), mpq(1, 2)) - radians(-60)) < 1e-20 #------------------------------------------------------------------------------ # Trig functions - complex version # Pick a value that gives distinctly different results for sin, cos , and tan. x = 1j * math.pi / 6 assert abs(sin(x) - cmath.sin(x)) < 1e-14 assert abs(cos(x) - cmath.cos(x)) < 1e-14 assert abs(tan(x) - cmath.tan(x)) < 1e-14 assert abs(asin(sin(x)) - x) < 1e-14 assert abs(acos(cos(x)) - x) < 1e-14 assert abs(atan(tan(x)) - x) < 1e-14 assert abs(cis(x) - (cos(x) + 1j * sin(x))) < 1e-14 #------------------------------------------------------------------------------ # Exponential and log functions - real version x = 0.5 assert abs(sqrt(x) - math.sqrt(x)) < 1e-14 assert abs(log(x) - math.log(x)) < 1e-14
def test_tan(self): self.assertAlmostEqual(complex(-0.000187346, 0.999356), cmath.tan(complex(3, 4)))
width = 11.0 frames = 100 for frame in range(frames): img = Image.new('RGB', (3 * size / 2, size), "black") # create a new black image pixels = img.load() # create the pixel map gamma = 0.5 - (0.5 * math.cos(frame * 2 * math.pi / frames)) for i in range(img.size[0]): # for every pixel: for j in range(img.size[1]): x = 1.5 * ((width * i / img.size[0]) - (width / 2)) y = (width * j / img.size[1]) - (width / 2) z = y + (1.0j * x) if frame < frames / 2: z = z + (gamma * (cmath.tan(z) + cmath.exp(z * gamma))) else: z = z + (gamma * (cmath.tan(gamma * z) + cmath.exp(z))) phase = cmath.phase(z) if phase < 0: phase = (2 * math.pi) + phase H = phase / (2 * math.pi) S = 1 V = 0.75 - (0.25 * math.cos(np.abs(z) * 3 * math.pi)) color = list(colorsys.hsv_to_rgb(H, S, V)) for k in range(3): color[k] = int(255 * color[k]) pixels[i, j] = tuple(color) # set the colour accordingly #img.show() img.save("expintanout{:04}.png".format(frame))
def tan(x): if isinstance(x, complex): return cmath.tan(x) else: return math.tan(x)
(np.sin(fi) - np.sin(hi)) * pi * lap / la))**2 grN = -0.05 * np.max(I0) grV = 1.1 * np.max(I0) #def U(psi): return (((np.sin((np.sin(fi)-np.sin(psi))*pi*b/la)))/((np.sin(fi)-np.sin(psi))*pi*b/la))**2*(((np.sin((np.sin(fi)-np.sin(psi))*pi*Nr*lap/la)))/((np.sin(fi)-np.sin(psi))*pi*lap/la))**2 print("_______________________________________________") print("Период решётки", round(lap * 10**6, 3), "мкм") nr = 1 Q = 2 * pi * la * dmax / (nr * lap * np.cos(fi)) #эффективная толщина решётки fi2 = cm.asin(n * np.sin(fi) / nv) #расчёт угла распространения луча в основной среде RperpTE = (((cm.sin(fi2 - fi))**2) / ((cm.sin(fi2 + fi))**2) ) #коэффициент отражения для параллельной поляризации (TE) RparalTM = (((cm.tan(fi2 - fi))**2) / ((cm.tan(fi2 + fi))**2) ) #коэффициент отражения для перпендикулярной поляризации (TM) #расчёт фазовых сдвигов для 10нм толщины материала (металла или сверхпроводника), формулы согласно дипломке RMM = RmM[10]**(1 / 2) RME = RmE[10]**(1 / 2) RTM = abs(RparalTM) RTE = abs(RperpTE) eiE = RperpTE / RTE eiM = RparalTM / RTM E1 = np.arctan(eiE.imag / eiE.real) M1 = np.arctan(eiM.imag / eiM.real) print("Отражается TE", round(RTE * 100, 1), "%") print("Отражается TM", round(RTM * 100, 1), "%") YM = ((r12M + r23M * np.exp(1j * delta)) / (1 + r12M * r23M * np.exp(1j * delta)))**2
def b(): #a=input() plt.plot([tan(x) for x in range(int(e.get()))]) plt.show()
def y(a): return Cnb - Clb*Izz/Ixx*math.tan(a/RAD).real
width = 7.0 frames = 160 for frame in range(frames): img = Image.new('RGB', (3 * size / 2, size), "black") # create a new black image pixels = img.load() # create the pixel map gamma = 0.5 - (0.5 * math.cos(frame * 4 * math.pi / frames)) for i in range(img.size[0]): # for every pixel: for j in range(img.size[1]): x = 1.5 * ((width * i / img.size[0]) - (width / 2)) y = (width * j / img.size[1]) - (width / 2) z = y + (1.0j * x) if frame < frames / 4: z = (gamma * cmath.tan(z)) + ((1 - gamma) * z) elif frame < frames / 2: if z == 0: continue z = (gamma * cmath.tan(z)) + ((1 - gamma) * cmath.log(z)) elif frame < 3 * frames / 4: if z == 0: continue z = (gamma * cmath.exp(z)) + ((1 - gamma) * cmath.log(z)) else: z = (gamma * cmath.exp(z)) + ((1 - gamma) * z) H = 0.5 + (cmath.phase(z) / (2 * math.pi)) S = math.pow(np.abs(math.sin(2 * math.pi * np.abs(z))), 0.5) V = math.pow( np.abs( math.sin(z.real * 2 * math.pi) * math.sin(z.imag * 2 * math.pi)), 0.25) V = max(V, 1 - S)
def transmissionplanecalculation(ports, width, plane_height, frequencyBand, rel_permittivity, rel_permittivity_frequency_extraction, metal_conductivity, dielectric_conductivity, vdd_thickness, loss_tangent, rel_permeability = 1): ''' requires consistent units in input Assumes port dimensions are much smaller than smallest wavelength -->Requires checker, otherwise add sync terms to z(w) Based on "Characterization of Power Distribution Networks", Novak, Miller ''' import cmath, os permeability = 4.0 * pi() * 1E-7 permittivity = 8.854187817E-12 speed_light = 299792458 limits = (1,12) # fmax = frequencyBand[-1] # print fmax # b = 1.0 # a = 1.0 # m_limit = int( fmax * 2.0 * b * rel_permittivity ** (1 / 2.0) / speed_light ) #Missing a factor # n_limit = int( fmax * 2.0 * a * rel_permittivity ** (1 / 2.0) / speed_light ) #Missing a factor m_limit = 20 n_limit = 20 # print m_limit, n_limit prmtvyFile = open(os.path.join(os.path.dirname(os.path.realpath(__file__)),'permittivity_plot.csv'),'w') print prmtvyFile print "\n" print "Freq\t\tPort00(R)\t\tPort00(I)\t\tPort10(R)\t\tPort10(I)\t\tPort11(R)\t\tPort11(I)" for frequency in frequencyBand: rad_freq = frequency * 2 * pi() skinDepth = ( 2 / ( rad_freq * metal_conductivity * rel_permeability * permeability ) )**(1 / 2.0) ksubm = (1.0 - 1.0j) / skinDepth zedsubs = ( 2 * ksubm / metal_conductivity ) / ( cmath.tan(ksubm * vdd_thickness) ) zedOmega = zedsubs + 1.0j * rad_freq * rel_permeability * permeability * plane_height #This is not calculating the limits and loss_tangent needs to be adjusted as well complex_calculated_Er = complex_rel_permittivity(frequency, rel_permittivity, rel_permittivity_frequency_extraction, limits, loss_tangent) whyOmega = ( 1 / plane_height ) * ( dielectric_conductivity + 1.0j * rad_freq * permittivity * complex_calculated_Er ) prmtvyFile.write("{:2E},{:2E},{:2E},\n".format(frequency,complex_calculated_Er.real,complex_calculated_Er.imag)) print "\n{:2E}\t".format(frequency), for port in range(0,len(ports)): for txport in range(port,len(ports)): # print "Port({},{})\t".format(port,txport), z_sum = 0.0 + 0.0j for m in range(0,m_limit + 1): for n in range(0,n_limit + 1): z_index = z_sum + cosignFunc(ports[port], ports[txport], width, m,n) * \ ( (xi(m,n) ** 2.0 ) / ( width[0] * width[1] * ( kaysubn(m,width[0])**2.0 + kaysubn(n,width[1])**2.0 + zedOmega * whyOmega ) ) ) z_sum = z_index # print zedOmega * z_sum, "\t", print "{:2E}\t{:2E}\t".format((zedOmega * z_sum).real,(zedOmega * z_sum).imag), prmtvyFile.close() return
import cmath print( "N-GON ROOT CALCULATOR - by dreamVoyager \n A generalized root formula for the length of the side of an " "n-sided regular " "polygon with area x. \n Also works with complex numbers.") while True: try: x = complex(input(">Input 1 (n-gon):").replace("i", "j")) y = complex(input(">Input 2 (Area):").replace("i", "j")) except ValueError: print("Invalid input.") continue top = 4 * complex(y) try: tang = cmath.tan(cmath.pi / complex(x)) except ZeroDivisionError: print("Error: Division by 0.") continue bot = complex(x) / complex(tang) fraction = complex(top) / complex(bot) shaperoot = cmath.sqrt(complex(fraction)) z = str(x).replace("j", "i") w = str(y).replace("j", "i") if 0 <= shaperoot.imag: op = "+" else: op = "-" print( f"The {z}-gon root of {w} is {round(shaperoot.real, 10)}{op}{abs(round(shaperoot.imag, 10))}i" )
# exponents and logs 'exp': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.exp}, 'ln': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.log}, 'log': {'fix': 'prefix', 'arglen': (1, 2), 'func': log}, 'sqrt': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.sqrt}, # trig 'hypot': {'fix': 'prefix', 'arglen': None, 'func': math.hypot}, 'sin': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.sin}, 'cos': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.cos}, 'tan': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.tan}, 'csc': {'fix': 'prefix', 'arglen': (1,), 'func': lambda x: 1 / cmath.sin(x)}, 'sec': {'fix': 'prefix', 'arglen': (1,), 'func': lambda x: 1 / cmath.cos(x)}, 'cot': {'fix': 'prefix', 'arglen': (1,), 'func': lambda x: 1 / cmath.tan(x)}, 'sinh': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.sinh}, 'cosh': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.cosh}, 'tanh': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.tanh}, 'asin': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.asin}, 'acos': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.acos}, 'atan': {'fix': 'prefix', 'arglen': (1, 2), 'func': atan}, 'acsc': {'fix': 'prefix', 'arglen': (1,), 'func': lambda x: cmath.asin(1 / x) if x != 0 else cmath.asin(math.inf)}, 'asec': {'fix': 'prefix', 'arglen': (1,), 'func': lambda x: cmath.acos(1 / x) if x != 0 else cmath.acos(math.inf)}, 'acot': {'fix': 'prefix', 'arglen': (1,), 'func': lambda x: cmath.asin(1 / x) if x != 0 else cmath.atan(math.inf)}, 'asinh': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.asinh}, 'acosh': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.acosh}, 'atanh': {'fix': 'prefix', 'arglen': (1,), 'func': cmath.atanh},
z = complex(x, y) print(cmath.sin(z)) #2.cos()-This function returns the cos of complex number passed as a argument. import cmath x = 2.0 y = 1.0 z = complex(x, y) print(cmath.cos(z)) #3.tan()- This function returns the tan of complex number passed as a argument. import cmath x = 1.0 y = 1.0 z = complex(x, y) print(cmath.tan(z)) #Inverse Trigonometric functions. #1.asin()- This function returns the arc sine of the complex number passed in as a argument. import cmath x = 1.0 y = 1.0 z = complex(x, y) print(cmath.asin(z)) #2.acos()- This function returns the arc cosine of complex number passed in as a argument. import cmath x = 2.0 y = 1.0 z = complex(x, y) print(cmath.acos(z))
def calcControl(self): ''' Calculates the reference area for the VTP from the moment of equilibrium as a result of one engine failure (OEI). The VTP has to compensate the remaining thrust from the active engine and additional the drag from the inactive engine. :Source: Patrick Goden, Technische Universitaet Hamburg Harburg, Master Thesis ''' wingrefArea = self.parent.aircraft.wing.refArea.getValue() rhoAP = self.parent.aircraft.atmosphere.rhoAP.getValue() aAP = self.parent.aircraft.atmosphere.aAP.getValue() lVT = self.parent.lVT.getValue() aspectRatioVPT = self.parent.aspectRatio.getValue() aspectRatio = self.parent.aircraft.wing.aspectRatio.getValue() oswald = self.parent.aircraft.wing.oswald.getValue() phi50VTP = self.parent.phi50.getValue() cD0 = self.parent.aircraft.cD0.getValue() dCDTO = self.parent.aircraft.wing.flap.dCDTO.getValue() dCDextendedLG = self.parent.aircraft.landingGear.dCDextendedLG.getValue( ) nEngine = self.parent.aircraft.engine.nEngine.getValue() yEngine = self.parent.aircraft.engine.yEngine.getValue() mTOM = self.parent.aircraft.mTOM.getValue() cLTO = self.parent.aircraft.cLTO.getValue() refArea = self.parent.aircraft.wing.refArea.getValue() g = 9.81 vs = sqrt(2 * mTOM * g / (rhoAP * cLTO * refArea)) v1 = vs v2 = 1.2 * vs #m_TOW, posCoG_fuel_pay_nt,posCoG_fuel_pay_tn,posCoG_fuel,m_PAX,posCoGMIN_fuel_pay0, posCoGMIN_fuel_pay, posCoGMAX_fuel_pay0,posCoGMAX_fuel_pay,m_TOW_fuel_pay = self.parent.aircraft.posCoGMAX.massTable() x1 = self.parent.aircraft.sTOFL.x1 machTO = v2 / aAP qTO = rhoAP / 2 * v2**2 length_m_TOW_fuel_pay = len( self.parent.aircraft.posCoGMAX.m_TOW_fuel_pay) cLTO_var = np.zeros((length_m_TOW_fuel_pay, 1)) cDTO_var = np.zeros((length_m_TOW_fuel_pay, 1)) thrust_TO_var = np.zeros((length_m_TOW_fuel_pay, 1)) beta_var = np.zeros((length_m_TOW_fuel_pay, 1)) refAreaControl_var = np.zeros((length_m_TOW_fuel_pay, 1)) Phi = 5 # in [deg], maximum value according to the regulation of FAA zeta = 25 # in [deg], maximum value c_Q_beta_profile = 6.1416 # in [1/rad], for the VTP profile C_Q_zeta = 1.0616 # in [1/rad] kappaVTP = c_Q_beta_profile * (1 - machTO**2) / (2 * pi) kappaVTP = kappaVTP.real C_Q_beta = (2 * pi * aspectRatioVPT) / ( 2 + sqrt(aspectRatioVPT**2 / kappaVTP**2 * (tan(phi50VTP * pi / 180)**2 + 1 - machTO**2) + 4) ) #in [1/rad], for the VTP C_Q_beta = C_Q_beta.real mu = 0.025 cLTO_var = (2 * self.parent.aircraft.posCoGMAX.m_TOW_fuel_pay * 9.81) / (rhoAP * v2**2 * wingrefArea) cDTO_var = cD0 + dCDTO + dCDextendedLG + cLTO_var**2 / ( pi * aspectRatio * oswald) beta_var = -cLTO_var / C_Q_beta * Phi beta_var = beta_var.real #Assumption: Thrust equals roll drag, aerodynamic drag and acceleration to v1 in x1 #additional drag from the inoperative engine (factor 1.25 for windmilling fan with big BPR), estimation by Scholz, Dieter: #Skript zur Vorlesung Flugzeugentwurf, Hochschule fuer Angewandte Wissenschaften Hamburg, 1999 thrust_TO_var = 1.25 * ( mu * self.parent.aircraft.posCoGMAX.m_TOW_fuel_pay * 9.81 + rhoAP / 2 * v1**2 * cDTO_var * wingrefArea + self.parent.aircraft.posCoGMAX.m_TOW_fuel_pay * v1**2 / (2 * x1)) / nEngine refAreaControl_var = (thrust_TO_var * yEngine) / ( qTO * lVT * (-C_Q_beta * beta_var * pi / 180 + C_Q_zeta * zeta * pi / 180)) refAreaControl = refAreaControl_var.max() return refAreaControl
if a[0] == '-': variables[a[1:]] = -1.0 * (variables[b] if b in variables else b) else: variables['-' + a] = -1.0 * (variables[b] if b in variables else b) return b OPERATIONS = { '+': lambda a, b: a + b, '-': lambda a, b: b - a, '/': lambda a, b: b / a, '*': lambda a, b: a * b, '**': lambda a, b: b**a, 'sin': lambda a: cmath.sin(a), 'cos': lambda a: cmath.cos(a), 'tan': lambda a: cmath.tan(a), 'atan': lambda a: cmath.atan(a), 'asin': lambda a: cmath.asin(a), 'acos': lambda a: cmath.acos(a), 'sqrt': lambda a: a**0.5, '%': lambda a, b: b % a, 'ln': lambda a: cmath.log(a), 'log': lambda a, b: cmath.log(b, a), 'rad': lambda a: math.radians(a.real), 'deg': lambda a: math.degrees(a.real), 'arg': lambda a: cmath.phase(a), 'abs': lambda a: (a.real * a.real + a.imag * a.imag)**0.5, 'Re': lambda a: a.real, 'Im': lambda a: a.imag, '=': variableAssign }
def cot(self): comp_value = 1 / cmath.tan(self.comp_value) csecSquared = -(2 / (1 - cmath.cos(2 * self.comp_value))) comp_unc = self.comp_unc * csecSquared # if y = cot^2(x) than U(y) = -U(x) csc^2(x) return Ucom(comp_value, comp_unc, self.name, self.dep)
def p_expression_tan(t): 'expression : TAN expression' t[0] = cmath.tan(t[2])
def tan(x): return cmath.tan(x)