Skip to content

High: [Reactors] Sensitivity Jacobian writes species block into oversized non-isothermal state block #55

Description

@bernalde

Maintainer triage (June 29, 2026)

  • Status: Verified bug against the current master source in this fork.
  • Severity: High.
  • Area labels: area:reactors.
  • Tackle batch: P5 - medium-scope correctness defects.

The source review confirmed that the cited code path and failure mode are still present. The original audit details are preserved below for reproduction notes and suggested fixes.


Original audit details

Finding

The non-isothermal sensitivity Jacobian tries to assign an n_species x n_species kinetic Jacobian into a larger block that includes temperature.

Evidence

  • PharmaPy/Reactors.py:397-452 builds jac_states = np.zeros((num_states, num_states)).
  • PharmaPy/Reactors.py:437-438 assigns jac_r_kin into jac_states[:num_states - 1, :num_states - 1].
  • For jacket mode, num_states = n_species + temp + temp_ht, so the target block is (n_species + 1) x (n_species + 1), not n_species x n_species.
  • The non-isothermal parameter branch also leaves jac_params unset at PharmaPy/Reactors.py:446-452.

Impact

eval_sens=True fails for non-isothermal reactors with jacket states, and non-isothermal sensitivity equations are incomplete even when the shape happens to avoid immediate failure.

Likely fix

Assign kinetic derivatives only to the species block and explicitly implement temperature/jacket rows and parameter derivatives.

Metadata

Metadata

Assignees

Labels

area:reactorsBatch, CSTR, semibatch, and plug-flow reactor modelsbugSomething isn't workingcorrectnessModel/numerical correctness defectseverity:highConfirmed bug with major correctness impact or broken documented workflowstatus:verifiedSource-reviewed against the current codebase

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions