Calculating the radiation spectrum of relativistic particles using the Lienard-Wiechert potential.
Project description
安装方法
克隆仓库
git clone https://github.com/xsgeng/lwrad.git
然后用户安装
cd lwrad
# editable install
pip install --user -e .
直接安装
pip install --user git+https://github.com/xsgeng/lwrad.git
用法
CLI
# help
python -m lwrad --help
# smilei TrackParticles
python -m lwrad \
--smilei \
--ek-max 1.0 \
--nek 128 \
--theta-max 0.5 \
--ntheta 128 \
--direction x \
--theta-plane xy \
--savefig \
smilei/result/path \
species_name
# EPOCH
# TODO
CUDA加速
python -m lwrad --backend cuda [OPTIONS] PATH NAME
MPI
# multithreaded MPI
srun -n 2 -c 32 -u python -m lwrad [OPTIONS] PATH NAME
# 1 thread per MPI
srun -n 64 -u python -m lwrad --backend None [OPTIONS] PATH NAME
script
这里以Smilei输出的轨迹为例
import h5py
um = 1e-6
fs = 1e-15
l0 = 0.8*um
omega0 = 2*pi*c / l0
# 读取h5文件中的第0条轨迹
with h5py.File("tests/test.h5", "r") as f:
# 坐标xyz和时间t换算为国际单位
x = f['x'][:, 0] / 2/pi * l0
y = f['y'][:, 0] / 2/pi * l0
z = f['z'][:, 0] / 2/pi * l0
ux = f['px'][:, 0]
uy = f['py'][:, 0]
uz = f['pz'][:, 0]
t = np.arange(len(ux)) * f.attrs['dt'] / 2/pi * l0/c
直接计算辐射谱
from lwrad import get_lw_spectrum
# 用于确定角度范围
gamma0 = 5.0
theta_max = pi/2/gamma0
omega_max = 4*gamma0**2 * omega0 * 3
ntheta = 256
nomega = 256
theta_axis = np.linspace(-theta_max, theta_max, ntheta)
omega_axis = np.linspace(0, omega_max, nomega)
I = np.zeros((ntheta, nomega))
for itheta, theta in enumerate(theta_axis):
# 方向矢量
n = [np.cos(theta), 0, np.sin(theta)]
I[itheta, :] = get_lw_spectrum(x, y, z, ux, uy, uz, t, n, omega_axis)
作图
fig, ax = plt.subplots(
1, 1,
tight_layout = True,
figsize=(5, 4),
)
h = ax.pcolormesh(
omega_axis/(4*gamma0**2*omega0), theta_axis,
I,
cmap='jet',
shading='gouraud',
)
fig.colorbar(h, ax=ax)
axr = ax.twinx()
axr.plot(
omega_axis/(4*gamma0**2*omega0),
I.sum(axis=0),
color='w',
)
axr.set_yticks([])
ax.set_xlabel(r'$\omega/4\gamma_0^2\omega_0$')
ax.set_ylabel(r'$\theta$')
ax.set_title(rf'$a_0$={a0},$\gamma_0$={gamma0}')
结果对比Richard (2012) Figure 2.7(a)
参考文献
Richard (2012) (DOI: 10.5281/zenodo.843510) (2.32)、(2.36)、(2.39)式
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lwrad-0.5.3.tar.gz
(48.4 kB
view details)
Built Distribution
lwrad-0.5.3-py3-none-any.whl
(35.4 kB
view details)
File details
Details for the file lwrad-0.5.3.tar.gz
.
File metadata
- Download URL: lwrad-0.5.3.tar.gz
- Upload date:
- Size: 48.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b2f64f98de3f84568f01a5e9bcad57ab10a91f16039d5d5e64b02b03afbc624 |
|
MD5 | 16acb89da9742e7c33ec76b5c8cc47e8 |
|
BLAKE2b-256 | ecb24848a48165bf13ff29562560e8bfe91cfc8565b60eb10ccc89988247cc1c |
File details
Details for the file lwrad-0.5.3-py3-none-any.whl
.
File metadata
- Download URL: lwrad-0.5.3-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca5350b63af5de81a0e4ccd6c69da78322710d2df8f4a24c8eb1aec787fd1c2 |
|
MD5 | f495cfe2e38a6aaf189ba0581179127b |
|
BLAKE2b-256 | 5cf10276ee959845ef2a7a8da3b83602293153441b4281ed69ade01daf008e87 |