-
Notifications
You must be signed in to change notification settings - Fork 200
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
base: development
Are you sure you want to change the base?
Conversation
Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py
Outdated
Show resolved
Hide resolved
Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py
Outdated
Show resolved
Hide resolved
Until we add `__len__` via AMReX-Codes/pyamrex#407
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Ran locally for me, minus checksum stability.
This still uses the global API from Dave (but now from pyAMReX); if we want to parallelize it further we could do another follow-up :)
Use the one that does not rely on naming conventions but has named arguments. (The other one worked as well, but is deprecated.)
Examples/Physics_applications/spacecraft_charging/inputs_test_rz_spacecraft_charging_picmi.py
Outdated
Show resolved
Hide resolved
…rz_spacecraft_charging_picmi.py
We already have `.size` and we can iterate the `FabArray`, so we should support `len(mf)`, too. Seen in ECP-WarpX/WarpX#4817
2 * len(phi) | ||
nr = phi.shape[0] | ||
r = np.linspace(rmin, rmax, nr, endpoint=False) + (rmax - rmin) / ( | ||
2 * nr | ||
) # shift of the r points because the derivaties are calculated in the middle | ||
face_z0 = ( | ||
2 * np.pi * 1.0 / dz * ((phi[:, 0] - phi[:, 1]) * r).sum() * dr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks correct/as before: the :
is without ghost cells, ()
is with ghost cells.
https://pyamrex.readthedocs.io/en/latest/usage/compute.html
self.normalized_Er = warpx.multifab("Efield_fp", dir=self.dir_r, level=0).copy() | ||
self.normalized_Er.mult(1 / q_v, 0) | ||
self.normalized_Ez = warpx.multifab("Efield_fp", dir=self.dir_z, level=0).copy() | ||
self.normalized_Ez.mult(1 / q_v, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now perfectly parallel in MPI contexts, no global comms.
phi = PhiFPWrapper(include_ghosts=True) | ||
phi[...] += (q - q_v) * self.normalized_phi | ||
Er = warpx.multifab("Efield_fp", dir=self.dir_r, level=0) | ||
Er.saxpy(Er, (q - q_v), self.normalized_Er, 0, 0, 1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now perfectly parallel in MPI contexts, no global comms.
Er = warpx.multifab("Efield_fp", dir=self.dir_r, level=0) | ||
Er.saxpy(Er, (q - q_v), self.normalized_Er, 0, 0, 1, 0) | ||
Ez = warpx.multifab("Efield_fp", dir=self.dir_z, level=0) | ||
Ez.saxpy(Ez, (q - q_v), self.normalized_Ez, 0, 0, 1, 0) | ||
phi = warpx.multifab("phi_fp", level=0) | ||
phi.saxpy(phi, (q - q_v), self.normalized_phi, 0, 0, 1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: #5613 will change saxpy
Er = warpx.multifab("Efield_fp", dir=self.dir_r, level=0) | |
Er.saxpy(Er, (q - q_v), self.normalized_Er, 0, 0, 1, 0) | |
Ez = warpx.multifab("Efield_fp", dir=self.dir_z, level=0) | |
Ez.saxpy(Ez, (q - q_v), self.normalized_Ez, 0, 0, 1, 0) | |
phi = warpx.multifab("phi_fp", level=0) | |
phi.saxpy(phi, (q - q_v), self.normalized_phi, 0, 0, 1, 0) | |
Er = warpx.multifab("Efield_fp", dir=self.dir_r, level=0) | |
Er.saxpy(q - q_v, self.normalized_Er, 0, 0, 1, 0) | |
Ez = warpx.multifab("Efield_fp", dir=self.dir_z, level=0) | |
Ez.saxpy(q - q_v, self.normalized_Ez, 0, 0, 1, 0) | |
phi = warpx.multifab("phi_fp", level=0) | |
phi.saxpy(q - q_v, self.normalized_phi, 0, 0, 1, 0) |
No description provided.