Skip to content

Commit

Permalink
- add the equalityConstraint function to the DAE.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5389 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Apr 26, 2010
1 parent 4902135 commit 0ce4b58
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Compiler/Inst.mo
Expand Up @@ -13795,6 +13795,10 @@ algorithm
Absyn.Path fpath1, fpath2;
Integer dim1, dim2;
DAE.Exp zeroVector;
list<DAE.Element> elements, breakDAEElements;
DAE.FunctionTree functions, equalityConstraintFunctions;
DAE.DAElist equalityConstraintDAE;
SCode.Class equalityConstraintFunction;
equation
c1_1 = PrefixUtil.prefixCref(pre, c1);
c2_1 = PrefixUtil.prefixCref(pre, c2);
Expand All @@ -13816,16 +13820,27 @@ algorithm
// set the source of this element
source = DAEUtil.createElementSource(Env.getEnvPath(env), PrefixUtil.prefixToCrefOpt(pre), SOME((c1_1,c2_1)), NONE());

/* Add an edge to connection graph. The edge contains daes to be added in
both cases whether the edge remains or is broken.
*/
// Add an edge to connection graph. The edge contains the
// dae to be added in the case where the edge is broken.
zeroVector = Exp.makeRealArrayOfZeros(dim1);
graph = ConnectionGraph.addConnection(graph, c1_1, c2_1,
breakDAEElements =
{DAE.EQUATION(zeroVector,
DAE.CALL(fpath1,{DAE.CREF(c1_1, DAE.ET_OTHER()), DAE.CREF(c2_1, DAE.ET_OTHER())},
false, false, DAE.ET_REAL,DAE.NO_INLINE),
false, false, DAE.ET_REAL(), DAE.NO_INLINE()),
source // set the origin of the element
)});
)};
graph = ConnectionGraph.addConnection(graph, c1_1, c2_1, breakDAEElements);

// deal with equalityConstraint function!
// instantiate and add the equalityConstraint function to the dae function tree!
(cache,equalityConstraintFunction,env) = Lookup.lookupClass(cache,env,fpath1,false);
(cache,fpath1) = makeFullyQualified(cache,env,fpath1);
cache = Env.addCachedInstFunc(cache,fpath1);
(cache,env,ih,equalityConstraintDAE) =
implicitFunctionInstantiation(cache,env,ih,DAE.NOMOD(),pre,sets_1,equalityConstraintFunction,{});
equalityConstraintDAE = DAEUtil.addDaeFunction(equalityConstraintDAE);

dae = DAEUtil.joinDaes(dae, equalityConstraintDAE);
then
(cache,env,ih,sets_1,dae,graph);

Expand Down

0 comments on commit 0ce4b58

Please sign in to comment.