def getState(): if CTK.t == []: return import math referenceState = [] flowEquationSet = [] if CTK.__MAINTREE__ == 1: nzs = CPlot.getSelectedZones() fullBase = CPlot.isSelAFullBase(CTK.t, CTK.Nb, nzs) else: nzs = [] fullBase = 0 if CTK.__MAINTREE__ <= 0 or nzs == []: A = Internal.getBases(CTK.t) if A != []: A = A[0] else: return for n in A[2]: if n[0] == 'FlowEquationSet': flowEquationSet = n break for n in A[2]: if n[0] == 'ReferenceState': referenceState = n break elif fullBase > 0: A = CTK.t[2][fullBase] for n in A[2]: if n[0] == 'FlowEquationSet': flowEquationSet = n break for n in A[2]: if n[0] == 'ReferenceState': referenceState = n break else: nob = CTK.Nb[nzs[0]] + 1 noz = CTK.Nz[nzs[0]] A = CTK.t[2][nob][2][noz] for n in A[2]: if n[0] == 'FlowEquationSet': flowEquationSet = n break if flowEquationSet == []: B, r = Internal.getParentOfNode(CTK.t, A) for n in B[2]: if (n[0] == 'FlowEquationSet'): flowEquationSet = n break for n in A[2]: if n[0] == 'ReferenceState': referenceState = n break if referenceState == []: B, r = Internal.getParentOfNode(CTK.t, A) for n in B[2]: if (n[0] == 'ReferenceState'): referenceState = n break if flowEquationSet != []: # EquationDimension node = Internal.getNodeFromName1(flowEquationSet, 'EquationDimension') if node is not None: dim = Internal.getValue(node) if (dim == 2): VARS[0].set('2D') elif (dim == 3): VARS[0].set('3D') # GoverningEquations node = Internal.getNodeFromName1(flowEquationSet, 'GoverningEquations') if node is not None: eq = Internal.getValue(node) VARS[1].set(eq) # ReferenceState if referenceState == []: return else: state = referenceState # Mach node = Internal.getNodeFromName1(state, 'Mach') if node is not None: mach = Internal.getValue(node) VARS[2].set(str(mach)) else: mach = 0.5 # Reynolds node = Internal.getNodeFromName1(state, 'Reynolds') if node is not None: reynolds = Internal.getValue(node) VARS[3].set(str(reynolds)) else: reynolds = 1.e6 # Incidences node = Internal.getNodeFromName1(state, 'VelocityX') if node is not None: UInf = Internal.getValue(node) else: UInf = 0. node = Internal.getNodeFromName1(state, 'VelocityY') if node is not None: VInf = Internal.getValue(node) else: VInf = 0. node = Internal.getNodeFromName1(state, 'VelocityZ') if node is not None: WInf = Internal.getValue(node) else: WInf = 0. if abs(UInf) > 1.e-12: aly = math.atan(WInf / UInf) alz = math.atan(math.cos(aly) * VInf / UInf) else: aly = 0. alz = 0. VARS[4].set(str(alz * 180. / math.pi)) VARS[5].set(str(aly * 180. / math.pi)) # Modele de turbulence node = Internal.getNodeFromName(state, 'Density') if node is not None: Density = Internal.getValue(node) else: Density = 1. node = Internal.getNodeFromName(state, 'Rok') if node is not None: RokInf = Internal.getValue(node) else: RokInf = 1.e-6 Vit = UInf * UInf + VInf * VInf + WInf * WInf Vit = math.sqrt(Vit) if Vit > 1.e-10: TurbLevel = math.sqrt(2 * RokInf / (3 * Vit * Vit * Density)) else: TurbLevel = 1.e-4 MuInf = Density * Vit / max(reynolds, 1.e-10) # L=1 node = Internal.getNodeFromName(state, 'TurbulentSANuTildeDensity') if node is not None: RoNuTilde = Internal.getValue(node) else: RoNuTilde = 1.e-6 MutInf = RoNuTilde MutSMu = MutInf / max(MuInf, 1.e-12) VARS[9].set(str(MutSMu)) VARS[10].set(str(TurbLevel)) CTK.TXT.insert('START', 'State displayed.\n')
def setState(event=None): if CTK.t == []: return nzs = CPlot.getSelectedZones() # Mach mach = VARS[2].get() try: mach = float(mach) except: mach = 0. # Reynolds Re = VARS[3].get() try: Re = float(Re) except: Re = 1.e6 # Incidences alphaZ = VARS[4].get() try: alphaZ = float(alphaZ) except: alphaZ = 0. alphaY = VARS[5].get() try: alphaY = float(alphaY) except: alphaY = 0. # Grandeurs turb MutSMuInf = VARS[9].get() try: MutSMuInf = float(MutSMuInf) except: MutSMuInf = 0.2 TurbLevelInf = VARS[10].get() try: TurbLevelInf = float(TurbLevelInf) except: TurbLevelInf = 1.e-4 adim = '' ADIM = VARS[11].get() if ADIM == 'adim1(Ro,A,T)': adim = 'adim1' elif ADIM == 'adim2(Ro,U,T)': adim = 'adim2' elif ADIM == 'dim1(real UInf,TInf,PInf,Rgp=287.053)': adim = 'dim1' elif ADIM == 'dim2(real UInf,TInf,RoInf,Rgp=287.053)': adim = 'dim2' elif ADIM == 'dim3(real UInf,PInf,RoInf,Rgp=287.053)': adim = 'dim3' CTK.saveTree() if CTK.__MAINTREE__ <= 0 or nzs == []: nodes = Internal.getBases(CTK.t) fullBase = False else: fullBase = CPlot.isSelAFullBase(CTK.t, CTK.Nb, nzs) if fullBase > 0: nodes = [CTK.t[2][fullBase]] else: nodes = [] for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] nodes.append(CTK.t[2][nob][2][noz]) for b in nodes: p, r = Internal.getParentOfNode(CTK.t, b) C.addState2Node__(p[2][r], 'GoverningEquations', VARS[1].get()) if VARS[1].get() == 'NSTurbulent': if VARS[6].get() == 'SpalartAllmaras': C.addState2Node__(p[2][r], 'TurbulenceModel', 'OneEquation_SpalartAllmaras') elif VARS[6].get() == 'JonesLaunder(k-eps)': C.addState2Node__(p[2][r], 'TurbulenceModel', 'TwoEquation_JonesLaunder') elif VARS[6].get() == 'Wilcox(k-w)': C.addState2Node__(p[2][r], 'TurbulenceModel', 'TwoEquation_Wilcox') elif VARS[6].get() == 'MenterSST(k-w)': C.addState2Node__(p[2][r], 'TurbulenceModel', 'TwoEquation_MenterSST') C._addState(p[2][r], MInf=mach, alphaZ=alphaZ, alphaY=alphaY, ReInf=Re, MutSMuInf=MutSMuInf, TurbLevelInf=TurbLevelInf, adim=adim) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() if nzs == []: CTK.TXT.insert('START', 'State set in all bases.\n') elif fullBase > 0: CTK.TXT.insert('START', 'State set in selected base.\n') else: CTK.TXT.insert('START', 'State set in selected zones.\n')