'Solution' object has no attribute 'set_equivalence_ratio'

578 views
Skip to first unread message

Shonn McNeill

unread,
Oct 2, 2016, 2:32:30 PM10/2/16
to Cantera Users' Group
When I run the code the below using Python 3.5 I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-6c59b4df68d5> in <module>()
     10 for i in range(len(phi)):
     11     gas1.TP = 300, ct.one_atm
---> 12     gas21.set_equivalence_ratio(phi[i], 'CH4', 'O2:1, N2:3.76')
     13     gas1.equilibrate('HP')
     14     T_complete[i] = gas1.T

AttributeError: 'Solution' object has no attribute 'set_equivalence_ratio'

I have looked up the "set_equivalence_ratio" and it is an object in the ThermoPhase Class which is a base class for the Solution class used in the code.  For reference this is the flame_temperature.ipynb tutorial file from here.
 
%matplotlib notebook
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt    

# Get all of the Species objects defined in the GRI 3.0 mechanism
     species = {S.name: S for S in ct.Species.listFromFile('gri30.cti')}

     # Create an IdealGas object with species representing complete combustion
     complete_species = [species[S] for S in ('CH4','O2','N2','CO2','H2O')]
     gas1 = ct.Solution(thermo='IdealGas', species=complete_species)

     phi = np.linspace(0.5, 2.0, 100)
     T_complete = np.zeros(phi.shape)
     for i in range(len(phi)):
         gas1.TP = 300, ct.one_atm
         gas21.set_equivalence_ratio(phi[i], 'CH4', 'O2:1, N2:3.76')
         gas1.equilibrate('HP')
         T_complete[i] = gas1.T


Bryan W. Weber

unread,
Oct 2, 2016, 7:41:56 PM10/2/16
to Cantera Users' Group
Dear Shonn,

What version of Cantera are you using? IIRC, the set_equivalence_ratio method is only available in the developer 2.3.0 versions.

Regards,
Bryan

Shonn McNeill

unread,
Oct 4, 2016, 10:16:48 AM10/4/16
to Cantera Users' Group
Looks like Running Cantera Version: 2.2.1

Bryan W. Weber

unread,
Oct 4, 2016, 11:27:27 AM10/4/16
to Cantera Users' Group
Right, so that version is too old. You can either upgrade to the developer version, or calculate the mole fractions yourself.

Regards,
Bryan

vaibhav patel

unread,
Oct 5, 2016, 11:24:09 AM10/5/16
to Cantera Users' Group
Hi Bryan,

can you  please forward me the link to download cantera 2.3.0 version?

Regards,
Vaibhav

Bryan W. Weber

unread,
Oct 5, 2016, 12:01:42 PM10/5/16
to Cantera Users' Group
Vaibhav,

If you are using MATLAB or C++ you will need to compile it yourself: http://cantera.github.io/docs/sphinx/html/compiling.html#windows

Or, you can use the Anaconda Python distribution and install only the Python package by writing

conda install -c cantera/label/dev cantera

at the command line.

Regards,
Bryan
Reply all
Reply to author
Forward
0 new messages