Skip to content

Commit

Permalink
quicker alf
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Aug 2, 2024
1 parent 7209309 commit cd88daa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
16 changes: 12 additions & 4 deletions pyphare/pyphare/pharesee/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@


class Run:
def __init__(self, path):
def __init__(self, path, default_time=None):
self.path = path
self.default_time_ = default_time
import glob

self.available_diags = glob.glob(os.path.join(self.path, "*.h5"))
Expand Down Expand Up @@ -69,7 +70,7 @@ def _get(self, hierarchy, time, merged, interp):
"""
if merged:
domain = self.GetDomainSize()
dl = self.GetDl()
dl = self.GetDl(time=time)

# assumes all qties in the hierarchy have the same ghost width
# so take the first patch data of the first patch of the first level....
Expand Down Expand Up @@ -248,8 +249,15 @@ def GetDl(self, level="finest", time=None):

data_file = h5py.File(h5_filename, "r")

if time is None:
time = float(list(data_file[h5_time_grp_key].keys())[0])
def _get_time():
if time:
return time
if self.default_time_:
return self.default_time_
self.default_time_ = float(list(data_file[h5_time_grp_key].keys())[0])
return self.default_time_

time = _get_time()

hier = self._get_hierarchy(time, h5_filename.split("/")[-1])

Expand Down
13 changes: 8 additions & 5 deletions tests/functional/alfven_wave/alfven_wave1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyphare.simulator.simulator import Simulator
from pyphare.pharesee.hierarchy.fromh5 import get_times_from_h5
from pyphare.pharesee.run import Run
from pyphare.pharesee.hierarchy.hierarchy_utils import flat_finest_field


from tests.diagnostic import all_timestamps

Expand All @@ -23,11 +23,14 @@
def config():
# configure the simulation

final_time = 1000
time_step_nbr = 100000

sim = ph.Simulation(
smallest_patch_size=50,
largest_patch_size=50,
time_step_nbr=100000, # number of time steps (not specified if time_step and final_time provided)
final_time=1000, # simulation final time (not specified if time_step and time_step_nbr provided)
time_step_nbr=time_step_nbr, # number of time steps (not specified if time_step and final_time provided)
final_time=final_time, # simulation final time (not specified if time_step and time_step_nbr provided)
boundary_types="periodic", # boundary condition, string or tuple, length == len(cell) == len(dl)
cells=1000, # integer or tuple length == dimension
dl=1, # mesh size of the root level, float or tuple
Expand Down Expand Up @@ -88,7 +91,7 @@ def vthz(x):

ph.ElectronModel(closure="isothermal", Te=0.0)

timestamps = all_timestamps(sim)
timestamps = [0, int(final_time / 2), final_time]

for quantity in ["E", "B"]:
ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps)
Expand Down Expand Up @@ -145,7 +148,7 @@ def main():
if cpp.mpi_rank() == 0:
vphi, t, phi, a, k = phase_speed(".", 0.01, 1000)

r = Run(".")
r = Run(".", 0)
t = get_times_from_h5("EM_B.h5")
fig, ax = plt.subplots(figsize=(9, 5), nrows=1)

Expand Down
1 change: 0 additions & 1 deletion tests/functional/conservation/conserv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pyphare.pharesee.run import Run
from pyphare.pharesee.hierarchy.fromh5 import get_times_from_h5

import os
import numpy as np
from glob import glob

Expand Down
1 change: 0 additions & 1 deletion tests/functional/dispersion/dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pyphare.simulator.simulator import Simulator


import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

Expand Down
4 changes: 1 addition & 3 deletions tests/functional/ionIonBeam/ion_ion_beam1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
from pyphare.pharesee.hierarchy.fromh5 import get_times_from_h5
from pyphare.pharesee.run import Run

from tests.diagnostic import all_timestamps

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from scipy.optimize import curve_fit
from scipy.signal import find_peaks
from pyphare.pharesee import plotting
from pathlib import Path


mpl.use("Agg")

Expand Down

0 comments on commit cd88daa

Please sign in to comment.