mirror of
https://github.com/Cantera/cantera.git
synced 2026-07-31 16:48:28 -05:00
Add an overload netProductionRates_ddCi(SparseMatrix&) that fills a caller-owned sparse matrix and reuses its nonzero pattern across calls. The pattern of d(wdot_k)/d(c_m) is fixed for a given mechanism and derivative settings, so it is built once (delegating to the allocating path) and subsequent calls overwrite the value array in place with no allocation or symbolic SpGEMM. The BulkKinetics override fuses the stoichiometry-matrix product directly into the compressed column storage using an O(K) dense scatter column (m_rbuf3) rather than a K x K dense buffer, mirroring calculateCompositionDerivatives() with ddX=false. Result is numerically identical to the allocating netProductionRates_ddCi() (verified to <1e-12 relative). No new Python API. Benchmark (gri30, optimize=n library): ~1447 us/call allocating vs ~883 us/call reused = 1.64x on the primitive. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>