Skip to content

Commit 0b10fca

Browse files
oshapovalRemiLehepre-commit-ci[bot]
authored
Reduce particle shape when a particle approaches the EB (#5209)
**Description edited by @RemiLehe** # Overview This PR reduces the particle shape to order 1, when the particle gets closer to the embedded boundary: <img width="991" alt="Screenshot 2025-01-23 at 8 46 34 AM" src="https://github.com/user-attachments/assets/2e206606-110e-4018-aedc-385567fe43e7" /> This ensures that the particle does not deposit charge in valid cells, at the time when it is removed, which in turn ensures proper charge conservation with the electromagnetic solver. # Implementation - This PR allocates and initializes a new mask `eb_reduce_particle_shape` (and `iMultiFab`) that indicates in which cells to reduce the particle shape. - The deposition kernels have been modified to use this flag. In order to make sure that this PR does not affect the performance of the deposition kernel in the absence of EB, two versions of the deposition kernel are compiled. # Tests This PR adds tests similar to the ones introduced in #5562 to check for charge conservation near the embedded boundary, but with higher-order shape factors: - The 2D tests fail on `development` for shape 2 and 3 but pass on this PR. - For some reason, the 3D and RZ tests only fail on `development` for shape 3 ; they do pass for this PR. It is not clear why the tests do not fail on `development` with shape 2. **Note:** For now, this PR only modifies the current deposition (and only the Esirkepov kernel). A follow-up PR will also modify the charge deposition. --------- Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 355d7be commit 0b10fca

File tree

30 files changed

+799
-31
lines changed

30 files changed

+799
-31
lines changed

Examples/Tests/embedded_boundary_em_particle_absorption/CMakeLists.txt

+71
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ if(WarpX_EB)
1313
)
1414
endif()
1515

16+
if(WarpX_EB)
17+
add_warpx_test(
18+
test_3d_embedded_boundary_em_particle_absorption_sh_factor_2 # name
19+
3 # dims
20+
1 # nprocs
21+
inputs_test_3d_embedded_boundary_em_particle_absorption_sh_factor_2 # inputs
22+
"analysis.py" # analysis
23+
"analysis_default_regression.py --path diags/diag1" # checksum
24+
OFF # dependency
25+
)
26+
endif()
27+
28+
if(WarpX_EB)
29+
add_warpx_test(
30+
test_3d_embedded_boundary_em_particle_absorption_sh_factor_3 # name
31+
3 # dims
32+
1 # nprocs
33+
inputs_test_3d_embedded_boundary_em_particle_absorption_sh_factor_3 # inputs
34+
"analysis.py" # analysis
35+
"analysis_default_regression.py --path diags/diag1" # checksum
36+
OFF # dependency
37+
)
38+
endif()
1639

1740
if(WarpX_EB)
1841
add_warpx_test(
@@ -26,6 +49,30 @@ if(WarpX_EB)
2649
)
2750
endif()
2851

52+
if(WarpX_EB)
53+
add_warpx_test(
54+
test_2d_embedded_boundary_em_particle_absorption_sh_factor_2 # name
55+
2 # dims
56+
1 # nprocs
57+
inputs_test_2d_embedded_boundary_em_particle_absorption_sh_factor_2 # inputs
58+
"analysis.py" # analysis
59+
"analysis_default_regression.py --path diags/diag1" # checksum
60+
OFF # dependency
61+
)
62+
endif()
63+
64+
if(WarpX_EB)
65+
add_warpx_test(
66+
test_2d_embedded_boundary_em_particle_absorption_sh_factor_3 # name
67+
2 # dims
68+
1 # nprocs
69+
inputs_test_2d_embedded_boundary_em_particle_absorption_sh_factor_3 # inputs
70+
"analysis.py" # analysis
71+
"analysis_default_regression.py --path diags/diag1" # checksum
72+
OFF # dependency
73+
)
74+
endif()
75+
2976
if(WarpX_EB)
3077
add_warpx_test(
3178
test_rz_embedded_boundary_em_particle_absorption_sh_factor_1 # name
@@ -37,3 +84,27 @@ if(WarpX_EB)
3784
OFF # dependency
3885
)
3986
endif()
87+
88+
if(WarpX_EB)
89+
add_warpx_test(
90+
test_rz_embedded_boundary_em_particle_absorption_sh_factor_2 # name
91+
RZ # dims
92+
1 # nprocs
93+
inputs_test_rz_embedded_boundary_em_particle_absorption_sh_factor_2 # inputs
94+
"analysis.py" # analysis
95+
"analysis_default_regression.py --path diags/diag1" # checksum
96+
OFF # dependency
97+
)
98+
endif()
99+
100+
if(WarpX_EB)
101+
add_warpx_test(
102+
test_rz_embedded_boundary_em_particle_absorption_sh_factor_3 # name
103+
RZ # dims
104+
1 # nprocs
105+
inputs_test_rz_embedded_boundary_em_particle_absorption_sh_factor_3 # inputs
106+
"analysis.py" # analysis
107+
"analysis_default_regression.py --path diags/diag1" # checksum
108+
OFF # dependency
109+
)
110+
endif()

