Testing dusty wave with Godunov#

CI test for dusty wave with Godunov

  8 from math import *
  9
 10 import matplotlib as mpl
 11 import matplotlib.pyplot as plt
 12 import numpy as np
 13
 14 import shamrock
 15
 16
 17 def run_sim(times, x0, normalized_rd_num, normalized_rg_num, normalized_vd_num, normalized_vg_num):
 18     ctx = shamrock.Context()
 19     ctx.pdata_layout_new()
 20
 21     model = shamrock.get_Model_Ramses(context=ctx, vector_type="f64_3", grid_repr="i64_3")
 22
 23     multx = 1
 24     multy = 1
 25     multz = 1
 26
 27     sz = 1 << 1
 28     base = 16
 29
 30     cfg = model.gen_default_config()
 31     scale_fact = 1 / (sz * base * multx)
 32     cfg.set_scale_factor(scale_fact)
 33     cfg.set_Csafe(0.5)
 34     cfg.set_eos_gamma(1.0000001)
 35     cfg.set_dust_mode_hb(4)
 36     cfg.set_drag_mode_irk1(True)
 37     cfg.set_face_time_interpolation(False)
 38
 39     # =================== set drag coefficients for 2 fluids dust =========
 40     # cfg.set_alpha_values(2.5)          # ts = 0.4
 41
 42     # =================== set drag coefficients for 5 fluids dust =========
 43     cfg.set_alpha_values(float(1.0 / 0.1))  # ts = 0.1
 44     cfg.set_alpha_values(float(1.0 / 0.215443))  # ts = 0.215443
 45     cfg.set_alpha_values(float(1.0 / 0.464159))  # ts = 0.464159
 46     cfg.set_alpha_values(1.0)  # ts = 1.0
 47
 48     model.set_solver_config(cfg)
 49     model.init_scheduler(int(1e7), 1)
 50     model.make_base_grid((0, 0, 0), (sz, sz, sz), (base * multx, base * multy, base * multz))
 51
 52     # ================= Fields maps  =========================
 53
 54     def pertubation(x, A, Re, Im, L):
 55         return A * (Re * cos(2 * x * pi / L) - Im * sin(2 * x * pi / L))
 56
 57     """   ##  2 fluids test setup
 58     rhog_0    = 1.00000
 59     rhod_0    = 2.240000
 60     L         = 1
 61     A_rho     = 1e-4
 62     A_vel     = 1e-4
 63     Re_rho    = 1.0
 64     Im_rho    = 0.0
 65     Re_vel    = -0.7019594018594713
 66     Im_vel    = -0.30492431884998994
 67     Re_rd     = 0.16525079505682766
 68     Im_rd     = -1.247800745895827
 69     Re_vd     = -0.22164470614182466
 70     Im_vd     = 0.3685341424583546
 71     cs        = 1.0
 72     gamma     = 1.0000001
 73     ### Gas maps
 74     def rho_map(rmin,rmax)->float:
 75         x,y,z = rmin
 76         return rhog_0 + pertubation(x,A_rho,Re_rho,Im_rho,L)
 77     def rhovel_map(rmin, rmax)->tuple[float,float,float]:
 78         x,y,z = rmin
 79         rho = rhog_0 + pertubation(x,A_rho,Re_rho,Im_rho,L)
 80         vx  = pertubation(x,A_vel,Re_vel,Im_vel,L)
 81         return (rho*vx, 0, 0)
 82     def rhoe_map (rmin, rmax)->float:
 83         x,y,z   = rmin
 84         rho     = rhog_0 + pertubation(x,A_rho,Re_rho,Im_rho,L)
 85         vx      = pertubation(x,A_vel,Re_vel,Im_vel,L)
 86         press   = (cs * cs * rho) / gamma
 87         rhoeint = press / (gamma - 1.0)
 88         rhoekin = 0.5 * rho * (vx *vx + 0.0)
 89         return (rhoeint + rhoekin)
 90     ### Dust maps
 91     def rho_d_map(rmin,rmax)->float:
 92         x,y,z = rmin
 93         return rhod_0 + pertubation(x,A_rho,Re_rd,Im_rd,L)
 94     def rhovel_d_map(rmin, rmax)->tuple[float,float,float]:
 95         x,y,z = rmin
 96         rho = rhod_0 + pertubation(x,A_rho,Re_rd,Im_rd,L)
 97         vx  = pertubation(x,A_vel,Re_vd,Im_vd,L)
 98         return (rho*vx, 0, 0)"""
 99
