Open jinze-liu opened 4 months ago
WarpX does not currently support the lower_bound
and upper_bound
options. However, you can get the same affect by adding the limits to the expression.
Ex_expression="10.0*(y==0)*(z==0)"
Thank you very much! So, if I want to add a time-varying external electromagnetic field in a specific region (AnalyticAppliedField
), following your example, can I use Ex_expression="10.0*cos(ωt)*(y==0)*(z==0)
?
Yes, that would work, though it would be Ex_expression="10.0*cos(w*t)*(y==0)*(z==0)
and you wold have to define w
.
Thank you again! Your answer saved me a lot of time! Can we consider modifying the lower_bound
and upper_bound
in the Applied fields section of the Parameters: Python (PICMI) documentation? I initially thought this was feasible while reading it, but currently, it appears that these two are not supported.
Great, glad this could be solved.
For action items we need to address for WarpX' PICMI implementation:
if(..., ..., if( .., ..., ...))
(six if
: per direction and up/lo) for the lower and upper bound to support the PICMI feature in AnalyticInitialField
and AnalyticAppliedField
without changing any backend - or we could change the C++ backend implementation, of course@ax3l Hi!
Using the same simulation area and parameters, settingEx_expression="10.0*cos(4000*t)*(y==0)*(z==0)"
will result in all diagnosed data being zero. When using an if-statement you suggested, such as Ex_expression="10*cos(4000*t)* if (y == 0 and z == 0) else 0"
, a syntax error is shown. This might be due to my misunderstanding of how to use conditional statements. Could you explain the usage of conditional statements in more detail?
My simulation space length in the xyz directions is 0.000134, so when I try using Ex_expression="10.0*cos(4000*t)*(y<1e-4)*(z<1e-4)"
, the diagnosed data is not zero. Is this behavior due to numerical errors, meaning that strict conditions like y=0
and z=0
are not achievable?
Thanks!
The conditional expression would be if (y==0 and z==0, 10*cos(4000*t), 0.)
. Though this should give the same result as what I suggested. In your grid setup, are there grid cells that lie at exactly y and z equal to zero?
My grid points do start from (0, 0, 0)
, my grid is set to
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'])
Therefore, I'm puzzled why setting y==0
and z==0
results in all data being 0.
I had a chance to look at this again. I gave the wrong advice above. The expressions in AnalyticInitialField
don't allow for time dependence, only spatial dependence. With the electromagnetic solver, the fields are only applied to the grid during initialization, which is at t=0
.
@dpgrote Hi!In fact, if I want to define a time-dependent condition, I use the AnalyticAppliedField
, which should work. The main issue is still with the boundary conditions that were not correctly recognized and were silently ignored.
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
andAnalyticAppliedField
), and the value of the external electric field was still added to the entire simulation area. My code is as follows:Where did I go wrong? Are there any other methods to add an external electromagnetic field at a fixed plane or fixed point?