You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Thanks for this bug report on this recently introduced feature - the main issue is that docstrings are incorrect, i.e. these functions work with tuple arguments, not SolutionArrays; it's certainly true that the observed behavior needs to be fixed also. Overall, these functions are mainly meant as service functions for flame.to_solution_array and flame.from_solution_array. As a work-around, I'd recommend simply using those, i.e.
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 errorTypeError: 'float' object is not subscriptable
Steps to reproduce
System information
The text was updated successfully, but these errors were encountered: