jcaiuwyo / cantera

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

Matlab interface handles sparse arrays incorrectly #140

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When a gas is set where the mass fractions are specified as a sparse matrix, 
the resulting gas object does not have the specified concentrations. For 
example:

gas=IdealGasMix('gri30.cti'); %creates gas at 300K, 101325 Pa with y_H2=1
y=sparse(massFractions(gas)); %creates 53x1 sparse double a = (1,1)=1
gas1=set(gas,'Y',y);
gas2=set(gas,'Y',full(y));

it is then apparent that the two resulting gases 1 & 2 are not equivalent.

(Originally reported by Addison Stark in the Cantera User's Group)

Original issue reported on code.google.com by yarmond on 25 Jan 2013 at 4:50

GoogleCodeExporter commented 9 years ago
I think those very small values are actually what happens when Cantera treats 
the sparse array as a dense array and reads uninitialized memory beyond the end 
of the array (since the sparse array is much smaller than the dense one would 
be).

Original comment by yarmond on 25 Jan 2013 at 4:51

GoogleCodeExporter commented 9 years ago

Original comment by yarmond on 25 Jan 2013 at 4:51

GoogleCodeExporter commented 9 years ago
Attached please find a patch to check if a property value is specified by a 
sparse array. I'm not sure what the performance implications of this check 
would be, or whether it is even necessary, but since this bug was here and the 
fix seemed simple, I thought why not.

Bryan

Original comment by bryan.w....@gmail.com on 5 Jan 2014 at 6:08

Attachments:

GoogleCodeExporter commented 9 years ago
The above patch is based on r2644.

Original comment by bryan.w....@gmail.com on 5 Jan 2014 at 6:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2659.

Original comment by yarmond on 6 Jan 2014 at 6:46

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2694.

Original comment by yarmond on 23 Jan 2014 at 3:06