Warwick-Plasma / epoch

Particle-in-cell code for plasma physics simulations
https://epochpic.github.io
GNU General Public License v3.0
184 stars 58 forks source link

Probe problems in 2D simulations #691

Closed dorneremerald closed 3 months ago

dorneremerald commented 3 months ago

Dear all! I am using 2D EPOCH simulation to simulate a Laserpulse impact with Plasma. To track the accelerated particle passing through a boundary or arbitrary plane I wanted to use the probe blocks. I tried to achieve this, but in the output files no variable for this exists. The compiler flag in the makefile is set correctly i.e.

DEFINES += $(D)NO_PARTICLE_PROBES

Then I tried running a provided example deck (ramp.deck) in which a probing plane is defined, to see if the unaltered ramp deck gives a probe output. Although this should definitively give me an output for the probe it did not for me. I am using Python to read in the sdf files

import sdf

Open the .sdf file

file_path = '/home/yourpath/0001.sdf' data = sdf.read(file_path)

Print available data keys

print("Available keys in the file:") print(data.dict.keys())

According to this command which shows all keys I do not have the probe variable. Can somebody confirm that?

Available keys in the file: dict_keys(['Header', 'Run_info', 'Wall_time', 'Electric_Field_Ex', 'Electric_Field_Ey', 'Electric_Field_Ez', 'Magnetic_Field_Bx', 'Magnetic_Field_By', 'Magnetic_Field_Bz', 'Current_Jx', 'Current_Jy', 'Current_Jz', 'Particles_Weight_electron', 'Particles_Weight_proton', 'Particles_Px_electron', 'Particles_Px_proton', 'Grid_Particles_electron', 'Grid_Particles_proton', 'Derived_Average_Particle_Energy', 'Derived_Average_Particle_Energy_electron', 'Derived_Average_Particle_Energy_proton', 'Derived_Charge_Density', 'Derived_Number_Density', 'Derived_Number_Density_electron', 'Derived_Number_Density_proton', 'Grid_Grid', 'Grid_Grid_mid', 'Grid_en_electron', 'Grid_en_electron_mid', 'dist_fn_en_electron', 'Grid_x_energy_electron', 'Grid_x_energy_electron_mid', 'dist_fn_x_energy_electron', 'Grid_x_px_electron', 'Grid_x_px_electron_mid', 'dist_fn_x_px_electron', 'Grid_CPUs_Original_rank', 'Grid_CPUs_Original_rank_mid', 'CPUs_Original_rank', 'Grid_CPU_split_electron', 'Grid_CPU_split_electron_mid', 'CPU_split_electron', 'Grid_CPU_split_proton', 'Grid_CPU_split_proton_mid', 'CPU_split_proton', 'CPUs_Current_rank'])

I am wondering where the problem originates. Is the input deck the problem, the compiler flag, my way of reading the sdf file data or the feature of probing in 2D broken? Thanks in advance R Dorner

Status-Mirror commented 3 months ago

Hi R. Dorner,

EPOCH particle probes are only written to SDF files if a probe is triggered since the previous SDF dump. If 0000.sdf is printed at $t_0$, and 0001.sdf is at $t_1$, then 0001.sdf will only show a particle probe variable if particles pass it between $t_0$ and $t_1$.

A better example might be to try an input deck like this:

begin:control
    nx = 500
    ny = 500
    t_end = 70.0e-15
    x_min = 0
    x_max = 20e-6
    y_min = -10e-6
    y_max = 10e-6
    stdout_frequency = 100
end:control

begin:boundaries
    bc_x_min = open
    bc_x_max = open
    bc_y_min = open
    bc_y_max = open
end:boundaries

begin:species
    name = Electron
    mass = 1.0
    charge = -1.0
    npart = 100
    density = if ((x lt 1.0e-6) and (abs(y) lt 1.0e-6 ), 1.0e20, 0)
    drift_x = 5e-19
end:species

begin:output
    dt_snapshot = t_end
    particle_probes = always
end:output

begin:probe
   name = Electron_probe
   point = (10.0e-6, 0)
   normal = (1.0, 0.0)
   include_species : Electron
   dumpmask = always
end:probe

This is a modified version of our momentum-loading demo, where I have replaced the particle species with a near-1GeV electron bunch travelling from x_min to x_max. I have also included a particle probe at $x=10\mu m$. I've plotted a histogram for the probe macro-particles:

probe_hits

Hope this helps, Stuart