Skip to content

Range reactors - balance species value? #1372

@alongd

Description

@alongd

Using the following reactor:

simpleReactor(
    temperature=[(700,'K'),(900,'K')],
    pressure=(1,'bar'),
    nSimsTerm=12,
    initialMoleFractions={
        "C3H8": [0.03, 0.50],
	"O2": [0.10, 0.15],
	"NO": [0, 0.000300],
	"He": 0.5,
    },
    terminationConversion={
    'C3H8': 0.25,
    },
    terminationTime=(30,'s'),
    balanceSpecies = "He",
)

I got:

Traceback (most recent call last):
  File "/home/alongd/Code/RMG-Py//rmg.py", line 173, in <module>
    main()
  File "/home/alongd/Code/RMG-Py//rmg.py", line 167, in main
    rmg.execute(**kwargs)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/main.py", line 553, in execute
    self.initialize(**kwargs)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/main.py", line 387, in initialize
    self.loadInput(self.inputFile)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/main.py", line 211, in loadInput
    readInputFile(path, self)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/input.py", line 515, in readInputFile
    exec f in global_context, local_context
  File "/home/alongd/Dropbox (MIT)/runs/xo-Other_RMG/xo1514/input.py", line 51, in <module>
    balanceSpecies = "He",
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/input.py", line 225, in simpleReactor
    raise ValueError('The sum of the differences in the ranged mole fractions is greater than the mole fraction of the balance species, this would require the balanceSpecies mole fraction to be negative in some cases which is not allowed, either reduce the maximum mole fractions or dont use balanceSpecies')
ValueError: The sum of the differences in the ranged mole fractions is greater than the mole fraction of the balance species, this would require the balanceSpecies mole fraction to be negative in some cases which is not allowed, either reduce the maximum mole fractions or dont use balanceSpecies

The trace message is correct: the sum of the ranged mole fracs is indeed higher than the specified balance species' frac. This brings up several questions:

  1. If I change O2 and NO in the above example to their respective maximum values, RMG doesn't complain. I understand technically why (0.5 isn't grater than 0.5), but what is the rational?
  2. Can we calc the balance species' mole fraction to balance all other species to 1, even if that means increasing its concentration? We could output a warning that we ASSUME the other mole fractions are normalized if a balance species is used, but I wouldn't expect a crash in the above case.
  3. If a balance species is used, why should it's mole fraction be specified at all?
    Not specifying it leads to:
Error: local variable 'xbspcs' referenced before assignment
Traceback (most recent call last):
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/input.py", line 515, in readInputFile
    exec f in global_context, local_context
  File "/home/alongd/Dropbox (MIT)/runs/xo-Other_RMG/xo1514/input.py", line 50, in <module>
    balanceSpecies = "He",
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/input.py", line 224, in simpleReactor
    if total > xbspcs:
UnboundLocalError: local variable 'xbspcs' referenced before assignment
Traceback (most recent call last):
  File "/home/alongd/Code/RMG-Py//rmg.py", line 173, in <module>
    main()
  File "/home/alongd/Code/RMG-Py//rmg.py", line 167, in main
    rmg.execute(**kwargs)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/main.py", line 553, in execute
    self.initialize(**kwargs)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/main.py", line 387, in initialize
    self.loadInput(self.inputFile)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/main.py", line 211, in loadInput
    readInputFile(path, self)
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/input.py", line 515, in readInputFile
    exec f in global_context, local_context
  File "/home/alongd/Dropbox (MIT)/runs/xo-Other_RMG/xo1514/input.py", line 50, in <module>
    balanceSpecies = "He",
  File "/home/alongd/Code/RMG-Py/rmgpy/rmg/input.py", line 224, in simpleReactor
    if total > xbspcs:
UnboundLocalError: local variable 'xbspcs' referenced before assignment

@mjohnson541, would you take a look?

Metadata

Metadata

Assignees

Labels

stalestale issue/PR as determined by actions bot

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions