solenoid refocusing
Closed this issue · 11 comments
As I understand it, Wake-T
includes space-charge effects. In principle it can be used to model beamlines that include plasma lenses, quadrupoles, etc. We were considering to use it for modelling electron bunch refocusing in a solenoid, would this work? Is there a particular example to start from? Particularly for defining the solenoid.
Hi @berceanu,
Thanks for the interest! Space-charge forces are currently not included (they are implicitly taken into account in some plasma wakefield models, but not in general for all beamline elements). It's something I have in the radar, but so far other things have had higher priority.
While there is no solenoid element in Wake-T, it is in principle possible to track a beam in any arbitrary 3D field. Would this still be interesting for you if there are no space-charge effects? If so, I could give you a simple example to start from.
Hi Angel, thanks for the quick reply!
Yes indeed, that would still be interesting, at least for the high-energy electrons where space charge effects are smaller, so a starting example would be much appreciated.
Hi @berceanu,
sorry for the late follow up, busy times before the holidays :)
I had a look at the possibility of tracking particle bunches in any arbitrary fields and in the end I implemented a new base class for this. I believe it should work well for what you want to do.
If you want to try it out, you need to install the field_element
branch (e.g., by doing pip install -U git+https://github.com/AngelFP/Wake-T.git@field_element
).
I made a quick example below where a bunch is tracked through an azimuthal magnetic field, which is probably close to what you will need.
Let me know if you have any questions!
import numpy as np
import scipy.constants as ct
from wake_t.utilities.bunch_generation import get_gaussian_bunch_from_twiss
from wake_t.fields.analytical_field import AnalyticalField
from wake_t.beamline_elements import FieldElement
def b_x(x, y, z, t, bx, constants):
"""B_x component."""
k = constants[0]
bx -= k * y
def b_y(x, y, z, t, by, constants):
"""B_y component."""
k = constants[0]
by += k * x
# Define field (azimuthal magnetic field with a linear gradient of 100 T/m).
b_theta = AnalyticalField(b_x=b_x, b_y=b_y, constants=[-100])
# Create bunch.
emitt_nx = emitt_ny = 1e-6 # m
beta_x = beta_y = 1. # m
s_t = 100. # fs
gamma_avg = 1000
ene_spread = 0.1 # %
q_bunch = 30 # pC
xi_avg = 0. # m
n_part = 1e4
bunch = get_gaussian_bunch_from_twiss(
en_x=emitt_nx, en_y=emitt_ny, a_x=0, a_y=0, b_x=beta_x, b_y=beta_y,
ene=gamma_avg, ene_sp=ene_spread, s_t=s_t, xi_c=xi_avg,
q_tot=q_bunch, n_part=n_part, name='elec_bunch')
# Create field element.
element = FieldElement(
length=1, # in meters
dt_bunch=1e-3/ct.c, # time step for the particle pusher, in seconds
n_out=10, # number of output diagnostics
fields=[b_theta] # list of fields to apply
)
# Do tracking.
element.track(bunch, opmd_diag=True)
Thanks, much appreciated!
Hypothetically, if one would like to include space charge effects for the case of low-energy electrons, would Wake-T
be compatible with a, say, Green-function based Poisson solver for example?
I'm no expert in that method in particular, but I believe it should be possible. If all you need is the particle distribution at a time t
to compute E
and B
at that time it should be straightforward to implement this by using the NumericalField
class.
Is that something you would be interested in having a look at?
Possibly yes. Do you think implementing such a method in Wake-T could lead to publishable results, ie could we find a good physics case? Perhaps combined with ML?
There could be some case (e.g., a start-to-end modeling of a plasma accelerator where space charge is relevant in the beam transport). Do you have anything in mind related to ML?
By the way, did you have any chance to try out the solenoid case?
Sorry for the late follow-up, I'm just now back from vacation.
Short update for anyone following this, field_element
was merged into dev
via #102 and
the code above was incorporated into tests/test_field_element.py.
Hi @berceanu, thanks for taking care of this. I assume that the new FieldElement
worked well for your case?
Hi @AngelFP , yes indeed, thank you. Still thinking about the space charge, will probably create a new issue if/when I get the time.
Sounds great, thanks!