Commit c3aa425
authored
Handle impact ionization for cases where the non-target incident species is not in the products (#5852)
# Original issue
The structure `m_num_products_host` was being initialized in a
complicated way:
- First filled up as
```
if (it != product_species.end()) {
m_num_product_species = 3;
m_num_products_host.push_back(2); // the non-target species
m_num_products_host.push_back(1); // the target species
m_num_products_host.push_back(1); // corresponds to whichever ionization product species1 is not (ion or electron)
} else {
m_num_product_species = 4;
m_num_products_host.push_back(1); // the non-target species
m_num_products_host.push_back(1); // the target species
m_num_products_host.push_back(1); // first product species
m_num_products_host.push_back(1); // second product species
}
```
- then updated with:
```
if ((i < 2) & (num_products == 1)) {
num_products = 0;
}
```
This combination ends up begin incorrect in the case of impact
ionization reactions involving 4 species.
(e.g. $H + H_2 \rightarrow H_2 + H^+ + e^{-}$), since in this case, we
need to allocate space in the particle array for the non-ionized species
($H_2$) to have a scattered macroparticle - for conservation of energy.
This results in a `SegFault` in practice, when using impact ionization
reactions involving 4 species (which was not automatically tested,
before this PR).
# Changes in this PR
Since `m_num_products_host` is only used for product-producing DSMC
reactions, this code can be simplified to:
```
if (it != product_species.end()) {
m_num_product_species = 3;
m_num_products_host.push_back(2); // the non-target species
m_num_products_host.push_back(0); // the target species
m_num_products_host.push_back(1); // corresponds to whichever ionization product species1 is not (ion or electron)
} else {
m_num_product_species = 4;
m_num_products_host.push_back(1); // the non-target species
m_num_products_host.push_back(0); // the target species
m_num_products_host.push_back(1); // first product species
m_num_products_host.push_back(1); // second product species
}
```
and then we don't need:
```
if ((i < 2) & (num_products == 1)) {
num_products = 0;
}
```
# Automated test
I added a test featuring the reaction $H + H_2 \rightarrow H_2 + H^+ +
e^{-}$, where a beam of fast $H^+$ goes through a background gas of
$H_2$.1 parent 47af36e commit c3aa425
File tree
6 files changed
+220
-16
lines changed- Examples/Tests/ionization_dsmc
- Regression/Checksum/benchmarks_json
- Source/Particles/Collision/BinaryCollision/DSMC
6 files changed
+220
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
Lines changed: 3 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 118 | + | |
124 | 119 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 120 | | |
129 | 121 | | |
130 | 122 | | |
| |||
200 | 192 | | |
201 | 193 | | |
202 | 194 | | |
| 195 | + | |
203 | 196 | | |
204 | 197 | | |
205 | 198 | | |
| |||
331 | 324 | | |
332 | 325 | | |
333 | 326 | | |
334 | | - | |
| 327 | + | |
335 | 328 | | |
336 | 329 | | |
337 | 330 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
0 commit comments