media and fluid draft 2010-10-28 adrian pop & martin sjölund [[email protected],...
TRANSCRIPT
![Page 1: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/1.jpg)
Media and Fluid
Draft 2010-10-28
Adrian Pop & Martin Sjölund[[email protected], Martin.Sjö[email protected]]
![Page 3: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/3.jpg)
3
Requirements (I)
Front End (from Francesco) full support of replaceable redeclare extends of
functions, records and packages, as you can easily see by browsing, e.g., Modelica.Media.IdealGases.Common.SingleGasNasa
full support of arrays of records full support of package constants (including arrays
of records of constants): they are used widely in the package, for some reason they were often a problem in earlier versions of Dymola, and I somehow got the impression that they are also problematic in OMC, though I have difficulties understanding what's difficult about constants :)
![Page 4: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/4.jpg)
4
Requirements (II)
Back End (from Francesco) function inlining (I understand this is now firmly in
place) lateInline might help with the water/steam model,
but it is not essential common subexpression elimination can be
beneficial to avoid unnecessary multiple evaluations of heavy functions
tearing is essential in order to solve real-life nonlinear models efficiently
![Page 5: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/5.jpg)
5
Milestone White December (I)
Milestone White December Report
https://openmodelica.org:8443/cb/proj/report/execute.do?doc_id=1456
1336 Implement a preprocessing phase from SCode to SCode that simplifies instantiation
1334 Do dependency analysis in instElementList
1332 Media: Redeclare record doesn't work correctly
1333 Rewrite Cevalfunc to use the instantiated DAE instead of SCode.
NO (1327 Use DAE.Type instead of DAE.ExpType everywhere) MetaModelica profiling Back-end/Front-end separation
![Page 6: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/6.jpg)
6
Milestone White December (II)
https://openmodelica.org:8443/cb/issue/1336
Implement an preprocessing phase that removes
extends (copies the components from base class and applies the modifications)
imports (transforms all type names to fully qualified ones) redeclare (applies the redeclares by replacing the redeclared
parts) fully qualifies the class names (SCode.name becomes
SCode.path).
This will benefit us several ways instantiation will be easier and more robust. lookup will be less complex error messages will be better API functionality will not require partial instantiation
![Page 7: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/7.jpg)
7
Milestone White December (III)
https://openmodelica.org:8443/cb/issue/1334
Do dependency analysis in instElementList In order to instantiate Modelica.Media models, we need to instantiate elements
in the order of dependencies. First constants, then parameters, then variables. You need to start with constants that have no dependencies on other constants in the package. As a first step, we could simply say that constants with bindings that contain function calls are instantiated after any other constant (functions may refer to constants in this package). If this does not solve the issues, we need all dependencies in all functions called by this function, etc.
You can verify that this solves some issues in Modelica.Media by changing the order of the declared constants in packages.
Note: You cannot do the dependency analysis lazy (instElement on another element if we realize it's needed). The reason for this is that you sometimes end up with infinite loops.
In Inst.Classdef2 we currently sort all conditional components so that they are instantiated last, since they might depend on other components (this is safe to do, since conditional components can't be dependencies of each other or other components). If we do dependency checking I guess this is not needed any more.
![Page 8: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/8.jpg)
8
Milestone White December (IV)
https://openmodelica.org:8443/cb/issue/1332
Media: Redeclare record doesn't work correctly The correct record constructors are not added to the FunctionTree. Plus,
Cevalfunc does not work which means Media becomes really slow
class C record myR end myR;end C;
class B replaceable record R end R;end B;
class A extends B(redeclare record R = C.myR); Real r = fn(); function fn output Real r; algorithm R(); r := 42.42; end fn;end A;
![Page 9: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/9.jpg)
9
Milestone White December (V)
https://openmodelica.org:8443/cb/issue/1333
Rewrite Cevalfunc to use the instantiated DAE instead of SCode
Today Cevalfunc uses SCode (why is doing that, nobody knows, maybe BZ).
We should rewrite it so it uses the *ALREADY* instantiated DAE forthe function and interpret the DAE algorithm.
This will also speed up the function evaluation as you won‘t do Static.elabExp and Ceval.ceval all over again.
This is also needed for Modelica.Media as Cevalfunc doesn't handle extended or derived functions and some other things.
![Page 10: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/10.jpg)
10
Milestone White December (VI)
https://openmodelica.org:8443/cb/issue/1327
Use DAE.Type instead of DAE.ExpType everywhere
Right now we have two types: DAE.Type which we translate to DAE.ExpType.
We should *REMOVE* DAE.ExpType as the DAE.Type -> DAE.ExpType translation consumes a lot of CPU and Memory for nothing.
![Page 12: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/12.jpg)
12
Milestone White December (VII)
https://openmodelica.org:8443/cb/issue/1269
Implement stream connectors one-to-one connection only Implement stream connectors, the one-to-one connection only Modelica Specification 3.2, page 176-177 For inside-inside connections no equations are added. For outside-inside connections one equality equation is added.
inStream operator actualStream operator
![Page 13: Media and Fluid Draft 2010-10-28 Adrian Pop & Martin Sjölund [Adrian.Pop@liu.se, Martin.Sjölund@liu.se]Adrian.Pop@liu.seMartin.Sjölund@liu.se](https://reader036.vdocuments.site/reader036/viewer/2022072013/56649e535503460f94b49ef2/html5/thumbnails/13.jpg)
13
The End
This document is stored in Subversion (not yet, but it will be)https://
openmodelica.ida.liu.se/svn/OpenModelica/trunk/doc/performance
www.OpenModelica.org