ProcessedFiles = ['PVh=0.128037.txt','PVh=0.0677285.txt','PVh=0.0345033.txt']#,'PVh=0.0174767.txt',\ #'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] if MType == 'Small': ProcessedFiles = ['PTh=0.2.txt']#,'PTh=0.101015.txt'] dx = [0.2]#,0.101015] i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations = ProcessedMesh(Pfile) Mesh = HeliosMesh(Nodes,EdgeNodes,ElementEdges,Orientations) dt = 0.00000005*dx[i]**2 PDE = PDEFullMHD(Mesh,Re,Rm,Inu,InB,dt,theta) PDE.SetMHDBCandSource(ub,Eb,f,h) Solver = InexactNewtonTimeInt() time = np.arange(0,T,dt) for t in time: PDE.MHDComputeBC(t) PDE.MHDComputeSources(t) print('unx='+str(PDE.unx)) print('uny='+str(PDE.uny)) tempx = Solver.Newtoniter(PDE.MHDG,PDE.MHDConcatenate(PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.B,PDE.E,PDE.p),PDE.SetNumMHDDof(),1E-4,5000,PDE) PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.B,PDE.E,PDE.p = PDE.MHDUpdateInt(tempx,PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.B,PDE.E,PDE.p) PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.E = PDE.MHDUpdateBC(PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.E) i = i+1 SaveInmFile('funx','unx',PDE.unx) SaveInmFile('funy','uny',PDE.uny)
ProcessedFiles = ['PVh=0.128037.txt','PVh=0.0677285.txt','PVh=0.0345033.txt','PVh=0.0174767.txt',\ 'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 print(MType) for Pfile in ProcessedFiles: print('\n dx=' + str(dx[i])) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) #Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations,BottomToTop,LeftToRight,Corners = RetrieveAMRMesh("AMRmesh.txt") Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) dt = dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, exactu, InB, dt, theta) PDE.nMHDSetFlowBCandSource(exactu, f) PDE.nMHDsetElecMagField(exactB, exactE) PDE.nMHDFlowComputeBC() PDE.nMHDFlowupdatef() PDE.nComputeElecMagDOF() PDE.nMHDFlowupdatef() #PDE.unx,PDE.uny,PDE.umx,PDE.umy = PDE.FlowupdateBC(PDE.unx,PDE.uny,PDE.umx,PDE.umy) PDE.p = PDE.PhDOF(exactp) y = PDE.nMHDFlowG(PDE.FlowConcatenate()) ynx, yny, ymx, ymy, yp = PDE.nSplity(y) #print(yp) #err = PDE.TVhL2Norm(ynx,yny,ymx,ymy) v H1err = PDE.TVhH1Norm(ynx, yny, ymx, ymy) L2err = PDE.TVhL2Norm(ynx, yny, ymx, ymy)
ProcessedFiles = [ 'PVh=0.333333.txt', 'PVh=0.128037.txt', 'PVh=0.0677285.txt' ] #,'PVh=0.0345033.txt']#,'PVh=0.0174767.txt',\ #'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) dt = dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.nSetFlowBC(ub) Solver = InexactNewtonTimeInt() t = 0 PDE.nFlowComputeBC(t) #tempx = PDE.nFlowConcatenate() #for i in range(len(tempx)): # tempx[i] = i+1 #tempx[0] = 0.024031434275685715 PDE.nFlowSetSource(f) PDE.nFlowComputeSourceDOF() tempx = Solver.FlowSolve(PDE.nFlowG, PDE.nFlowConcatenate(), PDE.nNumFlowDOF(), 50, 1E-5) PDE.unx, PDE.uny, PDE.umx, PDE.umy, PDE.p = PDE.nFlowUpdateUnknownDOFs( tempx, PDE.unx, PDE.uny, PDE.umx, PDE.umy, PDE.p) #print(f'G(tempx)={PDE.nFlowG(tempx)}')
dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] if MType == 'Small': #ProcessedFiles = ['PTh=0.408248.txt','PTh=0.2.txt','PTh=0.101015.txt'] #ProcessedFiles = ['PTh=0.101015.txt'] ProcessedFiles = ['PTh=0.2.txt'] dx = [0.2, 0.101015] i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) dt = 0.00005 * dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.SetMHDBCandSource(exactu, exactE, f, h) Solver = InexactNewtonTimeInt() #time = np.arange(0,T,dt) time = [0] T = dt print(f'NumIntNodes={len(Mesh.NumInternalNodes)}') print(f'NumIntMidNodes={len(Mesh.NumInternalMidNodes)}') print(f'Edges={len(Mesh.EdgeNodes)}') print(f'Cells={len(Mesh.ElementEdges)}') for t in time: PDE.MHDComputeBC(t) PDE.MHDComputeSources(t) tempx = Solver.FlowSolve(
ProcessedFiles = ['PVh=0.128037.txt','PVh=0.0677285.txt','PVh=0.0345033.txt']#,'PVh=0.0174767.txt',\ #'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] if MType == 'Small': ProcessedFiles = ['PTh=0.2.txt']#,'PTh=0.101015.txt'] dx = [0.2]#,0.101015] i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations = ProcessedMesh(Pfile) Mesh = HeliosMesh(Nodes,EdgeNodes,ElementEdges,Orientations) dt = 0.001 PDE = PDEFullMHD(Mesh,Re,Rm,Inu,InB,dt,theta) PDE.MHDSetFlowBCandSource(ub,f) PDE.MHDsetElecMagField(B,E) PDE.ComputeElecMagDOF(0) PDE.MHDFlowupdatef(0) Solver = InexactNewtonTimeInt() T = 10*dt time = np.arange(0,T,dt) tempx = PDE.FlowConcatenate() for t in time: PDE.MHDFlowComputeBC(t) PDE.unx,PDE.uny,PDE.umx,PDE.umy = PDE.FlowUpdateBC(PDE.unx,PDE.uny,PDE.umx,PDE.umy) print('unx='+str(PDE.unx)) print('uny='+str(PDE.uny)) tempx = Solver.FlowSolve(PDE.FlowG,tempx,PDE.NumFlowDOF(),50,1E-5)
dx = [0.16666666666666666, 0.08333333333333333, 0.043478260869565216, 0.021739130434782608,\ 0.010989010989010988] if MType == 'Vor': ProcessedFiles = ['PVh=0.333333.txt','PVh=0.128037.txt','PVh=0.0677285.txt']#,'PVh=0.0345033.txt']#,'PVh=0.0174767.txt',\ #'PVh=0.0087872.txt'] dx = [0.333333,0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations = ProcessedMesh(Pfile) Mesh = HeliosMesh(Nodes,EdgeNodes,ElementEdges,Orientations) dt = dx[i]**2 PDE = PDEFullMHD(Mesh,Re,Rm,Inu,InB,dt,theta) Solver = InexactNewtonTimeInt() #tempx = PDE.nFlowConcatenate() #for i in range(len(tempx)): # tempx[i] = i+1 #tempx[0] = 0.024031434275685715 PDE.nMHDSetFlowBCandSource(exactu,f) PDE.nMHDsetElecMagField(exactB,exactE) PDE.nMHDFlowComputeBC() PDE.nMHDFlowupdatef() PDE.nComputeElecMagDOF() PDE.nMHDFlowupdatef() tempx = Solver.FlowSolve(PDE.nMHDFlowG,PDE.nFlowConcatenate(),PDE.nNumFlowDOF(),50,1E-5) PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.p = PDE.nFlowUpdateUnknownDOFs(tempx,PDE.unx,PDE.uny,PDE.umx,PDE.umy,PDE.p) d = PDE.nMHDFlowG(tempx)
] #ProcessedFiles = ['PTh=0.2.txt','PTh=0.101015.txt'] dx = [0.408024, 0.2, 0.101015] #dx = [0.408248,0.2,0.101015] #i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) #dt = 0.05*dx[i]**2 #i = i+1 #print(f'dt={dt}') #print(dt) dt = 0.001 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.SetFlowBCandSource(exactu, f) Solver = InexactNewtonTimeInt() time = [0] T = dt #time = np.arange(0,T,dt) #print(2*len(Mesh.NumInternalNodes)+2*len(Mesh.NumInternalMidNodes)+len(Mesh.ElementEdges)-1) #print(f'IntNodes={len(Mesh.NumInternalNodes)},IntMid={len(Mesh.NumInternalMidNodes)},Cells={len(Mesh.ElementEdges)}') #print(len(time)) tempx = PDE.FlowConcatenate() for t in time: PDE.FlowComputeBC(t) PDE.Flowupdatef(t) tempx = Solver.FlowSolve(PDE.FlowG, tempx, PDE.NumFlowDOF(), 50, 1E-5) #print(f'tempx[0]={tempx[0]}')
'PTh=0.408248.txt', 'PTh=0.2.txt', 'PTh=0.101015.txt' ] #ProcessedFiles = ['PTh=0.2.txt','PTh=0.101015.txt'] dx = [0.408024, 0.2, 0.101015] #dx = [0.408248,0.2,0.101015] #i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) #dt = 0.05*dx[i]**2 #i = i+1 #print(dt) dt = 1 / 1000 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.MHDSetFlowBCandSource(exactu, f) PDE.MHDsetElecMagField(exactB, exactE) Solver = InexactNewtonTimeInt() time = [0] T = dt #time = np.arange(0,T,dt) #print(2*len(Mesh.NumInternalNodes)+2*len(Mesh.NumInternalMidNodes)+len(Mesh.ElementEdges)-1) #print(f'IntNodes={len(Mesh.NumInternalNodes)},IntMid={len(Mesh.NumInternalMidNodes)},Cells={len(Mesh.ElementEdges)}') #print(len(time)) tempx1 = PDE.MHDFlowConcatenate() for t in time: PDE.MHDFlowComputeBC(t) PDE.MHDFlowupdatef(t) PDE.ComputeElecMagDOF(t)
'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 print(MType) for Pfile in ProcessedFiles: print('\n dx=' + str(dx[i])) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) #Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations,BottomToTop,LeftToRight,Corners = RetrieveAMRMesh("AMRmesh.txt") Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) #dt = dx[i]**2 dt = 1 / 1000 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.MHDSetFlowBCandSource(exactu, f) PDE.MHDsetElecMagField(exactB, exactE) xp = PDE.PhDOF(exactp) PDE.MHDFlowComputeBC(0) PDE.MHDFlowupdatef(0) PDE.ComputeElecMagDOF(0) PDE.MHDFlowupdatef(0) tempxun = PDE.NodalDOFs(ut, Mesh.Nodes) xunx, xuny = PDE.DecompIntoCoord(tempxun) tempxum = PDE.NodalDOFs(ut, Mesh.MidNodes) xumx, xumy = PDE.DecompIntoCoord(tempxum) y = PDE.MHDFlowG(PDE.MHDFloweConcatenate(xunx, xuny, xumx, xumy, xp)) ynx, yny, ymx, ymy, yp = PDE.MHDFlowSplity(y) #print(yp) #err = PDE.TVhL2Norm(ynx,yny,ymx,ymy) v
#ProcessedFiles = ['PTh=0.408248.txt','PTh=0.2.txt','PTh=0.101015.txt'] ProcessedFiles = ['PTh=0.101015.txt'] dx = [0.408248, 0.2, 0.101015] i = 0 for Pfile in ProcessedFiles: print(Pfile) uL.append(Pfile) BL.append(Pfile) EL.append(Pfile) pL.append(Pfile) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) print(Mesh.NumInternalNodes) dt = 0.00005 * dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.SetMHDBCandSource(exactu, exactE, f, h) Solver = InexactNewtonTimeInt() time = np.arange(0, T, dt) for t in time: Masserr = 0 for j in range(len(Mesh.ElementEdges)): lunx, luny, lumx, lumy = PDE.GetLocalTVhDOF( j, PDE.unx, PDE.uny, PDE.umx, PDE.umy) divu, A = PDE.DIVu(j, lunx, luny, lumx, lumy) Masserr = Masserr + PDE.PhInProd(i, divu * A, divu * A) Masserr = math.sqrt(Masserr) divB = PDE.BDivSquared(PDE.B) divus.append(Masserr) divBs.append(divB)
ProcessedFiles = ['PVh=0.128037.txt','PVh=0.0677285.txt','PVh=0.0345033.txt','PVh=0.0174767.txt',\ 'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 print(MType) for Pfile in ProcessedFiles: print('\n dx=' + str(dx[i])) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) #Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations,BottomToTop,LeftToRight,Corners = RetrieveAMRMesh("AMRmesh.txt") Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) dt = dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, initu, initB, dt, theta) PDE.SetMHDBCandSource(exactu, exactE, f, h) PDE.MHDComputeBC(0) PDE.MHDComputeSources(0) def ut(xv): return exactu(xv, dt) def Bt(xv): return exactB(xv, dt) def Et(xv): return exactE(xv, theta * dt) def pt(xv): return exactp(xv, theta * dt)
ProcessedFiles = [ 'PVh=0.128037.txt', 'PVh=0.0677285.txt', 'PVh=0.0345033.txt' ] #,'PVh=0.0174767.txt',\ #'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 for Pfile in ProcessedFiles: print(Pfile) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) dt = dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, Inu, InB, dt, theta) PDE.SetElectroBCAndSource(h, Eb) Solver = InexactNewtonTimeInt() time = np.arange(0, T, dt) for t in time: PDE.ElectroComputeBC(t) PDE.Electroupdateh(t) tempx = Solver.Newtoniter(PDE.ElectroG, PDE.ElectroConcatenate(), PDE.NumElectroDOF(), 1E-5, 50) PDE.ElectroUpdateUnknownDOFs(tempx) PDE.E = PDE.ElectroupdateBC(PDE.E) def exactB(xv): Bx = 0 By = math.cos(xv[0] + T) return np.array([Bx, By])
ProcessedFiles = ['PVh=0.128037.txt','PVh=0.0677285.txt','PVh=0.0345033.txt','PVh=0.0174767.txt',\ 'PVh=0.0087872.txt'] dx = [0.12803687993289598, 0.06772854614785964, 0.03450327796711771, 0.017476749542968805,\ 0.008787156237382746] i = 0 print(MType) for Pfile in ProcessedFiles: print('\n dx=' + str(dx[i])) Nodes, EdgeNodes, ElementEdges, BoundaryNodes, Orientations = ProcessedMesh( Pfile) #Nodes,EdgeNodes,ElementEdges,BoundaryNodes,Orientations,BottomToTop,LeftToRight,Corners = RetrieveAMRMesh("AMRmesh.txt") Mesh = HeliosMesh(Nodes, EdgeNodes, ElementEdges, Orientations) dt = dx[i]**2 PDE = PDEFullMHD(Mesh, Re, Rm, exactu, InB, dt, theta) PDE.nSetFlowBC(exactu) PDE.nFlowComputeBC(0) #PDE.unx,PDE.uny,PDE.umx,PDE.umy = PDE.FlowupdateBC(PDE.unx,PDE.uny,PDE.umx,PDE.umy) PDE.p = PDE.PhDOF(exactp) y = PDE.nFlowG(PDE.FlowConcatenate()) ynx, yny, ymx, ymy, yp = PDE.nSplity(y) print(yp) #err = PDE.TVhL2Norm(ynx,yny,ymx,ymy) v H1err = PDE.TVhH1Norm(ynx, yny, ymx, ymy) L2err = PDE.TVhL2Norm(ynx, yny, ymx, ymy) perr = PDE.PhL2Norm(yp) print('H1Err=' + str(H1err**2)) print('L2Err=' + str(L2err**2))