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 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.8689243084003538),
475 (0.7900129335228211),
476 (0.5798426608166762),
477 (0.2938225522344795),
478 (-0.0095796352711508),
479 (-0.2699129709030079),
480 (-0.44097593524666795),
481 (-0.523313237789369),
482 (-0.5165562695239045),
483 (-0.3957957995390226),
484 (-0.22238856311196373),
485 (-0.028397871740248878),
486 (0.1400617212723998),
487 (0.2618040653740161),
488 (0.3320986596555553),
489 (0.3429670040452914),
490 (0.28252577558285363),
491 (0.1790292769476842),
492 (0.0611093545530017),
493 (-0.04812964530531704),
494 (-0.1340592667029017),
495 (-0.18782778275910902),
496 (-0.2071717358484437),
497 (-0.18043883382723444),
498 (-0.12034051175280334),
499 ]
500 rdnum1_ref = [
501 (0.39257198938890125),
502 (0.5542035334949146),
503 (0.6031567492591042),
504 (0.5482164911435082),
505 (0.4022260360677895),
506 (0.20250748977638247),
507 (-0.0038546893395401635),
508 (-0.17772545608547186),
509 (-0.30161100033904586),
510 (-0.35857646032059465),
511 (-0.34146345458664407),
512 (-0.2590032824468747),
513 (-0.13790812224466856),
514 (-0.008080715668762522),
515 (0.10729383762714646),
516 (0.1956018641415123),
517 (0.24939622660472502),
518 (0.24512031496782005),
519 (0.20208434362590458),
520 (0.1322991840889389),
521 (0.052441947135632855),
522 (-0.023243113530342814),
523 (-0.08439859111743846),
524 (-0.1244774019971001),
525 (-0.13269876992703125),
526 (-0.11138071248969174),
527 ]
528 rdnum2_ref = [
529 (0.08434628695750471),
530 (0.2106234613201813),
531 (0.29233635731829827),
532 (0.30864096360977344),
533 (0.27245075904708016),
534 (0.19074432915103703),
535 (0.08645304943248056),
536 (-0.0163763947558792),
537 (-0.10489780718740042),
538 (-0.16585631000509368),
539 (-0.18501291153417),
540 (-0.16943323371251598),
541 (-0.1215592992932572),
542 (-0.05818253079713124),
543 (0.008476227008455597),
544 (0.06856968167401477),
545 (0.11502438559835919),
546 (0.1345589710807061),
547 (0.12906816951745848),
548 (0.10474245976199668),
549 (0.06807939950673277),
550 (0.026786679910753477),
551 (-0.01237846845022465),
552 (-0.044354519808513605),
553 (-0.06084145814568271),
554 (-0.06208091555016808),
555 ]
556 rdnum3_ref = [
557 (0.0029020000003043833),
558 (0.06956148160597309),
559 (0.11948308370257621),
560 (0.14159549809544814),
561 (0.13520241968878466),
562 (0.10570784073626882),
563 (0.06114704406146032),
564 (0.012644954090479388),
565 (-0.032774167729732184),
566 (-0.06816840718126826),
567 (-0.08535165213818807),
568 (-0.08568391917540552),
569 (-0.06862646604988143),
570 (-0.041949368014826405),
571 (-0.010991112647795731),
572 (0.019496359253690088),
573 (0.045411398288397464),
574 (0.06000667777783519),
575 (0.06237712182333155),
576 (0.05545930155337331),
577 (0.041067031455455094),
578 (0.02267052120474844),
579 (0.0037004655739636405),
580 (-0.01330230883556105),
581 (-0.023982772304753652),
582 (-0.02718012056646124),
583 ]
584 rgnum_ref = [
585 (0.9999999999998899),
586 (0.8688349495944436),
587 (0.5910913966955533),
588 (0.24642370436422922),
589 (-0.10192983860846105),
590 (-0.39677041999586216),
591 (-0.5616261642438225),
592 (-0.6124042747268632),
593 (-0.5885544362038697),
594 (-0.4245818736492435),
595 (-0.21318001317105484),
596 (0.01727539233220554),
597 (0.20464550652965485),
598 (0.3241370146556122),
599 (0.3798181242165022),
600 (0.382967052312555),
601 (0.30634932297157746),
602 (0.16514219501662097),
603 (0.02553928702075936),
604 (-0.09547997896985905),
605 (-0.18404092465562627),
606 (-0.2329574576809268),
607 (-0.24418904713052747),
608 (-0.21372740394154377),
609 (-0.1234808815664401),
610 (-0.04091953289209194),
611 ]
612 vdnum0_ref = [
613 (-0.77538),
614 (-0.781186383236733),
615 (-0.6556348063526707),
616 (-0.431692543997261),
617 (-0.15922820267203422),
618 (0.11119734803542475),
619 (0.32465204189864033),
620 (0.4472854797974426),
621 (0.48785696792567634),
622 (0.4422953343494822),
623 (0.31363825298202574),
624 (0.1444100268983182),
625 (-0.029593491256808366),
626 (-0.1702512989966378),
627 (-0.26183545779312434),
628 (-0.3030856597147541),
629 (-0.29443245106934907),
630 (-0.22154787441090817),
631 (-0.11833662986595124),
632 (-0.010149384784945393),
633 (0.08331396932387314),
634 (0.15054830693968646),
635 (0.18632856107039308),
636 (0.1910340352281365),
637 (0.15275810096450626),
638 (0.09193118807910677),
639 ]
640 vdnum1_ref = [
641 (-0.427268),
642 (-0.5309603274302681),
643 (-0.5382456189793695),
644 (-0.45029078119126137),
645 (-0.2937570630107788),
646 (-0.10279324321150173),
647 (0.08122475595499018),
648 (0.22378911020485165),
649 (0.3145730418492861),
650 (0.3428856624382193),
651 (0.3021212140322564),
652 (0.2120251011096913),
653 (0.09484809107712948),
654 (-0.021281651016827028),
655 (-0.11765423360886178),
656 (-0.18460281424303243),
657 (-0.2163047646237174),
658 (-0.20001699393414982),
659 (-0.14943812056652284),
660 (-0.07993746406650025),
661 (-0.006763838184138619),
662 (0.05807764256833735),
663 (0.10619564137021366),
664 (0.1333782902580678),
665 (0.13002136114951282),
666 (0.10324977746982779),
667 ]
668 vdnum2_ref = [
669 (-0.127928),
670 (-0.2243382283746973),
671 (-0.2760206636868744),
672 (-0.27220579966746783),
673 (-0.22027553130270333),
674 (-0.13444010386431185),
675 (-0.03563601519062676),
676 (0.055330261638473016),
677 (0.12789139719241827),
678 (0.17160771661733515),
679 (0.17762726797422304),
680 (0.15120346580458535),
681 (0.100972939744592),
682 (0.04079487861877566),
683 (-0.018036818208465574),
684 (-0.06770663215960371),
685 (-0.10216645884504397),
686 (-0.11175538977735708),
687 (-0.09977828679379383),
688 (-0.07210466726058655),
689 (-0.036021335786910226),
690 (0.0016061683962408043),
691 (0.034949136272573345),
692 (0.05993591866295704),
693 (0.06975885269855503),
694 (0.06552765574752095),
695 ]
696 vdnum3_ref = [
697 (-0.028963),
698 (-0.08274555765702404),
699 (-0.11865660363389191),
700 (-0.12877636631156245),
701 (-0.11443714294023342),
702 (-0.08075178512262489),
703 (-0.036775938607481656),
704 (0.007553788906539163),
705 (0.046460171634107),
706 (0.07393195401472996),
707 (0.08429278412481772),
708 (0.0785509205551686),
709 (0.05964847759684788),
710 (0.03352120599663045),
711 (0.005463917800776763),
712 (-0.02046925825971172),
713 (-0.04082120950357363),
714 (-0.05016012086852671),
715 (-0.04902162281092094),
716 (-0.03942149055550854),
717 (-0.024356974774582756),
718 (-0.006944696795883246),
719 (0.009917329517621492),
720 (0.02396880921609092),
721 (0.03149369616872048),
722 (0.03234582585608311),
723 ]
724 vgnum_ref = [
725 (-0.874365),
726 (-0.7099220326507727),
727 (-0.4261561487361488),
728 (-0.10465046845171813),
729 (0.19847712581412003),
730 (0.4358660029173281),
731 (0.5451490601709348),
732 (0.5515280703053866),
733 (0.49808292892149175),
734 (0.32096845590611023),
735 (0.11971531598819532),
736 (-0.08504474565502744),
737 (-0.23807427810913015),
738 (-0.32250378785285144),
739 (-0.3481462092267303),
740 (-0.3273923454130979),
741 (-0.24192131787380006),
742 (-0.10359979718690686),
743 (0.021859623166806383),
744 (0.12267004693966344),
745 (0.18918124141677414),
746 (0.21809383370807792),
747 (0.21365109301271507),
748 (0.1738734039620283),
749 (0.08392518783167185),
750 (0.0084378750306759),
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 rd0_diff = 9.71445146547012e-12 > 1e-12
780 rd1_diff = 5.947632143732395e-12 > 1e-12
781 rd2_diff = 3.027880030037622e-12 > 1e-12
782 rd3_diff = 4.440892098500626e-12 > 1e-12
783 rg_diff = 1.1102230246251565e-11 > 1e-12
784 vd0_diff = 3.4523772729500024e-12 > 1e-12
785 vd1_diff = 2.9127256162553294e-12 > 1e-12
786 vd2_diff = 2.0037860259947138e-12 > 1e-12
787 vd3_diff = 1.157754447866921e-12 > 1e-12
788 vg_diff = 6.4616922923477205e-12 > 1e-12
789
790 """
791
792
793 test_pass = True
794 rd0_max_pass = 1e-11
795 rd1_max_pass = 1e-11
796 rd2_max_pass = 1e-11
797 rd3_max_pass = 1e-11
798 rg_max_pass = 1e-10
799 vd0_max_pass = 1e-11
800 vd1_max_pass = 1e-11
801 vd2_max_pass = 1e-11
802 vd3_max_pass = 1e-11
803 vg_max_pass = 1e-11
804
805 err_log = ""
806 if np.max(rd0_diff) > rd0_max_pass:
807 err_log += f"rd0_diff = {np.max(rd0_diff)} > {rd0_max_pass} \n"
808 test_pass = False
809
810 if np.max(rd1_diff) > rd1_max_pass:
811 err_log += f"rd1_diff = {np.max(rd1_diff)} > {rd1_max_pass} \n"
812 test_pass = False
813
814 if np.max(rd2_diff) > rd2_max_pass:
815 err_log += f"rd2_diff = {np.max(rd2_diff)} > {rd2_max_pass} \n"
816 test_pass = False
817
818 if np.max(rd3_diff) > rd3_max_pass:
819 err_log += f"rd3_diff = {np.max(rd3_diff)} > {rd3_max_pass} \n"
820 test_pass = False
821
822 if np.max(rg_diff) > rg_max_pass:
823 err_log += f"rg_diff = {np.max(rg_diff)} > {rg_max_pass} \n"
824 test_pass = False
825
826 if np.max(vd0_diff) > vd0_max_pass:
827 err_log += f"vd0_diff = {np.max(vd0_diff)} > {vd0_max_pass} \n"
828 test_pass = False
829
830 if np.max(vd1_diff) > vd1_max_pass:
831 err_log += f"vd1_diff = {np.max(vd1_diff)} > {vd1_max_pass} \n"
832 test_pass = False
833
834 if np.max(vd2_diff) > vd2_max_pass:
835 err_log += f"vd2_diff = {np.max(vd2_diff)} > {vd2_max_pass} \n"
836 test_pass = False
837
838 if np.max(vd3_diff) > vd3_max_pass:
839 err_log += f"vd3_diff = {np.max(vd3_diff)} > {vd3_max_pass} \n"
840 test_pass = False
841
842 if np.max(vg_diff) > vg_max_pass:
843 err_log += f"vg_diff = {np.max(vg_diff)} > {vg_max_pass} \n"
844 test_pass = False
845
846 if test_pass == False:
847 exit("Test did not pass L2 margins : \n" + err_log)
Estimated memory usage: 0 MB