MinLoc = np.unravel_index(int(S.Scalar(field + "MinCell").getData()[-1]), ncel) MaxLoc = np.unravel_index(int(S.Scalar(field + "MaxCell").getData()[-1]), ncel) Validate("Location of minimum of scalar " + field, MinLoc, 10) Validate("Location of maximum of scalar " + field, MaxLoc, 10) # FIELD DIAGNOSTICS fields = [ "Ex", "Ey", "Ez", "Bx", "By", "Bz", "Bx_m", "By_m", "Bz_m", "Jx", "Jy", "Jz", "Rho", "Jx_test0", "Jy_test0", "Jz_test0", "Rho_test0" ] precisions = [ 0.1, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.1, 3e-5, 2e-5, 0.001, 0.1 ] for field, precision in zip(fields, precisions): Validate( "Field " + field, S.Field.Field0(field, slice={ "z": "all" }, timesteps=40, stride=4).getData()[-1], precision) # PROBE DIAGNOSTICS fields = ["Ex", "Ey", "Ez", "Bx", "By", "Bz", "Jx", "Jy", "Jz", "Rho"] precisions = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.3] for field, precision in zip(fields, precisions): Validate("Probe field " + field, S.Probe(0, field).getData()[-1], precision)
import os, re, numpy as np, h5py from Smilei import * S = Smilei(".", verbose=False) # FIELD DIAG Validate("List of fields in Field0", S.Field.Field0().getFields()) timesteps = list(S.Field.Field0().getAvailableTimesteps()) Validate("List of timesteps in Field0", timesteps) Ez = S.Field.Field0("Ez", timesteps=timesteps[-1]).getData()[0] Validate("Last Ez profile in Field0", Ez, 1e-7) # 0-D PROBE Ez = S.Probe(0, "Ez").getData() Validate("Ez vs time in Probe0", Ez, 1e-7) # 1-D PROBE Validate("List of fields in Probe1", S.Probe(1).getFields()) timesteps = S.Probe(1, "Ez").getAvailableTimesteps() Validate("List of timesteps in Probe1", timesteps) Ez = S.Probe(1, "Ez", timesteps=timesteps[-1]).getData()[0] Validate("Last Ez profile in Probe1", Ez, 1e-7) # UBAL SCALAR max_ubal = np.max(np.abs(S.Scalar.Ubal().getData())) Validate("Max Ubal is below 2%", max_ubal < 0.02)