-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zigzag structure of gamma-z phase space #1182
Comments
Sorry, because I'm not familiar with GitHub, I submitted two useless issues before, and I don't know if I can delete them. |
Here is the post-processing code in Jupyter Notebook. import h5py
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import c,e
step = 500
with h5py.File('./diags/hollow/openpmd_%06d.h5'%step, 'r') as f:
# display_h5_struct(f)
plt.figure(figsize=(11,5))
plt.subplot(121)
plasma = f['/data/%d/meshes/rho_plasma'%step][:]
plt.imshow(plasma[:,:,plasma.shape[2]//2].T, extent=[-400,400,-600,600], aspect='auto')
plt.xlabel('z (um)')
plt.ylabel('x (um)')
# plt.colorbar()
plt.sca(plt.gca().twinx())
Ez = f['/data/%d/meshes/Ez'%step][:]
Ex = (f['/data/%d/meshes/ExmBy'%step][:] + f['/data/%d/meshes/By'%step][:])[100,Ez.shape[1]//2,:]
Ez = Ez[:,Ez.shape[1]//2, Ez.shape[2]//2]
plt.plot(np.linspace(-400,400,len(Ex)), Ez/1e9, linewidth=1.0)
plt.ylabel('E (GV/m)')
plt.subplot(122)
z = f['/data/%d/particles/beam/position/z'%step][:]
x = f['/data/%d/particles/beam/position/x'%step][:]
px = f['/data/%d/particles/beam/momentum/x'%step][:]/c
gamma = np.sqrt(f['/data/%d/particles/beam/momentum/z'%step][:]**2 \
+ f['/data/%d/particles/beam/momentum/x'%step][:]**2 \
+ f['/data/%d/particles/beam/momentum/y'%step][:]**2)/c
weighting = f['/data/%d/particles/beam/weighting'%step][:]
hist,edges = np.histogram(z, bins=200)
plt.plot((edges[:-1]+edges[1:])/2*1e6, hist*weighting[0]*e/(edges[1]-edges[0])*c, linewidth=1.0, label='current')
plt.ylabel('current (A)')
plt.xlabel('z (um)')
plt.sca(plt.gca().twinx())
nslice = 400
sort_idx = np.argsort(z)[:(z.shape[0]//nslice)*nslice]
z, x, px, gamma = z[sort_idx].reshape(-1,nslice), x[sort_idx].reshape(-1,nslice), \
px[sort_idx].reshape(-1,nslice), \
gamma[sort_idx].reshape(-1,nslice)
plt.plot(np.mean(z, axis=1)*1e6, np.mean(gamma, axis=1), linewidth=1.0, color='red', label='gamma')
# plt.plot(np.mean(z, axis=1)*1e6, np.sqrt(np.mean(x**2, axis=1)*np.mean(px**2, axis=1)-np.mean(x*px, axis=1)**2)*1e6, linewidth=1.0, label='x')
# plt.ylim(0, 2.0)
cent:slice = slice(120,-120)
print("beta", np.mean(x[cent]*x[cent])/(1e-6/np.mean(gamma[cent])))
print("alpha", -np.mean(x[cent]*px[cent]/(1e-6)))
plt.legend()
plt.tight_layout()
plt.show() |
Hi @mulingLHY, |
Thanks for answering @MaxThevenet ,It indeed resolved my doubts.
|
Sounds good. |
@MaxThevenet Sorry for bothering again. Recently, after applying R56 to the beam from HiPACE++, I found that these little steps lead to micro-bunching in the beam. Lines 70 to 75 in 0ab9f68
Simply adding linear interpolation for Ez during the field gather can smooth the output gamma-z phase space, but I am not sure if there are issues with physical self-consistency.
|
Dear @mulingLHY, |
Thanks @MaxThevenet, Regarding the acquisition of fields data from previous cell, by examining the source code, I discovered that the fields can be 'shifted' to |
Great to see that you're looking into the code! |
After simulating with hollow plasma, I observed a zigzag structure in the gamma-z phase space. I suspect this might be due to the internal push of particles without proper interpolation of Ez? Or should I enable any additional options to address this issue?
Here are the simulation parameters:
Could anyone provide insights into this issue or confirm if the lack of Ez interpolation could be the cause?
Thank you!
The text was updated successfully, but these errors were encountered: