Question: why does my code return a value of zero . Python code : import numpy as np # Given reaction mechanism ( coefficients are already
why does my code return a value of zero
Python code :
import numpy as np
# Given reaction mechanism coefficients are already corrected
finput
CH CH CH
CH H H CH
CH CH H
CH CH H
CH CH CH
CH CH CH CH
CH CH CH CH
CH CH CH CH
reactions list
for line in finput:
strippedline line.strip
if strippedline#:
continue
if strippedline::
continue
for r in reactions:
i reactions.indexr
speciestmp list # temporary list for species
for r in reactions:
left rsplitstrip # reactants side
right rsplitstrip # products side
leftterms left.split # reactant species w stoichiometric coeff.
rightterms right.split # product species w stoichiometric coeff.
terms tstrip for t in lefttermststrip for t in rightterms # concatenate list comprehensions
for i in terms:
tmp isplit # split stoichiometric coefficient from species name
assert lentmp or lentmp terms r i r tmp r terms i tmp
if lentmp f:
speciestmpappendtmpstrip # species name if there is a stoichiometric coeff.
else:
speciestmpappendistrip # species name if there is no stoichiometric coeff.
speciesfiltered setspeciestmp # filter species as a set
species listspeciesfiltered # convert species set to list
print
species
species
print# of species lenspecies
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
