Skip to content

Commit

Permalink
fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasaunai committed Jul 30, 2024
1 parent a233cc7 commit ba2575a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
5 changes: 2 additions & 3 deletions tests/functional/alfven_wave/alfven_wave1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def main():
cpp = cpp_lib()

from pyphare.pharesee.run import Run
from pyphare.pharesee.hierarchy import flat_finest_field

sim = config()
Simulator(sim).run()
Expand All @@ -163,8 +162,8 @@ def main():

sorted_patches = sorted(B.level(1).patches, key=lambda p: p.box.lower[0])

x0 = sorted_patches[0].patch_datas["By"].x[0]
x1 = sorted_patches[-1].patch_datas["By"].x[-1]
x0 = sorted_patches[0].patch_datas["y"].x[0]
x1 = sorted_patches[-1].patch_datas["y"].x[-1]

B = r.GetB(t[-1])
by, xby = flat_finest_field(B, "By")
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/conservation/conserv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pyphare.pharein as ph
from pyphare.simulator.simulator import Simulator
from pyphare.pharesee.run import Run
from pyphare.pharesee.hierarchy import get_times_from_h5
from pyphare.pharesee.hierarchy.fromh5 import get_times_from_h5

import os
import numpy as np
Expand Down Expand Up @@ -155,17 +155,17 @@ def mag_energy(B, lvlNbr=0):
if lvlNbr == ilvl:
tot = 0.0
for ip, patch in enumerate(lvl.patches):
pdata = patch.patch_datas["Bx"]
pdata = patch.patch_datas["x"]

# Bx is primal, but By and Bz dual so
# we average By and Bz onto Bx to use them
# in the same formula
ghosts_nbr = pdata.ghosts_nbr[0]
bx = patch.patch_datas["Bx"].dataset[ghosts_nbr:-ghosts_nbr]
bytmp = patch.patch_datas["By"].dataset[
bx = patch.patch_datas["x"].dataset[ghosts_nbr:-ghosts_nbr]
bytmp = patch.patch_datas["y"].dataset[
ghosts_nbr - 1 : -(ghosts_nbr - 1)
]
bztmp = patch.patch_datas["Bz"].dataset[
bztmp = patch.patch_datas["z"].dataset[
ghosts_nbr - 1 : -(ghosts_nbr - 1)
]
by = 0.5 * (bytmp[1:] + bytmp[:-1])
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/ionIonBeam/ion_ion_beam1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pyphare.pharein as ph
from pyphare.simulator.simulator import Simulator
from pyphare.pharesee.hierarchy import get_times_from_h5
from pyphare.pharesee.hierarchy.fromh5 import get_times_from_h5
from pyphare.pharesee.run import Run

from tests.diagnostic import all_timestamps
Expand Down Expand Up @@ -126,8 +126,8 @@ def growth_b_right_hand(run_path, time_offset):
for time in times:
B_hier = r.GetB(time, merged=True, interp="linear")

by_interpolator, xyz_finest = B_hier["By"]
bz_interpolator, xyz_finest = B_hier["Bz"]
by_interpolator, xyz_finest = B_hier["y"]
bz_interpolator, xyz_finest = B_hier["z"]

# remove the last point so that "x" is periodic wo. last point = first point
x = xyz_finest[0][:-1]
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/shock/shock.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def main():
fig, ax = plt.subplots()
B = r.GetB(t, merged=True)
title = "interp order {} - t = {:06.3f}".format(interp_order, t)
x = B["By"][1][0]
By = B["By"][0]
x = B["y"][1][0]
By = B["y"][0]
ax.plot(x, By(x), color="k")
ax.set_title(title)
ax.set_ylim((-0.2, 5))
Expand Down Expand Up @@ -172,8 +172,8 @@ def main():
for r, color, interp_order in zip(runs, colors, (1, 2, 3)):
print(r.path)
B = r.GetB(t, merged=True)
x = B["By"][1][0]
By = B["By"][0]
x = B["y"][1][0]
By = B["y"][0]
ax.plot(x, By(x), color=color, label=f"interp order {interp_order}")
title = "interp order {} - t = {:06.3f}".format(interp_order, t)
ax.set_title(title)
Expand Down
16 changes: 8 additions & 8 deletions tests/functional/tdtagged/td1dtagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ def make_figure():
JwT = rwT.GetJ(plot_time, merged=True, interp="linear")
JNoRef = rNoRef.GetJ(plot_time, merged=True, interp="linear")

xbywT = BwT["By"][1][0]
bywT = BwT["By"][0](xbywT)
xbyNoRef = BNoRef["By"][1][0]
byNoRef = BNoRef["By"][0](xbyNoRef)
xjzwT = JwT["Jz"][1][0]
jzwT = JwT["Jz"][0](xjzwT)
xjzNoRef = JNoRef["Jz"][1][0]
jzNoRef = JNoRef["Jz"][0](xjzNoRef)
xbywT = BwT["y"][1][0]
bywT = BwT["y"][0](xbywT)
xbyNoRef = BNoRef["y"][1][0]
byNoRef = BNoRef["y"][0](xbyNoRef)
xjzwT = JwT["z"][1][0]
jzwT = JwT["z"][0](xjzwT)
xjzNoRef = JNoRef["z"][1][0]
jzNoRef = JNoRef["z"][0](xjzNoRef)

fig, axarr = plt.subplots(nrows=3, figsize=(8, 8))

Expand Down
6 changes: 3 additions & 3 deletions tests/simulator/test_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ def _test_B_is_as_provided_by_user(self, dim, interp_order, **kwargs):
self.assertTrue(ilvl == 0) # only level 0 is expected perfect precision
print("checking level {}".format(ilvl))
for patch in level.patches:
bx_pd = patch.patch_datas["Bx"]
by_pd = patch.patch_datas["By"]
bz_pd = patch.patch_datas["Bz"]
bx_pd = patch.patch_datas["x"]
by_pd = patch.patch_datas["y"]
bz_pd = patch.patch_datas["z"]

bx = bx_pd.dataset[:]
by = by_pd.dataset[:]
Expand Down

0 comments on commit ba2575a

Please sign in to comment.