fbpic / fbpic

Spectral, quasi-3D Particle-In-Cell code, for CPU and GPU
http://fbpic.github.io
Other
175 stars 71 forks source link

range of values for `ParticleChargeDensityDiagnostic` #496

Closed berceanu closed 3 years ago

berceanu commented 4 years ago
  1. Why does rho_electrons contain positive values? According to the docs, it is the

charge density of the specified species

i.e. the density of the plasma electrons in this case.

  1. Looking at the HDF5 file, it is measured in C/m^3, so shouldn't I get 1 if I divide it by (-q_e * n_e)? Instead, I get rho_electrons.min() / (-q_e * n_e) = 0.08681711041436878

Relevant code bits:

n_e=8.0e18 * 1.0e6,  # Density (electrons.meters^-3)
p_rmax=25.0e-6
[...]
plasma_elec = sim.add_new_species(
    q=-q_e,
    m=m_e,
    n=n_e,
    dens_func=dens_func,
    p_zmin=p_zmin,
    p_zmax=p_zmax,
    p_rmax=p_rmax,
    p_nz=p_nz,
    p_nr=p_nr,
    p_nt=p_nt,
    )
plasma_ions = sim.add_new_species(
    q=q_e,
    m=m_p,
    n=n_e,
    dens_func=dens_func,
    p_zmin=p_zmin,
    p_zmax=p_zmax,
    p_rmax=p_rmax,
    p_nz=p_nz,
    p_nr=p_nr,
    p_nt=p_nt,
)
[...]
sim.diags = [
    [...]
    ParticleChargeDensityDiagnostic(
        period=diag_period,
        sim=sim,
        species={"electrons": plasma_elec},
    ),
]
rho_electrons, info = ts.get_field(
    field="rho_electrons",
    iteration=382,
    plot=True,
)

rho_electrons

berceanu commented 4 years ago

I see the same issue in the LWFA + ionization example.

rho_electrons

For comparison, here is the full rho field:

rho

RemiLehe commented 3 years ago

Thanks for reporting this issue.

Regarding 1. (positive value): this is in fact somewhat expected. The reason is that the charge density that is written to the file is smoothed by default (so that it looks a bit less noisy). Because of the specific way in which it is smoothed (spectral filter in the Fourier-Bessel space), this can result to slightly positive value, especially near sharp gradients. (e.g. in your case, the positive values seem to appear near the sharp radial edges of the plasma)

Regarding 2. (values that do not match the expected physical values): this is unexpected. Are you maybe running boosted-frame simulation in this case? Would you be willing to share an input script that reproduces this issue?

berceanu commented 3 years ago

Hi Remi, thanks for your reply!

Regarding 2. (values that do not match the expected physical values): this is unexpected. Are you maybe running boosted-frame simulation in this case? Would you be willing to share an input script that reproduces this issue?

Well, I see that for the ionization example script there doesn't seem to be an issue.

The density of elec electrons (species "electrons") is n_e = 7.e24.

rho, rho_info = ts.get_field(
    field="rho_electrons",
    iteration=200,
    plot=True,
)
print(rho.min())  # -1193713.527295697
# close to 1, as expected
print(rho.min() / (-q_e * n_e))  # 1.064367696329484

rho_electrons