jcaiuwyo / cantera

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

Error in Solution using Matlab #169

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
When i set Temperature (K), Pressure (Pa) and Mass Fractions the solution in 
Cantera 2.0.2 r1514 is:

                          1 kg            1 kmol
                       -----------      ------------
          enthalpy     9.84637e+06        2.721e+08     J
   internal energy     9.48531e+06        2.621e+08     J
           entropy         8026.46        2.218e+05     J/K
    Gibbs function          214615        5.931e+06     J
 heat capacity c_p         11100.3        3.067e+05     J/K
 heat capacity c_v         10799.4        2.984e+05     J/K

while in Cantera 1.8 is:

                           1 kg            1 kmol
                        -----------      ------------
           enthalpy          861995        2.382e+07     J
    internal energy          500933        1.384e+07     J
            entropy         8914.15        2.463e+05     J/K
     Gibbs function    -9.83498e+06       -2.718e+08     J
  heat capacity c_p         1397.19        3.861e+04     J/K
  heat capacity c_v         1096.31        3.029e+04     J/K 

I'm using the same input:
Kinetic Mechanism: gri30.xml (attached to Cantera package)
Temperature: 1200 K
Pressure:101325 Pa
Mass Fractions (I report only the non zero value):
                            X                 Y          Chem. Pot. / RT    
                      -------------     ------------     ------------
                 O2       0.190045         0.220068         -28.7475
                CH4      0.0950226        0.0551661         -35.9613
                 N2       0.714932         0.724766         -25.6787

Why there is this difference?? I presume that there is an error in Cantera 2.02 
or that I'm using bad this new version. 

What version of the product are you using? On what operating system?
My operating system is Ubuntu 12.10

Original issue reported on code.google.com by Luigi.Ac...@gmail.com on 3 Aug 2013 at 3:10

GoogleCodeExporter commented 9 years ago
I'm using Matlab Cantera Interface

Original comment by Luigi.Ac...@gmail.com on 3 Aug 2013 at 3:12

GoogleCodeExporter commented 9 years ago
r1514 isn't even Cantera 2.0.0, let alone 2.0.2. Please try again with one of 
the following:
 - the 2.0.2 release tarball
 - the most recent version of the 2.0 maintenance branch
 - the most recent version of the 2.1 pre-release branch

If you still see the same behavior, post the script that you're using to 
generate these results.

Original comment by yarmond on 3 Aug 2013 at 5:00

GoogleCodeExporter commented 9 years ago
I have installed today the latest version of Cantera using: 
svn checkout http://cantera.googlecode.com/svn/cantera/trunk/ cantera

The version in the tarball is not fairly recent. With the version in the 
tarball I I had the problems I have described in the issue 168. Therefore I 
cannot use the tarball.

The script that I use to generate results is:

clc; clear all;
% Input

Y = zeros(53,1);
Y(4) =  0.220067884973670;
Y(14) = 0.0551660728267965;
Y(48) = 0.724766042199534;
T = 1200;
P = 101325;

% Cantera 1.8 - Section 1
addpath(genpath('/usr/local/cantera/matlab/toolbox'));  

gas = IdealGasMix('gri30.xml','gri30');

gas = set(gas,'T',T,'P',P,'Y',Y);

% Cantera 2 - Section 2
% run('/usr/local/cantera2/lib/cantera/matlab/toolbox/ctpath.m');             
% 
% gas = IdealGasMix('gri30.xml','gri30');
% gas = set(gas,'T',T,'P',P,'Y',Y);

I used the two sections alternately not at same time. 

Original comment by Luigi.Ac...@gmail.com on 3 Aug 2013 at 5:33

GoogleCodeExporter commented 9 years ago
I am unable to replicate this behavior using the current trunk revision, on 
what appears to be a fairly similar system (Ubuntu 12.10, running Matlab 
2013a). Some additional things that might help identify this problem:
- what are the results of 'scons test'?
- what compilation options are being provided to SCons (contents of 
cantera.conf)?
- Can you make sure there is not a modified copy of the 'gri30.xml' file 
present?
- In Matlab, both before and after the call to 'set', what is the output of the 
following:
    disp(massFractions(gas))
    disp(temperature(gas))
    disp(cp_mass(gas))
    disp(cp_R(gas))
- What results do you see using other mechanisms, e.g. the 'h2o2.xml' file also 
included with Cantera?
- What results do you see if you run the equivalent commands using the Python 
module?