100     ##  5 fluids test setup
101     L = 1
102     A_rho = 1e-4
103     A_vel = 1e-4
104
105     rhog_0 = 1.000000
106     Re_rho = 1.0
107     Im_rho = 0.0
108
109     Re_vel = -0.874365
110     Im_vel = -0.145215
111
112     rhod_1 = 0.100000
113     rhod_2 = 0.233333
114     rhod_3 = 0.366667
115     rhod_4 = 0.500000
116
117     Re_rd_1 = 0.080588
118     Im_rd_1 = -0.048719
119     Re_rd_2 = 0.09160
120     Im_rd_2 = -0.134955
121     Re_rd_3 = 0.030927
122     Im_rd_3 = -0.136799
123     Re_rd_4 = 0.001451
124     Im_rd_4 = -0.090989
125
126     Re_vd_1 = -0.775380
127     Im_vd_1 = 0.308952
128     Re_vd_2 = -0.427268
129     Im_vd_2 = 0.448704
130     Re_vd_3 = -0.127928
131     Im_vd_3 = 0.313967
132     Re_vd_4 = -0.028963
133     Im_vd_4 = 0.158693
134
135     cs = 1.0
136     gamma = 1.0000001
137
138     ### Gas maps
139     def rho_map(rmin, rmax):
140         x, y, z = rmin
141         return rhog_0 + pertubation(x, A_rho, Re_rho, Im_rho, L)
142
143     def rhovel_map(rmin, rmax):
144         x, y, z = rmin
145         rho = rhog_0 + pertubation(x, A_rho, Re_rho, Im_rho, L)
146         vx = pertubation(x, A_vel, Re_vel, Im_vel, L)
147         return (rho * vx, 0, 0)
148
149     def rhoe_map(rmin, rmax):
150         x, y, z = rmin
151         rho = rhog_0 + pertubation(x, A_rho, Re_rho, Im_rho, L)
152         vx = pertubation(x, A_vel, Re_vel, Im_vel, L)
153         press = (cs * cs * rho) / gamma
154         rhoeint = press / (gamma - 1.0)
155         rhoekin = 0.5 * rho * (vx * vx + 0.0)
156         return rhoeint + rhoekin
157
158     ### Dusts maps
159
160     def rho_d_1_map(rmin, rmax):
161         x, y, z = rmin
162         return rhod_1 + pertubation(x, A_rho, Re_rd_1, Im_rd_1, L)
163
164     def rhovel_d_1_map(rmin, rmax):
165         x, y, z = rmin
166         rho = rhod_1 + pertubation(x, A_rho, Re_rd_1, Im_rd_1, L)
167         vx = pertubation(x, A_vel, Re_vd_1, Im_vd_1, L)
168         return (rho * vx, 0, 0)
169
170     def rho_d_2_map(rmin, rmax):
171         x, y, z = rmin
172         return rhod_2 + pertubation(x, A_rho, Re_rd_2, Im_rd_2, L)
173
174     def rhovel_d_2_map(rmin, rmax):
175         x, y, z = rmin
176         rho = rhod_2 + pertubation(x, A_rho, Re_rd_2, Im_rd_2, L)
177         vx = pertubation(x, A_vel, Re_vd_2, Im_vd_2, L)
178         return (rho * vx, 0, 0)
179
180     def rho_d_3_map(rmin, rmax):
181         x, y, z = rmin
182         return rhod_3 + pertubation(x, A_rho, Re_rd_3, Im_rd_3, L)
183
184     def rhovel_d_3_map(rmin, rmax):
185         x, y, z = rmin
186         rho = rhod_3 + pertubation(x, A_rho, Re_rd_3, Im_rd_3, L)
187         vx = pertubation(x, A_vel, Re_vd_3, Im_vd_3, L)
188         return (rho * vx, 0, 0)
189
190     def rho_d_4_map(rmin, rmax):
191         x, y, z = rmin
192         return rhod_4 + pertubation(x, A_rho, Re_rd_4, Im_rd_4, L)
193
194     def rhovel_d_4_map(rmin, rmax):
195         x, y, z = rmin
196         rho = rhod_4 + pertubation(x, A_rho, Re_rd_4, Im_rd_4, L)
197         vx = pertubation(x, A_vel, Re_vd_4, Im_vd_4, L)
198         return (rho * vx, 0, 0)
199
200     # ============ set init fields values for gas =============
201     model.set_field_value_lambda_f64("rho", rho_map)
202     model.set_field_value_lambda_f64("rhoetot", rhoe_map)
203     model.set_field_value_lambda_f64_3("rhovel", rhovel_map)
204
205     # ============ set init fields values for dusts [2 fluid case] =============
206     # model.set_field_value_lambda_f64("rho_dust", rho_d_map)
207     # model.set_field_value_lambda_f64_3("rhovel_dust", rhovel_d_map)
208
209     # ============ set init fields values for dusts [5 fluid case] =============
210     model.set_field_value_lambda_f64("rho_dust", rho_d_1_map, 0)
211     model.set_field_value_lambda_f64_3("rhovel_dust", rhovel_d_1_map, 0)
212     model.set_field_value_lambda_f64("rho_dust", rho_d_2_map, 1)
213     model.set_field_value_lambda_f64_3("rhovel_dust", rhovel_d_2_map, 1)
214     model.set_field_value_lambda_f64("rho_dust", rho_d_3_map, 2)
215     model.set_field_value_lambda_f64_3("rhovel_dust", rhovel_d_3_map, 2)
216     model.set_field_value_lambda_f64("rho_dust", rho_d_4_map, 3)
217     model.set_field_value_lambda_f64_3("rhovel_dust", rhovel_d_4_map, 3)
218
219     def convert_to_cell_coords(dic):
220         cmin = dic["cell_min"]
221         cmax = dic["cell_max"]
222
223         xmin = []
224         ymin = []
225         zmin = []
226         xmax = []
227         ymax = []
228         zmax = []
229
230         for i in range(len(cmin)):
231             m, M = cmin[i], cmax[i]
232
233             mx, my, mz = m
234             Mx, My, Mz = M
235
236             for j in range(8):
237                 a, b = model.get_cell_coords(((mx, my, mz), (Mx, My, Mz)), j)
238
239                 x, y, z = a
240                 xmin.append(x)
241                 ymin.append(y)
242                 zmin.append(z)
243
244                 x, y, z = b
245                 xmax.append(x)
246                 ymax.append(y)
247                 zmax.append(z)
248
249         dic["xmin"] = np.array(xmin)
250         dic["ymin"] = np.array(ymin)
251         dic["zmin"] = np.array(zmin)
252         dic["xmax"] = np.array(xmax)
253         dic["ymax"] = np.array(ymax)
254         dic["zmax"] = np.array(zmax)
255
256         return dic
257
258     freq = 15
259     dt = 0.000
260     t = 0
261     tend = 2
262     for i in range(1000000):
263         if i % freq == 0:
264             dic_i = convert_to_cell_coords(ctx.collect_data())
265
266             vg_i = dic_i["rhovel"][0][0] / dic_i["rho"][0]
267             rg_i = dic_i["rho"][0]
268             rd_i = dic_i["rho_dust"][0]
269             vd_i = dic_i["rhovel_dust"][0][0] / dic_i["rho_dust"][0]
270             x0 = dic_i["xmin"][0]
271             # normalized_rg_num.append((rg_i - rhog_0)/A_rho)
272             # normalized_rd_num.append((rd_i - rhod_0)/(A_rho * rhod_0))
273             # normalized_vg_num.append(vg_i/A_vel)
274             # normalized_vd_num.append(vd_i/A_vel)
275
276             vg_i = dic_i["rhovel"][0][0] / dic_i["rho"][0]
277             rg_i = dic_i["rho"][0]
278             rd_1_i = dic_i["rho_dust"][0]
279             vd_1_i = dic_i["rhovel_dust"][0][0] / dic_i["rho_dust"][0]
280             rd_2_i = dic_i["rho_dust"][1]
281             vd_2_i = dic_i["rhovel_dust"][1][0] / dic_i["rho_dust"][1]
282             rd_3_i = dic_i["rho_dust"][2]
283             vd_3_i = dic_i["rhovel_dust"][2][0] / dic_i["rho_dust"][2]
284             rd_4_i = dic_i["rho_dust"][3]
285             vd_4_i = dic_i["rhovel_dust"][3][0] / dic_i["rho_dust"][3]
286
287             x0 = dic_i["xmin"][0]
288
289             normalized_rg_num.append((rg_i - rhog_0) / A_rho)
290             normalized_vg_num.append(vg_i / A_vel)
291
292             normalized_rd_num[0].append((rd_1_i - rhod_1) / (A_rho * rhod_1))
293             normalized_vd_num[0].append(vd_1_i / A_vel)
294             normalized_rd_num[1].append((rd_2_i - rhod_2) / (A_rho * rhod_2))
295             normalized_vd_num[1].append(vd_2_i / A_vel)
296             normalized_rd_num[2].append((rd_3_i - rhod_3) / (A_rho * rhod_3))
297             normalized_vd_num[2].append(vd_3_i / A_vel)
298             normalized_rd_num[3].append((rd_4_i - rhod_4) / (A_rho * rhod_4))
299             normalized_vd_num[3].append(vd_4_i / A_vel)
300
301         next_dt = model.evolve_once_override_time(t, dt)
302
303         t += dt
304
305         if i % freq == 0:
306             times.append(t)
307         dt = next_dt
308
309         if tend < t + next_dt:
310             dt = tend - t
311         if t == tend:
312             break
313
314
315 # ================ post treatment =========
316
317 ## ===== get numerical results ========
318 times = []
319 # normalized_rd_num    = []
320 # normalized_vd_num    = []
321 normalized_rg_num = []
322 normalized_vg_num = []
323 normalized_rd_num = [[], [], [], []]
324 normalized_vd_num = [[], [], [], []]
325 x0 = 0
326 # rhod_0    = 2.240000
327
328 rhod_1 = 0.100000
329 rhod_2 = 0.233333
330 rhod_3 = 0.366667
331 rhod_4 = 0.500000
332
333 run_sim(times, x0, normalized_rd_num, normalized_rg_num, normalized_vd_num, normalized_vg_num)
334
335 ## ========= get analytical values ========
336
337 from cmath import *
338
339
340 ## analytical function =============
341 def analytical_values(t, w, x, delta):
342     res = 0.0 + 0.0j
343     res = delta * exp(-t * w) * exp(pi * x * (2j))
344     return res.real, res.imag
345
346
347 """
348 ## 2 fluid gas and dust analytical solutions
349 w = 1.9158960 - 4.410541j
350 norm_rg_re = [analytical_values(t,w,x0,1.0 + 0.0j)[0] for t in times]
351 norm_rg_im = [analytical_values(t,w,x0,1.0 + 0.0j)[1] for t in times]
352 norm_vg_re = [analytical_values(t,w,x0,-0.701960 - 0.304924j)[0] for t in times]
353 norm_vg_im = [analytical_values(t,w,x0,-0.701960 - 0.304924j)[1] for t in times]
354 norm_rd_re = [(1.0/rhod_0) * analytical_values(t,w,x0,0.165251 - 1.247801j)[0] for t in times]
355 norm_rd_im = [analytical_values(t,w,x0,0.165251 - 1.247801j)[1] for t in times]
356 norm_vd_re = [analytical_values(t,w,x0,-0.221645 + 0.368534j)[0] for t in times]
357 norm_vd_im = [analytical_values(t,w,x0,-0.221645 + 0.368534j)[1] for t in times]"""
358
359
360 # ## 5 fluid gas and dust analytical solutions
361 w = 0.912414 - 5.493800j
362 norm_rg_re = [analytical_values(t, w, x0, 1.0 + 0.0j)[0] for t in times]
363 norm_rg_im = [analytical_values(t, w, x0, 1.0 + 0.0j)[1] for t in times]
364 norm_vg_re = [analytical_values(t, w, x0, -0.874365 - 0.145215j)[0] for t in times]
365 norm_vg_im = [analytical_values(t, w, x0, -0.874365 - 0.145215j)[1] for t in times]
366
367 norm_rd_1_re = [
368     (1.0 / rhod_1) * analytical_values(t, w, x0, 0.080588 - 0.048719j)[0] for t in times
369 ]
370 norm_rd_1_im = [
371     (1.0 / rhod_1) * analytical_values(t, w, x0, 0.080588 - 0.048719j)[1] for t in times
372 ]
373 norm_vd_1_im = [analytical_values(t, w, x0, -0.775380 + 0.308952j)[1] for t in times]
374 norm_vd_1_re = [analytical_values(t, w, x0, -0.775380 + 0.308952j)[0] for t in times]
375
376 norm_rd_2_re = [
377     (1.0 / rhod_2) * analytical_values(t, w, x0, 0.0916074536315816 - 0.13495523475722326j)[0]
378     for t in times
379 ]
380 norm_rd_2_im = [
381     (1.0 / rhod_2) * analytical_values(t, w, x0, 0.0916074536315816 - 0.13495523475722326j)[1]
382     for t in times
383 ]
384 norm_vd_2_re = [analytical_values(t, w, x0, -0.427268 + 0.448704j)[0] for t in times]
385 norm_vd_2_im = [analytical_values(t, w, x0, -0.427268 + 0.448704j)[1] for t in times]
386
387 norm_rd_3_re = [
388     (1.0 / rhod_3) * analytical_values(t, w, x0, 0.030927 - 0.136799j)[0] for t in times
389 ]
390 norm_rd_3_im = [
391     (1.0 / rhod_3) * analytical_values(t, w, x0, 0.030927 - 0.136799j)[1] for t in times
392 ]
393 norm_vd_3_re = [analytical_values(t, w, x0, -0.127928 + 0.313967j)[0] for t in times]
394 norm_vd_3_im = [analytical_values(t, w, x0, -0.127928 + 0.313967j)[1] for t in times]
395
396 norm_rd_4_re = [
397     (1.0 / rhod_4) * analytical_values(t, w, x0, 0.001451 - 0.090989j)[0] for t in times
398 ]
399 norm_rd_4_im = [
400     (1.0 / rhod_4) * analytical_values(t, w, x0, 0.001451 - 0.090989j)[1] for t in times
401 ]
402 norm_vd_4_re = [analytical_values(t, w, x0, -0.028963 + 0.158693j)[0] for t in times]
403 norm_vd_4_im = [analytical_values(t, w, x0, -0.028963 + 0.158693j)[1] for t in times]
404
405 # =============== plots ==================
406 """## 2 fluids
407
408 fig, axs = plt.subplots(1,2,figsize=(25,10))
409 plt.subplots_adjust(wspace=0.25)
410 axs[0].plot(times, normalized_rd_num, 'bo', lw = 3, label="Dust-num")
411 axs[0].plot(times, normalized_rg_num, 'r*', lw = 3, label="Gas-num")
412 axs[0].plot(times, norm_rd_re, 'b', lw = 1, label="Dust-ana" )
413 axs[0].plot(times, norm_rg_re, 'r', lw = 1, label="Gas-ana")
414 axs[0].set_xlabel('Time', fontsize=15,fontweight='bold')
415 axs[0].set_ylabel('Normalized Density', fontsize=15, fontweight='bold')
416 axs[1].plot(times, normalized_vd_num, 'bo', lw = 3, label="Dust-num")
417 axs[1].plot(times, normalized_vg_num, 'r*', lw = 3, label="Gas-num")
418 axs[1].plot(times, norm_vd_re, 'b', lw = 1, label="Dust-ana" )
419 axs[1].plot(times, norm_vg_re, 'r', lw = 1, label="Gas-ana")
420 axs[1].set_xlabel('Time', fontsize=15,fontweight='bold')
421 axs[1].set_ylabel('Normalized Velocity', fontsize=15, fontweight='bold')
422 plt.legend(prop={'weight' : 'bold'})
423 plt.savefig("dusty_wave_test_2fluids.png")"""
424
425
426 ## 5 fluids
427 if False:
428     fig, axs = plt.subplots(1, 2, figsize=(15, 7))
429     axs[0].plot(times, normalized_rd_num[0], "bo", lw=3, label="Dust1-num")
430     axs[0].plot(times, normalized_rd_num[1], "ro", lw=3, label="Dust2-num")
431     axs[0].plot(times, normalized_rd_num[2], "go", lw=3, label="Dust3-num")
432     axs[0].plot(times, normalized_rd_num[3], "co", lw=3, label="Dust4-num")
433     axs[0].plot(times, normalized_rg_num, "m*", lw=3, label="Gas-num")
434     axs[0].plot(times, norm_rd_1_re, "k", lw=1, label="Dust1-ana")
435     axs[0].plot(times, norm_rd_2_re, "k", lw=1, label="Dust2-ana")
436     axs[0].plot(times, norm_rd_3_re, "k", lw=1, label="Dust3-ana")
437     axs[0].plot(times, norm_rd_4_re, "k", lw=1, label="Dust4-ana")
438     axs[0].plot(times, norm_rg_re, "k", lw=1, label="Gas-ana")
439     axs[0].set_xlabel("Time")
440     axs[0].set_ylabel("Normalized Density")
441
442     axs[1].plot(times, normalized_vd_num[0], "bo", lw=3, label="Dust1-num")
443     axs[1].plot(times, normalized_vd_num[1], "ro", lw=3, label="Dust2-num")
444     axs[1].plot(times, normalized_vd_num[2], "go", lw=3, label="Dust3-num")
445     axs[1].plot(times, normalized_vd_num[3], "co", lw=3, label="Dust4-num")
446     axs[1].plot(times, normalized_vg_num, "m*", lw=3, label="Gas-num")
447     axs[1].plot(times, norm_vd_1_re, "k", lw=1, label="Dust1-ana")
448     axs[1].plot(times, norm_vd_2_re, "k", lw=1, label="Dust2-ana")
449     axs[1].plot(times, norm_vd_3_re, "k", lw=1, label="Dust3-ana")
450     axs[1].plot(times, norm_vd_4_re, "k", lw=1, label="Dust4-ana")
451     axs[1].plot(times, norm_vg_re, "k", lw=1, label="Gas-ana")
452     axs[1].set_xlabel("Time")
453     axs[1].set_ylabel("Normalized Velocity")
454
455     axs[0].legend()
456     axs[1].legend()
457
458     plt.savefig("dusty_wave_test_5fluids_new.png")
459
460 print(f"rdnum0 = {normalized_rd_num[0]}")
461 print(f"rdnum1 = {normalized_rd_num[1]}")
462 print(f"rdnum2 = {normalized_rd_num[2]}")
463 print(f"rdnum3 = {normalized_rd_num[3]}")
464 print(f"rgnum = {normalized_rg_num}")
465 print(f"vdnum0 = {normalized_vd_num[0]}")
466 print(f"vdnum1 = {normalized_vd_num[1]}")
467 print(f"vdnum2 = {normalized_vd_num[2]}")
468 print(f"vdnum3 = {normalized_vd_num[3]}")
469 print(f"vgnum = {normalized_vg_num}")
470
471
472 rdnum0_ref = [
473     (0.805880000000203),
474     (0.8689243077925067),
475     (0.7900129344901029),
476     (0.5798426664191392),
477     (0.2938225564075303),
478     (-0.009579637037793187),
479     (-0.26991296780826124),
480     (-0.4409759276943758),
481     (-0.5233132250329064),
482     (-0.5165562572517768),
483     (-0.395795789913389),
484     (-0.2223885476271281),
485     (-0.028397848157724056),
486     (0.14006175439035262),
487     (0.2618041011495653),
488     (0.332098698928307),
489     (0.34296704644193315),
490     (0.2825258215571891),
491     (0.1790293225792383),
492     (0.061109398673264696),
493     (-0.04812960177763558),
494     (-0.13405922108661317),
495     (-0.18782773463371646),
496     (-0.2071716863658035),
497     (-0.18043878479007122),
498     (-0.12034046096565108),
499 ]
500 rdnum1_ref = [
501     (0.39257198938890125),
502     (0.5542035347986355),
503     (0.6031567548213295),
504     (0.5482164998591679),
505     (0.4022260439388855),
506     (0.2025074960796827),
507     (-0.003854689554844436),
508     (-0.17772546738121425),
509     (-0.3016110220931041),
510     (-0.35857649286484655),
511     (-0.3414634939575878),
512     (-0.25900332734197895),
513     (-0.13790817100097535),
514     (-0.008080767335840339),
515     (0.10729378337641737),
516     (0.19560180599151578),
517     (0.24939616919818247),
518     (0.24512025887094602),
519     (0.20208428768247946),
520     (0.13229913026881834),
521     (0.05244189399592139),
522     (-0.023243167866717804),
523     (-0.08439864242052121),
524     (-0.12447745395442235),
525     (-0.13269882229236105),
526     (-0.11138076254971943),
527 ]
528 rdnum2_ref = [
529     (0.08434628695750471),
530     (0.21062346808748914),
531     (0.2923363733569692),
532     (0.30864098822793734),
533     (0.2724507899268962),
534     (0.19074436436526077),
535     (0.08645309262667734),
536     (-0.01637634427660739),
537     (-0.10489775335475349),
538     (-0.16585624855733302),
539     (-0.18501284828027997),
540     (-0.16943316656628848),
541     (-0.1215592315308565),
542     (-0.058182463429868644),
543     (0.00847630200294344),
544     (0.06856975476699509),
545     (0.11502446471833112),
546     (0.13455905428225787),
547     (0.12906825376968398),
548     (0.10474254094395367),
549     (0.06807948226772825),
550     (0.026786767934201317),
551     (-0.01237838059633799),
552     (-0.0443544400890218),
553     (-0.060841380837895906),
554     (-0.06208083850580668),
555 ]
556 rdnum3_ref = [
557     (0.0029020000003043833),
558     (0.06956148347114777),
559     (0.11948309374787414),
560     (0.14159551296577533),
561     (0.13520243927978015),
562     (0.10570786835417678),
563     (0.061147073666667495),
564     (0.012644984879184307),
565     (-0.03277412613522657),
566     (-0.06816835842027302),
567     (-0.08535160297640232),
568     (-0.08568386849483467),
569     (-0.06862641456328866),
570     (-0.041949313090983154),
571     (-0.010991046288655326),
572     (0.019496433840693328),
573     (0.045411472970879885),
574     (0.06000675009110168),
575     (0.06237719263779695),
576     (0.055459369678878545),
577     (0.041067093610180905),
578     (0.022670576287353583),
579     (0.0037005204323037333),
580     (-0.01330224985274242),
581     (-0.023982707549885518),
582     (-0.027180050371500286),
583 ]
584 rgnum_ref = [
585     (0.9999999999998899),
586     (0.8688349497520953),
587     (0.5910913976636678),
588     (0.24642370692662396),
589     (-0.10192983466050798),
590     (-0.39677041619112785),
591     (-0.561626161229567),
592     (-0.6124042725308421),
593     (-0.5885544339423454),
594     (-0.4245818746517749),
595     (-0.21318001503400907),
596     (0.01727538923690375),
597     (0.20464550396281922),
598     (0.3241370138651334),
599     (0.37981812456289177),
600     (0.3829670537625063),
601     (0.306349327250377),
602     (0.16514219895125137),
603     (0.025539290697818018),
604     (-0.0954799764940617),
605     (-0.18404092327450883),
606     (-0.23295745713025617),
607     (-0.24418904680079123),
608     (-0.21372740465763762),
609     (-0.12348088227143172),
610     (-0.04091953305862539),
611 ]
612 vdnum0_ref = [
613     (-0.77538),
614     (-0.7811863758910647),
615     (-0.6556347650488735),
616     (-0.4316925391136899),
617     (-0.15922820758957576),
618     (0.11119734045036302),
619     (0.3246520280748058),
620     (0.4472854623218433),
621     (0.48785697131173245),
622     (0.442295322836427),
623     (0.3136382584280283),
624     (0.14441004037288763),
625     (-0.02959348025296491),
626     (-0.17025129133723313),
627     (-0.26183545523685964),
628     (-0.303085651136941),
629     (-0.2944324560056733),
630     (-0.22154786434163998),
631     (-0.11833663676346025),
632     (-0.010149388077418078),
633     (0.0833139633620755),
634     (0.15054829766921585),
635     (0.186328556406826),
636     (0.19103403517545617),
637     (0.15275810723488148),
638     (0.09193119286409025),
639 ]
640 vdnum1_ref = [
641     (-0.427268),
642     (-0.5309603454208828),
643     (-0.5382456751876933),
644     (-0.45029083801954034),
645     (-0.29375712072072363),
646     (-0.102793273979704),
647     (0.08122473286418207),
648     (0.2237890933638007),
649     (0.31457303920617646),
650     (0.34288566207080834),
651     (0.30212119329923925),
652     (0.2120250892944267),
653     (0.09484808545876959),
654     (-0.02128164859184025),
655     (-0.11765422929628072),
656     (-0.18460283281708043),
657     (-0.216304773382997),
658     (-0.20001698763524023),
659     (-0.1494381161874679),
660     (-0.07993747333413012),
661     (-0.006763840063493263),
662     (0.05807764072894879),
663     (0.10619563228299671),
664     (0.13337829216323221),
665     (0.13002135329619113),
666     (0.10324978155771455),
667 ]
668 vdnum2_ref = [
669     (-0.127928),
670     (-0.22433822994326136),
671     (-0.27602066610296094),
672     (-0.2722057937325647),
673     (-0.2202755345324273),
674     (-0.1344401094732441),
675     (-0.035636026605325694),
676     (0.05533025280153579),
677     (0.1278913854203787),
678     (0.17160772283680298),
679     (0.17762725605765986),
680     (0.15120348961722455),
681     (0.10097293229240813),
682     (0.04079488263339769),
683     (-0.018036812005879706),
684     (-0.06770662850093334),
685     (-0.10216646251901662),
686     (-0.1117553730186458),
687     (-0.09977828418787547),
688     (-0.07210467925796142),
689     (-0.03602133435843739),
690     (0.0016061697720409604),
691     (0.03494914200641798),
692     (0.059935919787940335),
693     (0.06975884068164784),
694     (0.06552764505311985),
695 ]
696 vdnum3_ref = [
697     (-0.028963),
698     (-0.08274556735514085),
699     (-0.11865659880671561),
700     (-0.12877637836886333),
701     (-0.11443713845813151),
702     (-0.08075177828758495),
703     (-0.036775947979712675),
704     (0.007553784808566575),
705     (0.04646016756736207),
706     (0.0739319638991898),
707     (0.08429279118423574),
708     (0.07855091155478137),
709     (0.05964847012637353),
710     (0.033521208058918936),
711     (0.0054639253661799714),
712     (-0.02046924840749944),
713     (-0.040821194729435316),
714     (-0.05016010622677305),
715     (-0.049021615176800745),
716     (-0.03942149457236898),
717     (-0.024356990241931917),
718     (-0.006944707917118663),
719     (0.009917318467300065),
720     (0.023968795687178763),
721     (0.031493681350258824),
722     (0.03234581246322336),
723 ]
724 vgnum_ref = [
725     (-0.874365),
726     (-0.709922032828806),
727     (-0.426156149324301),
728     (-0.10465047095432616),
729     (0.198477120454305),
730     (0.4358659968677081),
731     (0.5451490549239694),
732     (0.5515280691563401),
733     (0.4980829279270518),
734     (0.32096845998912177),
735     (0.11971532182104656),
736     (-0.0850447382848111),
737     (-0.238074271749472),
738     (-0.32250378341554387),
739     (-0.3481462054848407),
740     (-0.3273923438079883),
741     (-0.24192132112753134),
742     (-0.10359979997242741),
743     (0.02185961990209998),
744     (0.12267004267841061),
745     (0.18918123690563873),
746     (0.21809383083453066),
747     (0.21365109098794338),
748     (0.17387340496791126),
749     (0.0839251890575102),
750     (0.008437877113669988),
751 ]
752
753 rd0_diff = [abs(normalized_rd_num[0][i] - rdnum0_ref[i]) for i in range(len(normalized_rd_num[0]))]
754 rd1_diff = [abs(normalized_rd_num[1][i] - rdnum1_ref[i]) for i in range(len(normalized_rd_num[1]))]
755 rd2_diff = [abs(normalized_rd_num[2][i] - rdnum2_ref[i]) for i in range(len(normalized_rd_num[2]))]
756 rd3_diff = [abs(normalized_rd_num[3][i] - rdnum3_ref[i]) for i in range(len(normalized_rd_num[3]))]
757 rg_diff = [abs(normalized_rg_num[i] - rgnum_ref[i]) for i in range(len(normalized_rg_num))]
758 vd0_diff = [abs(normalized_vd_num[0][i] - vdnum0_ref[i]) for i in range(len(normalized_vd_num[0]))]
759 vd1_diff = [abs(normalized_vd_num[1][i] - vdnum1_ref[i]) for i in range(len(normalized_vd_num[1]))]
760 vd2_diff = [abs(normalized_vd_num[2][i] - vdnum2_ref[i]) for i in range(len(normalized_vd_num[2]))]
761 vd3_diff = [abs(normalized_vd_num[3][i] - vdnum3_ref[i]) for i in range(len(normalized_vd_num[3]))]
762 vg_diff = [abs(normalized_vg_num[i] - vgnum_ref[i]) for i in range(len(normalized_vg_num))]
763
764 print(f"rd0_diff = {rd0_diff} with len = {len(rd0_diff)} \n")
765 print(f"rd1_diff = {rd1_diff} with len = {len(rd1_diff)} \n")
766 print(f"rd2_diff = {rd2_diff} with len = {len(rd2_diff)} \n")
767 print(f"rd3_diff = {rd3_diff} with len = {len(rd3_diff)} \n")
768 print(f"rg_diff = {rg_diff} with len = {len(rg_diff)} \n")
769 print(f"vd0_diff = {vd0_diff} with len = {len(vd0_diff)} \n")
770 print(f"vd1_diff = {vd1_diff} with len = {len(vd1_diff)} \n")
771 print(f"vd2_diff = {vd2_diff} with len = {len(vd2_diff)} \n")
772 print(f"vd3_diff = {vd3_diff} with len = {len(vd3_diff)} \n")
773 print(f"vg_diff = {vg_diff} with len = {len(vg_diff)} \n")
774
775
776 """
777 CI results:
778
779 rd1_diff = 1.6653373124952964e-11 > 9.526221144423298e-12
780 rd2_diff = 7.569696605647103e-12 > 4.551825249226861e-12
781 rg_diff = 1.1102230246251565e-11 > 6.671338147750939e-12
782 vd0_diff = 3.779143664672802e-12 > 2.8379045771739676e-12
783 vd1_diff = 2.7466917629226373e-12 > 1.9998527270356682e-12
784 vd2_diff = 1.936215077158465e-12 > 1.0505010186786967e-12
785 vd3_diff = 1.220287759728933e-12 > 1e-12
786 vg_diff = 7.118580030995858e-12 > 5.104230592916915e-12
787
788 """
789
790
791 test_pass = True
792 rd0_max_pass = 1.5265566588595902e-11 + 1e-14
793 rd1_max_pass = 1.6653373124952964e-11 + 1e-14
794 rd2_max_pass = 7.569696605647103e-12 + 1e-14
795 rd3_max_pass = 1.1102230246251565e-11 + 1e-14
796 rg_max_pass = 1.1102230246251565e-11 + 1e-14
797 vd0_max_pass = 3.779143664672802e-12 + 1e-14
798 vd1_max_pass = 2.7466917629226373e-12 + 1e-14
799 vd2_max_pass = 1.936215077158465e-12 + 1e-14
800 vd3_max_pass = 1.220287759728933e-12 + 1e-14
801 vg_max_pass = 7.118580030995858e-12 + 1e-14
802
803 err_log = ""
804 if np.max(rd0_diff) > rd0_max_pass:
805     err_log += f"rd0_diff = {np.max(rd0_diff)} > {rd0_max_pass} \n"
806     test_pass = False
807
808 if np.max(rd1_diff) > rd1_max_pass:
809     err_log += f"rd1_diff = {np.max(rd1_diff)} > {rd1_max_pass} \n"
810     test_pass = False
811
812 if np.max(rd2_diff) > rd2_max_pass:
813     err_log += f"rd2_diff = {np.max(rd2_diff)} > {rd2_max_pass} \n"
814     test_pass = False
815
816 if np.max(rd3_diff) > rd3_max_pass:
817     err_log += f"rd3_diff = {np.max(rd3_diff)} > {rd3_max_pass} \n"
818     test_pass = False
819
820 if np.max(rg_diff) > rg_max_pass:
821     err_log += f"rg_diff = {np.max(rg_diff)} > {rg_max_pass} \n"
822     test_pass = False
823
824 if np.max(vd0_diff) > vd0_max_pass:
825     err_log += f"vd0_diff = {np.max(vd0_diff)} > {vd0_max_pass} \n"
826     test_pass = False
827
828 if np.max(vd1_diff) > vd1_max_pass:
829     err_log += f"vd1_diff = {np.max(vd1_diff)} > {vd1_max_pass} \n"
830     test_pass = False
831
832 if np.max(vd2_diff) > vd2_max_pass:
833     err_log += f"vd2_diff = {np.max(vd2_diff)} > {vd2_max_pass} \n"
834     test_pass = False
835
836 if np.max(vd3_diff) > vd3_max_pass:
837     err_log += f"vd3_diff = {np.max(vd3_diff)} > {vd3_max_pass} \n"
838     test_pass = False
839
840 if np.max(vg_diff) > vg_max_pass:
841     err_log += f"vg_diff = {np.max(vg_diff)} > {vg_max_pass} \n"
842     test_pass = False
843
844 if test_pass == False:
845     exit("Test did not pass L2 margins : \n" + err_log)

Estimated memory usage: 0 MB

Gallery generated by Sphinx-Gallery