@@ -59,29 +59,24 @@ def test_h_average(self):
5959@pytest .mark .parametrize ("radius" , [1 , 4 ])
6060@pytest .mark .parametrize ("r0" , [3 , 5 ])
6161@pytest .mark .parametrize ("height" , [2 , 7 ])
62- @pytest .mark .parametrize ("c_top" , [8 , 9 ])
63- @pytest .mark .parametrize ("c_bottom" , [10 , 11 ])
64- def test_compute_cylindrical (r0 , radius , height , c_top , c_bottom ):
62+ def test_compute_cylindrical (r0 , radius , height ):
6563 """
6664 Test that AverageSurfaceCylindrical computes the value correctly on a hollow cylinder
6765
6866 Args:
6967 r0 (float): internal radius
7068 radius (float): cylinder radius
7169 height (float): cylinder height
72- c_top (float): concentration top
73- c_bottom (float): concentration bottom
7470 """
7571 # creating a mesh with FEniCS
7672 r1 = r0 + radius
77- z0 = 0
78- z1 = z0 + height
73+ z0 , z1 = 0 , height
74+
7975 mesh_fenics = f .RectangleMesh (f .Point (r0 , z0 ), f .Point (r1 , z1 ), 10 , 10 )
8076
8177 top_surface = f .CompiledSubDomain (
8278 f"on_boundary && near(x[1], { z1 } , tol)" , tol = 1e-14
8379 )
84-
8580 surface_markers = f .MeshFunction (
8681 "size_t" , mesh_fenics , mesh_fenics .topology ().dim () - 1
8782 )
@@ -93,15 +88,16 @@ def test_compute_cylindrical(r0, radius, height, c_top, c_bottom):
9388
9489 my_export = AverageSurfaceCylindrical ("solute" , top_id )
9590 V = f .FunctionSpace (mesh_fenics , "P" , 1 )
96- c_fun = lambda z : c_bottom + (c_top - c_bottom ) / (z1 - z0 ) * z
91+ c_fun = lambda r : 2 * r
92+
9793 expr = f .Expression (
98- ccode (c_fun (y )),
94+ ccode (c_fun (x )),
9995 degree = 1 ,
10096 )
10197 my_export .function = f .interpolate (expr , V )
10298 my_export .ds = ds
10399
104- expected_value = c_bottom + ( c_top - c_bottom ) / (z1 - z0 ) * height
100+ expected_value = 4 / 3 * ( r1 ** 3 - r0 ** 3 ) / (r1 ** 2 - r0 ** 2 )
105101
106102 computed_value = my_export .compute ()
107103
@@ -110,18 +106,14 @@ def test_compute_cylindrical(r0, radius, height, c_top, c_bottom):
110106
111107@pytest .mark .parametrize ("radius" , [2 , 4 ])
112108@pytest .mark .parametrize ("r0" , [3 , 5 ])
113- @pytest .mark .parametrize ("c_left" , [8 , 9 ])
114- @pytest .mark .parametrize ("c_right" , [10 , 11 ])
115- def test_compute_spherical (r0 , radius , c_left , c_right ):
109+ def test_compute_spherical (r0 , radius ):
116110 """
117111 Test that AverageSurfaceSpherical computes the average value correctly
118112 on a hollow sphere
119113
120114 Args:
121115 r0 (float): internal radius
122116 radius (float): sphere radius
123- c_left (float): concentration left
124- c_right (float): concentration right
125117 """
126118 # creating a mesh with FEniCS
127119 r1 = r0 + radius
@@ -142,7 +134,7 @@ def test_compute_spherical(r0, radius, c_left, c_right):
142134
143135 my_export = AverageSurfaceSpherical ("solute" , right_id )
144136 V = f .FunctionSpace (mesh_fenics , "P" , 1 )
145- c_fun = lambda r : c_left + ( c_right - c_left ) / ( r1 - r0 ) * r
137+ c_fun = lambda r : 4 * r
146138 expr = f .Expression (
147139 ccode (c_fun (x )),
148140 degree = 1 ,
@@ -151,7 +143,7 @@ def test_compute_spherical(r0, radius, c_left, c_right):
151143
152144 my_export .ds = ds
153145
154- expected_value = c_left + (( c_right - c_left ) / ( r1 - r0 )) * r1
146+ expected_value = 4 * r1
155147
156148 computed_value = my_export .compute ()
157149
0 commit comments