Commit 5f6ac11
x-lengyel: Avoid unphysical negative c_z in inverse solver.
In underpowered scenarios, the "solution" for inverse mode could be negative seeded impurities, if even with zero impurities the target temperature is below the
requested target temperature.
There was a bug where the solver was allowed to explore these negative values and then propagate them into the state, leading to NaNs.
Two separate fixes where done here:
1. Clip the seeded impurity ratios to zero in all places where it can be defined in Divertor1D states
2. Change the residual calculation to compare the calculated c_z to the state vector c_z (which is allowed to explore to negative values). This maintains
non-zero residuals and a gradient signal. The solver converges to "negative" impurities which are clipped to zero
3. Fix associated bug where if Z_eff=1 (no impurities) then we got a division by zero in the Jacobian. Just needed to add small value to Zeff within a formula.
PiperOrigin-RevId: 8606472371 parent 3e9f3c6 commit 5f6ac11
File tree
5 files changed
+89
-19
lines changed- torax
- _src/edge
- tests
- tests
5 files changed
+89
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
| 425 | + | |
425 | 426 | | |
426 | | - | |
| 427 | + | |
427 | 428 | | |
428 | 429 | | |
429 | 430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
345 | 351 | | |
346 | 352 | | |
347 | 353 | | |
348 | 354 | | |
349 | | - | |
| 355 | + | |
350 | 356 | | |
351 | 357 | | |
352 | 358 | | |
| |||
355 | 361 | | |
356 | 362 | | |
357 | 363 | | |
| 364 | + | |
358 | 365 | | |
359 | 366 | | |
360 | 367 | | |
| |||
468 | 475 | | |
469 | 476 | | |
470 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
471 | 482 | | |
472 | 483 | | |
473 | 484 | | |
474 | 485 | | |
475 | | - | |
| 486 | + | |
476 | 487 | | |
477 | 488 | | |
478 | 489 | | |
| |||
510 | 521 | | |
511 | 522 | | |
512 | 523 | | |
513 | | - | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
514 | 528 | | |
515 | 529 | | |
516 | 530 | | |
| |||
629 | 643 | | |
630 | 644 | | |
631 | 645 | | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | 646 | | |
639 | 647 | | |
640 | 648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
160 | 159 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 160 | + | |
165 | 161 | | |
166 | 162 | | |
167 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
549 | 550 | | |
550 | 551 | | |
551 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
552 | 615 | | |
553 | 616 | | |
554 | 617 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
0 commit comments