hkmoffat / cantera

Automatically exported from code.google.com/p/cantera
0 stars 0 forks source link

Segmentation fault in Cantera::Plog::update_C ? #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Python code based closely on the reactor1.py example, but using some.step() 
instead of sim.advance():

gg = importPhase('chem.cti')
gg.set(T = 1500, P = OneAtm, X = 
'Hyad(1):0.0041,Aa(2):0.00181,Hypp(3):0.00233,Lvgs(5):0.00024,Ppa(7):0.000194,Hf
2o(6):0.00032,Isegl(8):0.00075,Phl(9):0.0000452,Sygl(10):0.00004,H2O(4):0.0134,N
2:0.003')
r = Reactor(gg)
env = Reservoir(Air())
w = Wall(r,env)
w.set(K = 1.0e6)   # set expansion parameter. dV/dt = KA(P_1 - P_2)
w.set(A = 1.0)

steps = 2000
sim = ReactorNet([r])
time = 0.0
tfinal = 1e-2
tim = zeros(steps,'d')
data = zeros([steps,5],'d')

for n in xrange(steps):
    for i in xrange(10):
       time = sim.step(tfinal)
    if time > tfinal:
        break
        # save the results

What is the expected output? What do you see instead?

It crashes with a segmentation fault. Exactly when depends on the step size, 
end time, simulation temperature etc., but it reliably crashes, and the top of 
the stack trace always looks the same:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   _cantera.so                     0x0000000104211f97 
Cantera::Plog::update_C(double const*) + 167
1   _cantera.so                     0x000000010420c49b 
Cantera::GasKinetics::_update_rates_C() + 395
2   _cantera.so                     0x000000010420c8d2 
Cantera::GasKinetics::updateROP() + 18
3   _cantera.so                     0x000000010420c895 
Cantera::GasKinetics::getNetProductionRates(double*) + 21

Some complete crash reports are attached.

What version of the product are you using? On what operating system?

cantera-2.0.0b3
with Python 2.7.2
on Mac OS X 10.7.4 

Please provide any additional information below.

Original issue reported on code.google.com by r.h.w...@gmail.com on 9 Aug 2012 at 3:25

Attachments:

GoogleCodeExporter commented 9 years ago
Can you provide a copy of the input file you're using?

Original comment by yarmond on 9 Aug 2012 at 8:07

GoogleCodeExporter commented 9 years ago
The crash happens when the pressure becomes negative. The argument to update_C 
is the log of the pressure, which is NaN, so it can't find an appropriate pair 
of pressures to interpolate between.

Original comment by yarmond on 10 Aug 2012 at 2:52

GoogleCodeExporter commented 9 years ago
There are several changes to how errors are handled when using the CVODES 
integrator in r1778, r1779, r1780, and r1781 which help here.

Now trying to integrate this system leads to a different error message:

************************************************
                Cantera Error!
************************************************

Procedure: CVodesIntegrator
Error:    CVodes error encountered. Error code: -3
Components with largest weighted error estimates:
44: 224.665
18: -106.067
42: -45.4502
14: -9.20911
23: -1.66335
13: 1.38928
24: -0.456371
85: 0.423612
86: 0.421887
39: 0.415644

Which suggests an issue with species 42, 16, and 40 (zero indexed; the first 
two components of the CVODES solution vector are the internal energy and volume 
of the reactor). 

Looking at your mechanism file, I think the rate expressions for Reactions #344 
and #345 are suspicious. Commenting them out allows the simulation to run 
without errors.

Original comment by yarmond on 12 Aug 2012 at 12:09

GoogleCodeExporter commented 9 years ago
Thanks. Those two "suspicious" rates come directly from the Glarborg group's 
master mechanism
http://dx.doi.org/10.1016/j.proci.2008.06.188

 CH2CHOO=C2H2+HO2                     9.6E48  -8.868  110591 ! JIM/GLA08 ING/BOZ03 100 atm
 CH2CHOO=CH2O+HCO                     3.1E47  -8.701  111046 ! JIM/GLA08 ING/BOZ03 100 atm

So they presumably can't *always* be problematic...
We'll keep investigating.

Original comment by r.h.w...@gmail.com on 14 Aug 2012 at 7:23