Skip to content

Instantly share code, notes, and snippets.

@psalz
Last active February 5, 2024 14:20
Show Gist options
  • Save psalz/54163958d8ea258ad1dad57da9f5c142 to your computer and use it in GitHub Desktop.
Save psalz/54163958d8ea258ad1dad57da9f5c142 to your computer and use it in GitHub Desktop.
Smilei exchangeB ghost cells confusion
import math as m
import numpy as np
TkeV = 10
T = TkeV/511
dx = 0.5
dy = dx
Lx = 16
Ly = 4
dt = 0.75 * dx/m.sqrt(2.)
Tsim = 40 * dt
Main(
geometry = "2Dcartesian",
interpolation_order = 2,
timestep = dt,
simulation_time = Tsim,
cell_length = [dx,dy],
grid_length = [Lx,Ly],
number_of_patches = [4,1],
EM_boundary_conditions = [ ["periodic"], ["periodic"] ],
print_every = 1,
solve_poisson = True,
patch_arrangement = "linearized_XY",
)
strength = 10
size = 0.03
def whirl_x(x, y):
# translate to center
x -= Lx / 2
y -= Ly / 2
len = np.sqrt(x**2 + y**2)
taper = np.fmin(1.0, size * Ly / len if len > 0 else 1.0)
return strength * taper * -y / len
def whirl_y(x, y):
# translate to center
x -= Lx / 2
y -= Ly / 2
len = np.sqrt(x**2 + y**2)
taper = np.fmin(1.0, size * Lx / len if len > 0 else 1.0)
return strength * taper * x / len
ExternalField(
field = "Ex",
profile = whirl_x
)
ExternalField(
field = "Ey",
profile = whirl_y
)
Species(
name = "electron",
position_initialization = "regular",
momentum_initialization = "mj",
particles_per_cell = 9,
c_part_max = 1.0,
mass = 1.0,
charge = -1.0,
charge_density = 1.0,
mean_velocity = [0.0, 0.0, 0.0],
temperature = [T],
pusher = "boris",
boundary_conditions = [["periodic"], ["periodic"]],
)
DiagFields(
every = 2
)
DiagScalar(
every = 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment