Wakefields
Resistive Wall Wakefield Classes
ResistiveWallWakefield
dataclass
ResistiveWallWakefield(radius: float, conductivity: float, relaxation_time: float, geometry: Geometry = ROUND)
Bases: ResistiveWallWakefieldBase, ImpedanceWakefield
flowchart TD
beamphysics.wakefields.ResistiveWallWakefield[ResistiveWallWakefield]
beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase[ResistiveWallWakefieldBase]
beamphysics.wakefields.impedance.ImpedanceWakefield[ImpedanceWakefield]
beamphysics.wakefields.base.WakefieldBase[WakefieldBase]
beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase --> beamphysics.wakefields.ResistiveWallWakefield
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase
beamphysics.wakefields.impedance.ImpedanceWakefield --> beamphysics.wakefields.ResistiveWallWakefield
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.impedance.ImpedanceWakefield
click beamphysics.wakefields.ResistiveWallWakefield href "" "beamphysics.wakefields.ResistiveWallWakefield"
click beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase href "" "beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase"
click beamphysics.wakefields.impedance.ImpedanceWakefield href "" "beamphysics.wakefields.impedance.ImpedanceWakefield"
click beamphysics.wakefields.base.WakefieldBase href "" "beamphysics.wakefields.base.WakefieldBase"
Accurate impedance-based resistive wall wakefield model.
This class computes the short-range resistive wall wakefield by numerically evaluating the full longitudinal impedance Z(k) and transforming to the wakefield W(z) via FFT. This approach captures all physical effects including the anomalous skin effect at high frequencies.
Physics Background
When a relativistic charged particle travels through a conducting beam pipe, electromagnetic fields penetrate into the conductor due to the finite conductivity. The skin depth δ decreases with frequency:
At very high frequencies (relevant for short-range wakes), the electron mean free path becomes comparable to the skin depth, and the simple Ohmic model breaks down. The Drude model accounts for this through a frequency- dependent conductivity with relaxation time τ:
The longitudinal impedance per unit length for a round pipe is:
where ζ(k) is the surface impedance and a is the pipe radius.
The wakefield is obtained via cosine transform (for z ≤ 0):
Characteristic Scales
- s₀: Characteristic length scale:
$\(s_0 = \left( \frac{2a^2}{Z_0 \sigma_0} \right)^{1/3}\)$
For copper with a = 2.5 mm, s₀ ≈ 8 µm.
- W₀: Characteristic wake amplitude at z = 0:
- Round: \(W_0 = c Z_0 / (\pi a^2)\)
- Flat: \(W_0 = c Z_0 \pi / (16 a^2)\)
Geometry
- Round (circular pipe): Closed-form impedance expression.
- Flat (parallel plates): Requires numerical integration over transverse modes; more computationally expensive.
Parameters:
-
radius(float) –Radius of the beam pipe (m). For flat geometry, this is the half-gap.
-
conductivity(float) –Electrical DC conductivity of the wall material (S/m).
-
relaxation_time(float) –Drude-model relaxation time τ of the conductor (s). Typical values: Cu ≈ 27 fs, Al ≈ 8 fs.
-
geometry(str, default:ROUND) –Geometry of the beam pipe: 'round' or 'flat'. Default is 'round'.
Attributes:
Notes
- This model is ~10-20× slower than
ResistiveWallPseudomodebut more accurate, especially for the first oscillation peak. - The FFT-based convolution uses O(N log N) complexity for density convolution, compared to O(N) for the pseudomode model.
- For flat geometry, impedance calculation requires numerical integration and is significantly slower than round geometry.
See Also
ResistiveWallPseudomode : Fast approximate model using damped sinusoid
References
.. [1] K. Bane and G. Stupakov, "Resistive wall wakefield in the LCLS undulator beam pipe," SLAC-PUB-10707 (2004). https://www.slac.stanford.edu/cgi-wrap/getdoc/slac-pub-10707.pdf
.. [2] A. Chao, "Physics of Collective Beam Instabilities in High Energy Accelerators," Wiley, 1993, Chapter 2.
Examples:
>>> wake = ResistiveWallWakefield.from_material(
... "copper-slac-pub-10707", radius=2.5e-3, geometry="round"
... )
>>> wake.wake(-10e-6) # Wake at 10 µm behind source
>>> wake.impedance(1e5) # Impedance at k = 100/mm
Methods:
-
__call__–Evaluate the wakefield at position z (convenience method).
-
convolve_density–Compute integrated wakefield from a charge density distribution.
-
default_n_samples–Default number of uniform samples out to zmax.
-
from_material–Create a wakefield from a known material preset.
-
impedance–Evaluate the impedance at wavenumber k.
-
material_from_properties–Attempt to identify the material based on conductivity and relaxation time.
-
particle_kicks–Compute wakefield-induced energy kicks per unit length.
-
plot–Plot the resistive wall wakefield W(z).
-
plot_impedance–Plot the resistive wall impedance Z(k).
-
to_tabular–Resample this model onto a uniform
TabularWakefield. -
wake–Evaluate the wakefield at position z.
W0
property
W0
Characteristic wake amplitude W₀ at z=0 (V/C/m).
From SLAC-PUB-10707: - Round: W₀ = c·Z₀ / (π·a²) - Flat: W₀ = c·Z₀·π / (16·a²) = W₀_round · (π²/16)
The dimensionless scaled wake is Ŵ(z/s₀) = W(z) / W₀.
default_zmax
property
default_zmax: float
Distance behind the source particle beyond which the wake is negligible (m).
The tail falls as |z|^(-3/2); at 100 s0 it is about 1e-04 of W0 for a round pipe.
k_max
property
writable
k_max: float
Maximum wavenumber for integration.
min_wavelength
property
min_wavelength: float
Shortest length scale of the wake (m).
This is the period of the DC-conductivity wake of a round pipe.
s0
property
s0
Characteristic length scale s₀ of the resistive wall wakefield (m).
From SLAC-PUB-10707 Eq. (5):
where a is the pipe radius (round) or half-gap (flat), Z₀ is the impedance of free space, and σ₀ is the DC conductivity.
__call__
__call__(z: float | ndarray) -> float | ndarray
Evaluate the wakefield at position z (convenience method).
Source code in beamphysics/wakefields/resistive_wall/base.py
721 722 723 | |
convolve_density
convolve_density(density: ndarray, dz: float, offset: float = 0, include_self_kick: bool = True, plot: bool = False, ax=None) -> ndarray
Compute integrated wakefield from a charge density distribution.
This computes the causal wake potential:
where only particles ahead (larger z index) contribute to the wake felt by each particle. This is mathematically a correlation, not a convolution, and is computed efficiently using FFT.
Parameters:
-
density(ndarray) –Charge density array (C/m). Index 0 is the tail (back), index n-1 is the head (front).
-
dz(float) –Grid spacing (m).
-
offset(float, default:0) –Offset for the z coordinate (m). Default is 0.
-
include_self_kick(bool, default:True) –Whether to include the half self-kick term. Default is True.
-
plot(bool, default:False) –If True, plot the density profile and wake potential. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None and plot=True, creates a new figure.
Returns:
-
integrated_wake(ndarray) –Integrated longitudinal wakefield (V/m).
Source code in beamphysics/wakefields/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_n_samples
default_n_samples(zmax: float) -> int
Default number of uniform samples out to zmax.
Here lambda_min is min_wavelength, and 4 is the minimum for cubic
interpolation.
Parameters:
-
zmax(float) –Largest distance behind the source particle (m).
Returns:
-
int–
Source code in beamphysics/wakefields/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
from_material
classmethod
from_material(material: str, radius: float, geometry: Geometry | str = ROUND)
Create a wakefield from a known material preset.
Parameters:
-
material(str) –Material name. Must be in list(cls.MATERIALS)
-
radius(float) –Pipe radius (m)
-
geometry(str, default:ROUND) –Geometry type: 'round' or 'flat'
Source code in beamphysics/wakefields/resistive_wall/base.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
impedance
impedance(k)
Evaluate the impedance at wavenumber k.
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/resistive_wall/impedance.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
material_from_properties
material_from_properties(tol=0.01)
Attempt to identify the material based on conductivity and relaxation time.
Parameters:
-
tol(float, default:0.01) –Relative tolerance for matching, default is 1% (0.01)
Returns:
-
material(str or None) –Name of the matched material, or None if no match is found.
Source code in beamphysics/wakefields/resistive_wall/base.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |
particle_kicks
particle_kicks(z: ndarray, weight: ndarray, include_self_kick: bool = True, n_bins: int = None) -> ndarray
Compute wakefield-induced energy kicks per unit length.
Uses FFT-based density convolution with interpolation back to particle positions. This is O(N + M log M) where N is the number of particles and M is the number of grid points.
Parameters:
-
z(ndarray) –Particle positions (m).
-
weight(ndarray) –Particle charges (C).
-
include_self_kick(bool, default:True) –Whether to include the self-kick term. Default is True.
-
n_bins(int, default:None) –Number of bins for the density grid. Default is max(100, N//10).
Returns:
-
kicks(ndarray) –Energy kick per unit length at each particle (eV/m).
Source code in beamphysics/wakefields/impedance.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
plot
plot(zmax=None, zmin=0, n=200, normalized=False, ax=None)
Plot the resistive wall wakefield W(z).
Parameters:
-
zmax(float, default:None) –Maximum trailing distance (m). Defaults to 100 * s0.
-
zmin(float, default:0) –Minimum trailing distance (m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
normalized(bool, default:False) –If True, plot dimensionless Ŵ(z/s₀) = W(z)/W₀ vs z/s₀. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/resistive_wall/impedance.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
plot_impedance
plot_impedance(kmax: float = None, kmin: float = 0, n: int = 500, ax=None)
Plot the resistive wall impedance Z(k).
Parameters:
-
kmax(float, default:None) –Maximum wavenumber (1/m). Defaults to 10/s0.
-
kmin(float, default:0) –Minimum wavenumber (1/m). Default is 0.
-
n(int, default:500) –Number of points. Default is 500.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/resistive_wall/impedance.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
to_tabular
to_tabular(zmax: float | None = None, n: int | None = None) -> TabularWakefield
Resample this model onto a uniform TabularWakefield.
See TabularWakefield.from_wakefield.
Parameters:
-
zmax(float, default:None) –Largest distance behind the source particle (m). Defaults to
default_zmax. -
n(int, default:None) –Number of samples. Defaults to
default_n_samples(zmax).
Returns:
Examples:
>>> wake = ResistiveWallPseudomode.from_material(
... "copper-slac-pub-10707", radius=2.5e-3
... )
>>> table = wake.to_tabular()
Source code in beamphysics/wakefields/resistive_wall/base.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
wake
wake(z: ndarray | float, n_fft: int = 4096) -> ndarray | float
Evaluate the wakefield at position z.
If a wakefield function was provided, uses it directly. Otherwise, computes via cosine transform of Re[Z(k)]: - Scalars: numerical quadrature (accurate) - Arrays: FFT with interpolation (fast)
Parameters:
-
z(float or ndarray) –Longitudinal position (m).
-
n_fft(int, default:4096) –Number of FFT points for array evaluation. Default is 4096.
Returns:
-
W(float or ndarray) –Wakefield value (V/C/m). Returns 0 for z > 0.
Source code in beamphysics/wakefields/impedance.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
ResistiveWallPseudomode
dataclass
ResistiveWallPseudomode(radius: float, conductivity: float, relaxation_time: float, geometry: Geometry = ROUND)
Bases: ResistiveWallWakefieldBase, PseudomodeWakefield
flowchart TD
beamphysics.wakefields.ResistiveWallPseudomode[ResistiveWallPseudomode]
beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase[ResistiveWallWakefieldBase]
beamphysics.wakefields.pseudomode.PseudomodeWakefield[PseudomodeWakefield]
beamphysics.wakefields.base.WakefieldBase[WakefieldBase]
beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase --> beamphysics.wakefields.ResistiveWallPseudomode
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase
beamphysics.wakefields.pseudomode.PseudomodeWakefield --> beamphysics.wakefields.ResistiveWallPseudomode
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.pseudomode.PseudomodeWakefield
click beamphysics.wakefields.ResistiveWallPseudomode href "" "beamphysics.wakefields.ResistiveWallPseudomode"
click beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase href "" "beamphysics.wakefields.resistive_wall.base.ResistiveWallWakefieldBase"
click beamphysics.wakefields.pseudomode.PseudomodeWakefield href "" "beamphysics.wakefields.pseudomode.PseudomodeWakefield"
click beamphysics.wakefields.base.WakefieldBase href "" "beamphysics.wakefields.base.WakefieldBase"
Fast pseudomode-based resistive wall wakefield model.
This class models the short-range resistive wall wakefield using a damped sinusoidal "pseudomode" approximation. When a relativistic charged particle travels through a conducting beam pipe, it induces image currents in the pipe walls. Due to the finite conductivity of the wall material, these currents penetrate into the conductor and dissipate energy, creating a wakefield that acts on trailing particles.
Physics Background
The resistive wall impedance arises from the skin effect in the conducting walls. At high frequencies (short distances), the AC conductivity of metals deviates from DC behavior due to the Drude relaxation time τ:
This frequency dependence causes the wakefield to oscillate and decay exponentially behind the source particle. The wakefield can be well approximated by a single damped sinusoid (pseudomode):
where the parameters \(k_r\) (oscillation wavenumber) and \(Q_r\) (quality factor, related to decay rate \(d = k_r / 2Q_r\)) depend on the dimensionless relaxation parameter \(\Gamma = c\tau / s_0\).
Characteristic Scales
- s₀: Characteristic length scale where the wake transitions from the \(1/\sqrt{z}\) DC behavior to oscillatory AC behavior:
$\(s_0 = \left( \frac{2a^2}{Z_0 \sigma_0} \right)^{1/3}\)$
-
Γ: Dimensionless relaxation parameter \(\Gamma = c\tau / s_0\). For copper, Γ ≈ 0.8; for aluminum, Γ ≈ 0.2.
-
W₀: Characteristic wake amplitude at z = 0:
- Round: \(W_0 = c Z_0 / (\pi a^2)\)
- Flat: \(W_0 = c Z_0 \pi / (16 a^2)\)
Algorithm
The pseudomode form enables an O(N) algorithm for computing particle kicks, compared to O(N²) or O(N log N) for general wakefields. This makes it suitable for multi-pass tracking simulations.
Parameters:
-
radius(float) –Radius of the beam pipe (m). For flat geometry, this is half the gap.
-
conductivity(float) –Electrical DC conductivity of the wall material (S/m).
-
relaxation_time(float) –Drude-model relaxation time τ of the conductor (s). Typical values: Cu ≈ 27 fs, Al ≈ 8 fs.
-
geometry(str, default:ROUND) –Geometry of the beam pipe: 'round' or 'flat'. Default is 'round'.
Attributes:
-
s0(float) –Characteristic length scale (m)
-
Gamma(float) –Dimensionless relaxation parameter Γ = cτ/s₀
-
kr(float) –Resonant wavenumber (1/m)
-
Qr(float) –Quality factor of the pseudomode
Notes
- The pseudomode approximation has ~10-20% error compared to the full impedance model, primarily in the first oscillation peak.
- The polynomial fits for k_r and Q_r are valid for Γ ≲ 3. A warning is issued for larger values.
- Materials with known conductivity and τ values are available via
from_material().
See Also
ResistiveWallWakefield : Accurate impedance-based model (slower)
References
.. [1] K. Bane and G. Stupakov, "Resistive wall wakefield in the LCLS undulator beam pipe," SLAC-PUB-10707 (2004). https://www.slac.stanford.edu/cgi-wrap/getdoc/slac-pub-10707.pdf
.. [2] D. Sagan, "Bmad Manual," Section 24.6: Short-Range Wakefields. https://www.classe.cornell.edu/bmad/manual.html
.. [3] A. Chao, "Physics of Collective Beam Instabilities in High Energy Accelerators," Wiley, 1993, Chapter 2.
Examples:
>>> wake = ResistiveWallPseudomode.from_material(
... "copper-slac-pub-10707", radius=2.5e-3, geometry="round"
... )
>>> wake.wake(-10e-6) # Wake at 10 µm behind source
Methods:
-
__call__–Evaluate the wakefield at position z (convenience method).
-
convolve_density–Compute integrated wakefield from a charge density distribution.
-
default_n_samples–Default number of uniform samples out to zmax.
-
from_material–Create a wakefield from a known material preset.
-
impedance–Compute the impedance Z(k) analytically.
-
material_from_properties–Attempt to identify the material based on conductivity and relaxation time.
-
particle_kicks–Compute short-range wakefield energy kicks per unit length.
-
plot–Plot the resistive wall wakefield W(z).
-
plot_impedance–Plot the resistive wall impedance Z(k).
-
to_bmad–Export wakefield in Bmad format.
-
to_tabular–Resample this model onto a uniform
TabularWakefield. -
wake–Evaluate the pseudomode wakefield at position z.
Gamma
property
Gamma
Dimensionless relaxation time Γ = c * τ / s₀.
Qr
property
Qr
Dimensionless quality factor Q_r of the wakefield pseudomode.
W0
property
W0
Characteristic wake amplitude W₀ at z=0 (V/C/m).
From SLAC-PUB-10707: - Round: W₀ = c·Z₀ / (π·a²) - Flat: W₀ = c·Z₀·π / (16·a²) = W₀_round · (π²/16)
The dimensionless scaled wake is Ŵ(z/s₀) = W(z) / W₀.
decay_length
property
decay_length: float
Envelope decay length of the most slowly damped mode (m).
Raises:
-
ValueError–If any mode has d <= 0, so that the wake does not decay.
default_zmax
property
default_zmax: float
Distance behind the source particle beyond which the wake is negligible (m).
Here L is decay_length, so the envelope has fallen to exp(-10).
kr
property
kr
Real-valued wave number k_r of the wakefield pseudomode (1/m).
min_wavelength
property
min_wavelength: float
Shortest length scale of the wake (m).
The period of the fastest mode or the decay length of the most strongly damped mode, whichever is shorter.
Raises:
-
ValueError–If any mode has d <= 0.
modes
property
modes: list
List of Pseudomode objects.
n_modes
property
n_modes: int
Number of pseudomodes.
s0
property
s0
Characteristic length scale s₀ of the resistive wall wakefield (m).
From SLAC-PUB-10707 Eq. (5):
where a is the pipe radius (round) or half-gap (flat), Z₀ is the impedance of free space, and σ₀ is the DC conductivity.
__call__
__call__(z: float | ndarray) -> float | ndarray
Evaluate the wakefield at position z (convenience method).
Source code in beamphysics/wakefields/resistive_wall/base.py
721 722 723 | |
convolve_density
convolve_density(density: ndarray, dz: float, offset: float = 0, include_self_kick: bool = True, plot: bool = False, ax=None) -> ndarray
Compute integrated wakefield from a charge density distribution.
This computes the causal wake potential:
where only particles ahead (larger z index) contribute to the wake felt by each particle. This is mathematically a correlation, not a convolution, and is computed efficiently using FFT.
Parameters:
-
density(ndarray) –Charge density array (C/m). Index 0 is the tail (back), index n-1 is the head (front).
-
dz(float) –Grid spacing (m).
-
offset(float, default:0) –Offset for the z coordinate (m). Default is 0.
-
include_self_kick(bool, default:True) –Whether to include the half self-kick term. Default is True.
-
plot(bool, default:False) –If True, plot the density profile and wake potential. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None and plot=True, creates a new figure.
Returns:
-
integrated_wake(ndarray) –Integrated longitudinal wakefield (V/m).
Source code in beamphysics/wakefields/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_n_samples
default_n_samples(zmax: float) -> int
Default number of uniform samples out to zmax.
Here lambda_min is min_wavelength, and 4 is the minimum for cubic
interpolation.
Parameters:
-
zmax(float) –Largest distance behind the source particle (m).
Returns:
-
int–
Source code in beamphysics/wakefields/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
from_material
classmethod
from_material(material: str, radius: float, geometry: Geometry | str = ROUND)
Create a wakefield from a known material preset.
Parameters:
-
material(str) –Material name. Must be in list(cls.MATERIALS)
-
radius(float) –Pipe radius (m)
-
geometry(str, default:ROUND) –Geometry type: 'round' or 'flat'
Source code in beamphysics/wakefields/resistive_wall/base.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
impedance
impedance(k: ndarray | float) -> ndarray | complex
Compute the impedance Z(k) analytically.
Sums the contribution from each pseudomode using the analytic Fourier transform.
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/pseudomode.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
material_from_properties
material_from_properties(tol=0.01)
Attempt to identify the material based on conductivity and relaxation time.
Parameters:
-
tol(float, default:0.01) –Relative tolerance for matching, default is 1% (0.01)
Returns:
-
material(str or None) –Name of the matched material, or None if no match is found.
Source code in beamphysics/wakefields/resistive_wall/base.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |
particle_kicks
particle_kicks(z: ndarray, weight: ndarray, include_self_kick: bool = True) -> ndarray
Compute short-range wakefield energy kicks per unit length.
Uses an O(N) single-pass algorithm for each mode by exploiting the exponential form of the pseudomode wakefield.
Parameters:
-
z(ndarray) –Particle positions (m).
-
weight(ndarray) –Particle charges (C).
-
include_self_kick(bool, default:True) –If True, applies the self-kick. Default is True.
Returns:
-
kicks(ndarray) –Wake-induced energy kick per unit length (eV/m).
Source code in beamphysics/wakefields/pseudomode.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
plot
plot(zmax=None, zmin=0, n=200, normalized=False, ax=None)
Plot the resistive wall wakefield W(z).
Parameters:
-
zmax(float, default:None) –Maximum trailing distance (m). Defaults to 10 decay lengths.
-
zmin(float, default:0) –Minimum trailing distance (m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
normalized(bool, default:False) –If True, plot dimensionless Ŵ(z/s₀) = W(z)/W₀ vs z/s₀. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/resistive_wall/pseudomode.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
plot_impedance
plot_impedance(kmax: float = None, kmin: float = 0, n: int = 500, ax=None)
Plot the resistive wall impedance Z(k).
Parameters:
-
kmax(float, default:None) –Maximum wavenumber (1/m). Defaults to 10/s0.
-
kmin(float, default:0) –Minimum wavenumber (1/m). Default is 0.
-
n(int, default:500) –Number of points. Default is 500.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/resistive_wall/pseudomode.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
to_bmad
to_bmad(file=None, z_max=100, amp_scale=1, scale_with_length=True, z_scale=1)
Export wakefield in Bmad format.
Parameters:
-
file(str, default:None) –Output file path. If None, returns string only.
-
z_max(float, default:100) –Trailing z distance for Bmad.
-
amp_scale(float, default:1) –Amplitude scaling factor.
-
scale_with_length(bool, default:True) –Whether to scale with length.
-
z_scale(float, default:1) –Z scaling factor.
Returns:
-
str–Bmad-formatted wakefield string.
Source code in beamphysics/wakefields/resistive_wall/pseudomode.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
to_tabular
to_tabular(zmax: float | None = None, n: int | None = None) -> TabularWakefield
Resample this model onto a uniform TabularWakefield.
See TabularWakefield.from_wakefield.
Parameters:
-
zmax(float, default:None) –Largest distance behind the source particle (m). Defaults to
default_zmax. -
n(int, default:None) –Number of samples. Defaults to
default_n_samples(zmax).
Returns:
Examples:
>>> wake = ResistiveWallPseudomode.from_material(
... "copper-slac-pub-10707", radius=2.5e-3
... )
>>> table = wake.to_tabular()
Source code in beamphysics/wakefields/resistive_wall/base.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
wake
wake(z: ndarray | float) -> ndarray | float
Evaluate the pseudomode wakefield at position z.
Parameters:
-
z(float or ndarray) –Longitudinal position (m). Negative z is behind the source.
Returns:
-
W(float or ndarray) –Wakefield value (V/C/m). Returns 0 for z > 0.
Source code in beamphysics/wakefields/pseudomode.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
Base Classes
WakefieldBase
Bases: ABC
flowchart TD
beamphysics.wakefields.WakefieldBase[WakefieldBase]
click beamphysics.wakefields.WakefieldBase href "" "beamphysics.wakefields.WakefieldBase"
Abstract base class for longitudinal wakefield models.
All wakefield implementations should inherit from this class and implement the required abstract methods.
Sign Convention
The wakefield W(z) is defined for a trailing particle at position z relative to the source particle at z=0:
- z < 0: Behind the source (trailing particle feels the wake)
- z > 0: Ahead of the source (causality requires W=0)
The wake is positive for an energy-losing interaction (the trailing particle loses energy).
Methods:
-
wake–Evaluate the wakefield at position z (V/C/m)
-
impedance–Evaluate the impedance at wavenumber k (Ohm/m)
-
convolve_density–Compute integrated wake from a charge density distribution (V/m)
-
particle_kicks–Compute momentum kicks for a distribution of particles (eV/m)
-
plot–Plot the wakefield over a range of z values
-
plot_impedance–Plot the impedance over a range of wavenumbers
See Also
ParticleGroup.apply_wakefield : Apply wakefield kicks to a ParticleGroup
Attributes:
-
default_zmax(float) –Distance behind the source particle beyond which the wake is negligible (m).
-
min_wavelength(float) –Shortest length scale of the wake (m), which sets the default sampling.
default_zmax
property
default_zmax: float
Distance behind the source particle beyond which the wake is negligible (m).
Used as the default range when tabulating.
Raises:
-
NotImplementedError–If the model defines no default; pass zmax explicitly.
min_wavelength
property
min_wavelength: float
Shortest length scale of the wake (m), which sets the default sampling.
Raises:
-
NotImplementedError–If the model defines no length scale; pass n explicitly.
__call__
__call__(z: ndarray | float) -> ndarray | float
Evaluate the wakefield at position z (convenience method).
This is equivalent to calling wake(z).
Source code in beamphysics/wakefields/base.py
104 105 106 107 108 109 110 | |
convolve_density
convolve_density(density: ndarray, dz: float, offset: float = 0, include_self_kick: bool = True, plot: bool = False, ax=None) -> ndarray
Compute integrated wakefield from a charge density distribution.
This computes the causal wake potential:
where only particles ahead (larger z index) contribute to the wake felt by each particle. This is mathematically a correlation, not a convolution, and is computed efficiently using FFT.
Parameters:
-
density(ndarray) –Charge density array (C/m). Index 0 is the tail (back), index n-1 is the head (front).
-
dz(float) –Grid spacing (m).
-
offset(float, default:0) –Offset for the z coordinate (m). Default is 0.
-
include_self_kick(bool, default:True) –Whether to include the half self-kick term. Default is True.
-
plot(bool, default:False) –If True, plot the density profile and wake potential. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None and plot=True, creates a new figure.
Returns:
-
integrated_wake(ndarray) –Integrated longitudinal wakefield (V/m).
Source code in beamphysics/wakefields/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_n_samples
default_n_samples(zmax: float) -> int
Default number of uniform samples out to zmax.
Here lambda_min is min_wavelength, and 4 is the minimum for cubic
interpolation.
Parameters:
-
zmax(float) –Largest distance behind the source particle (m).
Returns:
-
int–
Source code in beamphysics/wakefields/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
impedance
abstractmethod
impedance(k: ndarray | float) -> ndarray | complex
Evaluate the impedance at wavenumber k.
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/base.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
particle_kicks
particle_kicks(z: ndarray, weight: ndarray, include_self_kick: bool = True) -> ndarray
Compute wakefield-induced energy kicks per unit length.
This is a default O(N²) implementation. Subclasses may override with more efficient algorithms.
Parameters:
-
z(ndarray) –Particle positions (m).
-
weight(ndarray) –Particle charges (C).
-
include_self_kick(bool, default:True) –Whether to include the self-kick term. Default is True.
Returns:
-
kicks(ndarray) –Energy kick per unit length at each particle (eV/m).
Source code in beamphysics/wakefields/base.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
plot
plot(zmax: float = None, zmin: float = 0, n: int = 200, ax=None)
Plot the wakefield over a range of z values.
Parameters:
-
zmax(float, default:None) –Maximum trailing distance (m). If None, uses a sensible default.
-
zmin(float, default:0) –Minimum trailing distance (m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
plot_impedance
plot_impedance(kmax: float = None, kmin: float = 0, n: int = 200, ax=None)
Plot the impedance over a range of wavenumbers.
Parameters:
-
kmax(float, default:None) –Maximum wavenumber (1/m). If None, uses a sensible default.
-
kmin(float, default:0) –Minimum wavenumber (1/m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
wake
abstractmethod
wake(z: ndarray | float) -> ndarray | float
Evaluate the wakefield at longitudinal position z.
Parameters:
-
z(float or ndarray) –Longitudinal position (m). Negative z is behind the source.
Returns:
-
W(float or ndarray) –Wakefield value (V/C/m). Returns 0 for z > 0 (causality).
Source code in beamphysics/wakefields/base.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
PseudomodeWakefield
PseudomodeWakefield(modes: list)
Bases: WakefieldBase
flowchart TD
beamphysics.wakefields.PseudomodeWakefield[PseudomodeWakefield]
beamphysics.wakefields.base.WakefieldBase[WakefieldBase]
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.PseudomodeWakefield
click beamphysics.wakefields.PseudomodeWakefield href "" "beamphysics.wakefields.PseudomodeWakefield"
click beamphysics.wakefields.base.WakefieldBase href "" "beamphysics.wakefields.base.WakefieldBase"
Wakefield represented as a sum of damped sinusoidal pseudomodes.
Models the longitudinal wakefield as:
This form is used to approximate short-range wakefields such as the resistive wall wake.
Parameters:
-
modes(list of Pseudomode or list of dict) –List of pseudomodes. Each can be a Pseudomode object or a dict with keys 'A', 'd', 'k', 'phi'.
Notes
- Wakefields are defined for z ≤ 0 (trailing the source particle).
- For z > 0, returns 0 (causality).
Examples:
Single mode::
pm = PseudomodeWakefield([Pseudomode(A=1e15, d=1e4, k=1e5, phi=np.pi/2)])
pm.wake(-10e-6) # Wake at 10 µm behind source
Multiple modes::
modes = [
Pseudomode(A=1e15, d=1e4, k=1e5, phi=np.pi/2),
Pseudomode(A=5e14, d=2e4, k=2e5, phi=np.pi/4),
]
pm = PseudomodeWakefield(modes)
Methods:
-
__call__–Evaluate the wakefield at position z (convenience method).
-
convolve_density–Compute integrated wakefield from a charge density distribution.
-
default_n_samples–Default number of uniform samples out to zmax.
-
impedance–Compute the impedance Z(k) analytically.
-
particle_kicks–Compute short-range wakefield energy kicks per unit length.
-
plot–Plot the pseudomode wakefield.
-
plot_impedance–Plot the impedance over a range of wavenumbers.
-
to_bmad–Format pseudomode parameters as Bmad-compatible strings.
-
wake–Evaluate the pseudomode wakefield at position z.
Attributes:
-
decay_length(float) –Envelope decay length of the most slowly damped mode (m).
-
default_zmax(float) –Distance behind the source particle beyond which the wake is negligible (m).
-
min_wavelength(float) –Shortest length scale of the wake (m).
-
modes(list) –List of Pseudomode objects.
-
n_modes(int) –Number of pseudomodes.
Source code in beamphysics/wakefields/pseudomode.py
213 214 215 216 217 218 219 220 221 | |
decay_length
property
decay_length: float
Envelope decay length of the most slowly damped mode (m).
Raises:
-
ValueError–If any mode has d <= 0, so that the wake does not decay.
default_zmax
property
default_zmax: float
Distance behind the source particle beyond which the wake is negligible (m).
Here L is decay_length, so the envelope has fallen to exp(-10).
min_wavelength
property
min_wavelength: float
Shortest length scale of the wake (m).
The period of the fastest mode or the decay length of the most strongly damped mode, whichever is shorter.
Raises:
-
ValueError–If any mode has d <= 0.
modes
property
modes: list
List of Pseudomode objects.
n_modes
property
n_modes: int
Number of pseudomodes.
__call__
__call__(z: ndarray | float) -> ndarray | float
Evaluate the wakefield at position z (convenience method).
This is equivalent to calling wake(z).
Source code in beamphysics/wakefields/base.py
104 105 106 107 108 109 110 | |
convolve_density
convolve_density(density: ndarray, dz: float, offset: float = 0, include_self_kick: bool = True, plot: bool = False, ax=None) -> ndarray
Compute integrated wakefield from a charge density distribution.
This computes the causal wake potential:
where only particles ahead (larger z index) contribute to the wake felt by each particle. This is mathematically a correlation, not a convolution, and is computed efficiently using FFT.
Parameters:
-
density(ndarray) –Charge density array (C/m). Index 0 is the tail (back), index n-1 is the head (front).
-
dz(float) –Grid spacing (m).
-
offset(float, default:0) –Offset for the z coordinate (m). Default is 0.
-
include_self_kick(bool, default:True) –Whether to include the half self-kick term. Default is True.
-
plot(bool, default:False) –If True, plot the density profile and wake potential. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None and plot=True, creates a new figure.
Returns:
-
integrated_wake(ndarray) –Integrated longitudinal wakefield (V/m).
Source code in beamphysics/wakefields/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_n_samples
default_n_samples(zmax: float) -> int
Default number of uniform samples out to zmax.
Here lambda_min is min_wavelength, and 4 is the minimum for cubic
interpolation.
Parameters:
-
zmax(float) –Largest distance behind the source particle (m).
Returns:
-
int–
Source code in beamphysics/wakefields/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
impedance
impedance(k: ndarray | float) -> ndarray | complex
Compute the impedance Z(k) analytically.
Sums the contribution from each pseudomode using the analytic Fourier transform.
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/pseudomode.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
particle_kicks
particle_kicks(z: ndarray, weight: ndarray, include_self_kick: bool = True) -> ndarray
Compute short-range wakefield energy kicks per unit length.
Uses an O(N) single-pass algorithm for each mode by exploiting the exponential form of the pseudomode wakefield.
Parameters:
-
z(ndarray) –Particle positions (m).
-
weight(ndarray) –Particle charges (C).
-
include_self_kick(bool, default:True) –If True, applies the self-kick. Default is True.
Returns:
-
kicks(ndarray) –Wake-induced energy kick per unit length (eV/m).
Source code in beamphysics/wakefields/pseudomode.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
plot
plot(zmax: float = 0.001, zmin: float = 0, n: int = 200, ax=None)
Plot the pseudomode wakefield.
Source code in beamphysics/wakefields/pseudomode.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
plot_impedance
plot_impedance(kmax: float = None, kmin: float = 0, n: int = 200, ax=None)
Plot the impedance over a range of wavenumbers.
Parameters:
-
kmax(float, default:None) –Maximum wavenumber (1/m). If None, uses a sensible default.
-
kmin(float, default:0) –Minimum wavenumber (1/m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
to_bmad
to_bmad(type: str = 'longitudinal', transverse_dependence: str = 'none') -> str
Format pseudomode parameters as Bmad-compatible strings.
Parameters:
-
type(str, default:'longitudinal') –Wake type. Default is "longitudinal".
-
transverse_dependence(str, default:'none') –Transverse dependence. Default is "none".
Returns:
-
str–Bmad-formatted string (one line per mode).
Source code in beamphysics/wakefields/pseudomode.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
wake
wake(z: ndarray | float) -> ndarray | float
Evaluate the pseudomode wakefield at position z.
Parameters:
-
z(float or ndarray) –Longitudinal position (m). Negative z is behind the source.
Returns:
-
W(float or ndarray) –Wakefield value (V/C/m). Returns 0 for z > 0.
Source code in beamphysics/wakefields/pseudomode.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
ImpedanceWakefield
ImpedanceWakefield(impedance_func: Callable[[ndarray], ndarray], wakefield_func: Callable[[ndarray], ndarray] = None, k_max: float = 10000000.0)
Bases: WakefieldBase
flowchart TD
beamphysics.wakefields.ImpedanceWakefield[ImpedanceWakefield]
beamphysics.wakefields.base.WakefieldBase[WakefieldBase]
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.ImpedanceWakefield
click beamphysics.wakefields.ImpedanceWakefield href "" "beamphysics.wakefields.ImpedanceWakefield"
click beamphysics.wakefields.base.WakefieldBase href "" "beamphysics.wakefields.base.WakefieldBase"
Wakefield defined through its longitudinal impedance Z(k).
Uses FFT-based convolution in frequency domain for efficient wake potential calculations.
Parameters:
-
impedance_func(callable) –Function that returns complex impedance Z(k) (Ohm/m) for wave number k (1/m). Should handle arrays.
-
wakefield_func(callable, default:None) –Function that returns wakefield W(z) (V/C/m) for position z (m). If not provided, uses numerical cosine transform of impedance.
-
k_max(float, default:10000000.0) –Maximum wavenumber for integration (1/m). Default is 1e7.
Notes
The wakefield W(z) is defined for z ≤ 0 (trailing particles), with W(z) = 0 for z > 0 (causality). The impedance Z(k) is related to the wakefield by:
And the inverse:
Examples:
>>> def my_impedance(k):
... return 100 / (1 + 1j * k * 1e-6) # Simple resonator
>>> wake = ImpedanceWakefield(my_impedance)
Methods:
-
__call__–Evaluate the wakefield at position z (convenience method).
-
convolve_density–Compute integrated wakefield from a charge density distribution.
-
default_n_samples–Default number of uniform samples out to zmax.
-
impedance–Evaluate the impedance at wavenumber k.
-
particle_kicks–Compute wakefield-induced energy kicks per unit length.
-
plot–Plot the wakefield over a range of z values.
-
plot_impedance–Plot the impedance over a range of wavenumbers.
-
wake–Evaluate the wakefield at position z.
Attributes:
-
default_zmax(float) –Distance behind the source particle beyond which the wake is negligible (m).
-
k_max(float) –Maximum wavenumber for integration.
-
min_wavelength(float) –Shortest length scale of the wake (m), which sets the default sampling.
Source code in beamphysics/wakefields/impedance.py
61 62 63 64 65 66 67 68 69 | |
default_zmax
property
default_zmax: float
Distance behind the source particle beyond which the wake is negligible (m).
Used as the default range when tabulating.
Raises:
-
NotImplementedError–If the model defines no default; pass zmax explicitly.
k_max
property
writable
k_max: float
Maximum wavenumber for integration.
min_wavelength
property
min_wavelength: float
Shortest length scale of the wake (m), which sets the default sampling.
Raises:
-
NotImplementedError–If the model defines no length scale; pass n explicitly.
__call__
__call__(z: ndarray | float) -> ndarray | float
Evaluate the wakefield at position z (convenience method).
This is equivalent to calling wake(z).
Source code in beamphysics/wakefields/base.py
104 105 106 107 108 109 110 | |
convolve_density
convolve_density(density: ndarray, dz: float, offset: float = 0, include_self_kick: bool = True, plot: bool = False, ax=None) -> ndarray
Compute integrated wakefield from a charge density distribution.
This computes the causal wake potential:
where only particles ahead (larger z index) contribute to the wake felt by each particle. This is mathematically a correlation, not a convolution, and is computed efficiently using FFT.
Parameters:
-
density(ndarray) –Charge density array (C/m). Index 0 is the tail (back), index n-1 is the head (front).
-
dz(float) –Grid spacing (m).
-
offset(float, default:0) –Offset for the z coordinate (m). Default is 0.
-
include_self_kick(bool, default:True) –Whether to include the half self-kick term. Default is True.
-
plot(bool, default:False) –If True, plot the density profile and wake potential. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None and plot=True, creates a new figure.
Returns:
-
integrated_wake(ndarray) –Integrated longitudinal wakefield (V/m).
Source code in beamphysics/wakefields/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_n_samples
default_n_samples(zmax: float) -> int
Default number of uniform samples out to zmax.
Here lambda_min is min_wavelength, and 4 is the minimum for cubic
interpolation.
Parameters:
-
zmax(float) –Largest distance behind the source particle (m).
Returns:
-
int–
Source code in beamphysics/wakefields/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
impedance
impedance(k: ndarray | float) -> ndarray | complex
Evaluate the impedance at wavenumber k.
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/impedance.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
particle_kicks
particle_kicks(z: ndarray, weight: ndarray, include_self_kick: bool = True, n_bins: int = None) -> ndarray
Compute wakefield-induced energy kicks per unit length.
Uses FFT-based density convolution with interpolation back to particle positions. This is O(N + M log M) where N is the number of particles and M is the number of grid points.
Parameters:
-
z(ndarray) –Particle positions (m).
-
weight(ndarray) –Particle charges (C).
-
include_self_kick(bool, default:True) –Whether to include the self-kick term. Default is True.
-
n_bins(int, default:None) –Number of bins for the density grid. Default is max(100, N//10).
Returns:
-
kicks(ndarray) –Energy kick per unit length at each particle (eV/m).
Source code in beamphysics/wakefields/impedance.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
plot
plot(zmax: float = None, zmin: float = 0, n: int = 200, ax=None)
Plot the wakefield over a range of z values.
Parameters:
-
zmax(float, default:None) –Maximum trailing distance (m). If None, uses a sensible default.
-
zmin(float, default:0) –Minimum trailing distance (m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
plot_impedance
plot_impedance(kmax: float = None, kmin: float = 0, n: int = 200, ax=None)
Plot the impedance over a range of wavenumbers.
Parameters:
-
kmax(float, default:None) –Maximum wavenumber (1/m). If None, uses a sensible default.
-
kmin(float, default:0) –Minimum wavenumber (1/m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
wake
wake(z: ndarray | float, n_fft: int = 4096) -> ndarray | float
Evaluate the wakefield at position z.
If a wakefield function was provided, uses it directly. Otherwise, computes via cosine transform of Re[Z(k)]: - Scalars: numerical quadrature (accurate) - Arrays: FFT with interpolation (fast)
Parameters:
-
z(float or ndarray) –Longitudinal position (m).
-
n_fft(int, default:4096) –Number of FFT points for array evaluation. Default is 4096.
Returns:
-
W(float or ndarray) –Wakefield value (V/C/m). Returns 0 for z > 0.
Source code in beamphysics/wakefields/impedance.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
TabularWakefield
TabularWakefield(z: ndarray, W: ndarray, fill_value: float = 0.0, kind: str = 'cubic')
Bases: WakefieldBase
flowchart TD
beamphysics.wakefields.TabularWakefield[TabularWakefield]
beamphysics.wakefields.base.WakefieldBase[WakefieldBase]
beamphysics.wakefields.base.WakefieldBase --> beamphysics.wakefields.TabularWakefield
click beamphysics.wakefields.TabularWakefield href "" "beamphysics.wakefields.TabularWakefield"
click beamphysics.wakefields.base.WakefieldBase href "" "beamphysics.wakefields.base.WakefieldBase"
Wakefield defined by user-supplied tabular data with interpolation.
Uses cubic spline interpolation to evaluate the wakefield at arbitrary positions between the supplied data points.
Parameters:
-
z(ndarray) –Longitudinal positions (m). Should be negative (behind source) and must be strictly increasing.
-
W(ndarray) –Wakefield values (V/C/m) at each z position. At z = 0 this is W(0-), the wake immediately behind the source particle.
-
fill_value(float, default:0.0) –Value to return outside the interpolation range. Default is 0.
-
kind(str, default:'cubic') –Interpolation method. Default is 'cubic'.
Examples:
>>> z = -np.linspace(1e-3, 0, 100)
>>> wake = TabularWakefield(z, 1e15 * np.exp(z / 100e-6) * np.sin(1e5 * z))
>>> wake.wake(-50e-6) # 50 µm behind the source
Methods:
-
__call__–Evaluate the wakefield at position z (convenience method).
-
convolve_density–Compute integrated wakefield from a charge density distribution.
-
default_n_samples–Number of uniform samples that keeps the finest spacing of the table.
-
from_bmad–Read the longitudinal wake from a Bmad z_long wake table.
-
from_impact_t–Read the longitudinal wake from an IMPACT-T wake table.
-
from_impact_z–Read the longitudinal wake from an IMPACT-Z wake table.
-
from_wakefield–Resample a wakefield model onto a uniform table.
-
impedance–Compute the impedance Z(k) via numerical FFT.
-
particle_kicks–Compute wakefield-induced energy kicks per unit length.
-
plot–Plot the wakefield over a range of z values.
-
plot_impedance–Plot the impedance over a range of wavenumbers.
-
to_bmad–Format this table as the value of a Bmad
sr_wakewith a z_long table. -
to_impact_t–Build, and optionally write, the IMPACT-T wakefield table for this wake.
-
to_impact_z–Build, and optionally write, the IMPACT-Z wakefield table for this wake.
-
wake–Evaluate the wakefield at position z using interpolation.
Attributes:
-
W_data(ndarray) –Return the W data points.
-
default_zmax(float) –Range covered by the table (m).
-
min_wavelength(float) –Shortest length scale of the wake (m), which sets the default sampling.
-
z_data(ndarray) –Return the z data points.
Source code in beamphysics/wakefields/tabular.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
W_data
property
W_data: ndarray
Return the W data points.
default_zmax
property
default_zmax: float
Range covered by the table (m).
min_wavelength
property
min_wavelength: float
Shortest length scale of the wake (m), which sets the default sampling.
Raises:
-
NotImplementedError–If the model defines no length scale; pass n explicitly.
z_data
property
z_data: ndarray
Return the z data points.
__call__
__call__(z: ndarray | float) -> ndarray | float
Evaluate the wakefield at position z (convenience method).
This is equivalent to calling wake(z).
Source code in beamphysics/wakefields/base.py
104 105 106 107 108 109 110 | |
convolve_density
convolve_density(density: ndarray, dz: float, offset: float = 0, include_self_kick: bool = True, plot: bool = False, ax=None) -> ndarray
Compute integrated wakefield from a charge density distribution.
This computes the causal wake potential:
where only particles ahead (larger z index) contribute to the wake felt by each particle. This is mathematically a correlation, not a convolution, and is computed efficiently using FFT.
Parameters:
-
density(ndarray) –Charge density array (C/m). Index 0 is the tail (back), index n-1 is the head (front).
-
dz(float) –Grid spacing (m).
-
offset(float, default:0) –Offset for the z coordinate (m). Default is 0.
-
include_self_kick(bool, default:True) –Whether to include the half self-kick term. Default is True.
-
plot(bool, default:False) –If True, plot the density profile and wake potential. Default is False.
-
ax(Axes, default:None) –Axes to plot on. If None and plot=True, creates a new figure.
Returns:
-
integrated_wake(ndarray) –Integrated longitudinal wakefield (V/m).
Source code in beamphysics/wakefields/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_n_samples
default_n_samples(zmax: float) -> int
Number of uniform samples that keeps the finest spacing of the table.
Here Delta z_min is the finest spacing within -zmax <= z <= 0.
Parameters:
-
zmax(float) –Largest distance behind the source particle (m).
Returns:
-
int–
Source code in beamphysics/wakefields/tabular.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
from_bmad
classmethod
from_bmad(source: ndarray, amp_scale: float = 1, z_scale: float = 1, kind: str = 'cubic') -> TabularWakefield
Read the longitudinal wake from a Bmad z_long wake table.
This is the inverse of to_bmad, applied to the array that pytao returns for
tao.ele_wake(ele_id, who="sr_z_long_table"). Bmad extends the table
symmetrically about z = 0; the rows ahead of the source particle are dropped,
and the grid is rebuilt to end exactly at z = 0.
Parameters:
-
source(ndarray) –Table of shape (n, 2) holding z (m) and W (V/C/m) on a uniform grid.
-
amp_scale(float, default:1) –Bmad
sr%amp_scale. Default is 1. -
z_scale(float, default:1) –Bmad
sr%z_scale. Default is 1. -
kind(str, default:'cubic') –Interpolation method. Default is 'cubic'.
Returns:
Raises:
-
ValueError–If the table is empty (the element has no z_long wake), if z_scale is not positive, if the grid is not uniform or has no row at z = 0, or if the wake is nonzero ahead of the source particle.
Notes
With scale_with_length = F, Bmad reads the table in V/C; pass amp_scale
divided by the structure length to obtain V/C/m. The smoothing_sigma and
position_dependence settings are ignored.
Examples:
>>> rows = tao.ele_wake("pipe1", who="sr_z_long_table")
>>> table = TabularWakefield.from_bmad(rows)
Source code in beamphysics/wakefields/tabular.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
from_impact_t
classmethod
from_impact_t(source: str | PathLike | ndarray, length: float, kind: str = 'cubic') -> TabularWakefield
Read the longitudinal wake from an IMPACT-T wake table.
The table has no position column, so its length must be supplied. The
transverse columns are ignored. See
beamphysics.interfaces.impact.parse_impact_t_wakefield.
Parameters:
-
source((str, Path or ndarray)) –Path to the table, or the table itself as an array of shape (n, 3) or (n, 2).
-
length(float) –Distance covered by the table (m), given as V7 on the -6 element.
-
kind(str, default:'cubic') –Interpolation method. Default is 'cubic'.
Returns:
Examples:
>>> table = TabularWakefield.from_impact_t("fort.41", length=3.55e-4)
Source code in beamphysics/wakefields/tabular.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
from_impact_z
classmethod
from_impact_z(source: str | PathLike | ndarray, kind: str = 'cubic') -> TabularWakefield
Read the longitudinal wake from an IMPACT-Z wake table.
The abscissa s = -z is mirrored into z <= 0, and the transverse columns are
ignored. See beamphysics.interfaces.impact.parse_impact_z_wakefield.
Parameters:
-
source((str, Path or ndarray)) –Path to the table, or the table itself as an array of shape (n, 4), such as an entry of the
file_dataof a lume-impactImpactZInput. -
kind(str, default:'cubic') –Interpolation method. Default is 'cubic'.
Returns:
Examples:
>>> table = TabularWakefield.from_impact_z("rfdata41.in")
Source code in beamphysics/wakefields/tabular.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
from_wakefield
classmethod
from_wakefield(wakefield: WakefieldBase, zmax: float | None = None, n: int | None = None, kind: str = 'cubic') -> TabularWakefield
Resample a wakefield model onto a uniform table.
The wake is evaluated at n equally spaced points from z = -zmax to z = 0.
This makes an expensive model, such as ResistiveWallWakefield, cheap to
evaluate, and gives the uniform table that IMPACT-Z and Bmad read.
Parameters:
-
wakefield(WakefieldBase) –Model to resample.
-
zmax(float, default:None) –Largest distance behind the source particle (m). Defaults to
wakefield.default_zmax. -
n(int, default:None) –Number of samples. Defaults to
wakefield.default_n_samples(zmax). -
kind(str, default:'cubic') –Interpolation method. Default is 'cubic'.
Returns:
-
TabularWakefield–Table covering -zmax <= z <= 0.
Raises:
-
ValueError–If zmax is not positive, if n < 4, or if a
TabularWakefieldsource does not cover -zmax <= z <= 0, which would silently pad the result with zeros. -
NotImplementedError–If zmax or n is omitted and the model defines no default for it.
Examples:
>>> wake = ResistiveWallPseudomode.from_material(
... "copper-slac-pub-10707", radius=2.5e-3
... )
>>> table = TabularWakefield.from_wakefield(wake)
Source code in beamphysics/wakefields/tabular.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
impedance
impedance(k: ndarray | float) -> ndarray | complex
Compute the impedance Z(k) via numerical FFT.
Uses FFT to compute the Fourier transform of the tabular wake data.
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/tabular.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | |
particle_kicks
particle_kicks(z: ndarray, weight: ndarray, include_self_kick: bool = True) -> ndarray
Compute wakefield-induced energy kicks per unit length.
This is a default O(N²) implementation. Subclasses may override with more efficient algorithms.
Parameters:
-
z(ndarray) –Particle positions (m).
-
weight(ndarray) –Particle charges (C).
-
include_self_kick(bool, default:True) –Whether to include the self-kick term. Default is True.
Returns:
-
kicks(ndarray) –Energy kick per unit length at each particle (eV/m).
Source code in beamphysics/wakefields/base.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
plot
plot(zmax: float = None, zmin: float = 0, n: int = 200, ax=None)
Plot the wakefield over a range of z values.
Parameters:
-
zmax(float, default:None) –Maximum trailing distance (m). If None, uses a sensible default.
-
zmin(float, default:0) –Minimum trailing distance (m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
plot_impedance
plot_impedance(kmax: float = None, kmin: float = 0, n: int = 200, ax=None)
Plot the impedance over a range of wavenumbers.
Parameters:
-
kmax(float, default:None) –Maximum wavenumber (1/m). If None, uses a sensible default.
-
kmin(float, default:0) –Minimum wavenumber (1/m). Default is 0.
-
n(int, default:200) –Number of points. Default is 200.
-
ax(Axes, default:None) –Axes to plot on. If None, creates a new figure.
Source code in beamphysics/wakefields/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
to_bmad
to_bmad(file: str | PathLike | None = None, amp_scale: float = 1, z_scale: float = 1, scale_with_length: bool = True) -> str
Format this table as the value of a Bmad sr_wake with a z_long table.
Bmad needs a uniform table that ends at z = 0. Any other table is first resampled at its finest spacing, limited to 10000 rows. Bmad uses the same sign conventions and halves the z = 0 entry itself, so W(0-) is written.
Parameters:
-
file(str or Path, default:None) –If given, also write the value there, for use as
sr_wake = call::<file>. -
amp_scale(float, default:1) –Bmad
amp_scale. Default is 1. -
z_scale(float, default:1) –Bmad
z_scale. Default is 1. -
scale_with_length(bool, default:True) –If True (default), Bmad reads the table in V/C/m and multiplies it by the element length. If False, Bmad reads it in V/C, so multiply a table in V/C/m by the structure length, for example through amp_scale.
Returns:
-
str–
Warns:
-
UserWarning–If the resample would need more than 10000 rows.
Notes
Bmad applies the table by a circular convolution over the table extended symmetrically about z = 0, so the table must be longer than the bunch.
Examples:
>>> table.to_bmad("wake.bmad") # sr_wake = call::wake.bmad
Source code in beamphysics/wakefields/tabular.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
to_impact_t
to_impact_t(file: str | PathLike | None = None, zmax: float | None = None, n: int | None = None, wake_x: Callable[[ndarray], ndarray] | None = None, wake_y: Callable[[ndarray], ndarray] | None = None) -> tuple[ndarray, float]
Build, and optionally write, the IMPACT-T wakefield table for this wake.
See beamphysics.interfaces.impact.create_impact_t_wakefield_data.
Parameters:
-
file(str or Path, default:None) –If given, also write the table there, conventionally as
fort.{Bmpstp}. -
zmax(float | None, default:None) –As for
create_impact_t_wakefield_data. -
n(float | None, default:None) –As for
create_impact_t_wakefield_data. -
wake_x(float | None, default:None) –As for
create_impact_t_wakefield_data. -
wake_y(float | None, default:None) –As for
create_impact_t_wakefield_data.
Returns:
-
data(ndarray) –Array of shape (n, 3) with columns Wz (V/C/m), Wx and Wy (V/C/m^2).
-
length(float) –Distance covered by the table (m), to be given as V7.
Examples:
>>> data, length = table.to_impact_t("fort.41", n=1000)
Source code in beamphysics/wakefields/tabular.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
to_impact_z
to_impact_z(file: str | PathLike | None = None, zmax: float | None = None, n: int | None = None, wake_x: Callable[[ndarray], ndarray] | None = None, wake_y: Callable[[ndarray], ndarray] | None = None) -> ndarray
Build, and optionally write, the IMPACT-Z wakefield table for this wake.
See beamphysics.interfaces.impact.create_impact_z_wakefield_rfdata.
Parameters:
-
file(str or Path, default:None) –If given, also write the table there, conventionally as
rfdata{file_id}.in. -
zmax(float | None, default:None) –As for
create_impact_z_wakefield_rfdata. -
n(float | None, default:None) –As for
create_impact_z_wakefield_rfdata. -
wake_x(float | None, default:None) –As for
create_impact_z_wakefield_rfdata. -
wake_y(float | None, default:None) –As for
create_impact_z_wakefield_rfdata.
Returns:
-
ndarray–Array of shape (n, 4) with columns s (m), Wz (V/C/m), Wx and Wy (V/C/m^2).
Examples:
>>> table.to_impact_z("rfdata41.in")
Source code in beamphysics/wakefields/tabular.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
wake
wake(z: ndarray | float) -> ndarray | float
Evaluate the wakefield at position z using interpolation.
Parameters:
-
z(float or ndarray) –Longitudinal position (m).
Returns:
-
W(float or ndarray) –Interpolated wakefield value (V/C/m). Returns fill_value outside the data range, and 0 for z > 0 (causality).
Source code in beamphysics/wakefields/tabular.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
Pseudomode
dataclass
Pseudomode(A: float, d: float, k: float, phi: float)
Single pseudomode parameters for a damped sinusoidal wakefield component.
Represents one term in the sum: W(z) = A·exp(d·z)·sin(k·z + φ)
Parameters:
-
A(float) –Amplitude coefficient (V/C/m).
-
d(float) –Exponential decay rate (1/m).
-
k(float) –Oscillation wavenumber (1/m).
-
phi(float) –Phase offset (rad).
Methods:
-
__call__–Evaluate this mode at position z (array input assumed).
-
impedance–Compute the impedance Z(k) for this pseudomode analytically.
-
to_bmad–Format this mode as a Bmad short-range wake specification.
__call__
__call__(z: ndarray) -> ndarray
Evaluate this mode at position z (array input assumed).
Source code in beamphysics/wakefields/pseudomode.py
52 53 54 | |
impedance
impedance(k: ndarray | float) -> ndarray | complex
Compute the impedance Z(k) for this pseudomode analytically.
For a pseudomode wakefield defined for z ≤ 0:
The impedance is defined as:
Derivation:
Substituting the wakefield:
Using \(\sin(\theta) = \frac{e^{i\theta} - e^{-i\theta}}{2i}\):
Since \(d > 0\), both integrals converge:
Evaluating:
Mathematica verification:
(* Define the wakefield and compute impedance numerically *)
W[z_, A_, d_, k0_, phi_] := A Exp[d z] Sin[k0 z + phi]
(* Analytical result *)
Zanalytic[k_, A_, d_, k0_, phi_] :=
A/(2 I c) (Exp[I phi]/(d + I (k0 - k)) - Exp[-I phi]/(d - I (k0 + k)))
(* Numerical integration (should match) *)
Znumeric[k_, A_, d_, k0_, phi_] :=
1/c NIntegrate[W[z, A, d, k0, phi] Exp[-I k z], {z, -Infinity, 0}]
(* Test with sample values *)
c = 299792458;
{A, d, k0, phi} = {1*^15, 1*^4, 1*^5, Pi/4};
ktest = 5*^4;
{Zanalytic[ktest, A, d, k0, phi], Znumeric[ktest, A, d, k0, phi]}
(* Both should give the same complex number *)
Parameters:
-
k(float or ndarray) –Wavenumber (1/m).
Returns:
-
Z(complex or ndarray) –Impedance (Ohm/m).
Source code in beamphysics/wakefields/pseudomode.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
to_bmad
to_bmad(type: str = 'longitudinal', transverse_dependence: str = 'none') -> str
Format this mode as a Bmad short-range wake specification.
Parameters:
-
type(str, default:'longitudinal') –Wake type. Default is "longitudinal".
-
transverse_dependence(str, default:'none') –Transverse dependence. Default is "none".
Returns:
-
str–One Bmad mode entry of the form
type = {A, d, k, phi, dependence}.
Notes
Bmad gives the phase in units of 2 pi, so the fourth field is phi / (2 * pi).
Source code in beamphysics/wakefields/pseudomode.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
Tabulation and Interchange
TabularWakefield is the common format for exchanging wakes with tracking codes. TabularWakefield.from_wakefield, or to_tabular on the resistive wall classes, resamples any model onto a uniform table. When zmax or n is omitted, each model supplies default_zmax and default_n_samples.
IMPACT-Z
IMPACT-Z reads a four-column table, rfdata{file_id}.in, through its -41 element. The builder returns an array, so that a driver such as lume-impact can decide where to write it, and the readers accept either a path or an array.
create_impact_z_wakefield_rfdata
create_impact_z_wakefield_rfdata(wakefield: WakefieldBase, zmax: float | None = None, n: int | None = None, wake_x: Callable[[ndarray], ndarray] | None = None, wake_y: Callable[[ndarray], ndarray] | None = None) -> ndarray
Build an IMPACT-Z wakefield table for a wakefield model.
The wake is sampled at n uniform distances s = -z from 0 to zmax. IMPACT-Z uses the same sign convention, so only the abscissa is mirrored.
Parameters:
-
wakefield(WakefieldBase) –Longitudinal wakefield model.
-
zmax(float, default:None) –Largest distance behind the source particle (m). Defaults to
wakefield.default_zmax. -
n(int, default:None) –Number of rows. Defaults to
wakefield.default_n_samples(zmax), limited to 5000. -
wake_x(callable, default:None) –Dipole wakes (V/C/m^2) as functions of z <= 0 (m). Their columns are zero if omitted.
-
wake_y(callable, default:None) –Dipole wakes (V/C/m^2) as functions of z <= 0 (m). Their columns are zero if omitted.
Returns:
-
ndarray–Array of shape (n, 4) with columns s (m), Wz (V/C/m), Wx and Wy (V/C/m^2).
Raises:
-
ValueError–If n exceeds the 5000 rows IMPACT-Z allocates.
-
NotImplementedError–If zmax or n is omitted and the model defines no default for it.
Warns:
-
UserWarning–If the default n exceeds 5000, in which case the wake is under-resolved.
Notes
IMPACT-Z extrapolates linearly beyond the last row, so the table should cover the full bunch length.
Examples:
>>> wake = ResistiveWallPseudomode.from_material(
... "copper-slac-pub-10707", radius=2.5e-3
... )
>>> rfdata = create_impact_z_wakefield_rfdata(wake)
Source code in beamphysics/interfaces/impact.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
parse_impact_z_wakefield
parse_impact_z_wakefield(source: str | PathLike | ndarray) -> dict[str, ndarray]
Parse an IMPACT-Z wakefield table, as read by the -41 element.
The file rfdata{file_id}.in holds the distance s = -z >= 0 behind the source
particle, Wz, Wx and Wy on a uniform grid. The abscissa is shifted to start at
zero, as IMPACT-Z does.
Parameters:
-
source((str, Path or ndarray)) –Path to the table, or the table itself as an array of shape (n, 4).
Returns:
-
dict–Keys 's' (m), 'Wz' (V/C/m), 'Wx' and 'Wy' (V/C/m^2).
Raises:
-
ValueError–If the table does not have four columns and at least two rows on a uniform, increasing grid. IMPACT-Z would silently misread a non-uniform grid.
Source code in beamphysics/interfaces/impact.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
write_impact_z_wakefield
write_impact_z_wakefield(filename: str | PathLike, wakefield: WakefieldBase, zmax: float | None = None, n: int | None = None, wake_x: Callable[[ndarray], ndarray] | None = None, wake_y: Callable[[ndarray], ndarray] | None = None) -> None
Write an IMPACT-Z wakefield table for a wakefield model.
The table is built by create_impact_z_wakefield_rfdata and written with 17
significant digits, so that it reads back exactly.
Parameters:
-
filename(str or Path) –Output path, conventionally
rfdata{file_id}.in. -
wakefield(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
zmax(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
n(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
wake_x(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
wake_y(WakefieldBase) –As for
create_impact_z_wakefield_rfdata.
Source code in beamphysics/interfaces/impact.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | |
IMPACT-T
IMPACT-T reads a three-column table, fort.{Bmpstp}, through its -6 element. The file has no position column, so the builder also returns the length of the table, which is entered as V7.
create_impact_t_wakefield_data
create_impact_t_wakefield_data(wakefield: WakefieldBase, zmax: float | None = None, n: int | None = None, wake_x: Callable[[ndarray], ndarray] | None = None, wake_y: Callable[[ndarray], ndarray] | None = None) -> tuple[ndarray, float]
Build an IMPACT-T wakefield table for a wakefield model.
The wake is sampled as for create_impact_z_wakefield_rfdata. IMPACT-T has no
position column and takes the row spacing as V7 / (n - 1), so the covered length
is returned for use as V7.
Parameters:
-
wakefield(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
zmax(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
wake_x(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
wake_y(WakefieldBase) –As for
create_impact_z_wakefield_rfdata. -
n(int, default:None) –Number of rows. Defaults to
wakefield.default_n_samples(zmax), limited to 1000.
Returns:
-
data(ndarray) –Array of shape (n, 3) with columns Wz (V/C/m), Wx and Wy (V/C/m^2).
-
length(float) –Distance covered by the table (m), to be given as V7.
Raises:
-
ValueError–If n exceeds the 1000 rows IMPACT-T reads.
-
NotImplementedError–If zmax or n is omitted and the model defines no default for it.
Warns:
-
UserWarning–If the default n exceeds 1000, in which case the wake is under-resolved.
Notes
The -6 element reads the table when Bnseg > 0 and V6 <= 0. The three-column format requires IMPACT-T 3.0 or later.
Examples:
>>> data, length = create_impact_t_wakefield_data(wake, n=1000)
Source code in beamphysics/interfaces/impact.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
parse_impact_t_wakefield
parse_impact_t_wakefield(source: str | PathLike | ndarray, length: float) -> dict[str, ndarray]
Parse an IMPACT-T wakefield table, as read by the -6 element.
The file fort.{Bmpstp} holds Wz, Wx and Wy with no position column. Its rows
are equally spaced in s = -z from 0 to length.
Parameters:
-
source((str, Path or ndarray)) –Path to the table, or the table itself as an array of shape (n, 3). The two-column tables of IMPACT-T before 3.0, with one transverse column for both planes, are also accepted.
-
length(float) –Distance covered by the table (m), given as V7 on the -6 element.
Returns:
-
dict–Keys 's' (m), 'Wz' (V/C/m), 'Wx' and 'Wy' (V/C/m^2).
Raises:
-
ValueError–If length is not positive, or if the table does not have two or three columns and between 2 and 1000 rows.
Source code in beamphysics/interfaces/impact.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
write_impact_t_wakefield
write_impact_t_wakefield(filename: str | PathLike, wakefield: WakefieldBase, zmax: float | None = None, n: int | None = None, wake_x: Callable[[ndarray], ndarray] | None = None, wake_y: Callable[[ndarray], ndarray] | None = None) -> float
Write an IMPACT-T wakefield table for a wakefield model.
The table is built by create_impact_t_wakefield_data and written with 17
significant digits.
Parameters:
-
filename(str or Path) –Output path, conventionally
fort.{Bmpstp}. -
wakefield(WakefieldBase) –As for
create_impact_t_wakefield_data. -
zmax(WakefieldBase) –As for
create_impact_t_wakefield_data. -
n(WakefieldBase) –As for
create_impact_t_wakefield_data. -
wake_x(WakefieldBase) –As for
create_impact_t_wakefield_data. -
wake_y(WakefieldBase) –As for
create_impact_t_wakefield_data.
Returns:
-
float–Distance covered by the table (m), to be given as V7.
Source code in beamphysics/interfaces/impact.py
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | |
Bmad
TabularWakefield.to_bmad formats a table as the value of a Bmad sr_wake, and TabularWakefield.from_bmad reads back the table that pytao returns for tao.ele_wake(ele_id, who="sr_z_long_table"). The table must be longer than the bunch, because Bmad applies it by a circular convolution.
Low-level Functions
longitudinal_impedance_round
longitudinal_impedance_round(k: float | ndarray, a: float, sigma0: float, ctau: float) -> complex | ndarray
Compute longitudinal impedance Z(k) for round (circular pipe) geometry.
Uses closed-form expression (SLAC-PUB-10707 Eq. 2).
Parameters:
-
k(float or ndarray) –Longitudinal wave number (1/m)
-
a(float) –Pipe radius (m)
-
sigma0(float) –DC conductivity (S/m)
-
ctau(float) –Relaxation distance c·τ (m)
Returns:
-
Zk(complex or np.ndarray of complex) –Longitudinal impedance (Ohm/m)
Source code in beamphysics/wakefields/resistive_wall/base.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
longitudinal_impedance_flat
longitudinal_impedance_flat(k: float | ndarray, a: float, sigma0: float, ctau: float) -> complex | ndarray
Compute longitudinal impedance Z(k) for flat (parallel plate) geometry.
Uses numerical integration over the transverse wavenumber (SLAC-PUB-10707 Eq. 13, after Henke and Napoly).
Parameters:
-
k(float or ndarray) –Longitudinal wave number (1/m)
-
a(float) –Half-gap height between parallel plates (m)
-
sigma0(float) –DC conductivity (S/m)
-
ctau(float) –Relaxation distance c·τ (m)
Returns:
-
Zk(complex or np.ndarray of complex) –Longitudinal impedance (Ohm/m)
Source code in beamphysics/wakefields/resistive_wall/base.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
wakefield_from_impedance
wakefield_from_impedance(z: float | ndarray, Zk_func: callable, k_max: float = 10000000.0, epsabs: float = 1e-09, epsrel: float = 1e-06) -> float | ndarray
Compute wakefield W(z) from Re[Z(k)] using a cosine transform (quadrature).
For z ≤ 0 (trailing particles):
Returns 0 for z > 0 (causality).
Parameters:
-
z(float or ndarray) –Longitudinal position (m). Negative z is behind the source.
-
Zk_func(callable) –Function returning complex impedance Z(k) (Ohm/m)
-
k_max(float, default:10000000.0) –Upper limit of k integration (1/m). Default is 1e7.
-
epsabs(float, default:1e-09) –Absolute tolerance. Default is 1e-9.
-
epsrel(float, default:1e-06) –Relative tolerance. Default is 1e-6.
Returns:
-
Wz(float or ndarray) –Wakefield (V/C/m)
Source code in beamphysics/wakefields/resistive_wall/base.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
wakefield_from_impedance_fft
wakefield_from_impedance_fft(z: ndarray, Zk_func: callable, k_max: float = 10000000.0, n_fft: int = 8192) -> ndarray
Compute wakefield W(z) from Z(k) using FFT and interpolation.
Much faster than wakefield_from_impedance for arrays.
Parameters:
-
z(ndarray) –Longitudinal positions (m). Negative z is behind the source.
-
Zk_func(callable) –Function returning complex impedance Z(k) (Ohm/m)
-
k_max(float, default:10000000.0) –Upper limit of k integration (1/m). Default is 1e7.
-
n_fft(int, default:8192) –Number of FFT points. Default is 8192.
Returns:
-
Wz(ndarray) –Wakefield (V/C/m)
Source code in beamphysics/wakefields/resistive_wall/base.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
ac_conductivity
ac_conductivity(k: float | ndarray, sigma0: float, ctau: float) -> complex | ndarray
Frequency-dependent AC conductivity with relaxation time (Drude model).
Parameters:
-
k(float or ndarray) –Longitudinal wave number (1/m)
-
sigma0(float) –DC conductivity (S/m)
-
ctau(float) –Relaxation distance c·τ (m)
Returns:
-
sigma(complex or np.ndarray of complex) –AC conductivity (S/m)
Source code in beamphysics/wakefields/resistive_wall/base.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
surface_impedance
surface_impedance(k: float | ndarray, sigma0: float, ctau: float) -> complex | ndarray
Surface impedance for a conducting wall with AC conductivity.
Parameters:
-
k(float or ndarray) –Longitudinal wave number (1/m)
-
sigma0(float) –DC conductivity (S/m)
-
ctau(float) –Relaxation distance c·τ (m)
Returns:
-
zeta(complex or np.ndarray of complex) –Surface impedance (dimensionless)
Source code in beamphysics/wakefields/resistive_wall/base.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
characteristic_length
characteristic_length(a: float, sigma0: float) -> float
Characteristic length scale s₀ for resistive wall wakefield.
From SLAC-PUB-10707 Eq. (5):
Parameters:
-
a(float) –Half-gap height (flat) or radius (round) (m)
-
sigma0(float) –DC conductivity (S/m)
Returns:
-
s0(float) –Characteristic length (m)
Source code in beamphysics/wakefields/resistive_wall/base.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |