本文整理汇总了Python中species.Species.molecule方法的典型用法代码示例。如果您正苦于以下问题:Python Species.molecule方法的具体用法?Python Species.molecule怎么用?Python Species.molecule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类species.Species
的用法示例。
在下文中一共展示了Species.molecule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadChemkinFile
# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import molecule [as 别名]
def loadChemkinFile(path, dictionaryPath=None):
"""
Load a Chemkin input file to `path` on disk, returning lists of the species
and reactions in the Chemkin file.
"""
speciesList = []; speciesDict = {}
reactionList = []
# If the dictionary path is given, the read it and generate Molecule objects
# You need to append an additional adjacency list for nonreactive species, such
# as N2, or else the species objects will not store any structures for the final
# HTML output.
if dictionaryPath:
with open(dictionaryPath, 'r') as f:
adjlist = ''
for line in f:
if line.strip() == '' and adjlist.strip() != '':
# Finish this adjacency list
species = Species().fromAdjacencyList(adjlist)
species.generateResonanceIsomers()
speciesDict[species.label] = species
adjlist = ''
else:
if "InChI" in line:
line = line.split()[0] + '\n'
if '//' in line:
index = line.index('//')
line = line[0:index]
adjlist += line
def removeCommentFromLine(line):
if '!' in line:
index = line.index('!')
comment = line[index+1:-1]
line = line[0:index] + '\n'
return line, comment
else:
comment = ''
return line, comment
def checkDuplicateKinetics(reaction, kinetics,comments,dupReactionList,reactionList):
if 'DUP' in kinetics:
kinetics = kinetics.replace('\nDUP','')
reaction = readKineticsEntry(kinetics,speciesDict,energyUnits,moleculeUnits)
reaction.kinetics.comment = comments
if dupReactionList:
if not reaction.hasTemplate(dupReactionList[-1].reactants,dupReactionList[-1].products):
# It's not the same kind of duplicate reaction
oldReactionKinetics = MultiKinetics()
for item in dupReactionList:
oldReactionKinetics.kineticsList.append(item.kinetics)
oldReaction = dupReactionList[0]
oldReaction.kinetics = oldReactionKinetics
reactionList.append(oldReaction)
dupReactionList = []
dupReactionList.append(reaction)
kinetics = ''
comments = ''
return reaction, kinetics, comments, dupReactionList, reactionList
else:
# No more duplicate reactions
if dupReactionList:
# add previous reaction if they were duplicate reactions
oldReactionKinetics = MultiKinetics()
for item in dupReactionList:
oldReactionKinetics.kineticsList.append(item.kinetics)
oldReaction = dupReactionList[0]
oldReaction.kinetics = oldReactionKinetics
reactionList.append(oldReaction)
dupReactionList = []
# add this new, nonduplicate reaction
reaction = readKineticsEntry(kinetics,speciesDict,energyUnits,moleculeUnits)
reaction.kinetics.comment = comments
reactionList.append(reaction)
kinetics = ''
comments = ''
return reaction, kinetics, comments, dupReactionList, reactionList
with open(path, 'r') as f:
line = f.readline()
while line != '':
line = removeCommentFromLine(line)[0]
line = line.strip()
tokens = line.split()
if 'SPECIES' in line:
# List of species identifiers
index = tokens.index('SPECIES')
tokens = tokens[index+1:]
while 'END' not in tokens:
line = f.readline()
line = removeCommentFromLine(line)[0]
line = line.strip()
tokens.extend(line.split())
for token in tokens:
if token == 'END':
#.........这里部分代码省略.........