Open GoogleCodeExporter opened 9 years ago
Note: this issue was originally reported in the Cantera User's Group:
https://groups.google.com/forum/?fromgroups=#!topic/cantera-users/7QUmPpNmRfA
Original comment by yarmond
on 29 Mar 2013 at 5:31
The changes in r2550 and r2551 eliminate the floating point exceptions.
However, there are still cases where the solver unexpectedly fails to converge.
The following script (for the 'new' Python module) which tests random (but
repeatable) mixture compositions has a failure rate of 5.8%:
import cantera
from random import random as rand
import random
random.seed(0)
gas = cantera.Solution('gri30.xml')
#gas = cantera.Solution('chemC2H4_100.xml')
fail_count = 0
def g():
a,b,c = rand(), 2*rand(), rand()
gas.TPX = 299.999, 100002, 'C2H4:%f, N2:%f, O2:%f' % (a,b,c)
h0,p0 = gas.HP
print a,b,c
try:
gas.equilibrate('HP', 0)
except:
print 'failed at', gas.TPX
global fail_count
fail_count += 1
h1,p1 = gas.HP
print ' ',h1-h0, p1-p0
for i in range(500):
print '======', i, '======'
g()
print 'Finished with %d failures.' % fail_count
Original comment by yarmond
on 30 Sep 2013 at 2:04
The frequency of failures seems to increase as both the initial temperature and pressure are increased. Setting the initial conditions in the above example to 1200 K and 5 bar increases the failure rate to 111 out of 500 samples (22%).
File does not open - may no longer be reproducible.
The input file is linked on the relevant Users' Group thread: https://groups.google.com/g/cantera-users/c/7QUmPpNmRfA/m/CJJTRzbMg-wJ
The solver does not fail at the single point that was originally demonstrated from that input file in any case. The behavior for the wider range of test cases using the script I provided and the GRI 3.0 mechanism is still the same. Here is an updated version for modern Python and Cantera versions:
import cantera as ct
from random import random as rand
import random
random.seed(0)
gas = ct.Solution('gri30.yaml')
fail_count = 0
def g():
a,b,c = rand(), 2*rand(), rand()
gas.TPX = 299.999, 100002, {'C2H4': a, 'N2': b, 'O2': c}
h0,p0 = gas.HP
try:
gas.equilibrate('HP', solver='element_potential')
except:
print(f'failed at X = {gas.mole_fraction_dict()}')
global fail_count
fail_count += 1
h1,p1 = gas.HP
if abs(h1 - h0) > 1e-3 or abs(p1 - p0) > 1e-4:
print(' ', h1-h0, p1-p0)
for i in range(500):
g()
print(f'Finished with {fail_count} failures.')
As before, this fails on 29/500 cases as written and with T and P increased to 1200 K and 5 bar, the number of failures increases to 111/500.
Original issue reported on code.google.com by
yarmond
on 29 Mar 2013 at 5:30Attachments: