Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyamrex in spacecraft charging example #4817

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pywarpx import picmi
from pywarpx.callbacks import installafterEsolve, installafterInitEsolve
from pywarpx.fields import ExWrapper, EzWrapper, PhiFPWrapper, RhoFPWrapper
from pywarpx.fields import PhiFPWrapper, RhoFPWrapper
from pywarpx.particle_containers import ParticleBoundaryBufferWrapper


Expand Down Expand Up @@ -49,10 +49,11 @@ 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
# TODO: add guard cells
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]", 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
Expand All @@ -79,10 +80,11 @@ def save_normalized_vacuum_Efields(
assert np.all(abs(rho[...]) < 1.0e-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("Efield_fp[x]", 0).copy()
self.normalized_Er.mult(1 / q_v, 0)
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

Expand Down
Loading