Original comment by yarmond on 4 Aug 2013 at 3:44

GoogleCodeExporter commented 9 years ago
Every Test performed through scons test is successful.
The file cantera.conf is:

prefix = '/usr/local/cantera2/'
python_package = 'minimal'
matlab_toolbox = 'y'
matlab_path = '/usr/local/MATLAB/R2011a/'
use_sundials = 'y'
sundials_include = '/usr/local/include/'
sundials_libdir = '/usr/local/lib/'
blas_lapack_libs = 'blas,lapack'

The gri30 is unmodified. But I have compared the gri30.xml contained in 
Cantera1.8 with gri30.xml contained in Cantera 2 with meld:

21c21
<     <kinetics model="GRI30"/>
---
>     <kinetics model="GasKinetics"/>
41c41
<     <kinetics model="GRI30"/>
---
>     <kinetics model="GasKinetics"/>
61c61
<     <kinetics model="GRI30"/>
---
>     <kinetics model="GasKinetics"/>
1484c1484
<            2.7000000000000002
---
>            2.7
1757c1757
<            -1.4099999999999999
---
>            -1.41
1799c1799
<            1.8300000000000001
---
>            1.83
1827c1827
<            1.9199999999999999
---
>            1.92
1911c1911
<            -0.85999999999999999
---
>            -0.86
1940c1940
<            -0.76000000000000001
---
>            -0.76
1968c1968
<            -0.80000000000000004
---
>            -0.8
1982c1982
<            -0.67069999999999996
---
>            -0.6707
2011c2011
<            -0.59999999999999998
---
>            -0.6
2157c2157
<            -2.7599999999999998
---
>            -2.76
2187c2187
<            -0.53400000000000003
---
>            -0.534
2192c2192
<            -4.7599999999999998
---
>            -4.76
2208c2208
<            1.6200000000000001
---
>            1.62
2222c2222
<            0.47999999999999998
---
>            0.48
2227c2227
<            -2.5699999999999998
---
>            -2.57
2257c2257
<            0.45400000000000001
---
>            0.454
2262c2262
<            -4.8200000000000003
---
>            -4.82
2278c2278
<            0.45400000000000001
---
>            0.454
2283c2283
<            -4.7999999999999998
---
>            -4.8
2299c2299
<            1.8999999999999999
---
>            1.9
2318c2318
<            -4.6500000000000004
---
>            -4.65
2348c2348
<            0.65000000000000002
---
>            0.65
2362c2362
<            -0.089999999999999997
---
>            -0.09
2376c2376
<            0.51500000000000001
---
>            0.515
2381c2381
<            -7.4400000000000004
---
>            -7.44
2397c2397
<            1.6299999999999999
---
>            1.63
2439c2439
<            -0.23000000000000001
---
>            -0.23
2453c2453
<            2.1000000000000001
---
>            2.1
2467c2467
<            2.1000000000000001
---
>            2.1
2486c2486
<            -4.7999999999999998
---
>            -4.8
2507c2507
<            -7.2699999999999996
---
>            -7.27
2523c2523
<            0.27000000000000002
---
>            0.27
2528c2528
<            -3.8599999999999999
---
>            -3.86
2558c2558
<            0.45400000000000001
---
>            0.454
2563c2563
<            -7.6200000000000001
---
>            -7.62
2579c2579
<            2.5299999999999998
---
>            2.53
2593c2593
<            -0.98999999999999999
---
>            -0.99
2598c2598
<            -7.0800000000000001
---
>            -7.08
2628c2628
<            1.8999999999999999
---
>            1.9
2703c2703
<            -3.4199999999999999
---
>            -3.42
2738c2738
<            -0.90000000000000002
---
>            -0.9
2754c2754
<            2.3999999999999999
---
>            2.4
2880c2880
<            -1.4299999999999999
---
>            -1.43
2885c2885
<            -5.9199999999999999
---
>            -5.92
2901c2901
<            1.6000000000000001
---
>            1.6
2915c2915
<            -1.3400000000000001
---
>            -1.34
2929c2929
<            1.6000000000000001
---
>            1.6
2971c2971
<            1.1799999999999999
---
>            1.18
3069c3069
<            2.2999999999999998
---
>            2.3
3139c3139
<            2.1200000000000001
---
>            2.12
3396c3396
<            -3.7400000000000002
---
>            -3.74
3529c3529
<            -5.1100000000000003
---
>            -5.11
3629c3629
<            -1.1599999999999999
---
>            -1.16
3634c3634
<            -6.3600000000000003
---
>            -6.36
3776c3776
<            2.4700000000000002
---
>            2.47
3790c3790
<            -1.1799999999999999
---
>            -1.18
3795c3795
<            -7.0300000000000002
---
>            -7.03
3811c3811
<            0.10000000000000001
---
>            0.1
3839c3839
<            2.8100000000000001
---
>            2.81
3966c3966
<            7.5999999999999996
---
>            7.6
3994c3994
<            0.90000000000000002
---
>            0.9
4008c4008
<            -1.3899999999999999
---
>            -1.39
4027c4027
<            -9.3000000000000007
---
>            -9.3
4218c4218
<            -1.4099999999999999
---
>            -1.41
4373c4373
<            -0.23000000000000001
---
>            -0.23
4387c4387
<            -0.45000000000000001
---
>            -0.45
4570c4570
<            -1.3200000000000001
---
>            -1.32
4599c4599
<            0.71999999999999997
---
>            0.72
4613c4613
<            1.8999999999999999
---
>            1.9
4697c4697
<            2.4500000000000002
---
>            2.45
4824c4824
<            -3.2999999999999998
---
>            -3.3
4839c4839
<            2.6400000000000001
---
>            2.64
4853c4853
<            2.6400000000000001
---
>            2.64
4867c4867
<            1.5800000000000001
---
>            1.58
4881c4881
<            2.0299999999999998
---
>            2.03
4895c4895
<            2.2599999999999998
---
>            2.26
4909c4909
<            2.5600000000000001
---
>            2.56
4928c4928
<            -3.3999999999999999
---
>            -3.4
4986c4986
<            0.14999999999999999
---
>            0.15
4991c4991
<            -3.1600000000000001
---
>            -3.16
5105c5105
<            -1.3799999999999999
---
>            -1.38
5119c5119
<            -0.68999999999999995
---
>            -0.69
5133c5133
<            -0.35999999999999999
---
>            -0.36
5147c5147
<            -1.3799999999999999
---
>            -1.38
5161c5161
<            -0.68999999999999995
---
>            -0.69
5175c5175
<            -0.35999999999999999
---
>            -0.36
5287c5287
<            1.4099999999999999
---
>            1.41
5301c5301
<            1.5700000000000001
---
>            1.57
5315c5315
<            2.1099999999999999
---
>            2.11
5400c5400
<            -0.68999999999999995
---
>            -0.69
5414c5414
<            0.17999999999999999
---
>            0.18
5484c5484
<            0.14999999999999999
---
>            0.15
5498c5498
<            2.3999999999999999
---
>            2.4
5512c5512
<            1.6000000000000001
---
>            1.6
5526c5526
<            1.9399999999999999
---
>            1.94
5610c5610
<            1.8300000000000001
---
>            1.83
5666c5666
<            0.42999999999999999
---
>            0.43
5671c5671
<            -2.7999999999999998
---
>            -2.8
5743c5743
<            0.28999999999999998
---
>            0.29
5757c5757
<            1.6100000000000001
---
>            1.61
5813c5813
<            1.1599999999999999
---
>            1.16
5827c5827
<            1.1599999999999999
---
>            1.16
5841c5841
<            0.72999999999999998
---
>            0.73
5883c5883
<            0.42199999999999999
---
>            0.422
5888c5888
<            -7.6299999999999999
---
>            -7.63
6023c6023
<            2.6800000000000002
---
>            2.68
6065c6065
<            2.7200000000000002
---
>            2.72
6079c6079
<            3.6499999999999999
---
>            3.65
6093c6093
<            1.6000000000000001
---
>            1.6
6149c6149
<            2.1899999999999999
---
>            2.19
6205c6205
<            -0.32000000000000001
---
>            -0.32

