我是化学网络模型的新手。目前,我正在转换以前的学生python代码,以适应实验室中的新版本。你知道吗
首先,定义了来自机理(预定义)的气体混合物
gas_mix = ct.import_phases(mech,['gas'])
然后,我想得到物种的数量,并使用cantera nSpecies
nsp = gas_mix.nSpecies()
我得到的错误信息是
AttributeError: 'list' object has no attribute 'nSpecies'
我也试过:
nsp = gas_mix.n_species
它也显示了
AttributeError: 'list' object has no attribute
你能帮我一下吗? 谢谢并致以最诚挚的问候, 尤比
它看起来像是
import_phases
返回一个对象列表,或者是一个“gas mix”列表,或者只是一个“gas”对象。我不是很确定,因为这是非常具体的程序,你正在工作。你知道吗无论如何,请尝试在
gas_mix
中的值上循环,看看是否可以调用nSpecies()
方法或访问n_species
属性:也许这会让你更接近你想要的。你知道吗
函数
import_phases
返回一个列表,对于从同一个文件导入多个阶段定义的情况非常有用,例如其中
mixtures[0]
和mixtures[2]
将是单相定义。如果只想定义一个阶段,则更容易编写:或者,如果机制文件仅包含一个阶段定义,则
从这里,你应该可以访问物种的数量
文档页面“Migrating from the Old Python Module”中描述了从旧Cantera接口迁移到新Cantera接口的许多细节。你知道吗
相关问题 更多 >
编程相关推荐