Note
Go to the end to download the full example code.
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
221 cmin = dic["cell_min"]
222 cmax = dic["cell_max"]
223
224 xmin = []
225 ymin = []
226 zmin = []
227 xmax = []
228 ymax = []
229 zmax = []
230
231 for i in range(len(cmin)):
232
233 m, M = cmin[i], cmax[i]
234
235 mx, my, mz = m
236 Mx, My, Mz = M
237
238 for j in range(8):
239 a, b = model.get_cell_coords(((mx, my, mz), (Mx, My, Mz)), j)
240
241 x, y, z = a
242 xmin.append(x)
243 ymin.append(y)
244 zmin.append(z)
245
246 x, y, z = b
247 xmax.append(x)
248 ymax.append(y)
249 zmax.append(z)
250
251 dic["xmin"] = np.array(xmin)
252 dic["ymin"] = np.array(ymin)
253 dic["zmin"] = np.array(zmin)
254 dic["xmax"] = np.array(xmax)
255 dic["ymax"] = np.array(ymax)
256 dic["zmax"] = np.array(zmax)
257
258 return dic
259
260 freq = 15
261 dt = 0.000
262 t = 0
263 tend = 2
264 for i in range(1000000):
265
266 if i % freq == 0:
267 dic_i = convert_to_cell_coords(ctx.collect_data())
268
269 vg_i = dic_i["rhovel"][0][0] / dic_i["rho"][0]
270 rg_i = dic_i["rho"][0]
271 rd_i = dic_i["rho_dust"][0]
272 vd_i = dic_i["rhovel_dust"][0][0] / dic_i["rho_dust"][0]
273 x0 = dic_i["xmin"][0]
274 # normalized_rg_num.append((rg_i - rhog_0)/A_rho)
275 # normalized_rd_num.append((rd_i - rhod_0)/(A_rho * rhod_0))
276 # normalized_vg_num.append(vg_i/A_vel)
277 # normalized_vd_num.append(vd_i/A_vel)
278
279 vg_i = dic_i["rhovel"][0][0] / dic_i["rho"][0]
280 rg_i = dic_i["rho"][0]
281 rd_1_i = dic_i["rho_dust"][0]
282 vd_1_i = dic_i["rhovel_dust"][0][0] / dic_i["rho_dust"][0]
283 rd_2_i = dic_i["rho_dust"][1]
284 vd_2_i = dic_i["rhovel_dust"][1][0] / dic_i["rho_dust"][1]
285 rd_3_i = dic_i["rho_dust"][2]
286 vd_3_i = dic_i["rhovel_dust"][2][0] / dic_i["rho_dust"][2]
287 rd_4_i = dic_i["rho_dust"][3]
288 vd_4_i = dic_i["rhovel_dust"][3][0] / dic_i["rho_dust"][3]
289
290 x0 = dic_i["xmin"][0]
291
292 normalized_rg_num.append((rg_i - rhog_0) / A_rho)
293 normalized_vg_num.append(vg_i / A_vel)
294
295 normalized_rd_num[0].append((rd_1_i - rhod_1) / (A_rho * rhod_1))
296 normalized_vd_num[0].append(vd_1_i / A_vel)
297 normalized_rd_num[1].append((rd_2_i - rhod_2) / (A_rho * rhod_2))
298 normalized_vd_num[1].append(vd_2_i / A_vel)
299 normalized_rd_num[2].append((rd_3_i - rhod_3) / (A_rho * rhod_3))
300 normalized_vd_num[2].append(vd_3_i / A_vel)
301 normalized_rd_num[3].append((rd_4_i - rhod_4) / (A_rho * rhod_4))
302 normalized_vd_num[3].append(vd_4_i / A_vel)
303
304 next_dt = model.evolve_once_override_time(t, dt)
305
306 t += dt
307
308 if i % freq == 0:
309 times.append(t)
310 dt = next_dt
311
312 if tend < t + next_dt:
313 dt = tend - t
314 if t == tend:
315 break
316
317
318 # ================ post treatment =========
319
320 ## ===== get numerical results ========
321 times = []
322 # normalized_rd_num = []
323 # normalized_vd_num = []
324 normalized_rg_num = []
325 normalized_vg_num = []
326 normalized_rd_num = [[], [], [], []]
327 normalized_vd_num = [[], [], [], []]
328 x0 = 0
329 # rhod_0 = 2.240000
330
331 rhod_1 = 0.100000
332 rhod_2 = 0.233333
333 rhod_3 = 0.366667
334 rhod_4 = 0.500000
335
336 run_sim(times, x0, normalized_rd_num, normalized_rg_num, normalized_vd_num, normalized_vg_num)
337
338 ## ========= get analytical values ========
339
340 from cmath import *
341
342
343 ## analytical function =============
344 def analytical_values(t, w, x, delta):
345 res = 0.0 + 0.0j
346 res = delta * exp(-t * w) * exp(pi * x * (2j))
347 return res.real, res.imag
348
349
350 """
351 ## 2 fluid gas and dust analytical solutions
352 w = 1.9158960 - 4.410541j
353 norm_rg_re = [analytical_values(t,w,x0,1.0 + 0.0j)[0] for t in times]
354 norm_rg_im = [analytical_values(t,w,x0,1.0 + 0.0j)[1] for t in times]
355 norm_vg_re = [analytical_values(t,w,x0,-0.701960 - 0.304924j)[0] for t in times]
356 norm_vg_im = [analytical_values(t,w,x0,-0.701960 - 0.304924j)[1] for t in times]
357 norm_rd_re = [(1.0/rhod_0) * analytical_values(t,w,x0,0.165251 - 1.247801j)[0] for t in times]
358 norm_rd_im = [analytical_values(t,w,x0,0.165251 - 1.247801j)[1] for t in times]
359 norm_vd_re = [analytical_values(t,w,x0,-0.221645 + 0.368534j)[0] for t in times]
360 norm_vd_im = [analytical_values(t,w,x0,-0.221645 + 0.368534j)[1] for t in times]"""
361
362
363 # ## 5 fluid gas and dust analytical solutions
364 w = 0.912414 - 5.493800j
365 norm_rg_re = [analytical_values(t, w, x0, 1.0 + 0.0j)[0] for t in times]
366 norm_rg_im = [analytical_values(t, w, x0, 1.0 + 0.0j)[1] for t in times]
367 norm_vg_re = [analytical_values(t, w, x0, -0.874365 - 0.145215j)[0] for t in times]
368 norm_vg_im = [analytical_values(t, w, x0, -0.874365 - 0.145215j)[1] for t in times]
369
370 norm_rd_1_re = [
371 (1.0 / rhod_1) * analytical_values(t, w, x0, 0.080588 - 0.048719j)[0] for t in times
372 ]
373 norm_rd_1_im = [
374 (1.0 / rhod_1) * analytical_values(t, w, x0, 0.080588 - 0.048719j)[1] for t in times
375 ]
376 norm_vd_1_im = [analytical_values(t, w, x0, -0.775380 + 0.308952j)[1] for t in times]
377 norm_vd_1_re = [analytical_values(t, w, x0, -0.775380 + 0.308952j)[0] for t in times]
378
379 norm_rd_2_re = [
380 (1.0 / rhod_2) * analytical_values(t, w, x0, 0.0916074536315816 - 0.13495523475722326j)[0]
381 for t in times
382 ]
383 norm_rd_2_im = [
384 (1.0 / rhod_2) * analytical_values(t, w, x0, 0.0916074536315816 - 0.13495523475722326j)[1]
385 for t in times
386 ]
387 norm_vd_2_re = [analytical_values(t, w, x0, -0.427268 + 0.448704j)[0] for t in times]
388 norm_vd_2_im = [analytical_values(t, w, x0, -0.427268 + 0.448704j)[1] for t in times]
389
390 norm_rd_3_re = [
391 (1.0 / rhod_3) * analytical_values(t, w, x0, 0.030927 - 0.136799j)[0] for t in times
392 ]
393 norm_rd_3_im = [
394 (1.0 / rhod_3) * analytical_values(t, w, x0, 0.030927 - 0.136799j)[1] for t in times
395 ]
396 norm_vd_3_re = [analytical_values(t, w, x0, -0.127928 + 0.313967j)[0] for t in times]
397 norm_vd_3_im = [analytical_values(t, w, x0, -0.127928 + 0.313967j)[1] for t in times]
398
399 norm_rd_4_re = [
400 (1.0 / rhod_4) * analytical_values(t, w, x0, 0.001451 - 0.090989j)[0] for t in times
401 ]
402 norm_rd_4_im = [
403 (1.0 / rhod_4) * analytical_values(t, w, x0, 0.001451 - 0.090989j)[1] for t in times
404 ]
405 norm_vd_4_re = [analytical_values(t, w, x0, -0.028963 + 0.158693j)[0] for t in times]
406 norm_vd_4_im = [analytical_values(t, w, x0, -0.028963 + 0.158693j)[1] for t in times]
407
408 # =============== plots ==================
409 """## 2 fluids
410
411 fig, axs = plt.subplots(1,2,figsize=(25,10))
412 plt.subplots_adjust(wspace=0.25)
413 axs[0].plot(times, normalized_rd_num, 'bo', lw = 3, label="Dust-num")
414 axs[0].plot(times, normalized_rg_num, 'r*', lw = 3, label="Gas-num")
415 axs[0].plot(times, norm_rd_re, 'b', lw = 1, label="Dust-ana" )
416 axs[0].plot(times, norm_rg_re, 'r', lw = 1, label="Gas-ana")
417 axs[0].set_xlabel('Time', fontsize=15,fontweight='bold')
418 axs[0].set_ylabel('Normalized Density', fontsize=15, fontweight='bold')
419 axs[1].plot(times, normalized_vd_num, 'bo', lw = 3, label="Dust-num")
420 axs[1].plot(times, normalized_vg_num, 'r*', lw = 3, label="Gas-num")
421 axs[1].plot(times, norm_vd_re, 'b', lw = 1, label="Dust-ana" )
422 axs[1].plot(times, norm_vg_re, 'r', lw = 1, label="Gas-ana")
423 axs[1].set_xlabel('Time', fontsize=15,fontweight='bold')
424 axs[1].set_ylabel('Normalized Velocity', fontsize=15, fontweight='bold')
425 plt.legend(prop={'weight' : 'bold'})
426 plt.savefig("dusty_wave_test_2fluids.png")"""
427
428
429 ## 5 fluids
430 if False:
431 fig, axs = plt.subplots(1, 2, figsize=(15, 7))
432 axs[0].plot(times, normalized_rd_num[0], "bo", lw=3, label="Dust1-num")
433 axs[0].plot(times, normalized_rd_num[1], "ro", lw=3, label="Dust2-num")
434 axs[0].plot(times, normalized_rd_num[2], "go", lw=3, label="Dust3-num")
435 axs[0].plot(times, normalized_rd_num[3], "co", lw=3, label="Dust4-num")
436 axs[0].plot(times, normalized_rg_num, "m*", lw=3, label="Gas-num")
437 axs[0].plot(times, norm_rd_1_re, "k", lw=1, label="Dust1-ana")
438 axs[0].plot(times, norm_rd_2_re, "k", lw=1, label="Dust2-ana")
439 axs[0].plot(times, norm_rd_3_re, "k", lw=1, label="Dust3-ana")
440 axs[0].plot(times, norm_rd_4_re, "k", lw=1, label="Dust4-ana")
441 axs[0].plot(times, norm_rg_re, "k", lw=1, label="Gas-ana")
442 axs[0].set_xlabel("Time")
443 axs[0].set_ylabel("Normalized Density")
444
445 axs[1].plot(times, normalized_vd_num[0], "bo", lw=3, label="Dust1-num")
446 axs[1].plot(times, normalized_vd_num[1], "ro", lw=3, label="Dust2-num")
447 axs[1].plot(times, normalized_vd_num[2], "go", lw=3, label="Dust3-num")
448 axs[1].plot(times, normalized_vd_num[3], "co", lw=3, label="Dust4-num")
449 axs[1].plot(times, normalized_vg_num, "m*", lw=3, label="Gas-num")
450 axs[1].plot(times, norm_vd_1_re, "k", lw=1, label="Dust1-ana")
451 axs[1].plot(times, norm_vd_2_re, "k", lw=1, label="Dust2-ana")
452 axs[1].plot(times, norm_vd_3_re, "k", lw=1, label="Dust3-ana")
453 axs[1].plot(times, norm_vd_4_re, "k", lw=1, label="Dust4-ana")
454 axs[1].plot(times, norm_vg_re, "k", lw=1, label="Gas-ana")
455 axs[1].set_xlabel("Time")
456 axs[1].set_ylabel("Normalized Velocity")
457
458 axs[0].legend()
459 axs[1].legend()
460
461 plt.savefig("dusty_wave_test_5fluids_new.png")
462
463 print(f"rdnum0 = {normalized_rd_num[0]}")
464 print(f"rdnum1 = {normalized_rd_num[1]}")
465 print(f"rdnum2 = {normalized_rd_num[2]}")
466 print(f"rdnum3 = {normalized_rd_num[3]}")
467 print(f"rgnum = {normalized_rg_num}")
468 print(f"vdnum0 = {normalized_vd_num[0]}")
469 print(f"vdnum1 = {normalized_vd_num[1]}")
470 print(f"vdnum2 = {normalized_vd_num[2]}")
471 print(f"vdnum3 = {normalized_vd_num[3]}")
472 print(f"vgnum = {normalized_vg_num}")
473
474
475 rdnum0_ref = [
476 (0.805880000000203),
477 (0.8689243077925067),
478 (0.7900129344901029),
479 (0.5798426664191392),
480 (0.2938225564075303),
481 (-0.009579637037793187),
482 (-0.26991296780826124),
483 (-0.4409759276943758),
484 (-0.5233132250329064),
485 (-0.5165562572517768),
486 (-0.395795789913389),
487 (-0.2223885476271281),
488 (-0.028397848157724056),
489 (0.14006175439035262),
490 (0.2618041011495653),
491 (0.332098698928307),
492 (0.34296704644193315),
493 (0.2825258215571891),
494 (0.1790293225792383),
495 (0.061109398673264696),
496 (-0.04812960177763558),
497 (-0.13405922108661317),
498 (-0.18782773463371646),
499 (-0.2071716863658035),
500 (-0.18043878479007122),
501 (-0.12034046096565108),
502 ]
503 rdnum1_ref = [
504 (0.39257198938890125),
505 (0.5542035347986355),
506 (0.6031567548213295),
507 (0.5482164998591679),
508 (0.4022260439388855),
509 (0.2025074960796827),
510 (-0.003854689554844436),
511 (-0.17772546738121425),
512 (-0.3016110220931041),
513 (-0.35857649286484655),
514 (-0.3414634939575878),
515 (-0.25900332734197895),
516 (-0.13790817100097535),
517 (-0.008080767335840339),
518 (0.10729378337641737),
519 (0.19560180599151578),
520 (0.24939616919818247),
521 (0.24512025887094602),
522 (0.20208428768247946),
523 (0.13229913026881834),
524 (0.05244189399592139),
525 (-0.023243167866717804),
526 (-0.08439864242052121),
527 (-0.12447745395442235),
528 (-0.13269882229236105),
529 (-0.11138076254971943),
530 ]
531 rdnum2_ref = [
532 (0.08434628695750471),
533 (0.21062346808748914),
534 (0.2923363733569692),
535 (0.30864098822793734),
536 (0.2724507899268962),
537 (0.19074436436526077),
538 (0.08645309262667734),
539 (-0.01637634427660739),
540 (-0.10489775335475349),
541 (-0.16585624855733302),
542 (-0.18501284828027997),
543 (-0.16943316656628848),
544 (-0.1215592315308565),
545 (-0.058182463429868644),
546 (0.00847630200294344),
547 (0.06856975476699509),
548 (0.11502446471833112),
549 (0.13455905428225787),
550 (0.12906825376968398),
551 (0.10474254094395367),
552 (0.06807948226772825),
553 (0.026786767934201317),
554 (-0.01237838059633799),
555 (-0.0443544400890218),
556 (-0.060841380837895906),
557 (-0.06208083850580668),
558 ]
559 rdnum3_ref = [
560 (0.0029020000003043833),
561 (0.06956148347114777),
562 (0.11948309374787414),
563 (0.14159551296577533),
564 (0.13520243927978015),
565 (0.10570786835417678),
566 (0.061147073666667495),
567 (0.012644984879184307),
568 (-0.03277412613522657),
569 (-0.06816835842027302),
570 (-0.08535160297640232),
571 (-0.08568386849483467),
572 (-0.06862641456328866),
573 (-0.041949313090983154),
574 (-0.010991046288655326),
575 (0.019496433840693328),
576 (0.045411472970879885),
577 (0.06000675009110168),
578 (0.06237719263779695),
579 (0.055459369678878545),
580 (0.041067093610180905),
581 (0.022670576287353583),
582 (0.0037005204323037333),
583 (-0.01330224985274242),
584 (-0.023982707549885518),
585 (-0.027180050371500286),
586 ]
587 rgnum_ref = [
588 (0.9999999999998899),
589 (0.8688349497520953),
590 (0.5910913976636678),
591 (0.24642370692662396),
592 (-0.10192983466050798),
593 (-0.39677041619112785),
594 (-0.561626161229567),
595 (-0.6124042725308421),
596 (-0.5885544339423454),
597 (-0.4245818746517749),
598 (-0.21318001503400907),
599 (0.01727538923690375),
600 (0.20464550396281922),
601 (0.3241370138651334),
602 (0.37981812456289177),
603 (0.3829670537625063),
604 (0.306349327250377),
605 (0.16514219895125137),
606 (0.025539290697818018),
607 (-0.0954799764940617),
608 (-0.18404092327450883),
609 (-0.23295745713025617),
610 (-0.24418904680079123),
611 (-0.21372740465763762),
612 (-0.12348088227143172),
613 (-0.04091953305862539),
614 ]
615 vdnum0_ref = [
616 (-0.77538),
617 (-0.7811863758910647),
618 (-0.6556347650488735),
619 (-0.4316925391136899),
620 (-0.15922820758957576),
621 (0.11119734045036302),
622 (0.3246520280748058),
623 (0.4472854623218433),
624 (0.48785697131173245),
625 (0.442295322836427),
626 (0.3136382584280283),
627 (0.14441004037288763),
628 (-0.02959348025296491),
629 (-0.17025129133723313),
630 (-0.26183545523685964),
631 (-0.303085651136941),
632 (-0.2944324560056733),
633 (-0.22154786434163998),
634 (-0.11833663676346025),
635 (-0.010149388077418078),
636 (0.0833139633620755),
637 (0.15054829766921585),
638 (0.186328556406826),
639 (0.19103403517545617),
640 (0.15275810723488148),
641 (0.09193119286409025),
642 ]
643 vdnum1_ref = [
644 (-0.427268),
645 (-0.5309603454208828),
646 (-0.5382456751876933),
647 (-0.45029083801954034),
648 (-0.29375712072072363),
649 (-0.102793273979704),
650 (0.08122473286418207),
651 (0.2237890933638007),
652 (0.31457303920617646),
653 (0.34288566207080834),
654 (0.30212119329923925),
655 (0.2120250892944267),
656 (0.09484808545876959),
657 (-0.02128164859184025),
658 (-0.11765422929628072),
659 (-0.18460283281708043),
660 (-0.216304773382997),
661 (-0.20001698763524023),
662 (-0.1494381161874679),
663 (-0.07993747333413012),
664 (-0.006763840063493263),
665 (0.05807764072894879),
666 (0.10619563228299671),
667 (0.13337829216323221),
668 (0.13002135329619113),
669 (0.10324978155771455),
670 ]
671 vdnum2_ref = [
672 (-0.127928),
673 (-0.22433822994326136),
674 (-0.27602066610296094),
675 (-0.2722057937325647),
676 (-0.2202755345324273),
677 (-0.1344401094732441),
678 (-0.035636026605325694),
679 (0.05533025280153579),
680 (0.1278913854203787),
681 (0.17160772283680298),
682 (0.17762725605765986),
683 (0.15120348961722455),
684 (0.10097293229240813),
685 (0.04079488263339769),
686 (-0.018036812005879706),
687 (-0.06770662850093334),
688 (-0.10216646251901662),
689 (-0.1117553730186458),
690 (-0.09977828418787547),
691 (-0.07210467925796142),
692 (-0.03602133435843739),
693 (0.0016061697720409604),
694 (0.03494914200641798),
695 (0.059935919787940335),
696 (0.06975884068164784),
697 (0.06552764505311985),
698 ]
699 vdnum3_ref = [
700 (-0.028963),
701 (-0.08274556735514085),
702 (-0.11865659880671561),
703 (-0.12877637836886333),
704 (-0.11443713845813151),
705 (-0.08075177828758495),
706 (-0.036775947979712675),
707 (0.007553784808566575),
708 (0.04646016756736207),
709 (0.0739319638991898),
710 (0.08429279118423574),
711 (0.07855091155478137),
712 (0.05964847012637353),
713 (0.033521208058918936),
714 (0.0054639253661799714),
715 (-0.02046924840749944),
716 (-0.040821194729435316),
717 (-0.05016010622677305),
718 (-0.049021615176800745),
719 (-0.03942149457236898),
720 (-0.024356990241931917),
721 (-0.006944707917118663),
722 (0.009917318467300065),
723 (0.023968795687178763),
724 (0.031493681350258824),
725 (0.03234581246322336),
726 ]
727 vgnum_ref = [
728 (-0.874365),
729 (-0.709922032828806),
730 (-0.426156149324301),
731 (-0.10465047095432616),
732 (0.198477120454305),
733 (0.4358659968677081),
734 (0.5451490549239694),
735 (0.5515280691563401),
736 (0.4980829279270518),
737 (0.32096845998912177),
738 (0.11971532182104656),
739 (-0.0850447382848111),
740 (-0.238074271749472),
741 (-0.32250378341554387),
742 (-0.3481462054848407),
743 (-0.3273923438079883),
744 (-0.24192132112753134),
745 (-0.10359979997242741),
746 (0.02185961990209998),
747 (0.12267004267841061),
748 (0.18918123690563873),
749 (0.21809383083453066),
750 (0.21365109098794338),
751 (0.17387340496791126),
752 (0.0839251890575102),
753 (0.008437877113669988),
754 ]
755
756 rd0_diff = [abs(normalized_rd_num[0][i] - rdnum0_ref[i]) for i in range(len(normalized_rd_num[0]))]
757 rd1_diff = [abs(normalized_rd_num[1][i] - rdnum1_ref[i]) for i in range(len(normalized_rd_num[1]))]
758 rd2_diff = [abs(normalized_rd_num[2][i] - rdnum2_ref[i]) for i in range(len(normalized_rd_num[2]))]
759 rd3_diff = [abs(normalized_rd_num[3][i] - rdnum3_ref[i]) for i in range(len(normalized_rd_num[3]))]
760 rg_diff = [abs(normalized_rg_num[i] - rgnum_ref[i]) for i in range(len(normalized_rg_num))]
761 vd0_diff = [abs(normalized_vd_num[0][i] - vdnum0_ref[i]) for i in range(len(normalized_vd_num[0]))]
762 vd1_diff = [abs(normalized_vd_num[1][i] - vdnum1_ref[i]) for i in range(len(normalized_vd_num[1]))]
763 vd2_diff = [abs(normalized_vd_num[2][i] - vdnum2_ref[i]) for i in range(len(normalized_vd_num[2]))]
764 vd3_diff = [abs(normalized_vd_num[3][i] - vdnum3_ref[i]) for i in range(len(normalized_vd_num[3]))]
765 vg_diff = [abs(normalized_vg_num[i] - vgnum_ref[i]) for i in range(len(normalized_vg_num))]
766
767 print(f"rd0_diff = {rd0_diff} with len = {len(rd0_diff)} \n")
768 print(f"rd1_diff = {rd1_diff} with len = {len(rd1_diff)} \n")
769 print(f"rd2_diff = {rd2_diff} with len = {len(rd2_diff)} \n")
770 print(f"rd3_diff = {rd3_diff} with len = {len(rd3_diff)} \n")
771 print(f"rg_diff = {rg_diff} with len = {len(rg_diff)} \n")
772 print(f"vd0_diff = {vd0_diff} with len = {len(vd0_diff)} \n")
773 print(f"vd1_diff = {vd1_diff} with len = {len(vd1_diff)} \n")
774 print(f"vd2_diff = {vd2_diff} with len = {len(vd2_diff)} \n")
775 print(f"vd3_diff = {vd3_diff} with len = {len(vd3_diff)} \n")
776 print(f"vg_diff = {vg_diff} with len = {len(vg_diff)} \n")
777
778
779 """
780 CI results:
781
782 rd1_diff = 1.6653373124952964e-11 > 9.526221144423298e-12
783 rd2_diff = 7.569696605647103e-12 > 4.551825249226861e-12
784 rg_diff = 1.1102230246251565e-11 > 6.671338147750939e-12
785 vd0_diff = 3.779143664672802e-12 > 2.8379045771739676e-12
786 vd1_diff = 2.7466917629226373e-12 > 1.9998527270356682e-12
787 vd2_diff = 1.936215077158465e-12 > 1.0505010186786967e-12
788 vd3_diff = 1.220287759728933e-12 > 1e-12
789 vg_diff = 7.118580030995858e-12 > 5.104230592916915e-12
790
791 """
792
793
794 test_pass = True
795 rd0_max_pass = 1.5265566588595902e-11 + 1e-14
796 rd1_max_pass = 1.6653373124952964e-11 + 1e-14
797 rd2_max_pass = 7.569696605647103e-12 + 1e-14
798 rd3_max_pass = 1.1102230246251565e-11 + 1e-14
799 rg_max_pass = 1.1102230246251565e-11 + 1e-14
800 vd0_max_pass = 3.779143664672802e-12 + 1e-14
801 vd1_max_pass = 2.7466917629226373e-12 + 1e-14
802 vd2_max_pass = 1.936215077158465e-12 + 1e-14
803 vd3_max_pass = 1.220287759728933e-12 + 1e-14
804 vg_max_pass = 7.118580030995858e-12 + 1e-14
805
806 err_log = ""
807 if np.max(rd0_diff) > rd0_max_pass:
808 err_log += f"rd0_diff = {np.max(rd0_diff)} > {rd0_max_pass} \n"
809 test_pass = False
810
811 if np.max(rd1_diff) > rd1_max_pass:
812 err_log += f"rd1_diff = {np.max(rd1_diff)} > {rd1_max_pass} \n"
813 test_pass = False
814
815 if np.max(rd2_diff) > rd2_max_pass:
816 err_log += f"rd2_diff = {np.max(rd2_diff)} > {rd2_max_pass} \n"
817 test_pass = False
818
819 if np.max(rd3_diff) > rd3_max_pass:
820 err_log += f"rd3_diff = {np.max(rd3_diff)} > {rd3_max_pass} \n"
821 test_pass = False
822
823 if np.max(rg_diff) > rg_max_pass:
824 err_log += f"rg_diff = {np.max(rg_diff)} > {rg_max_pass} \n"
825 test_pass = False
826
827 if np.max(vd0_diff) > vd0_max_pass:
828 err_log += f"vd0_diff = {np.max(vd0_diff)} > {vd0_max_pass} \n"
829 test_pass = False
830
831 if np.max(vd1_diff) > vd1_max_pass:
832 err_log += f"vd1_diff = {np.max(vd1_diff)} > {vd1_max_pass} \n"
833 test_pass = False
834
835 if np.max(vd2_diff) > vd2_max_pass:
836 err_log += f"vd2_diff = {np.max(vd2_diff)} > {vd2_max_pass} \n"
837 test_pass = False
838
839 if np.max(vd3_diff) > vd3_max_pass:
840 err_log += f"vd3_diff = {np.max(vd3_diff)} > {vd3_max_pass} \n"
841 test_pass = False
842
843 if np.max(vg_diff) > vg_max_pass:
844 err_log += f"vg_diff = {np.max(vg_diff)} > {vg_max_pass} \n"
845 test_pass = False
846
847 if test_pass == False:
848 exit("Test did not pass L2 margins : \n" + err_log)
Estimated memory usage: 0 MB