From 4a5babae51d0f9a91d308c7577ba1c17e207cb2a Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Tue, 2 Apr 2024 14:10:06 -0700 Subject: [PATCH 1/3] Use pyamrex in examples --- .../spacecraft_charging/PICMI_inputs_rz.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Examples/Physics_applications/spacecraft_charging/PICMI_inputs_rz.py b/Examples/Physics_applications/spacecraft_charging/PICMI_inputs_rz.py index 6eefdca942d..70d85df209b 100644 --- a/Examples/Physics_applications/spacecraft_charging/PICMI_inputs_rz.py +++ b/Examples/Physics_applications/spacecraft_charging/PICMI_inputs_rz.py @@ -47,10 +47,13 @@ def correct_space_charge_fields(self, q=None): q = compute_actual_charge_on_spacecraft() # Correct fields so as to recover the actual charge - Er = ExWrapper(include_ghosts=True) - Er[...] += (q - q_v)*self.normalized_Er - Ez = EzWrapper(include_ghosts=True) - Ez[...] += (q - q_v)*self.normalized_Ez + Config = sim.extension.Config + Er = sim.extension.warpx.multifab(f"Efield_fp[x][level=0]") + for er, n_er in zip( Er.to_numpy(), self.normalized_Er.to_numpy() ): + er[...] += (q - q_v)*n_er + Ez = sim.extension.warpx.multifab(f"Efield_fp[z][level=0]") + for ez, n_ez in zip( Ez.to_numpy(), self.normalized_Ez.to_numpy() ): + ez[...] += (q - q_v)*n_ez phi = PhiFPWrapper(include_ghosts=True) phi[...] += (q - q_v)*self.normalized_phi self.spacecraft_potential += (q - q_v)*self.spacecraft_capacitance @@ -75,10 +78,11 @@ def save_normalized_vacuum_Efields(self,): assert np.all( abs(rho[...]) < 1.e-11 ) # Record fields - Er = ExWrapper(include_ghosts=True)[:,:] - self.normalized_Er = Er[...] /q_v - Ez = EzWrapper(include_ghosts=True)[:,:] - self.normalized_Ez = Ez[...] /q_v + # TODO: add guard cells + self.normalized_Er = sim.extension.warpx.multifab(f"Efield_fp[x][level=0]").copy() + self.normalized_Er.mult( 1/q_v, 0 ) + self.normalized_Ez = sim.extension.warpx.multifab(f"Efield_fp[z][level=0]").copy() + self.normalized_Ez.mult( 1/q_v, 0 ) phi = PhiFPWrapper(include_ghosts=True)[:,:] self.normalized_phi = phi[...] /q_v From 9795d8996daf4c3270fa13db653de2ef5d8df3cb Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Mon, 23 Sep 2024 16:21:51 -0700 Subject: [PATCH 2/3] Fix minor typo --- .../inputs_test_rz_spacecraft_charging_picmi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py b/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py index 03314b9df9a..9e8c320ccf0 100644 --- a/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py +++ b/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py @@ -51,9 +51,9 @@ def correct_space_charge_fields(self, q=None): # Correct fields so as to recover the actual charge # TODO: add guard cells Er = sim.extension.warpx.multifab("Efield_fp[x][level=0]") - Er.saxpy(Er, (q - q_v) * self.normalized_Er, 0, 0, 1, 0) + Er.saxpy(Er, (q - q_v), self.normalized_Er, 0, 0, 1, 0) Ez = sim.extension.warpx.multifab("Efield_fp[z][level=0]") - Ez.saxpy(Ez, (q - q_v) * self.normalized_Ez, 0, 0, 1, 0) + Ez.saxpy(Ez, (q - q_v), self.normalized_Ez, 0, 0, 1, 0) phi = PhiFPWrapper(include_ghosts=True) phi[...] += (q - q_v) * self.normalized_phi self.spacecraft_potential += (q - q_v) * self.spacecraft_capacitance From 2fea46a4c26af4f3c6b0544822c49614e47fc83e Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Tue, 24 Sep 2024 06:36:24 -0700 Subject: [PATCH 3/3] Fix breaking API change --- .../inputs_test_rz_spacecraft_charging_picmi.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py b/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py index 9e8c320ccf0..2e94e090b01 100644 --- a/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py +++ b/Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py @@ -50,9 +50,9 @@ def correct_space_charge_fields(self, q=None): # Correct fields so as to recover the actual charge # TODO: add guard cells - Er = sim.extension.warpx.multifab("Efield_fp[x][level=0]") + Er = sim.extension.warpx.multifab("Efield_fp[x]", 0) Er.saxpy(Er, (q - q_v), self.normalized_Er, 0, 0, 1, 0) - Ez = sim.extension.warpx.multifab("Efield_fp[z][level=0]") + Ez = sim.extension.warpx.multifab("Efield_fp[z]", 0) Ez.saxpy(Ez, (q - q_v), self.normalized_Ez, 0, 0, 1, 0) phi = PhiFPWrapper(include_ghosts=True) phi[...] += (q - q_v) * self.normalized_phi @@ -81,13 +81,9 @@ def save_normalized_vacuum_Efields( # Record fields # TODO: add guard cells - self.normalized_Er = sim.extension.warpx.multifab( - "Efield_fp[x][level=0]" - ).copy() + self.normalized_Er = sim.extension.warpx.multifab("Efield_fp[x]", 0).copy() self.normalized_Er.mult(1 / q_v, 0) - self.normalized_Ez = sim.extension.warpx.multifab( - "Efield_fp[z][level=0]" - ).copy() + self.normalized_Ez = sim.extension.warpx.multifab("Efield_fp[z]", 0).copy() self.normalized_Ez.mult(1 / q_v, 0) phi = PhiFPWrapper(include_ghosts=True)[:, :] self.normalized_phi = phi[...] / q_v