Open
Description
For the three-dimensional case, when adding an external electric field, I want to add it on the line in the x-direction where yz=0 (i.e., the boundary). According to the documentation, I used upper and lower to limit the region of application. However, I found that it didn't work (I tried both AnalyticInitialField
and AnalyticAppliedField
), and the value of the external electric field was still added to the entire simulation area. My code is as follows:
from pywarpx import callbacks, fields, libwarpx, picmi
import numpy as np
# Define simulation domain
nx, ny, nz = 256, 256, 256
Lx, Ly, Lz = 0.04188, 0.04188, 0.04188 # domain size in mete
# Define the simulation grid
grid = picmi.Cartesian3DGrid(
number_of_cells=[nx, ny, nz],
lower_bound=[0, 0, 0],
upper_bound=[Lx, Ly, Lz],
lower_boundary_conditions=['periodic', 'periodic', 'periodic'],
upper_boundary_conditions=['periodic', 'periodic', 'periodic']
)
# Electromagnetic solver
solver = picmi.ElectromagneticSolver(
grid=grid,
cfl=1.0
)
# Plasma parameters
density = 7.9e18 # in m^-3
temperature = 0 # in Kelvin
# Define electron species
electrons = picmi.Species(
particle_type='electron',
name='electrons',
initial_distribution=picmi.UniformDistribution(
density=density,
upper_bound=[None, None, None],
directed_velocity=[0., 0., 0.]
)
)
# Initialize the simulation
sim = picmi.Simulation(
solver=solver,
max_steps=6000,
verbose=1,
particle_shape=3,
warpx_current_deposition_algo='esirkepov',
)
# Add species to the simulation
sim.add_species(electrons, layout=picmi.GriddedLayout(grid=grid, n_macroparticle_per_cell=[1, 1, 1]))
# Define and add the external electric field
external_Efield = picmi.AnalyticInitialField(
Ex_expression="10.0", ##Ex_expression= 10.0*cos(4000*t)
Ey_expression="0.0",
Ez_expression="0.0",
lower_bound=[0.0, 0.0, 0.0],
upper_bound=[Lx, 0.0, 0.0]
)
sim.add_applied_field(external_Efield) # Correct method to add applied fields
sim.step()
Where did I go wrong? Are there any other methods to add an external electromagnetic field at a fixed plane or fixed point?