aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xExamples/Tests/restart_eb/PICMI_inputs_restart_eb.py128
-rw-r--r--Regression/Checksum/benchmarks_json/Python_restart_eb.json10
-rw-r--r--Regression/WarpX-tests.ini19
-rw-r--r--Source/Diagnostics/WarpXIO.cpp2
4 files changed, 159 insertions, 0 deletions
diff --git a/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py b/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py
new file mode 100755
index 000000000..7d1dd4530
--- /dev/null
+++ b/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py
@@ -0,0 +1,128 @@
+#!/usr/bin/env python3
+#
+# Mirroring Modules/ParticleBoundaryScrape setup, this tests that restarting
+# with an EB works properly.
+
+import sys
+
+from pywarpx import picmi
+
+##########################
+# numerics parameters
+##########################
+
+# --- Number of time steps
+max_steps = 60
+diagnostic_intervals = 30
+
+# --- Grid
+nx = 64
+ny = 64
+nz = 128
+
+cfl = 0.99
+
+xmin = -125e-6
+ymin = -125e-6
+zmin = -149e-6
+xmax = 125e-6
+ymax = 125e-6
+zmax = 1e-6
+
+##########################
+# physics components
+##########################
+
+uniform_plasma_elec = picmi.UniformDistribution(
+ density = 1e23, # number of electrons per m^3
+ lower_bound = [-1e-5, -1e-5, -149e-6],
+ upper_bound = [1e-5, 1e-5, -129e-6],
+ directed_velocity = [0., 0., 2000.*picmi.constants.c] # uth the std of the (unitless) momentum
+)
+
+electrons = picmi.Species(
+ particle_type='electron', name='electrons',
+ initial_distribution=uniform_plasma_elec,
+ warpx_save_particles_at_xhi=1, warpx_save_particles_at_eb=1
+)
+
+##########################
+# numerics components
+##########################
+
+grid = picmi.Cartesian3DGrid(
+ number_of_cells = [nx, ny, nz],
+ lower_bound = [xmin, ymin, zmin],
+ upper_bound = [xmax, ymax, zmax],
+ lower_boundary_conditions=['none', 'none', 'none'],
+ upper_boundary_conditions=['none', 'none', 'none'],
+ lower_boundary_conditions_particles=['open', 'open', 'open'],
+ upper_boundary_conditions_particles=['open', 'open', 'open'],
+ warpx_max_grid_size = 32
+)
+
+solver = picmi.ElectromagneticSolver(
+ grid=grid, cfl=cfl
+)
+
+embedded_boundary = picmi.EmbeddedBoundary(
+ implicit_function="-max(max(max(x-12.5e-6,-12.5e-6-x),max(y-12.5e-6,-12.5e-6-y)),max(z-(-6.15e-5),-8.65e-5-z))"
+)
+
+##########################
+# diagnostics
+##########################
+
+field_diag = picmi.FieldDiagnostic(
+ name = 'diag1',
+ grid = grid,
+ period = diagnostic_intervals,
+ data_list = ['Ex', 'Ey', 'Ez', 'Bx', 'By', 'Bz'],
+ write_dir = '.',
+ warpx_file_prefix = 'Python_restart_eb_plt'
+)
+
+checkpoint = picmi.Checkpoint(
+ name = 'chkpoint',
+ period = diagnostic_intervals,
+ write_dir = '.',
+ warpx_file_prefix = f'Python_restart_eb_chk'
+)
+
+##########################
+# simulation setup
+##########################
+
+sim = picmi.Simulation(
+ solver = solver,
+ max_steps = max_steps,
+ warpx_embedded_boundary=embedded_boundary,
+ verbose=True,
+ warpx_load_balance_intervals=40,
+ warpx_load_balance_efficiency_ratio_threshold=0.9
+)
+
+sim.add_species(
+ electrons,
+ layout = picmi.GriddedLayout(
+ n_macroparticle_per_cell=[1, 1, 1], grid=grid
+ )
+)
+
+for arg in sys.argv:
+ if arg.startswith("amr.restart"):
+ restart_file_name = arg.split("=")[1]
+ sim.amr_restart = restart_file_name
+ sys.argv.remove(arg)
+
+sim.add_diagnostic(field_diag)
+sim.add_diagnostic(checkpoint)
+sim.initialize_inputs()
+sim.initialize_warpx()
+
+##########################
+# simulation run
+##########################
+
+step_number = sim.extension.getistep(0)
+sim.step(max_steps - step_number)
diff --git a/Regression/Checksum/benchmarks_json/Python_restart_eb.json b/Regression/Checksum/benchmarks_json/Python_restart_eb.json
new file mode 100644
index 000000000..25087c575
--- /dev/null
+++ b/Regression/Checksum/benchmarks_json/Python_restart_eb.json
@@ -0,0 +1,10 @@
+{
+ "lev=0": {
+ "Bx": 148618.63186220315,
+ "By": 148618.63186220315,
+ "Bz": 3385.851454453729,
+ "Ex": 55362729623335.9,
+ "Ey": 55362729623335.89,
+ "Ez": 68396725892689.86
+ }
+} \ No newline at end of file
diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini
index 16ce07bbc..b1f6fd262 100644
--- a/Regression/WarpX-tests.ini
+++ b/Regression/WarpX-tests.ini
@@ -871,6 +871,25 @@ doVis = 0
compareParticles = 0
particleTypes = electrons
+[Python_restart_eb]
+buildDir = .
+inputFile = Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py
+runtime_params =
+customRunCmd = python3 PICMI_inputs_restart_eb.py
+dim = 3
+addToCompileString = USE_EB=TRUE USE_PYTHON_MAIN=TRUE
+restartTest = 1
+restartFileNum = 30
+useMPI = 1
+numprocs = 1
+useOMP = 1
+numthreads = 1
+compileTest = 0
+doVis = 0
+compareParticles = 1
+particleTypes = electrons
+analysisRoutine = Examples/Tests/restart/analysis_restart.py
+
[LaserInjection]
buildDir = .
inputFile = Examples/Modules/laser_injection/inputs_3d_rt
diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp
index 2eb392f48..1c5eb12ae 100644
--- a/Source/Diagnostics/WarpXIO.cpp
+++ b/Source/Diagnostics/WarpXIO.cpp
@@ -334,6 +334,8 @@ WarpX::InitFromCheckpoint ()
}
}
+ InitializeEBGridData(maxLevel());
+
// Initialize particles
mypc->AllocData();
mypc->Restart(restart_chkfile);