Cantera 1.8 before set
Mass Fractions: 
[1  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0   0   0   0]
Temperature : 300
cp_mass: 14311,7735529272
cp_R: 
[3,46995185615900   2,50000000008657    2,63400195957100    3,53457252526700    3,593493360
06000   4,04072433633700    4,20111259724400    5,10656488220300    2,50620801655960    3,5089
4749766300  4,21457463772900    4,06474562982700    4,62767913510400    4,30100381516000    3
,50510397612610 4,47626607850120    4,16384948496500    4,26286875842000    5,83000862101
800 4,56926124900000    5,31060943008000    5,05709744859000    5,30815929800600    5,153304
66423000    5,17827407603000    6,09384472404000    6,34068320701000    5,83801560609000    6,2
4193994054500   7,03720016560000    2,50000000000000    3,51104698813000    4,0735824308700
0   4,29363353826000    4,17288764859000    3,59110879790000    4,47823303484000    4,65582454
878000  4,07741176613000    3,50699764595400    4,32080224032000    4,61091860843900    5,920
21334382000 5,64234296784540    5,57677517634728    5,60164502284520    4,83254802485000    
3,49697672760000    2,50000000000000    8,60981559770000    8,89414347493000    6,6308125575
0000    6,67587616020000]
after set:
Mass Fractions: 
[0  0   0   0,220067884973670   0   0   0   0   0   0   0   0   0   0,0551660728267965  0   0   0   0   0   0   0   0   0   
0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0,724766042199534   0   0   0   0   0
]
Temperature : 1200
cp_mass: 1397,19335483438
cp_R: 
[3,72844821853536   2,49999999841448    2,51189398012538    4,28779740191616    3,805546530
93056   5,27721931624512    5,96756913354240    7,89868705568320    2,50052464662195    4,0622
4610818688  5,64355350957888    5,63363600975360    7,60458548249216    9,79076282927200    4
,10721262319424 6,77207205701696    6,05034705087104    7,98796799464960    9,89198837788
864 10,0291929114240    11,6815512026080    6,71282520346880    8,61730623692032    10,25221
26350182    12,2304353253504    14,0546719347264    16,0893384765760    8,69045325012480    10,
7424075507366   11,0951339830464    2,50242646453248    3,89179271162880    5,5590472042201
6   7,33217112743040    6,00668442877440    4,18358402734336    6,54953105452800    6,85147282
020992  6,14034496567782    4,11640894094528    6,31378054484480    8,14212946615040    8,844
44976471040 8,91471384018240    8,33910428077568    8,71888666320320    6,88740883298944    
4,05407978800640    2,50000000000000    20,5845144150976    22,6308630908416    12,439787282
6880    14,4823796133632]

