def test_dump_diags_timestamps(self): print("test_dump_diags dim/interp:{}/{}".format(1, 1)) simulation = ph.Simulation(**simArgs.copy()) sim = simulation dump_every = 1 timestamps = np.arange(0, sim.final_time + sim.time_step, dump_every * sim.time_step) setup_model(10) for quantity in ["B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, flush_every=ElectromagDiagnostics.h5_flush_never, ) Simulator(simulation).run() def make_time(stamp): return "{:.10f}".format(stamp) for diagInfo in ph.global_vars.sim.diagnostics: h5_filename = os.path.join(out, h5_filename_from(diagInfo)) self.assertTrue(os.path.exists(h5_filename)) h5_file = h5py.File(h5_filename, "r") for timestamp in timestamps: self.assertIn(make_time(timestamp), h5_file[h5_time_grp_key])
def withTagging(**kwargs): Simulation(smallest_patch_size=20, largest_patch_size=20, time_step_nbr=2000, final_time=20., boundary_types="periodic", cells=200, dl=1.0, refinement="tagging", max_nbr_levels=3, diag_options={ "format": "phareh5", "options": { "dir": kwargs["diagdir"], "mode": "overwrite" } }) MaxwellianFluidModel(bx=bx, by=by, bz=bz, protons={ "charge": 1, "density": density, **vvv }) ElectronModel(closure="isothermal", Te=0.12) sim = ph.global_vars.sim timestamps = all_timestamps(sim) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def test_hierarchy_timestamp_cadence(self, refinement_boxes): dim = refinement_boxes["L0"]["B0"].ndim time_step = .001 # time_step_nbr chosen to force diagnostics dumping double imprecision cadence calculations accuracy testing time_step_nbr = 101 final_time = time_step * time_step_nbr for trailing in [0, 1]: # 1 = skip init dumps for i in [2, 3]: simInput = simArgs.copy() diag_outputs = f"phare_outputs_hierarchy_timestamp_cadence_{dim}_{self.ddt_test_id()}_{i}" simInput["diag_options"]["options"]["dir"] = diag_outputs simInput["time_step_nbr"] = time_step_nbr ph.global_vars.sim = None simulation = ph.Simulation(**simInput) setup_model(10) timestamps = np.arange(0, final_time, time_step * i)[trailing:] for quantity in ["B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, flush_every=ElectromagDiagnostics.h5_flush_never, ) Simulator(simulation).run() for diagInfo in simulation.diagnostics: h5_filename = os.path.join(diag_outputs, h5_filename_from(diagInfo)) self.assertTrue(os.path.exists(h5_filename)) hier = hierarchy_from(h5_filename=h5_filename) time_hier_keys = list(hier.time_hier.keys()) self.assertEqual(len(time_hier_keys), len(timestamps)) for i, timestamp in enumerate(time_hier_keys): self.assertEqual(hier.format_timestamp(timestamps[i]), timestamp)
def uniform(vth, dl, cells, nbr_steps): Simulation( smallest_patch_size=20, largest_patch_size=20, time_step_nbr=nbr_steps, final_time=50., boundary_types="periodic", cells=cells, dl=dl, diag_options={"format": "phareh5", "options": {"dir": "vth{}dx{}".format(vth,dl), "mode":"overwrite"}} ) def density(x): return 1. def by(x): return 0. def bz(x): return 0. def bx(x): return 1. def vx(x): return 0. def vy(x): return 0. def vz(x): return 0. def vthx(x): return vth def vthy(x): return vth def vthz(x): return vth vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} ) ElectronModel(closure="isothermal", Te=0.) sim = ph.global_vars.sim timestamps = np.arange(0, sim.final_time, 50*sim.time_step) for quantity in ["B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for name in ["domain", "levelGhost", "patchGhost"]: ParticleDiagnostics(quantity=name, compute_timestamps=timestamps, write_timestamps=timestamps, population_name="protons")
MaxwellianFluidModel(bx=bx, protons={"density":n}, background={}) ElectronModel(closure="isothermal",Te = Te) ElectromagDiagnostics( diag_type="E", # available : ("E", "B") write_every=10, compute_every=5, start_teration=0, last_iteration=990, path = 'ElectromagDiagnostics1' # where output files will be written, [default: name] ) FluidDiagnostics( diag_type="density", # choose in (rho_s, flux_s) write_every=10, # write on disk every x iterations compute_every=5, # compute diagnostics every x iterations ( x <= write_every) start_iteration=0, # iteration at which diag is enabled last_iteration=990, # iteration at which diag is turned off population_name="protons" # name of the population for which the diagnostics is made #,path = 'FluidDiagnostics1' # where output files will be written, [default: name] )
def config(): # configure the simulation 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) 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 hyper_resistivity=0.001, refinement_boxes={"L0": { "B0": [(450, ), (550, )] }}, diag_options={ "format": "phareh5", "options": { "dir": ".", "mode": "overwrite" } }) def density(x): return 1. def by(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.01 * np.cos(2 * np.pi * x / L[0]) def bz(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.01 * np.sin(2 * np.pi * x / L[0]) def bx(x): return 1. def vx(x): return 0. def vy(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.01 * np.cos(2 * np.pi * x / L[0]) def vz(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.01 * np.sin(2 * np.pi * x / L[0]) def vthx(x): return 0.01 def vthy(x): return 0.01 def vthz(x): return 0.01 vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel(bx=bx, by=by, bz=bz, protons={ "charge": 1, "density": density, **vvv }) ElectronModel(closure="isothermal", Te=0.0) timestamps = all_timestamps(gv.sim) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def config(): # most unstable mode at k=0.19, that is lambda = 33 # hence the length of the box is 33, and the fourier mode will be 1 Simulation( smallest_patch_size=20, largest_patch_size=60, final_time=50, time_step=0.0005, boundary_types="periodic", cells=165, dl=0.2, hyper_resistivity = 0.01, refinement_boxes={"L0": {"B0": [( 50, ), (110, )]}, "L1": {"B0": [(140, ), (180, )]} }, diag_options={"format": "phareh5", "options": {"dir": "ion_ion_beam1d", "mode": "overwrite"}} ) def densityMain(x): return 1. def densityBeam(x): return .01 def bx(x): return 1. def by(x): return 0. def bz(x): return 0. def vB(x): return 5. def v0(x): return 0. def vth(x): return np.sqrt(0.1) vMain = { "vbulkx": v0, "vbulky": v0, "vbulkz": v0, "vthx": vth, "vthy": vth, "vthz": vth } vBulk = { "vbulkx": vB, "vbulky": v0, "vbulkz": v0, "vthx": vth, "vthy": vth, "vthz": vth } MaxwellianFluidModel( bx=bx, by=by, bz=bz, main={"charge": 1, "density": densityMain, **vMain}, beam={"charge": 1, "density": densityBeam, **vBulk} ) ElectronModel(closure="isothermal", Te=0.0) sim = ph.global_vars.sim timestamps = np.arange(0, sim.final_time, 1.) for quantity in ["B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def config(): """ Configure the simulation This function defines the Simulation object, user initialization model and diagnostics. """ Simulation( smallest_patch_size=20, largest_patch_size=20, time_step_nbr= 6000, # number of time steps (not specified if time_step and final_time provided) final_time= 30, # 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=2500, # integer or tuple length == dimension dl=0.2, # mesh size of the root level, float or tuple #max_nbr_levels=1, # (default=1) max nbr of levels in the AMR hierarchy nesting_buffer=0, refinement_boxes={"L0": { "B0": [(125, ), (750, )] }}, diag_options={ "format": "phareh5", "options": { "dir": "shock_20dx_dx02_refined", "mode": "overwrite" } }) def density(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain()[0] v1 = 1 v2 = 1. return v1 + (v2 - v1) * (S(x, L * 0.2, 1) - S(x, L * 0.8, 1)) def S(x, x0, l): return 0.5 * (1 + np.tanh((x - x0) / l)) def bx(x): return 0. def by(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain()[0] v1 = 0.125 v2 = 4.0 return v1 + (v2 - v1) * (S(x, L * 0.2, 1) - S(x, L * 0.8, 1)) def bz(x): return 0. def T(x): return 0.1 def vx(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain()[0] v1 = 0. v2 = 0. return v1 + (v2 - v1) * (S(x, L * 0.25, 1) - S(x, L * 0.75, 1)) def vy(x): return 0. def vz(x): return 0. def vthx(x): return T(x) def vthy(x): return T(x) def vthz(x): return T(x) vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel(bx=bx, by=by, bz=bz, protons={ "charge": 1, "density": density, **vvv }) ElectronModel(closure="isothermal", Te=0.12) sim = ph.global_vars.sim timestamps = np.arange(0, sim.final_time + sim.time_step, sim.time_step) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def config(): """ Configure the simulation This function defines the Simulation object, user initialization model and diagnostics. """ Simulation( smallest_patch_size=20, largest_patch_size=20, time_step_nbr= 2000, # number of time steps (not specified if time_step and final_time provided) final_time= 20., # 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=500, # integer or tuple length == dimension dl=1., # mesh size of the root level, float or tuple refinement_boxes={ "L0": { "B0": [(80, ), (180, )] }, "L1": { "B0": [(200, ), (300, )] } }, diag_options={ "format": "phareh5", "options": { "dir": "td_noflow", "mode": "overwrite" } }) def density(x): return 1. def S(x, x0, l): return 0.5 * (1 + np.tanh((x - x0) / l)) def bx(x): return 0. def by(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain()[0] v1 = -1 v2 = 1. return v1 + (v2 - v1) * (S(x, L * 0.25, 1) - S(x, L * 0.75, 1)) def bz(x): return 0.5 def b2(x): return bx(x)**2 + by(x)**2 + bz(x)**2 def T(x): K = 1 return 1 / density(x) * (K - b2(x) * 0.5) def vx(x): return 0. def vy(x): return 0. def vz(x): return 0. def vthx(x): return T(x) def vthy(x): return T(x) def vthz(x): return T(x) vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel(bx=bx, by=by, bz=bz, protons={ "charge": 1, "density": density, **vvv }) ElectronModel(closure="isothermal", Te=0.12) sim = ph.global_vars.sim dt_dump = 0.1 n_dump = int(sim.final_time / dt_dump) + 1 timestamps = np.linspace(0, sim.final_time, n_dump) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def config(): """ Configure the simulation This function defines the Simulation object, user initialization model and diagnostics. """ Simulation( smallest_patch_size=10, largest_patch_size=20, time_step_nbr=2000, # number of time steps (not specified if time_step and final_time provided) final_time=20, # 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=400, # integer or tuple length == dimension dl=0.5, # mesh size of the root level, float or tuple max_nbr_levels=3, # (default=1) max nbr of levels in the AMR hierarchy nesting_buffer=2, refinement = "tagging", diag_options={"format": "phareh5", "options": {"dir": "refine_dx05_lvl3","mode":"overwrite"}} ) def density(x): return 1. def S(x,x0,l): return 0.5*(1+np.tanh((x-x0)/l)) def bx(x): return 0. def by(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain()[0] v1=-1 v2=1. return v1 + (v2-v1)*(S(x,L*0.25,1) -S(x, L*0.75, 1)) def bz(x): return 0.5 def b2(x): return bx(x)**2 + by(x)**2 + bz(x)**2 def T(x): K = 1 return 1/density(x)*(K - b2(x)*0.5) def vx(x): return 1. def vy(x): return 0. def vz(x): return 0. def vthx(x): return T(x) def vthy(x): return T(x) def vthz(x): return T(x) vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} ) ElectronModel(closure="isothermal", Te=0.12) timestamps = all_timestamps(gv.sim) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def config(): Simulation( smallest_patch_size=15, largest_patch_size=25, time_step_nbr=1000, time_step=0.001, # boundary_types="periodic", cells=(100, 100), dl=(0.2, 0.2), refinement_boxes={}, hyper_resistivity=0.001, resistivity=0.001, diag_options={ "format": "phareh5", "options": { "dir": diag_outputs, "mode": "overwrite" } }, strict=True, ) def density(x, y): from pyphare.pharein.global_vars import sim L = sim.simulation_domain()[1] return 0.2 + 1. / np.cosh((y - L * 0.3) / 0.5)**2 + 1. / np.cosh( (y - L * 0.7) / 0.5)**2 def S(y, y0, l): return 0.5 * (1. + np.tanh((y - y0) / l)) def by(x, y): from pyphare.pharein.global_vars import sim Lx = sim.simulation_domain()[0] Ly = sim.simulation_domain()[1] w1 = 0.2 w2 = 1.0 x0 = (x - 0.5 * Lx) y1 = (y - 0.3 * Ly) y2 = (y - 0.7 * Ly) w3 = np.exp(-(x0 * x0 + y1 * y1) / (w2 * w2)) w4 = np.exp(-(x0 * x0 + y2 * y2) / (w2 * w2)) w5 = 2.0 * w1 / w2 return (w5 * x0 * w3) + (-w5 * x0 * w4) def bx(x, y): from pyphare.pharein.global_vars import sim Lx = sim.simulation_domain()[0] Ly = sim.simulation_domain()[1] w1 = 0.2 w2 = 1.0 x0 = (x - 0.5 * Lx) y1 = (y - 0.3 * Ly) y2 = (y - 0.7 * Ly) w3 = np.exp(-(x0 * x0 + y1 * y1) / (w2 * w2)) w4 = np.exp(-(x0 * x0 + y2 * y2) / (w2 * w2)) w5 = 2.0 * w1 / w2 v1 = -1 v2 = 1. return v1 + (v2 - v1) * (S(y, Ly * 0.3, 0.5) - S(y, Ly * 0.7, 0.5)) + ( -w5 * y1 * w3) + (+w5 * y2 * w4) def bz(x, y): return 0. def b2(x, y): return bx(x, y)**2 + by(x, y)**2 + bz(x, y)**2 def T(x, y): K = 1 temp = 1. / density(x, y) * (K - b2(x, y) * 0.5) assert np.all(temp > 0) return temp def vx(x, y): return 0. def vy(x, y): return 0. def vz(x, y): return 0. def vthx(x, y): return np.sqrt(T(x, y)) def vthy(x, y): return np.sqrt(T(x, y)) def vthz(x, y): return np.sqrt(T(x, y)) vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz, "nbr_part_per_cell": 100 } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={ "charge": 1, "density": density, **vvv, "init": { "seed": 12334 } }, ) ElectronModel(closure="isothermal", Te=0.0) sim = ph.global_vars.sim dt = 10 * sim.time_step nt = sim.final_time / dt + 1 timestamps = (dt * np.arange(nt)) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def config(diag_outputs, model_init={}, refinement_boxes=None): ph.global_vars.sim = None Simulation( smallest_patch_size=10, largest_patch_size=20, time_step_nbr= 1, final_time= 0.001, #boundary_types="periodic", cells=(50, 100), dl=(0.40, 0.40), #refinement="tagging", #max_nbr_levels = 3, refinement_boxes=refinement_boxes, hyper_resistivity=0.0050, resistivity=0.001, diag_options={"format": "phareh5", "options": {"dir": diag_outputs, "mode":"overwrite", "fine_dump_lvl_max": 10}} ) def density(x, y): from pyphare.pharein.global_vars import sim Lx = sim.simulation_domain()[0] return 1. def bx(x, y): return 0.1 def by(x, y): from pyphare.pharein.global_vars import sim Lx = sim.simulation_domain()[0] Ly = sim.simulation_domain()[1] return 0.2 def bz(x, y): return 1. def T(x, y): return 1. def vx(x, y): return 1.0 def vy(x, y): return 0. def vz(x, y): return 0. def vthx(x, y): return np.sqrt(T(x, y)) def vthy(x, y): return np.sqrt(T(x, y)) def vthz(x, y): return np.sqrt(T(x, y)) vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz, "nbr_part_per_cell":100, "init": model_init, } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} ) ElectronModel(closure="isothermal", Te=0.0) sim = ph.global_vars.sim dt = 1*sim.time_step nt = sim.final_time/dt+1 timestamps = dt * np.arange(nt) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) return sim
def config_uni(**kwargs): """ Configure the simulation This function defines the Simulation object, user initialization model and diagnostics. """ Simulation( smallest_patch_size=20, largest_patch_size=20, time_step_nbr=2000, # number of time steps (not specified if time_step and final_time provided) final_time=20., # 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=500, # integer or tuple length == dimension dl=1.0, # mesh size of the root level, float or tuple refinement_boxes={"L0": {"B0": [(100, ), (200, )]}, "L1":{"B0":[(300,),(350,)]}}, diag_options={"format": "phareh5", "options": {"dir": kwargs["diagdir"],"mode":"overwrite"}} ) def density(x): return 1. def bx(x): return 0. def by(x): return 1. def bz(x): return 0.5 def vx(x): return kwargs["vx"] def vy(x): return 0. def vz(x): return 0. def vthx(x): return 0.1 def vthy(x): return 0.1 def vthz(x): return 0.1 vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} ) ElectronModel(closure="isothermal", Te=0.12) timestamps = all_timestamps(gv.sim) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def fromNoise(): # in this configuration there are no prescribed waves # and only eigen modes existing in the simulation noise # will be visible Simulation( smallest_patch_size=20, largest_patch_size=20, # the following time step number # and final time mean that the # smallest frequency will be 2/100 # and the largest 2/dt = 2e3 time_step_nbr=100000, final_time=100., boundary_types="periodic", # smallest wavelength will be 2*0.2=0.4 # and largest 50 cells=500, dl=0.2, diag_options={"format": "phareh5", "options": {"dir": "dispersion", "mode":"overwrite"}} ) def density(x): return 1. def by(x): return 0. def bz(x): return 0. def bx(x): return 1. def vx(x): return 0. def vy(x): return 0. def vz(x): return 0. def vthx(x): return 0.01 def vthy(x): return 0.01 def vthz(x): return 0.01 vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} ) ElectronModel(closure="isothermal", Te=0.) sim = ph.global_vars.sim timestamps = np.arange(0, sim.final_time +sim.time_step, sim.time_step) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )
def prescribedModes(): # in this configuration there user prescribed # wavelength, at which more energy is thus expected # than in modes naturally present in the simulation noise Simulation( smallest_patch_size=20, largest_patch_size=20, # the following time step number # and final time mean that the # smallest frequency will be 2/100 # and the largest 2/dt = 2e3 time_step_nbr=100000, final_time=100., boundary_types="periodic", # smallest wavelength will be 2*0.2=0.4 # and largest 50 cells=500, dl=0.2, diag_options={"format": "phareh5", "options": {"dir": "dispersion", "mode":"overwrite"}} ) def density(x): return 1. def by(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.1*np.cos(2*np.pi*x/L[0]) def bz(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return -0.1*np.sin(2*np.pi*x/L[0]) def bx(x): return 1. def vx(x): return 0. def vy(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.1*np.cos(2*np.pi*x/L[0]) def vz(x): from pyphare.pharein.global_vars import sim L = sim.simulation_domain() return 0.1*np.sin(2*np.pi*x/L[0]) def vthx(x): return 0.01 def vthy(x): return 0.01 def vthz(x): return 0.01 vvv = { "vbulkx": vx, "vbulky": vy, "vbulkz": vz, "vthx": vthx, "vthy": vthy, "vthz": vthz } MaxwellianFluidModel( bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} ) ElectronModel(closure="isothermal", Te=0.) sim = ph.global_vars.sim timestamps = np.arange(0, sim.final_time +sim.time_step, sim.time_step) for quantity in ["E", "B"]: ElectromagDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, ) for quantity in ["density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, compute_timestamps=timestamps, )