Skip to content

restore_data refers to P[0] instead of P #942

@kahilah

Description

@kahilah

In function restore_data() in onedim.pyx the pressure is restored simply setting
self.P = P[0]

However, prior to that call, P is defined as T, P, Y = states where states is the function argument. If user has created the states by using f.collect_data() function, P is not an array but a float, hence evoking an error TypeError: 'float' object is not subscriptable

Steps to reproduce

import cantera as ct
import numpy as np

# Simulation parameters
p = ct.one_atm  # pressure [Pa]
Tin = 300.0  # unburned gas temperature [K]
reactants = 'H2:1.1, O2:1, AR:5'  # premixed gas composition
width = 0.03  # m
loglevel = 1  # amount of diagnostic output (0 to 8)

# IdealGasMix object used to compute mixture properties, set to the state of the
# upstream fuel-air mixture
gas = ct.Solution('h2o2.xml')
gas.TPX = Tin, p, reactants

# Set up flame object
f = ct.FreeFlame(gas, width=width)
f.set_refine_criteria(ratio=3, slope=0.06, curve=0.12)
f.show_solution()

# Solve with mixture-averaged transport model
f.transport_model = 'Mix'
f.solve(loglevel=loglevel, auto=True)

fdata_tmp = f.collect_data('flame', ['grid'])

f.restore_data('flame', fdata_tmp[0], fdata_tmp[1], fdata_tmp[2])

System information

  • Cantera version: development version installed by conda
  • OS: Centos 7
  • Python 3.8

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