From a68476100c069615d607b596f3a68b0322b96b81 Mon Sep 17 00:00:00 2001 From: eyadammak Date: Thu, 15 Feb 2024 12:56:41 -0800 Subject: [PATCH 1/3] adding RZ example --- Examples/Tests/point_of_contact_EB/inputs_3d | 2 +- Examples/Tests/point_of_contact_EB/inputs_rz | 48 +++++++++++++++++++ Python/pywarpx/particle_containers.py | 23 +++------ .../Point_of_contact_EB_rz.json | 17 +++++++ Regression/WarpX-tests.ini | 19 ++++++++ 5 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 Examples/Tests/point_of_contact_EB/inputs_rz create mode 100644 Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json diff --git a/Examples/Tests/point_of_contact_EB/inputs_3d b/Examples/Tests/point_of_contact_EB/inputs_3d index 64f8b520161..005733487e5 100644 --- a/Examples/Tests/point_of_contact_EB/inputs_3d +++ b/Examples/Tests/point_of_contact_EB/inputs_3d @@ -19,7 +19,7 @@ boundary.potential_hi_y = 0 boundary.potential_lo_z = 0 boundary.potential_hi_z = 0 -warpx.const_dt = 1.216119097e-10 +warpx.const_dt = 1e-10 warpx.eb_implicit_function = "-(x**2+y**2+z**2-0.2**2)" # Do not evolve the E and B fields diff --git a/Examples/Tests/point_of_contact_EB/inputs_rz b/Examples/Tests/point_of_contact_EB/inputs_rz new file mode 100644 index 00000000000..a492c1f705a --- /dev/null +++ b/Examples/Tests/point_of_contact_EB/inputs_rz @@ -0,0 +1,48 @@ +amr.max_level = 0 + +max_step = 3 + +amr.n_cell = 64 64 +amr.blocking_factor = 8 +amr.max_grid_size = 128 + +geometry.dims = RZ +geometry.prob_lo = 0.0 -0.26 +geometry.prob_hi = 0.26 0.26 + +boundary.field_lo = none periodic +boundary.field_hi = pec periodic +boundary.potential_lo_x = 0 +boundary.potential_hi_x = 0 +boundary.potential_lo_y = 0 +boundary.potential_hi_y = 0 +boundary.potential_lo_z = 0 +boundary.potential_hi_z = 0 + +warpx.const_dt = 1e-10 +warpx.eb_implicit_function = "-(x**2 -0.2**2)" + +# Do not evolve the E and B fields +algo.maxwell_solver = none +algo.field_gathering = momentum-conserving +algo.particle_shape = 1 + +particles.species_names = electron +electron.charge = -q_e +electron.mass = m_e +electron.injection_style = "SingleParticle" +electron.single_particle_pos = -0.25 0 0 +electron.single_particle_u = 1 0.5 0.0 +electron.single_particle_weight = 1 + +electron.save_particles_at_eb = 1 + +diagnostics.diags_names = diag1 diag2 + +diag1.intervals = 1 +diag1.diag_type = Full +diag1.fields_to_plot = Er +diag1.format = openpmd + +diag2.diag_type = BoundaryScraping +diag2.format = openpmd diff --git a/Python/pywarpx/particle_containers.py b/Python/pywarpx/particle_containers.py index 393663bc8cf..2566f7b6d43 100644 --- a/Python/pywarpx/particle_containers.py +++ b/Python/pywarpx/particle_containers.py @@ -772,9 +772,9 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) form x/y/z_hi/lo or eb. comp_name : str - The component of the array data that will be returned. If - "step_scraped" the special attribute holding the timestep at - which a particle was scraped will be returned. + The component of the array data that will be returned. + "x", "y", "z", "ux", "uy", "uz", "w" + "step_scraped","time_scraped", "nx", "ny", "nz" level : int Which AMR level to retrieve scraped particle data from. @@ -784,20 +784,9 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) part_container = self.particle_buffer.get_particle_container( species_name, self._get_boundary_number(boundary) ) - data_array = [] - if comp_name == 'step_scraped': - # the step scraped is always the final integer component - comp_idx = part_container.num_int_comps - 1 - for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)): - soa = pti.soa() - data_array.append(xp.array(soa.get_int_data(comp_idx), copy=False)) - else: - container_wrapper = ParticleContainerWrapper(species_name) - comp_idx = container_wrapper.particle_container.get_comp_index(comp_name) - for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)): - soa = pti.soa() - data_array.append(xp.array(soa.get_real_data(comp_idx), copy=False)) - return data_array + comp = part_container.int_comp_names[comp_name] + comp = part_container.real_comp_names[comp_name] + return comp def clear_buffer(self): diff --git a/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json b/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json new file mode 100644 index 00000000000..1da1e775f2a --- /dev/null +++ b/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json @@ -0,0 +1,17 @@ +{ + "lev=0": { + "Er": 0.0 + }, + "lev=1": { + "Er": 0.0 + }, + "electron": { + "particle_position_x": 0.0, + "particle_position_y": 0.0, + "particle_position_z": 0.0, + "particle_momentum_x": 0.0, + "particle_momentum_y": 0.0, + "particle_momentum_z": 0.0, + "particle_weight": 0.0 + } +} diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 066faadc0a8..9fb763b683e 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -4539,6 +4539,25 @@ particleTypes = electrons outputFile = Point_of_contact_EB_3d_plt analysisRoutine = Examples/Tests/point_of_contact_EB/analysis.py +[Point_of_contact_EB_rz] +buildDir = . +inputFile = Examples/Tests/point_of_contact_EB/inputs_rz +runtime_params = +dim = 2 +addToCompileString = USE_RZ=TRUE USE_EB=TRUE +cmakeSetupOpts = -DWarpX_DIMS=RZ -DWarpX_EB=ON +restartTest = 0 +useMPI = 1 +numprocs = 2 +useOMP = 0 +numthreads = 1 +compileTest = 0 +doVis = 0 +compareParticles = 0 +particleTypes = electrons +outputFile = Point_of_contact_EB_rz_plt +analysisRoutine = Examples/Tests/point_of_contact_EB/analysis.py + [ImplicitPicard_1d] buildDir = . inputFile = Examples/Tests/Implicit/inputs_1d From 189786baba42e7c7945ca85d4511ba0ac4e5507c Mon Sep 17 00:00:00 2001 From: Eya D <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:00:35 -0800 Subject: [PATCH 2/3] Update particle_containers.py --- Python/pywarpx/particle_containers.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Python/pywarpx/particle_containers.py b/Python/pywarpx/particle_containers.py index 2566f7b6d43..393663bc8cf 100644 --- a/Python/pywarpx/particle_containers.py +++ b/Python/pywarpx/particle_containers.py @@ -772,9 +772,9 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) form x/y/z_hi/lo or eb. comp_name : str - The component of the array data that will be returned. - "x", "y", "z", "ux", "uy", "uz", "w" - "step_scraped","time_scraped", "nx", "ny", "nz" + The component of the array data that will be returned. If + "step_scraped" the special attribute holding the timestep at + which a particle was scraped will be returned. level : int Which AMR level to retrieve scraped particle data from. @@ -784,9 +784,20 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) part_container = self.particle_buffer.get_particle_container( species_name, self._get_boundary_number(boundary) ) - comp = part_container.int_comp_names[comp_name] - comp = part_container.real_comp_names[comp_name] - return comp + data_array = [] + if comp_name == 'step_scraped': + # the step scraped is always the final integer component + comp_idx = part_container.num_int_comps - 1 + for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)): + soa = pti.soa() + data_array.append(xp.array(soa.get_int_data(comp_idx), copy=False)) + else: + container_wrapper = ParticleContainerWrapper(species_name) + comp_idx = container_wrapper.particle_container.get_comp_index(comp_name) + for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)): + soa = pti.soa() + data_array.append(xp.array(soa.get_real_data(comp_idx), copy=False)) + return data_array def clear_buffer(self): From bf9675e4f1b46ec6a9f9f2ba99797a790c9d3790 Mon Sep 17 00:00:00 2001 From: Eya D <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:54:48 -0800 Subject: [PATCH 3/3] Update Point_of_contact_EB_rz.json --- .../Checksum/benchmarks_json/Point_of_contact_EB_rz.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json b/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json index 1da1e775f2a..422f31548d2 100644 --- a/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json +++ b/Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json @@ -2,9 +2,6 @@ "lev=0": { "Er": 0.0 }, - "lev=1": { - "Er": 0.0 - }, "electron": { "particle_position_x": 0.0, "particle_position_y": 0.0, @@ -15,3 +12,4 @@ "particle_weight": 0.0 } } +