Skip to content

Commit d021649

Browse files
authored
Fix restart with ionization and add automated test (BLAST-WarpX#6291)
PR BLAST-WarpX#5481 replaced `NewIntComp` (which can be called several times with the same real time component) with `AddIntComp` (which can only be called only once on a real-time component, and raises an error if it is called a second time). As a consequence, simulations that involve field ionization now abort during restart, with the following message: ``` AddIntComp: name 'ionizationLevel' is already present in the SoA. SIGABRT ``` as reported in BLAST-WarpX#1546 This is because `AddIntComp` is first called for `ionizationLevel` here: https://github.com/BLAST-WarpX/warpx/blob/development/Source/Diagnostics/ParticleIO.cpp#L219 and later added again here: https://github.com/BLAST-WarpX/warpx/blob/development/Source/Particles/PhysicalParticleContainer.cpp#L1516 This PR avoids the second call by adding an `if` condition. It also adds a restart test. (The test fails when using the `development` branch, because the code aborts during restart.)
1 parent 10b298e commit d021649

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

Examples/Tests/field_ionization/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ add_warpx_test(
2121
OFF # dependency
2222
)
2323

24+
25+
add_warpx_test(
26+
test_2d_ionization_lab_restart # name
27+
2 # dims
28+
2 # nprocs
29+
inputs_test_2d_ionization_lab_restart # inputs
30+
"analysis.py diags/diag1001600" # analysis
31+
"analysis_default_regression.py --path diags/diag1001600 --rtol 1e-2" # checksum
32+
test_2d_ionization_lab # dependency
33+
)
34+
2435
add_warpx_test(
2536
test_2d_ionization_picmi # name
2637
2 # dims

Examples/Tests/field_ionization/inputs_test_2d_ionization_lab

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ laser1.profile_focal_distance = 0
5252
laser1.wavelength = 0.8e-6
5353

5454
# Diagnostics
55-
diagnostics.diags_names = diag1
55+
diagnostics.diags_names = diag1 chk
56+
5657
diag1.intervals = 10000
5758
diag1.diag_type = Full
59+
60+
chk.intervals = 1000
61+
chk.diag_type = Full
62+
chk.format = checkpoint
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# base input parameters
2+
FILE = inputs_test_2d_ionization_lab
3+
4+
# test input parameters
5+
amr.restart = "../test_2d_ionization_lab/diags/chk001000"

Regression/Checksum/benchmarks_json/test_2d_ionization_lab.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
"Ez": 3028.1738497993415,
99
"jx": 1.2111358355443756e+16,
1010
"jy": 0.0,
11-
"jz": 1.3638088639277835e-07
11+
"jz": 1.3637783796991858e-07
1212
},
1313
"ions": {
1414
"particle_ionizationLevel": 72897.0,
1515
"particle_momentum_x": 1.7613240076033055e-18,
1616
"particle_momentum_y": 0.0,
17-
"particle_momentum_z": 3.6186967472865243e-23,
17+
"particle_momentum_z": 3.618696747286525e-23,
1818
"particle_position_x": 0.03200001180710321,
1919
"particle_position_y": 0.12800000462171646,
2020
"particle_weight": 9.999999999999999e-11
2121
},
2222
"electrons": {
23-
"particle_momentum_x": 4.433634396795001e-18,
23+
"particle_momentum_x": 4.433468593927309e-18,
2424
"particle_momentum_y": 0.0,
25-
"particle_momentum_z": 2.6671140603432366e-18,
26-
"particle_orig_z": 0.4301725637223404,
27-
"particle_position_x": 0.11022808158588382,
28-
"particle_position_y": 0.6413954792104292,
25+
"particle_momentum_z": 2.6671137299190897e-18,
26+
"particle_orig_z": 0.4301725637223405,
27+
"particle_position_x": 0.11022808329781983,
28+
"particle_position_y": 0.6413952835649748,
2929
"particle_weight": 3.443203124999999e-10
3030
}
3131
}

Source/Particles/PhysicalParticleContainer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,9 @@ PhysicalParticleContainer::InitIonizationModule ()
15131513
physical_element == "H" || !do_adk_correction,
15141514
"Correction to ADK by Zhang et al., PRA 90, 043410 (2014) only works with Hydrogen");
15151515
// Add runtime integer component for ionization level
1516-
AddIntComp("ionizationLevel");
1516+
if (!HasiAttrib("ionizationLevel")) {
1517+
AddIntComp("ionizationLevel");
1518+
}
15171519
// Get atomic number and ionization energies from file
15181520
const int ion_element_id = utils::physics::ion_map_ids.at(physical_element);
15191521
ion_atomic_number = utils::physics::ion_atomic_numbers[ion_element_id];

0 commit comments

Comments
 (0)