Skip to content

Broken piston.py example #875

@ischoegl

Description

@ischoegl

System information

  • Cantera version: development version
  • OS: ubuntu 18.04
  • Python/MATLAB version: 3.6.9

Expected behavior

Example runs without errors

Actual behavior

Example errors with

In [14]: %run piston.py
time [s]    T1 [K]      T2 [K]      V1 [m^3]    V2 [m^3]    V1+V2 [m^3]  X(CO)     
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/src/interfaces/cython/cantera/examples/reactors/piston.py in <module>()
     54 net = ct.ReactorNet([r1, r2])
     55 
---> 56 states1 = ct.SolutionArray(r1.thermo, extra=['t', 'v'])
     57 states2 = ct.SolutionArray(r2.thermo, extra=['t', 'v'])
     58 

/usr/local/lib/python3.6/dist-packages/cantera/composite.py in __init__(self, phase, shape, states, extra, meta)
    548                     raise ValueError(
    549                         "Unable to create extra column '{}': name is already "
--> 550                         "used by SolutionArray objects.".format(name))
    551                 self._extra[name] = []
    552 

ValueError: Unable to create extra column 'v': name is already used by SolutionArray objects.

To Reproduce

Steps to reproduce the behavior: see above

Additional context

The extra column v masks a pre-existing thermo state, which previously did not raise an error. The fix is trivial.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions