Commit 183d055
committed
perf(BMT): recover the primal tendency from the Rosenbrock Jacobian pass
ForwardDiff's Jacobian pass already evaluates the primal tendency f as the dual
.value and discards it, so the separate f = g(x) repeats a full (quadrature-
dominated) tendency evaluation. Recover f from the same pass via DiffResults
(jacobian! into an immutable JacobianResult). Applies to the 2M+P3 and the 1M
ExactJacobian paths; the analytic Donor/CoupledDonor 1M Jacobians (no f
by-product) keep their separate evaluation.
Both paths now go through the shared `_tendency_and_jacobian(jacobian, g, x)`
method, which reconstructs the same `FieldVector` species type as `x`
(`MicroState1M` or `MicroState2MP3`), removing the duplicated DiffResults code in
the 2M+P3 substep loop.
~27% faster per Rosenbrock substep; f and J bit-identical, no extra allocations,
type-stable, composes with outer AD.1 parent 49695f3 commit 183d055
3 files changed
Lines changed: 30 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | 432 | | |
434 | 433 | | |
435 | | - | |
| 434 | + | |
| 435 | + | |
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| 445 | + | |
445 | 446 | | |
446 | 447 | | |
447 | 448 | | |
| |||
749 | 750 | | |
750 | 751 | | |
751 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
752 | 774 | | |
753 | 775 | | |
754 | 776 | | |
| |||
777 | 799 | | |
778 | 800 | | |
779 | 801 | | |
780 | | - | |
781 | 802 | | |
782 | 803 | | |
783 | 804 | | |
784 | 805 | | |
785 | 806 | | |
786 | 807 | | |
787 | 808 | | |
788 | | - | |
789 | 809 | | |
790 | 810 | | |
791 | | - | |
| 811 | + | |
| 812 | + | |
792 | 813 | | |
793 | 814 | | |
794 | 815 | | |
| |||
798 | 819 | | |
799 | 820 | | |
800 | 821 | | |
| 822 | + | |
801 | 823 | | |
802 | 824 | | |
803 | 825 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
0 commit comments