add_sensitivity_reaction accepts the same reaction twice although the docstring says it raises
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Start by rebuilding from source and running the reproduction script so you see the missing exception, then read Reactor::addSensitivityReaction and ReactorSurface::addSensitivityReaction (src/reactor/) and check how ReactorNet::registerSensitivityParameter stores parameters, since that is where a duplicate check belongs. Also fix the missing space in the "after theintegrator" message there. Done means the second call raises CanteraError, n_sensitivity_params stays 1, and a regression test in the Python reactor test suite covers both the duplicate and the message.
Written by the indexing model from the issue text.
Description
Problem description
The docstring of add_sensitivity_reaction says: "Specifying the same reaction more than one time raises an exception." It does not: the parameter is registered a second time. Reactor::addSensitivityReaction and ReactorSurface::addSensitivityReaction do not check for an existing parameter.
There is also a missing space in the related message in ReactorNet::registerSensitivityParameter: "Sensitivity parameters cannot be added after theintegrator has been initialized."
Steps to reproduce
import cantera as ct
gas = ct.Solution("h2o2.yaml")
gas.TPX = 1000.0, ct.one_atm, "H2:2, O2:1, AR:4"
r = ct.IdealGasConstPressureReactor(gas, clone=True)
net = ct.ReactorNet([r])
r.add_sensitivity_reaction(2)
r.add_sensitivity_reaction(2)
print(net.n_sensitivity_params)
Behavior
No exception; prints 2. Expected: CanteraError on the second call, as documented.
System information
- Cantera version: 4.0.0a2,
mainat 25c1ab1 (built from source); also seen in 3.2.0 - OS: Linux x86_64 (glibc 2.43)
- Python 3.13.16, NumPy 2.5.4, Cython 3.3.1, SUNDIALS 7.2.0
Additional context
Found while writing tests for our own use of Cantera; the example was reduced and run by an AI coding agent (Claude Code), and checked against existing issues.
- Dominant language
- C++
- Stars
- 885
- Forks
- 438
- Avg merge
- 3h 41m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Cantera/cantera
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Names for cantera library in LibCantera.jl don't match built library names, preventing Julia cantera interface from loadingPossibly taken @redwing509 claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Incorrect reference state in some of the YAML files.Possibly taken @hazalkoom claimed this 61 days ago. OpenInput
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
std::fdim drops partial derivative w.r.t second argument in forward and reverse modePossibly taken @ADITYASINGH1206 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
vgvassilev/clad#2534 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
HAP.cpp fixOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100