Repository navigation
Commit b09d279
authored
Regular low-speed collision substep in stost (#615)
## Cause
In `collis_alp::stost` the speed p is advanced by Euler-Maruyama with
the substep bounded by `fraction*p/|fpeff|` and
`fraction**2*p**2/(6*dpp)`. Near p = 0 the speed process is a 3-D
Bessel-type process (`fpeff ~ 2*dpp/p`). In a cold plasma and from a
subthermal start, about one call in 1e6 to 1e7 lets the discrete walk
descend geometrically to p ~ 1e-10 within one call. The substep then
falls below ulp of the remaining time and `stost` returns `ierr = 4`, so
the caller rejects the step. Below p ~ 1e-8 the `plim` floor in
`coleff_local` also weakens the repulsive drift.
## Fix
For `iswmode` 1 and 2, below `p_switch = 1/max(velrat)` over the field
species with `efcolf > 0` (thermal speed of the slowest species over
v0), the substep is taken in Cartesian velocity space. This is the same
generator, but regular at p = 0:
`v_new = v + A*vhat*h + sqrt(2*Dpar*h)*xi1*vhat +
sqrt(2*Dperp*h)*(xi2*e2 + xi3*e3)`
with `Dpar = dpp`, `Dperp = dhh*p**2` and `A = fpeff - 2*Dperp/p`,
evaluated without the 1/p cancellation in the new helper
`coleff_cartesian` (next to `coleff_local`/`onseff`). Ito check: `dp =
(A + 2*Dperp/p) dt + sqrt(2*Dpar) dW = fpeff dt + ...` and the pitch
generator is `Dperp/p**2 d/dlambda (1-lambda**2) d/dlambda`. Above
`p_switch`, and whenever `velrat` is zero (synthetic tests), the
existing scheme is unchanged.
## Tests
New `test_collision_low_speed` (labels `unit;collisions;physics`), cold
H plasma at 20 eV with 2.5% C6+, n_e = 2e19 m^-3:
- Start at p = 1e-9 and 1e-12 must return `ierr = 0` (the old code
returns `ierr = 4` immediately, checked once by hand).
- First moments of one substep on both sides of `p_switch` match
`fpeff*h` and `-2*dhh*lambda*h` within 5 sigma.
- 4096 markers from p = 1e-6 thermalize to the Maxwellian `<p**2>`,
`<lambda> = 0`, `<lambda**2> = 1/3` within 5 sigma, and subthermal
markers never error over 2000 seeds.
Verified on macOS arm64 (gfortran 16, Release): `ctest -L collisions`
passes (12/12, including `test_collision_substeps` and the new test).
`golden_record_collision` could not run there, because
`golden_record.sh` uses bash 4 `exec {fd}` redirection.
Chris&AI1 parent 8263951 commit b09d279
3 files changed
Lines changed: 231 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
121 | 153 | | |
122 | 154 | | |
123 | 155 | | |
| |||
288 | 320 | | |
289 | 321 | | |
290 | 322 | | |
| 323 | + | |
291 | 324 | | |
292 | 325 | | |
293 | | - | |
294 | | - | |
| 326 | + | |
| 327 | + | |
295 | 328 | | |
296 | 329 | | |
297 | 330 | | |
| |||
324 | 357 | | |
325 | 358 | | |
326 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
327 | 368 | | |
328 | 369 | | |
329 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
330 | 410 | | |
331 | 411 | | |
332 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
538 | 544 | | |
539 | 545 | | |
540 | 546 | | |
| |||
| 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 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
0 commit comments