@@ -170,7 +170,7 @@ def generate_true(i):
170170
171171 interactions_off_axis = interactions_off_axis .reshape (coord [0 ].shape )
172172
173- interactions_total = np . zeros ( coord [ 0 ]. shape )
173+ interactions_total = interactions_on_axis * 0
174174 interactions_total [mask_on_axis ] = interactions_on_axis [mask_on_axis ]
175175 interactions_total [mask_off_axis ] = interactions_off_axis [mask_off_axis ]
176176
@@ -186,25 +186,42 @@ def create_logarithmic_mesh(res):
186186
187187 return mesh_points , x_grid , y_grid
188188
189- def create_plot (relerr_on , str_title ):
190- fig , ax = plt .subplots (1 , 1 , figsize = (15 , 8 ))
191-
189+ def create_plot (relerr_on , ax , str_title , acbar = True ):
192190 n_levels = 18
193191 levels = 10 ** np .linspace (- n_levels + 2 , 1 , n_levels )
194192 cs = ax .contourf (x_grid , y_grid , relerr_on .reshape (res , res ), locator = ticker .LogLocator (), cmap = cm .coolwarm , levels = levels , extend = "both" )
195- cbar = fig . colorbar ( cs )
196-
197- cbar .set_ticks (levels )
198- cbar .set_ticklabels (["1e" + str (int (i )) for i in np .linspace (- n_levels + 2 , 1 , n_levels )])
193+ if acbar :
194+ cbar = fig . colorbar ( cs )
195+ cbar .set_ticks (levels )
196+ cbar .set_ticklabels (["1e" + str (int (i )) for i in np .linspace (- n_levels + 2 , 1 , n_levels )])
199197
200198 ax .set_xscale ('log' )
201199 ax .set_yscale ('log' )
202200 ax .set_xlabel ("$x_1$-coordinate" , fontsize = 15 )
203201 ax .set_ylabel ("$x_2$-coordinate" , fontsize = 15 )
204- plt .title (str_title )
202+ ax .set_title (str_title )
203+
204+ return cs
205+
206+ def create_suite_plot (relerr_on , relerr_off , relerr_comb , str_title ):
207+ fig , (ax1 ,ax2 ,ax3 ) = plt .subplots (1 , 3 , figsize = (15 , 8 ))
208+ cs = create_plot (relerr_on , ax1 , "On-Axis Recurrence" , False )
209+ cs = create_plot (relerr_off , ax2 , "Off-Axis Recurrence ($p_{offaxis}=8$)" , False )
210+ cs = create_plot (relerr_comb , ax3 , "On/Off-Axis Recurrence ($m=100$)" , False )
211+
212+ n_levels = 18
213+ levels = 10 ** np .linspace (- n_levels + 2 , 1 , n_levels )
214+
215+
216+ fig .subplots_adjust (wspace = 0.3 , hspace = 0.5 )
217+
218+ cbar = fig .colorbar (cs , ax = [ax1 ,ax2 ,ax3 ], shrink = 0.9 , location = 'bottom' )
219+ cbar .set_ticks (levels )
220+ cbar .set_ticklabels (["1e" + str (int (i )) for i in np .linspace (- n_levels + 2 , 1 , n_levels )])
221+ fig .suptitle (str_title , fontsize = 16 )
205222
206223#========================= DEFINE PLOT RESOLUTION ====================================
207- res = 8
224+ res = 32
208225mesh_points , x_grid , y_grid = create_logarithmic_mesh (res )
209226
210227#========================= DEFINE GREEN'S FUNCTIONS/PDE's ====================================
@@ -231,23 +248,28 @@ def create_plot(relerr_on, str_title):
231248helmholtz2d = laplacian (w ) + w
232249g_x_y_helmholtz = (1j / 4 ) * hankel1 (0 , k * abs_dist )
233250#========================= LAPLACE 2D ====================================
234- # interactions_on_axis, interactions_off_axis, interactions_true, interactions_total = produce_error_for_recurrences(mesh_points, laplace2d, g_x_y_laplace, 9)
251+ interactions_on_axis , interactions_off_axis , interactions_true , interactions_total = produce_error_for_recurrences (mesh_points , laplace2d , g_x_y_laplace , 9 , m = 1e2 / 2 )
235252
236- #relerr_on = np.abs((interactions_on_axis-interactions_true)/interactions_true)
237- #plt.figure(1)
238- #create_plot(relerr_on, "Laplace (2D): On-Axis Recurrence, 9th Order Derivative Evaluation Error $(u_{recur}-u_{sym})/u_{sym}$")
253+ relerr_on = np .abs ((interactions_on_axis - interactions_true )/ interactions_true )
254+ relerr_off = np .abs ((interactions_off_axis - interactions_true )/ interactions_true )
255+ relerr_comb = np .abs ((interactions_total - interactions_true )/ interactions_true )
256+
257+ create_suite_plot (relerr_on , relerr_off , relerr_comb , "Laplace 2D: 9th Order Derivative Evaluation Error $(u_{recur}-u_{sympy})/u_{recur}$" )
239258
240259#========================= HELMOLTZ 2D ====================================
241- # interactions_on_axis, interactions_off_axis, interactions_true, interactions_total = produce_error_for_recurrences(mesh_points, helmholtz2d, g_x_y_helmholtz, 9 )
260+ interactions_on_axis , interactions_off_axis , interactions_true , interactions_total = produce_error_for_recurrences (mesh_points , helmholtz2d , g_x_y_helmholtz , 8 )
242261
243- #relerr_on = np.abs((interactions_on_axis-interactions_true)/interactions_true)
244- #create_plot(relerr_on, "Helmholtz (2D): On-Axis Recurrence, 8th Order Derivative Evaluation Error $(u_{recur}-u_{sym})/u_{sym}$")
262+ relerr_on = np .abs ((interactions_on_axis - interactions_true )/ interactions_true )
263+ relerr_off = np .abs ((interactions_off_axis - interactions_true )/ interactions_true )
264+ relerr_comb = np .abs ((interactions_total - interactions_true )/ interactions_true )
265+
266+ create_suite_plot (relerr_on , relerr_off , relerr_comb , "Helmholtz 2D: 8th Order Derivative Evaluation Error $(u_{recur}-u_{sympy})/u_{recur}$" )
245267
246268
247269#======================== BIHARMONIC 2D ===================================
248- interactions_on_axis , interactions_off_axis , interactions_true , interactions_total = produce_error_for_recurrences (mesh_points , biharmonic_pde , g_x_y_biharmonic , 7 )
270+ # interactions_on_axis, interactions_off_axis, interactions_true, interactions_total = produce_error_for_recurrences(mesh_points, biharmonic_pde, g_x_y_biharmonic, 7)
249271
250- relerr_on = np .abs ((interactions_on_axis - interactions_true )/ interactions_true )
251- create_plot (relerr_on , "Biharmonic (2D): On-Axis Recurrence, 8th Order Derivative Evaluation Error $(u_{recur}-u_{sym})/u_{sym}$" )
272+ # relerr_on = np.abs((interactions_on_axis-interactions_true)/interactions_true)
273+ # create_plot(relerr_on, "Biharmonic (2D): On-Axis Recurrence, 8th Order Derivative Evaluation Error $(u_{recur}-u_{sym})/u_{sym}$")
252274
253275plt .show ()
0 commit comments