Cantera 2 before set
There is the following warning:
WARNING: 'class GRI_30_Kinetics' is deprecated. To be removed in Cantera 2.2.
Mass Fractions: 
[1  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0   0   0   0]
Temperature : 300
cp_mass: 14311,7562537744
cp_R: 
[3,46995185615900   2,50000000008657    2,63400195957100    3,53457252526700    3,593493360
06000   4,04072433633700    4,20111259724400    5,10656488220300    2,50620801655960    3,5089
4749766300  4,21457463772900    4,06474562982700    4,62767913510400    4,30100381516000    3
,50510397612610 4,47626607850120    4,16384948496500    4,26286875842000    5,83000862101
800 9,21728735036433    5,31060943008000    5,05709744859000    5,30815929800600    5,153304
66423000    5,17827407603000    6,09384472404000    6,34068320701000    30,4364766866527    6,2
4193994054500   7,03720016560000    2,50000000000000    70,2029521583164    4,0735824308700
0   4,29363353826000    4,17288764859000    3,59110879790000    12,3476449536445    4,65582454
878000  4,07741176613000    3,50699764595400    4,32080224032000    37,4824063447828    65,34
94676731049 5,64234296784540    5,57677517634728    5,60164502284520    30,2225108763708    
5,68597391415352    2,50000000000000    24,4251189389731    -0,460445890719813  12,8670940
728200  6,67587616020000]
after set:
Mass Fractions: 
[0  0   0   0,220067884973670   0   0   0   0   0   0   0   0   0   0,0551660728267965  0   0   0   0   0   0   0   0   0   
0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0,724766042199534   0   0   0   0   0
]
Temperature : 1200
cp_mass: 11100,2901274369
cp_R: 
[3,72844821853536   2,49999999841448    2,51189398012538    4,28779740191616    3,805546530
93056   5,27721931624512    5,96756913354240    7,89868705568320    2,50052464662195    4,0622
4610818688  5,64355350957888    5,63363600975360    7,60458548249216    9,79076282927200    4
,10721262319424 6,77207205701696    6,05034705087104    7,98796799464960    9,89198837788
864 78,3071426294705    11,6815512026080    6,71282520346880    8,61730623692032    10,25221
26350182    12,2304353253504    14,0546719347264    16,0893384765760    221,420015282906    10,
7424075507366   11,0951339830464    2,50242646453248    425,994426333271    5,5590472042201
6   7,33217112743040    6,00668442877440    4,18358402734336    95,7311120379323    6,85147282
020992  6,14034496567782    4,11640894094528    6,31378054484480    271,654041485906    446,7
61123078705 8,91471384018240    8,33910428077568    8,71888666320320    200,205594193094    
49,1612420694706    2,50000000000000    188,308712318224    24,1169863286981    104,92185078
5157    14,4823796133632]

