From: michael Date: Mon, 30 Nov 2020 13:11:43 +0000 (+0100) Subject: Corrected indentation, expected values and missing parenthesis X-Git-Tag: V9_7_0~112 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c662adafb6253a4149f4eb168e72817fa0db299;p=tools%2Fsolverlab.git Corrected indentation, expected values and missing parenthesis --- diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_DelaunayTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_DelaunayTriangles.py index 50b1a34..06622d2 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_DelaunayTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_DelaunayTriangles.py @@ -31,16 +31,16 @@ def convergence_StationaryDiffusion_2DFE_Dirichlet_DelaunayTriangles(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1 - assert max_sol_num<1.2 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-1 + assert max_sol_num<1.2 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -66,7 +66,7 @@ def convergence_StationaryDiffusion_2DFE_Dirichlet_DelaunayTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FE for diffusion on 2D Delaunay triangles meshes: scheme order is ", -a + print( "FE for diffusion on 2D Delaunay triangles meshes: scheme order is ", -a) assert abs(a+2)<0.02 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles.py index b441469..8d2bd2f 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles(): ### 2D FE right triangles mesh method = 'FE' BC = 'Dirichlet' - meshList=[5,20,50,100, 200,400] + meshList=[5,20,50,100, 200] nbMeshes=len(meshList) error_tab=[0]*nbMeshes mesh_size_tab=[0]*nbMeshes @@ -30,16 +30,16 @@ def convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-0.001 - assert max_sol_num<1.003 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-0.001 + assert max_sol_num<1.003 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -65,7 +65,7 @@ def convergence_StationaryDiffusion_2DFE_Dirichlet_RightTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FE for diffusion on 2D right triangle meshes: scheme order is ", -a + print( "FE for diffusion on 2D right triangle meshes: scheme order is ", -a) assert abs(a+2)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Neumann_DelaunayTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Neumann_DelaunayTriangles.py index 24d7bd9..fb46aca 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Neumann_DelaunayTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFE_Neumann_DelaunayTriangles.py @@ -28,19 +28,19 @@ def convergence_StationaryDiffusion_2DFE_Neumann_DelaunayTriangles(): curv_abs=np.linspace(0,sqrt(2),resolution+1) plt.close('all') i=0 - testColor="Orange (not order 2), singular matrix" + testColor="Red, to be investigated" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1 - assert max_sol_num<1.2 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>=-1 + assert max_sol_num<1.2 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -66,7 +66,7 @@ def convergence_StationaryDiffusion_2DFE_Neumann_DelaunayTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FE for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a + print( "FE for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a) assert abs(a+0.82)<0.02 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles.py index 4e95981..29234f1 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFE_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles(): ### 2D FE right triangles mesh method = 'FE' BC = 'Neumann' - meshList=[5,20,50,100, 200,400] + meshList=[5,20,50,100, 200] nbMeshes=len(meshList) error_tab=[0]*nbMeshes mesh_size_tab=[0]*nbMeshes @@ -27,19 +27,19 @@ def convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles(): curv_abs=np.linspace(0,sqrt(2),resolution+1) plt.close('all') i=0 - testColor="Orange (not order 2), singular matrix" + testColor="Red, to be investigated" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1.22 - assert max_sol_num<1. - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-1.22 + assert max_sol_num<1. + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -65,7 +65,7 @@ def convergence_StationaryDiffusion_2DFE_Neumann_RightTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FE for diffusion on 2D right triangle meshes: scheme order is ", -a + print( "FE for diffusion on 2D right triangle meshes: scheme order is ", -a) assert abs(a+0.91)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_DelaunayTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_DelaunayTriangles.py index abb8bfd..6c900b1 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_DelaunayTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_DelaunayTriangles.py @@ -31,16 +31,16 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_DelaunayTriangles(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1 - assert max_sol_num<1.2 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-1 + assert max_sol_num<1.2 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -66,7 +66,7 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_DelaunayTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a + print( "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a) assert abs(a+0.6)<0.02 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_EquilateralTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_EquilateralTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_EquilateralTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_EquilateralTriangles.py index 7c6967f..2821c44 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_EquilateralTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_EquilateralTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_EquilateralTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_EquilateralTriangles.py @@ -33,15 +33,15 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_EquilateralTriangles(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1 - assert max_sol_num<1.2 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + assert min_sol_num>-1 + assert max_sol_num<1.2 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -67,7 +67,7 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_EquilateralTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D Equilateral triangle meshes: scheme order is ", -a + print( "FV for diffusion on 2D Equilateral triangle meshes: scheme order is ", -a) assert abs(a+1.97)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Hexagons/convergence_StationaryDiffusion_2DFV_Dirichlet_Hexagons.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Hexagons/convergence_StationaryDiffusion_2DFV_Dirichlet_Hexagons.py index 06cfd1f..e6adc3e 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Hexagons/convergence_StationaryDiffusion_2DFV_Dirichlet_Hexagons.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Hexagons/convergence_StationaryDiffusion_2DFV_Dirichlet_Hexagons.py @@ -31,16 +31,16 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_Hexagons(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1 - assert max_sol_num<1.2 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-1 + assert max_sol_num<1.2 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -66,7 +66,7 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_Hexagons(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D hexagon meshes: scheme order is ", -a + print( "FV for diffusion on 2D hexagon meshes: scheme order is ", -a) assert abs(a+1.94)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_RightTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_RightTriangles.py index d4e51f9..02c0d12 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_RightTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_RightTriangles/convergence_StationaryDiffusion_2DFV_Dirichlet_RightTriangles.py @@ -30,16 +30,16 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_RightTriangles(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-0.001 - assert max_sol_num<1.01 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-0.001 + assert max_sol_num<1.01 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -65,7 +65,7 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_RightTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D right triangle meshes: scheme order is ", -a + print( "FV for diffusion on 2D right triangle meshes: scheme order is ", -a) assert abs(a+0.02)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Squares/convergence_StationaryDiffusion_2DFV_Dirichlet_Squares.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Squares/convergence_StationaryDiffusion_2DFV_Dirichlet_Squares.py index 14b7b9e..43d2132 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Squares/convergence_StationaryDiffusion_2DFV_Dirichlet_Squares.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Dirichlet_Squares/convergence_StationaryDiffusion_2DFV_Dirichlet_Squares.py @@ -27,18 +27,18 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_Squares(): curv_abs=np.linspace(0,sqrt(2),resolution+1) plt.close('all') i=0 - testColor="Green" + testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num> 1e-5 - assert max_sol_num<1.04 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + my_mesh=cm.Mesh(0,1,nx,0,1,nx) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + assert min_sol_num> 1e-5 + assert max_sol_num<1.04 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -63,7 +63,7 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_Squares(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D square meshes: scheme order is ", -a + print( "FV for diffusion on 2D square meshes: scheme order is ", -a) assert abs(a+2)<0.1 # Plot of convergence curve @@ -107,4 +107,4 @@ def convergence_StationaryDiffusion_2DFV_Dirichlet_Squares(): with open('Convergence_Poisson_2DFV_'+mesh_name+'.json', 'w') as outfile: json.dump(convergence_synthesis, outfile) if __name__ == """__main__""": - convergence_StationaryDiffusion_2DFV_Dirichlet_Squares() + convergence_StationaryDiffusion_2DFV_Dirichlet_Squares() diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Neumann_DelaunayTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Neumann_DelaunayTriangles.py index c22b1f3..b42965f 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Neumann_DelaunayTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_DelaunayTriangles/convergence_StationaryDiffusion_2DFV_Neumann_DelaunayTriangles.py @@ -31,16 +31,16 @@ def convergence_StationaryDiffusion_2DFV_Neumann_DelaunayTriangles(): testColor="Red"#Linear solver fails # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1 - assert max_sol_num<1.2 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-1 + assert max_sol_num<1.2 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -66,7 +66,7 @@ def convergence_StationaryDiffusion_2DFV_Neumann_DelaunayTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a + print( "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a) assert abs(a+0.6)<0.02 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles.py index 01eeb8e..0728abf 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_RightTriangles/convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles(): ### 2D FV right triangles mesh method = 'FV' BC = 'Neumann' - meshList=[5,20,50,100, 200,400] + meshList=[5,20,50,100, 200] nbMeshes=len(meshList) error_tab=[0]*nbMeshes mesh_size_tab=[0]*nbMeshes @@ -27,19 +27,19 @@ def convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles(): curv_abs=np.linspace(0,sqrt(2),resolution+1) plt.close('all') i=0 - testColor="Orange \n (suspicious order 0 convergence), singular matrix"#Convergence of the linear solver if direct solver. Scheme seems to diverge (order -0.005) + testColor="Red, to be investigated"#Convergence of the linear solver if direct solver. Scheme seems to diverge (order -0.005) # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,1) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>-1.22 - assert max_sol_num<1. - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>-1.22 + assert max_sol_num<1. + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -65,7 +65,7 @@ def convergence_StationaryDiffusion_2DFV_Neumann_RightTriangles(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D right triangle meshes: scheme order is ", -a + print( "FV for diffusion on 2D right triangle meshes: scheme order is ", -a) assert abs(a-0.005)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_Squares/convergence_StationaryDiffusion_2DFV_Neumann_Squares.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_Squares/convergence_StationaryDiffusion_2DFV_Neumann_Squares.py index cd3c35c..125e283 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_Squares/convergence_StationaryDiffusion_2DFV_Neumann_Squares.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/2DFV_Neumann_Squares/convergence_StationaryDiffusion_2DFV_Neumann_Squares.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_2DFV_Neumann_Squares(): ### 2D FV Square mesh method='FV' BC = 'Neumann' - meshList=[5,20,50,100, 200,400] + meshList=[5,20,50,100, 200] nbMeshes=len(meshList) error_tab=[0]*nbMeshes mesh_size_tab=[0]*nbMeshes @@ -27,18 +27,18 @@ def convergence_StationaryDiffusion_2DFV_Neumann_Squares(): curv_abs=np.linspace(0,sqrt(2),resolution+1) plt.close('all') i=0 - testColor="Green, despite singular matrix" + testColor="Red, to be investigated" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num> -1. - assert max_sol_num<1. - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + my_mesh=cm.Mesh(0,1,nx,0,1,nx) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + assert min_sol_num> -1. + assert max_sol_num<1. + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -63,7 +63,7 @@ def convergence_StationaryDiffusion_2DFV_Neumann_Squares(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 2D square meshes: scheme order is ", -a + print( "FV for diffusion on 2D square meshes: scheme order is ", -a) assert abs(a+2)<0.1 # Plot of convergence curve @@ -107,4 +107,4 @@ def convergence_StationaryDiffusion_2DFV_Neumann_Squares(): with open('Convergence_Poisson_2DFV_'+mesh_name+'.json', 'w') as outfile: json.dump(convergence_synthesis, outfile) if __name__ == """__main__""": - convergence_StationaryDiffusion_2DFV_Neumann_Squares() + convergence_StationaryDiffusion_2DFV_Neumann_Squares() diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra.py index cbcdf63..41e7fbc 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra(): ### 3D FE Delaunay Tetrahedra meshes method = 'FE' BC = 'Dirichlet' - meshList=['meshCubeTetrahedra_0','meshCubeTetrahedra_1','meshCubeTetrahedra_2','meshCubeTetrahedra_3','meshCubeTetrahedra_4','meshCubeTetrahedra_5','meshCubeTetrahedra_6'] + meshList=['meshCubeTetrahedra_0','meshCubeTetrahedra_1','meshCubeTetrahedra_2','meshCubeTetrahedra_3','meshCubeTetrahedra_4','meshCubeTetrahedra_5'] mesh_path=os.environ['CDMATH_INSTALL']+'/share/meshes/3DTetrahedra/' mesh_name='cubeWithDelaunayTetrahedra' meshType="Unstructured_Tetrahedra" @@ -31,16 +31,16 @@ def convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra(): testColor="Orange (not order 2)" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>=0 - assert max_sol_num<1 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>=0 + assert max_sol_num<1 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -65,7 +65,7 @@ def convergence_StationaryDiffusion_3DFE_Dirichlet_DelaunayTetrahedra(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FE for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a + print( "FE for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a) assert abs(a+0.627)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra.py index 55c9d78..5e14457 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFE_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra(): ### 3D FE Regular Tetrahedra meshes method = 'FE' BC = 'Dirichlet' - meshList=[5,20,50,70] + meshList=[5,10,20] mesh_name='cubeWithRegularTetrahedra' meshType="Regular_Tetrahedra" nbMeshes=len(meshList) @@ -30,16 +30,16 @@ def convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra(): testColor="Orange (not order 2)" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>=0. - assert max_sol_num<1. - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>=0. + assert max_sol_num<1. + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -64,8 +64,8 @@ def convergence_StationaryDiffusion_3DFE_Dirichlet_RegularTetrahedra(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FE for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a - assert abs(a+1.34)<0.001 + print( "FE for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a) + assert abs(a+1.34)<0.003 # Plot of convergence curve plt.close() diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_DelaunayTetrahedra.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_DelaunayTetrahedra.py index fe1856f..7cac0cf 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_DelaunayTetrahedra.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_DelaunayTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_DelaunayTetrahedra.py @@ -31,16 +31,16 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_DelaunayTetrahedra(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for filename in meshList: - my_mesh=cm.Mesh(mesh_path+filename+".med") - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(mesh_path+filename+".med") + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>=0 - assert max_sol_num<1 - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>=0 + assert max_sol_num<1 + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -66,7 +66,7 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_DelaunayTetrahedra(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a + print( "FV for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a) assert abs(a+0.54)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularCubes/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularCubes/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes.py index 6b34d9d..524a57f 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularCubes/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularCubes/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes(): ### 3D FV Regular Cubes meshes method = 'FV' BC = 'Dirichlet' - meshList=[5,20,50,100] + meshList=[5,10,20,30] mesh_name='cubeWithRegularCubes' meshType="Regular_Cubes" nbMeshes=len(meshList) @@ -30,16 +30,16 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes(): testColor="Orange (not order 2)" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>0. - assert max_sol_num<1. - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>0. + assert max_sol_num<1. + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -65,7 +65,7 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_RegularCubes(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a + print( "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a) assert abs(a+1.34)<0.01 # Plot of convergence curve diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra.py index 71aee7c..0458f49 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/3DFV_Dirichlet_RegularTetrahedra/convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra.py @@ -15,7 +15,7 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra(): ### 3D FV Regular Tetrahedra meshes method = 'FV' BC = 'Dirichlet' - meshList=[5,10,20,30] + meshList=[5,10,15,20] mesh_name='cubeWithRegularTetrahedra' meshType="Regular_Tetrahedra" nbMeshes=len(meshList) @@ -30,16 +30,16 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra(): testColor="Green" # Storing of numerical errors, mesh sizes and diagonal values for nx in meshList: - my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1) - error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) + my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1) + error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC) - assert min_sol_num>0. - assert max_sol_num<1. - plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') - error_tab[i]=log10(error_tab[i]) - time_tab[i]=log10(time_tab[i]) - mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) - i=i+1 + assert min_sol_num>0. + assert max_sol_num<1. + plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells') + error_tab[i]=log10(error_tab[i]) + time_tab[i]=log10(time_tab[i]) + mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i]) + i=i+1 end = time.time() @@ -64,8 +64,8 @@ def convergence_StationaryDiffusion_3DFV_Dirichlet_RegularTetrahedra(): a=( a3*b1-a2*b2)/det b=(-a2*b1+a1*b2)/det - print "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a - assert abs(a+0.006)<0.001 + print( "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a) + assert abs(a+0.0006)<0.001 # Plot of convergence curve plt.close() diff --git a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/validationStationaryDiffusionEquation.py b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/validationStationaryDiffusionEquation.py index a703256..d6d869b 100644 --- a/CoreFlows/examples/Python/Convergence/StationaryDiffusion/validationStationaryDiffusionEquation.py +++ b/CoreFlows/examples/Python/Convergence/StationaryDiffusion/validationStationaryDiffusionEquation.py @@ -201,11 +201,11 @@ def SolveStationaryDiffusionEquation(my_mesh,resolution,MeshType,method,BC): erreur_abs=0 if method =='FE': for i in range(my_mesh.getNumberOfNodes()) : - if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) : + if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) : erreur_abs = abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) else: for i in range(my_mesh.getNumberOfCells()) : - if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) : + if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) : erreur_abs = abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs ) print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)