Examples/Tests/embedded_boundary_em_particle_absorption/analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
elif dim == "thetaMode":
4040
# In RZ: there are issues with divE on axis
4141
# Set the few cells around the axis to 0 for this test
42-
divE_avg[13:19] = 0
42+
divE_avg[:, 13:19] = 0
4343
tolerance = 4e-12
4444

4545

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# base input parameters
2+
FILE = inputs_base
3+
4+
geometry.dims = 2
5+
amr.n_cell = 32 32
6+
geometry.prob_lo = -10 -10
7+
geometry.prob_hi = 10 10
8+
boundary.field_lo = pec absorbing_silver_mueller
9+
boundary.field_hi = pec absorbing_silver_mueller
10+
11+
algo.particle_shape = 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# base input parameters
2+
FILE = inputs_base
3+
4+
geometry.dims = 2
5+
amr.n_cell = 32 32
6+
geometry.prob_lo = -10 -10
7+
geometry.prob_hi = 10 10
8+
boundary.field_lo = pec absorbing_silver_mueller
9+
boundary.field_hi = pec absorbing_silver_mueller
10+
11+
algo.particle_shape = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# base input parameters
2+
FILE = inputs_base
3+
4+
geometry.dims = 3
5+
amr.n_cell = 32 32 32
6+
geometry.prob_lo = -10 -10 -10
7+
geometry.prob_hi = 10 10 10
8+
boundary.field_lo = pec pec absorbing_silver_mueller
9+
boundary.field_hi = pec pec absorbing_silver_mueller
10+
11+
algo.particle_shape = 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# base input parameters
2+
FILE = inputs_base
3+
4+
geometry.dims = 3
5+
amr.n_cell = 32 32 32
6+
geometry.prob_lo = -10 -10 -10
7+
geometry.prob_hi = 10 10 10
8+
boundary.field_lo = pec pec absorbing_silver_mueller
9+
boundary.field_hi = pec pec absorbing_silver_mueller
10+
11+
algo.particle_shape = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# base input parameters
2+
FILE = inputs_base
3+
4+
geometry.dims = RZ
5+
amr.n_cell = 16 32
6+
geometry.prob_lo = 0 -10
7+
geometry.prob_hi = 10 10
8+
boundary.field_lo = none absorbing_silver_mueller
9+
boundary.field_hi = pec absorbing_silver_mueller
10+
11+
algo.particle_shape = 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# base input parameters
2+
FILE = inputs_base
3+
4+
geometry.dims = RZ
5+
amr.n_cell = 16 32
6+
geometry.prob_lo = 0 -10
7+
geometry.prob_hi = 10 10
8+
boundary.field_lo = none absorbing_silver_mueller
9+
boundary.field_hi = pec absorbing_silver_mueller
10+
11+
algo.particle_shape = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"lev=0": {
3+
"divE": 2.4521053721245334e-08,
4+
"rho": 0.0
5+
},
6+
"electron": {
7+
"particle_position_x": 0.0,
8+
"particle_position_y": 0.0,
9+
"particle_position_z": 0.0,
10+
"particle_momentum_x": 0.0,
11+
"particle_momentum_y": 0.0,
12+
"particle_momentum_z": 0.0,
13+
"particle_weight": 0.0
14+
},
15+
"positron": {
16+
"particle_position_x": 0.0,
17+
"particle_position_y": 0.0,
18+
"particle_position_z": 0.0,
19+
"particle_momentum_x": 0.0,
20+
"particle_momentum_y": 0.0,
21+
"particle_momentum_z": 0.0,
22+
"particle_weight": 0.0
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"lev=0": {
3+
"divE": 2.2059346534892452e-08,
4+
"rho": 0.0
5+
},
6+
"electron": {
7+
"particle_position_x": 0.0,
8+
"particle_position_y": 0.0,
9+
"particle_position_z": 0.0,
10+
"particle_momentum_x": 0.0,
11+
"particle_momentum_y": 0.0,
12+
"particle_momentum_z": 0.0,
13+
"particle_weight": 0.0
14+
},
15+
"positron": {
16+
"particle_position_x": 0.0,
17+
"particle_position_y": 0.0,
18+
"particle_position_z": 0.0,
19+
"particle_momentum_x": 0.0,
20+
"particle_momentum_y": 0.0,
21+
"particle_momentum_z": 0.0,
22+
"particle_weight": 0.0
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"lev=0": {
3+
"Bx": 0.0,
4+
"By": 2.3792992316172512e-15,
5+
"Bz": 0.0 ,
6+
"Ex": 6.177046470842443e-07,
7+
"Ey": 0.0,
8+
"Ez": 7.259396011803518e-07,
9+
"divE": 2.809306467366024e-07,
10+
"rho": 0.0
11+
},
12+
"electron": {
13+
"particle_position_x": 0.0,
14+
"particle_position_y": 0.0,
15+
"particle_position_z": 0.0,
16+
"particle_momentum_x": 0.0,
17+
"particle_momentum_y": 0.0,
18+
"particle_momentum_z": 0.0,
19+
"particle_weight": 0.0
20+
},
21+
"positron": {
22+
"particle_position_x": 0.0,
23+
"particle_position_y": 0.0,
24+
"particle_position_z": 0.0,
25+
"particle_momentum_x": 0.0,
26+
"particle_momentum_y": 0.0,
27+
"particle_momentum_z": 0.0,
28+
"particle_weight": 0.0
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"lev=0": {
3+
"Bx": 0.0,
4+
"By": 2.3948084603369097e-15,
5+
"Bz": 0.0,
6+
"Ex": 6.747158562891953e-07,
7+
"Ey": 0.0,
8+
"Ez": 5.541309886315263e-07,
9+
"divE": 2.091715826275267e-07,
10+
"rho": 0.0
11+
},
12+
"electron": {
13+
"particle_position_x": 0.0,
14+
"particle_position_y": 0.0,
15+
"particle_position_z": 0.0,
16+
"particle_momentum_x": 0.0,
17+
"particle_momentum_y": 0.0,
18+
"particle_momentum_z": 0.0,
19+
"particle_weight": 0.0
20+
},
21+
"positron": {
22+
"particle_position_x": 0.0,
23+
"particle_position_y": 0.0,
24+
"particle_position_z": 0.0,
25+
"particle_momentum_x": 0.0,
26+
"particle_momentum_y": 0.0,
27+
"particle_momentum_z": 0.0,
28+
"particle_weight": 0.0
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"lev=0": {
3+
"Bx": 0.0,
4+
"By": 2.379299231617251e-15,
5+
"Bz": 0.0,
6+
"Ex": 6.177046470842443e-07,
7+
"Ey": 0.0,
8+
"Ez": 7.259396011803522e-07,
9+
"divE": 2.8093064673660275e-07,
10+
"rho": 0.0
11+
},
12+
"electron": {
13+
"particle_position_x": 0.0,
14+
"particle_position_y": 0.0,
15+
"particle_position_z": 0.0,
16+
"particle_momentum_x": 0.0,
17+
"particle_momentum_y": 0.0,
18+
"particle_momentum_z": 0.0,
19+
"particle_weight": 0.0
20+
},
21+
"positron": {
22+
"particle_position_x": 0.0,
23+
"particle_position_y": 0.0,
24+
"particle_position_z": 0.0,
25+
"particle_momentum_x": 0.0,
26+
"particle_momentum_y": 0.0,
27+
"particle_momentum_z": 0.0,
28+
"particle_weight": 0.0
29+
}
30+
}
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"lev=0": {
3+
"divE": 4.928354322096152e-07,
4+
"rho": 0.0
5+
},
6+
"electron": {
7+
"particle_position_x": 0.0,
8+
"particle_position_y": 0.0,
9+
"particle_position_z": 0.0,
10+
"particle_momentum_x": 0.0,
11+
"particle_momentum_y": 0.0,
12+
"particle_momentum_z": 0.0,
13+
"particle_weight": 0.0
14+
},
15+
"positron": {
16+
"particle_position_x": 0.0,
17+
"particle_position_y": 0.0,
18+
"particle_position_z": 0.0,
19+
"particle_momentum_x": 0.0,
20+
"particle_momentum_y": 0.0,
21+
"particle_momentum_z": 0.0,
22+
"particle_weight": 0.0
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"lev=0": {
3+
"divE": 4.3355127342920327e-07,
4+
"rho": 0.0
5+
},
6+
"electron": {
7+
"particle_position_x": 0.0,
8+
"particle_position_y": 0.0,
9+
"particle_position_z": 0.0,
10+
"particle_momentum_x": 0.0,
11+
"particle_momentum_y": 0.0,
12+
"particle_momentum_z": 0.0,
13+
"particle_weight": 0.0
14+
},
15+
"positron": {
16+
"particle_position_x": 0.0,
17+
"particle_position_y": 0.0,
18+
"particle_position_z": 0.0,
19+
"particle_momentum_x": 0.0,
20+
"particle_momentum_y": 0.0,
21+
"particle_momentum_z": 0.0,
22+
"particle_weight": 0.0
23+
}
24+
}

0 commit comments

Comments
 (0)