- Index
- » Programming
- » Modelica Language
- » Incorrect handling of Composition...
Incorrect handling of Composition Vector in MixtureGasNasa
Incorrect handling of Composition Vector in MixtureGasNasa
1. The redecalred function setStat_phX in MixtureGasNasa package (in Modelica 3.2.2) has logic to enable
setting the state composition vector (full) properly if user passes the reduced vector as its input.
state := if size(X,1) == 0 then
689 ThermodynamicState(p=p,T=T_hX(h,reference_X),X=reference_X)
690 else if size(X,1) == nX then
691 ThermodynamicState(p=p,T=T_hX(h,X),X=X)
692 else
693 ThermodynamicState(p=p,T=T_hX(h,X), X=cat(1,X,{1-sum(X)}));
But the code (colored in red) ... when executed is executed ... the argument X in the function call T_hX appears to be incorrectly passed.
Either it should have just passed original reduced size vector X or the concatenated( the full) vector. It appears to send a vector of size that is full, but with the end component composition set to zero.
To illustrate the point, I am attaching the "total.mo" for consideration. Here is the output I get when I compile and execute the model. I modified "Modelica 3.2.2/Media/IdealGases/Common/package.mo to provide some debug messages that help. One should expect Xfull to be {0.1,0,1,0.1,0.1,0.1,0.5}
The fix is to change the input argument line in T_hX in the package to
input MassFraction[:] X "Mass fractions of composition";
My compiler version is v1.11.0-dev.23+g1a9bdf2
gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
Linux vishnu 4.2.3-200.fc22.x86_64 #1 SMP Thu Oct 8 03:23:55 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Output from the model execution
record SimulationResult
resultFile = "/home/ravi/DSTO/projects/Om/testing/valve/bug2/work/plant_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-06,
method = 'dassl', fileNamePrefix = 'plant', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "assert | warning |
calling setState_phX ==> nX=6, p=100000, h=100000, X=[0.1, 0.1, 0.1, 0.1, 0.1]
assert | warning
|[b] T_hX Called h = 100000(J/kg) nX = 6 X = [0.1, 0.1, 0.1, 0.1, 0.1, 0] Xfull = [0.1, 0.1, 0.1, 0.1, 0.1, 0] [/b]
",
timeFrontend = 1.455699987,
timeBackend = 0.002906534,
timeSimCode = 0.002218748,
timeTemplates = 0.015725235,
timeCompile = 0.37132361,
timeSimulation = 0.008871003000000001,
timeTotal = 1.856828653
end SimulationResult;
"Warning: Assuming fixed start value for the following 1 variables:
h:VARIABLE(start = 100000.0 unit = "J/kg" ) type: Real
"
simulation done
No. of Plant Variables = 12
1468312980_total.mo
- ravi
- 32 Posts
- Index
- » Programming
- » Modelica Language
- » Incorrect handling of Composition...