Skip to content

Commit 057d403

Browse files
authored
Fix bug where tmax was ignored in flux injection (#5430)
There was a bug where WarpX would only read `flux_tmin`, `flux_tmax` for the injection from a plane, but not for the injection from the EB. This PR fixes the bug, and uses `tmin`/`tmax` in the CI test for the EB injection.
1 parent f8b3270 commit 057d403

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

Examples/Tests/flux_injection/analysis_flux_injection_from_eb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
fn = sys.argv[1]
3333
ds = yt.load(fn)
3434
ad = ds.all_data()
35-
t_max = ds.current_time.item() # time of simulation
35+
t_inj = 0.5e-8 # duration for which the flux injection was active
3636

3737
# Extract the dimensionality of the simulation
3838
with open("./warpx_used_inputs", "r") as f:
@@ -52,7 +52,7 @@
5252
emission_surface = 4 * np.pi * R**2 # in m^2
5353
elif dims == "2D":
5454
emission_surface = 2 * np.pi * R # in m
55-
Ntot = flux * emission_surface * t_max
55+
Ntot = flux * emission_surface * t_inj
5656

5757
# Parameters of the histogram
5858
hist_bins = 50

Examples/Tests/flux_injection/inputs_base_from_eb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ electron.inject_from_embedded_boundary = 1
2929
electron.num_particles_per_cell = 100
3030
electron.flux_profile = parse_flux_function
3131
electron.flux_function(x,y,z,t) = "1."
32+
electron.flux_tmin = 0.25e-8
33+
electron.flux_tmax = 0.75e-8
3234
electron.momentum_distribution_type = gaussianflux
3335
electron.ux_th = 0.01
3436
electron.uy_th = 0.01
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"lev=0": {},
33
"electron": {
4-
"particle_momentum_x": 6.990772711451971e-19,
5-
"particle_momentum_y": 5.4131306169803364e-20,
6-
"particle_momentum_z": 6.997294931789925e-19,
7-
"particle_position_x": 35518.95120597846,
8-
"particle_position_y": 35517.855675902414,
9-
"particle_weight": 1.25355e-07
4+
"particle_momentum_x": 3.4911323396038835e-19,
5+
"particle_momentum_y": 2.680312173420972e-20,
6+
"particle_momentum_z": 3.4918430443688734e-19,
7+
"particle_position_x": 17950.08139982036,
8+
"particle_position_y": 17949.47183079554,
9+
"particle_weight": 6.269e-08
1010
}
1111
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"lev=0": {},
33
"electron": {
4-
"particle_momentum_x": 4.371688233196277e-18,
5-
"particle_momentum_y": 4.368885079657374e-18,
6-
"particle_momentum_z": 4.367429424105371e-18,
7-
"particle_position_x": 219746.94401890738,
8-
"particle_position_y": 219690.7015248918,
9-
"particle_position_z": 219689.45580938633,
10-
"particle_weight": 4.954974999999999e-07
4+
"particle_momentum_x": 2.1855512033870577e-18,
5+
"particle_momentum_y": 2.1826030840183147e-18,
6+
"particle_momentum_z": 2.181852403122796e-18,
7+
"particle_position_x": 111042.81925863726,
8+
"particle_position_y": 111012.52928910403,
9+
"particle_position_z": 111015.90903542604,
10+
"particle_weight": 2.4775750000000003e-07
1111
}
1212
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"lev=0": {},
33
"electron": {
4-
"particle_momentum_x": 6.734984863106283e-19,
5-
"particle_momentum_y": 6.786279785869023e-19,
6-
"particle_momentum_z": 1.0527983828124758e-18,
7-
"particle_position_x": 53309.270966506396,
8-
"particle_position_y": 53302.3776094842,
9-
"particle_theta": 58707.74469425615,
10-
"particle_weight": 4.991396867417661e-07
4+
"particle_momentum_x": 3.3665608248716305e-19,
5+
"particle_momentum_y": 3.392690322852239e-19,
6+
"particle_momentum_z": 5.254577143779578e-19,
7+
"particle_position_x": 26933.772112044953,
8+
"particle_position_y": 26926.994273876346,
9+
"particle_theta": 29492.77423173835,
10+
"particle_weight": 2.4953304765944705e-07
1111
}
1212
}

Source/Initialization/PlasmaInjector.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ void PlasmaInjector::setupNFluxPerCell (amrex::ParmParse const& pp_species)
305305
}
306306
#endif
307307

308+
utils::parser::queryWithParser(pp_species, source_name, "flux_tmin", flux_tmin);
309+
utils::parser::queryWithParser(pp_species, source_name, "flux_tmax", flux_tmax);
310+
308311
// Check whether injection from the embedded boundary is requested
309312
utils::parser::queryWithParser(pp_species, source_name, "inject_from_embedded_boundary", m_inject_from_eb);
310313
if (m_inject_from_eb) {
@@ -318,8 +321,6 @@ void PlasmaInjector::setupNFluxPerCell (amrex::ParmParse const& pp_species)
318321
// Parse the parameters of the plane (position, normal direction, etc.)
319322

320323
utils::parser::getWithParser(pp_species, source_name, "surface_flux_pos", surface_flux_pos);
321-
utils::parser::queryWithParser(pp_species, source_name, "flux_tmin", flux_tmin);
322-
utils::parser::queryWithParser(pp_species, source_name, "flux_tmax", flux_tmax);
323324
std::string flux_normal_axis_string;
324325
utils::parser::get(pp_species, source_name, "flux_normal_axis", flux_normal_axis_string);
325326
flux_normal_axis = -1;

0 commit comments

Comments
 (0)