Creating internal boundary where particles that hit it are removed from simulation #4755
Replies: 3 comments 1 reply
-
Thanks for the reproducer, let us debug this in #4952 |
Beta Was this translation helpful? Give feedback.
-
Regarding the issue with the dielectric, I think one solution would be for you to implement a quick hack of WarpX:
|
Beta Was this translation helpful? Give feedback.
-
Hi @Poto45, @RemiLehe and I discussed the two options we spoke about at IPAC for the particle absorption at the dielectric. We think using the EBs with the small modification to not let them act on fields (but just on particles) in the source code is the quickest way to success. After #4865 is merged, we could even make this an input parameters Alternatively, you can use a regular simulation and no EBs, by adding the particle removal logic from Python. For this, you just need to add a callback once per step that removes particles that go out of bounds. In the callback, loop over the particles tiles x = soa.real[0]
y = soa.real[1]
mask = np.abs(x) > 1e-6 and np.abs(y) > 1e-6 # for 2mu box geometry, adjust as needed Then in the same inner loop, set Complete example: from pywarpx import picmi
from pywarpx.callbacks import callfromafterstep
# Preparation: set up the simulation
# sim = picmi.Simulation(...)
# ...
@callfromafterstep
def my_after_step_callback():
warpx = sim.extension.warpx
Config = sim.extension.Config
if Config.have_gpu:
import cupy as xp
else:
import numpy as xp
# data access
multi_pc = warpx.multi_particle_container()
pc = multi_pc.get_particle_container_from_name("electrons")
# iterate over mesh-refinement levels
for lvl in range(pc.finest_level + 1):
# get every local chunk of particles
for pti in pc.iterator(pc, level=lvl):
soa = pti.soa().to_xp()
x = soa.real[0]
y = soa.real[1]
# mark particles that reach the dielectric
mask = xp.abs(x) > 1e-6 and xp.abs(y) > 1e-6 # for 2mu box geometry, adjust as needed
# remove particles that are out-of-bounds
soa.idcpu[mask] = 16777216
sim.step(nsteps=100) |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm running dielectric wakefield simulations where the dielectric is an enclosed rectangular tube. I have the epsilon function for the dielectric and a "conductor" layer surrounding the dielectric using the sigma function. One issue I'm running into is that the electrons' y locations extend "into" the dielectric. I've been searching through for a scraping function, but am only finding functions that are for the external boundary of the simulation (like the outside surface of the dielectric). Is there a function I can use where I can manually enter a boundary surface at the inside surface of the dielectric that deletes any particles that hit it?
Also, I've been having issues with the epsilon and sigma functions such that it cannot be described in z, which is the direction of the moving window I'm using. For example, if I want the dielectric to go from 10cm to 160 cm instead of 0cm to 150cm, warpx just doesn't read the string correctly and there ends up being no dielectric anywhere. If people use a moving window and a function in all three coordinates, would you be able to share it with me? I'd really like to use a moving window with epsilon and sigma functions being dependent on x, y, and z. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions