Warwick-Plasma / epoch

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

Asymmetric E-fields from a symmetric electron beam #87

Open keithbennett opened 3 years ago

keithbennett commented 3 years ago

In GitLab by Aravinda Perera on 11 Sep 2020, 03:36 (GitLab issue GL#2247)

Summary

I'm looking at the polar field components of a cylindrically symmetric electron beam in EPOCH3D (gaussian with equal width in y & z, gaussian in x, and propagating along its central axis in x. There is an unphysical azimuthal E field component of ~1-10% of other components. Is there a way to remove or reduce this?

Steps to reproduce

input.deck

Python snippet to get azimuthal field from cartesian outputs:

# Assuming that Ey[:, :, :] and Ez[:, :, :] are 3D arrays from output

# Extract a slice from inside beam
Ey2D = Ey[:, :, 300]
Ez2D = Ez[:, :, 300]

# Generate Y and Z coordinate grids
ycen, zcen =  0.0,0.0   # beam center
yhw, zhw = 1.0, 1.0
y = np.linspace(-yhw - ycen, yhw - ycen, np.shape(Ey2D)[1])
z = np.linspace(-zhw - zcen, zhw - zcen, np.shape(Ez2D)[0])
Y, Z = np.meshgrid(y, z)

# Find cos and sin
cos = Y/np.sqrt(Z**2 + Y**2)
sin = Z/np.sqrt(Z**2 + Y**2)

# Gives polar field components
Ephi = Ez2D*cos - Ey2D*sin
Er = Ey2D*cos + Ez2D*sin

EPOCH version: 4.17.7 with -DPARTICLE_ID4

I use use_current_correction = T (but also present for F)

What is the current bug behavior?

Even though the Ex field and Er = Ey cos(phi) + Ez sin(phi) field seem azimuthally symmetric, there is an unphysical Ephi = Ey sin(phi) - Ez cos(phi) field with max. amplitude Ex/Ephi ~ 10-100

The following changes also don't seem to affect the problem:

Unfortunately the simulations I want to do are quite sensitive to Ephi and amplify it in an unstable way, so this causes a problem. Could it be due to a cartesian grid-induced effect?

What is the expected correct behavior?

Ephi << Ex, Er if at all.

Relevant logs and/or screenshots

y-z plane slices through the bulk of the beam

image

The unphysical Ephi field follows the center of the beam, mostly unchanged if I offset it in the window: image

But changes shape somewhat if I use unequal resolution in y and z: image Left: equal grid resolution. Right: 2:1 resolution.

keithbennett commented 3 years ago

In GitLab by Thomas Goffrey (@TomGoffrey) on 01 Oct 2020, 13:18

Does the situation improve if you take into account the grid staggering?

The lines:

Ephi = Ez2D*cos - Ey2D*sin
Er = Ey2D*cos + Ez2D*sin

aren't necessarily sensible as Ey, Ez are not defined at the same points in space.

You could attempt to account for this by averaging components to the cell centre before doing the transform. You should also check that you are using the correct grid for the transform. It might be safer to use the grid variables in the SDF file.

That all being said, it could just be a result of trying to simulate a cylindrical set-up in a Cartesian domain. We do plan on adding a cylindrical version of EPOCH, but the approximate time scale is ~1 year.