I don't know how to explain these differences.

I haven't installed the full Python module but only minimal Python module.

I will try h2o2.xml soon.

Original comment by Luigi.Ac...@gmail.com on 5 Aug 2013 at 10:18

GoogleCodeExporter commented 9 years ago
The only meaningful change to the included XML file is the one that changes the 
kinetics model from "GRI30" to "GasKinetics". The rest are equivalent 
representations of floating point numbers.

The warning that you get, "WARNING: 'class GRI_30_Kinetics' is deprecated. To 
be removed in Cantera 2.2." strongly suggests that you are not using the 
gri30.xml file from Cantera 2.1. You can confirm that this is the case by 
making a copy of gri30.xml from Cantera 2.1 with a different name, e.g. 
gri30a.xml, and using that file instead. 

The fact that you're getting matching cp/R values for most but not all species 
also suggests that you have a copy of gri30.xml that's been modified in some 
way, as does that fact that the tests (many of which use the GRI mechanism) 
pass.

Original comment by yarmond on 5 Aug 2013 at 2:28

GoogleCodeExporter commented 9 years ago
I copied the file gri30.xml from the folder 
/usr/local/cantera2/share/cantera/data to the folder /home/luigi/Scrivania with 
the name gri30a.xml as suggested. 
After I used the Matlab script: 

run('/usr/local/cantera2/lib/cantera/matlab/toolbox/ctpath.m');
gas = IdealGasMix('gri30a.xml','gri30');
Cp_R = cp_R(gas)';

the results is the same:

cp_R : 
[3,46995185615900   2,50000000008657    2,63400195957100    3,53457252526700    3,593493360
06000   4,04072433633700    4,20111259724400    5,10656488220300    2,50620801655960    3,5089
4749766300  4,21457463772900    4,06474562982700    4,62767913510400    4,30100381516000    3
,50510397612610 4,47626607850120    4,16384948496500    4,26286875842000    5,83000862101
800 9,21728735036433    5,31060943008000    5,05709744859000    5,30815929800600    5,153304
66423000    5,17827407603000    6,09384472404000    6,34068320701000    30,4364766866527    6,2
4193994054500   7,03720016560000    2,50000000000000    70,2029521583164    4,0735824308700
0   4,29363353826000    4,17288764859000    3,59110879790000    12,3476449536445    4,65582454
878000  4,07741176613000    3,50699764595400    4,32080224032000    37,4824063447828    65,34
94676731049 5,64234296784540    5,57677517634728    5,60164502284520    30,2225108763708    
5,68597391415352    2,50000000000000    24,4251189389731    -0,460445890719813  12,8670940
728200  6,67587616020000
]

There is still a not expected negative value. However there is not the previous 
warning. 

Original comment by Luigi.Ac...@gmail.com on 5 Aug 2013 at 2:51

Attachments:

GoogleCodeExporter commented 9 years ago
I have verified again my system configuration. I'm using Ubuntu 11.10 and 
Matlab 2011a.

Original comment by Luigi.Ac...@gmail.com on 5 Aug 2013 at 2:53

GoogleCodeExporter commented 9 years ago
Can you try removing the line:

    blas_lapack_libs = 'blas,lapack'

from cantera.conf? I believe this problem has the same underlying cause as 
Issue 34.

Original comment by yarmond on 5 Aug 2013 at 3:37

GoogleCodeExporter commented 9 years ago
Thank you. I have solved the problem by removing the line blas_lapack_libs = 
'blas,lapack' from cantera.conf and by recompiling the package.

Original comment by Luigi.Ac...@gmail.com on 5 Aug 2013 at 4:13

GoogleCodeExporter commented 9 years ago
Thanks for the confirmation that that change fixes it. 

The modifications in r2267, which introduce LAPACK/BLAS calls while creating 
setting up the NASA polynomial objects, are what cause this behavior to 
manifest in this particular instance.

Original comment by yarmond on 5 Aug 2013 at 4:41