-
-
Notifications
You must be signed in to change notification settings - Fork 392
Description
Problem description
When adding "extra" columns to SolutionArray, they can be accessed as attributes of the object. However, presumably because lambda is reserved for lambda functions in Python, it breaks this feature.
Steps to reproduce
Because the radial pressure gradient is named lambda in the AxisymmetricFlow object, converting it to a SolutionArray demonstrates the issue:
>>> import cantera as ct
>>> gas = ct.Solution("gri30.yaml")
>>> flame = ct.CounterflowDiffusionFlame(gas, width=0.02)
>>> sol = flame.to_array()
>>> print(sol.extra)
['grid', 'velocity', 'spread_rate', 'lambda']
>>> print(sol.lambda)
File "<python-input-1>", line 1
print(sol.lambda)
^^^^^^
SyntaxError: invalid syntaxThough one workaround is to use getattr instead:
>>> print(getattr(sol, "lambda"))
[0. 0. 0. 0. 0. 0.]Behavior
I would expect to be able to access the radial pressure gradient the same way I would any other extra parameter, e.g. velocity:
>>> print(sol.velocity))
[0. 0. 0. 0. 0. 0.]I presume this may be why the radial pressure gradient is still called L in FlameBase, and perhaps there is a way to map sol.L to getattr(sol, "lambda") without breaking other functionality or user expectations. Also, apologies if this has already been discussed, I wasn't able to find anything about it when I searched the issues and pull requests for "lambda."
System information
- Cantera version: 3.1.0
- OS: RHEL 8.10
- Python version: 3.13