Skip to content

Commit 1426ac9

Browse files
author
Jens Frenkel
committed
- remove path from "Get Var " error message
- incidenceRowExp1 matchcontinue -> match - add uode index reduction method, this is the underlying ODE without any constrained stapilization or projection techniques - add print message to unneccesary case in traversingincidenceRowExpSolvableFinder git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14763 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 6c81ce4 commit 1426ac9

File tree

4 files changed

+51
-166
lines changed

4 files changed

+51
-166
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,9 +3693,18 @@ algorithm
36933693
pa = incidenceRowExp1(varslst,p,pa,false);
36943694
then
36953695
((e,false,(vars,pa,ofunctionTree)));
3696+
/* higher derivative, is only present during index reduction */
3697+
case (((e as DAE.CALL(path = Absyn.IDENT(name = "der"),expLst = {DAE.CREF(componentRef = cr),DAE.ICONST(_)}),(vars,pa,ofunctionTree))))
3698+
equation
3699+
(varslst,p) = BackendVariable.getVar(cr, vars);
3700+
pa = incidenceRowExp1(varslst,p,pa,false);
3701+
then
3702+
((e,false,(vars,pa,ofunctionTree)));
36963703

3704+
/* this case should not be here, because it points out that somewhere the dummy var replacement was not done */
36973705
case (((e as DAE.CALL(path = Absyn.IDENT(name = "der"),expLst = {DAE.CREF(componentRef = cr)}),(vars,pa,ofunctionTree))))
36983706
equation
3707+
print("Use the devel case\n");
36993708
cr = ComponentReference.crefPrefixDer(cr);
37003709
(varslst,p) = BackendVariable.getVar(cr, vars);
37013710
pa = incidenceRowExp1(varslst,p,pa,false);
@@ -3784,56 +3793,54 @@ end traversingincidenceRowExpFinder;
37843793
protected function incidenceRowExp1
37853794
input list<Var> inVarLst;
37863795
input list<Integer> inIntegerLst;
3787-
input list<Integer> inIntegerLst1;
3796+
input list<Integer> inVarIndxLst;
37883797
input Boolean notinder;
3789-
output list<Integer> outIntegerLst;
3798+
output list<Integer> outVarIndxLst;
37903799
algorithm
3791-
outIntegerLst := matchcontinue (inVarLst,inIntegerLst,inIntegerLst1,notinder)
3800+
outVarIndxLst := match (inVarLst,inIntegerLst,inVarIndxLst,notinder)
37923801
local
37933802
list<Var> rest;
3794-
list<Integer> irest,res,vars;
3803+
list<Integer> irest,vars;
37953804
Integer i,i1;
37963805
Boolean b;
37973806
case ({},{},vars,_) then vars;
37983807
/*If variable x is a state, der(x) is a variable in incidence matrix,
37993808
x is inserted as negative value, since it is needed by debugging and
38003809
index reduction using dummy derivatives */
3801-
case (BackendDAE.VAR(varKind = BackendDAE.STATE(_)) :: rest,i::irest,vars,b)
3802-
equation
3803-
i1 = Util.if_(b,-i,i);
3804-
failure(_ = List.getMemberOnTrue(i1, vars, intEq));
3805-
res = incidenceRowExp1(rest,irest,i1::vars,b);
3806-
then res;
3807-
case (BackendDAE.VAR(varKind = BackendDAE.STATE_DER()) :: rest,i::irest,vars,b)
3808-
equation
3809-
failure(_ = List.getMemberOnTrue(i, vars, intEq));
3810-
res = incidenceRowExp1(rest,irest,i::vars,b);
3811-
then res;
3812-
case (BackendDAE.VAR(varKind = BackendDAE.VARIABLE()) :: rest,i::irest,vars,b)
3813-
equation
3814-
failure(_ = List.getMemberOnTrue(i, vars, intEq));
3815-
res = incidenceRowExp1(rest,irest,i::vars,b);
3816-
then res;
3817-
case (BackendDAE.VAR(varKind = BackendDAE.DISCRETE()) :: rest,i::irest,vars,b)
3818-
equation
3819-
failure(_ = List.getMemberOnTrue(i, vars, intEq));
3820-
res = incidenceRowExp1(rest,irest,i::vars,b);
3821-
then res;
3822-
case (BackendDAE.VAR(varKind = BackendDAE.DUMMY_DER()) :: rest,i::irest,vars,b)
3823-
equation
3824-
failure(_ = List.getMemberOnTrue(i, vars, intEq));
3825-
res = incidenceRowExp1(rest,irest,i::vars,b);
3826-
then res;
3827-
case (BackendDAE.VAR(varKind = BackendDAE.DUMMY_STATE()) :: rest,i::irest,vars,b)
3828-
equation
3829-
failure(_ = List.getMemberOnTrue(i, vars, intEq));
3830-
res = incidenceRowExp1(rest,irest,i::vars,b);
3831-
then res;
3832-
case (_ :: rest,_::irest,vars,b)
3833-
equation
3834-
res = incidenceRowExp1(rest,irest,vars,b);
3835-
then res;
3836-
end matchcontinue;
3810+
case (BackendDAE.VAR(varKind = BackendDAE.STATE(_)) :: rest,i::irest,_,_)
3811+
equation
3812+
i1 = Util.if_(notinder,-i,i);
3813+
b = List.isMemberOnTrue(i1, inVarIndxLst, intEq);
3814+
vars = List.consOnTrue(not b, i1, inVarIndxLst);
3815+
then incidenceRowExp1(rest,irest,vars,notinder);
3816+
case (BackendDAE.VAR(varKind = BackendDAE.STATE_DER()) :: rest,i::irest,_,_)
3817+
equation
3818+
b = List.isMemberOnTrue(i, inVarIndxLst, intEq);
3819+
vars = List.consOnTrue(not b, i, inVarIndxLst);
3820+
then incidenceRowExp1(rest,irest,vars,notinder);
3821+
case (BackendDAE.VAR(varKind = BackendDAE.VARIABLE()) :: rest,i::irest,_,_)
3822+
equation
3823+
b = List.isMemberOnTrue(i, inVarIndxLst, intEq);
3824+
vars = List.consOnTrue(not b, i, inVarIndxLst);
3825+
then incidenceRowExp1(rest,irest,vars,notinder);
3826+
case (BackendDAE.VAR(varKind = BackendDAE.DISCRETE()) :: rest,i::irest,_,_)
3827+
equation
3828+
b = List.isMemberOnTrue(i, inVarIndxLst, intEq);
3829+
vars = List.consOnTrue(not b, i, inVarIndxLst);
3830+
then incidenceRowExp1(rest,irest,vars,notinder);
3831+
case (BackendDAE.VAR(varKind = BackendDAE.DUMMY_DER()) :: rest,i::irest,_,_)
3832+
equation
3833+
b = List.isMemberOnTrue(i, inVarIndxLst, intEq);
3834+
vars = List.consOnTrue(not b, i, inVarIndxLst);
3835+
then incidenceRowExp1(rest,irest,vars,notinder);
3836+
case (BackendDAE.VAR(varKind = BackendDAE.DUMMY_STATE()) :: rest,i::irest,_,_)
3837+
equation
3838+
b = List.isMemberOnTrue(i, inVarIndxLst, intEq);
3839+
vars = List.consOnTrue(not b, i, inVarIndxLst);
3840+
then incidenceRowExp1(rest,irest,vars,notinder);
3841+
case (_ :: rest,_::irest,_,_)
3842+
then incidenceRowExp1(rest,irest,inVarIndxLst,notinder);
3843+
end match;
38373844
end incidenceRowExp1;
38383845

38393846
public function traversingincidenceRowExpFinderwithInput "
@@ -8374,6 +8381,7 @@ protected
83748381
String strIndexReductionMethod;
83758382
algorithm
83768383
allIndexReductionMethods := {(BackendDAETransform.reduceIndexDummyDer,"dummyDerivative",IndexReduction.noStateDeselection,"dummyDerivative"),
8384+
(IndexReduction.pantelidesIndexReduction,"Pantelites",IndexReduction.noStateDeselection,"uode"),
83778385
(IndexReduction.pantelidesIndexReduction,"Pantelites",IndexReduction.dynamicStateSelection,"dynamicStateSelection")};
83788386
strIndexReductionMethod := getIndexReductionMethodString();
83798387
strIndexReductionMethod := Util.getOptionOrDefault(ostrIndexReductionMethod,strIndexReductionMethod);

Compiler/BackEnd/Derive.mo

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -160,130 +160,6 @@ algorithm
160160
end matchcontinue;
161161
end differentiateEquationTime;
162162

163-
protected function removeCrefFromDerCref "
164-
Author: Frenkel TUD"
165-
input list<DAE.Exp> inCrefOrDerCref;
166-
input list<DAE.Exp> inDerCref;
167-
output list<DAE.Exp> outCrefOrDerCref;
168-
algorithm
169-
outCrefOrDerCref := match(inCrefOrDerCref,inDerCref)
170-
local
171-
list<DAE.Exp> rest,crefOrDerCref,crefOrDerCref1;
172-
DAE.Exp e;
173-
174-
case (inCrefOrDerCref,{}) then inCrefOrDerCref;
175-
176-
case (inCrefOrDerCref,e::rest)
177-
equation
178-
crefOrDerCref = removeCrefFromDerCref(inCrefOrDerCref,rest);
179-
(crefOrDerCref1, _) = List.deleteMemberOnTrue(e,crefOrDerCref,Expression.expEqual);
180-
then
181-
crefOrDerCref1;
182-
end match;
183-
end removeCrefFromDerCref;
184-
185-
protected function traversingcrefOrDerCrefFinder "
186-
Author: Frenkel TUD
187-
Returns a list containing, unique, all componentRef or der(componentRef) in an Expression."
188-
input tuple<DAE.Exp, tuple<list<DAE.Exp>,list<DAE.Exp>,BackendDAE.Variables> > inExp;
189-
output tuple<DAE.Exp, tuple<list<DAE.Exp>,list<DAE.Exp>,BackendDAE.Variables> > outExp;
190-
algorithm
191-
outExp := matchcontinue(inExp)
192-
local
193-
list<DAE.Exp> crefOrDerCref,derCref;
194-
DAE.Exp e,e1;
195-
BackendDAE.Variables timevars;
196-
DAE.ComponentRef cr;
197-
198-
// CREF
199-
case( (e as DAE.CREF(componentRef = cr), (crefOrDerCref,derCref,timevars)) )
200-
equation
201-
// exlude time
202-
failure(DAE.CREF_IDENT(ident = "time",subscriptLst = {}) = cr);
203-
(_,_) = BackendVariable.getVar(cr, timevars);
204-
then
205-
((e, (e::crefOrDerCref,derCref,timevars) ));
206-
207-
// der(CREF)
208-
case ( (e as DAE.CALL(path = Absyn.IDENT(name = "der"),expLst={e1 as DAE.CREF(componentRef = cr)}), (crefOrDerCref,derCref,timevars)) )
209-
equation
210-
(_,_) = BackendVariable.getVar(cr, timevars);
211-
then
212-
((e, (e::crefOrDerCref,e1::derCref,timevars) ));
213-
214-
// der(der(CREF))
215-
case ( (e as DAE.CALL(path = Absyn.IDENT(name = "der"),expLst={e1 as DAE.CALL(path = Absyn.IDENT(name = "der"),expLst={DAE.CREF(componentRef = cr)})}), (crefOrDerCref,derCref,timevars)) )
216-
equation
217-
(_,_) = BackendVariable.getVar(cr, timevars);
218-
then
219-
((e, (e::crefOrDerCref,e1::derCref,timevars) ));
220-
221-
case(inExp) then inExp;
222-
end matchcontinue;
223-
end traversingcrefOrDerCrefFinder;
224-
225-
protected function addArray "
226-
Author: Frenkel TUD"
227-
input Integer inIndex;
228-
input array<Type_a> inArray;
229-
input Type_a inA;
230-
input Integer inNumber;
231-
input list<tuple<Integer,Integer,Integer>> inDerivedArray;
232-
output Integer outIndex;
233-
output array<Type_a> outArray;
234-
output list<tuple<Integer,Integer,Integer>> outDerivedArray;
235-
output Boolean outAdd;
236-
replaceable type Type_a subtypeof Any;
237-
algorithm
238-
(outIndex,outArray,outDerivedArray,outAdd) := matchcontinue (inIndex,inArray,inA,inNumber,inDerivedArray)
239-
local
240-
list<tuple<Integer,Integer,Integer>> rest,derivedArray;
241-
tuple<Integer,Integer,Integer> dArray;
242-
list<Type_a> alst,alst1;
243-
Integer index,index1,dindex,dnumber,dnumber_1;
244-
array<Type_a> a1;
245-
Boolean add;
246-
// no derived functions without outputs
247-
case (inIndex,inArray,inA,inNumber,derivedArray)
248-
equation
249-
true = intEq(inNumber,0);
250-
then
251-
(inIndex,inArray,derivedArray,false);
252-
// not derived
253-
case (inIndex,inArray,inA,inNumber,{})
254-
equation
255-
alst = arrayList(inArray);
256-
alst1 = listAppend(alst,{inA});
257-
a1 = listArray(alst1);
258-
index = arrayLength(inArray);
259-
then
260-
(index,a1,{(inIndex,index,1)},true);
261-
// derived
262-
case (inIndex,inArray,inA,inNumber,(dArray as (index,dindex,dnumber))::rest)
263-
equation
264-
// search
265-
true = intEq(inIndex,index);
266-
true = dnumber < inNumber;
267-
dnumber_1 = dnumber + 1;
268-
then
269-
(dindex,inArray,(index,dindex,dnumber_1)::rest,true);
270-
case (inIndex,inArray,inA,inNumber,(dArray as (index,dindex,dnumber))::rest)
271-
equation
272-
// search
273-
true = intEq(inIndex,index);
274-
false = dnumber < inNumber;
275-
then
276-
(dindex,inArray,(index,dindex,dnumber)::rest,false);
277-
case (inIndex,inArray,inA,inNumber,(dArray as (index,dindex,dnumber))::rest)
278-
equation
279-
false = intEq(inIndex,index);
280-
// next
281-
(index1,a1,derivedArray,add) = addArray(inIndex,inArray,inA,inNumber,rest);
282-
then
283-
(index1,a1,dArray::derivedArray,add);
284-
end matchcontinue;
285-
end addArray;
286-
287163
public function differentiateExpTime "function: differentiateExpTime
288164
This function differentiates expressions with respect to the \'time\' variable.
289165
All other variables that are varying over time are given as the second variable.

Compiler/Util/Flags.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ constant ConfigFlag INDEX_REDUCTION_METHOD = CONFIG_FLAG(15, "indexReductionMeth
619619
NONE(), EXTERNAL(), STRING_FLAG("dynamicStateSelection"),
620620
SOME(STRING_DESC_OPTION({
621621
("dummyDerivative", Util.gettext("simple index reduction method, select dummy states based on heuristics")),
622+
("uode", Util.gettext("use the underlying ode without the constraints")),
622623
("dynamicStateSelection", Util.gettext("simple index reduction method, select (dynamic) dummy states based on analysis of the system"))})),
623624
Util.gettext("Sets the index reduction method to use. See +help=optmodules for more info."));
624625
constant ConfigFlag POST_OPT_MODULES = CONFIG_FLAG(16, "postOptModules",

Compiler/runtime/SimulationResultsCmp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ void* SimulationResultsCmp_compareResults(int runningTestsuite, const char *file
696696
fixCommaInName(&var2,len);
697697
dataref = getData(var2,reffilename,size_ref,&simresglob_ref);
698698
if (dataref.n==0) {
699-
fprintf(stderr, "Get Data of Var %s from file %s failed\n",var,reffilename);
699+
fprintf(stderr, "Get Data of Var %s from file %s failed\n",var,runningTestsuite ? SystemImpl__basename(reffilename) : reffilename);
700700
c_add_message(-1, ErrorType_scripting, ErrorLevel_warning, gettext("Get Data of Var failed!\n"), msg, 0);
701701
ngetfailedvars++;
702702
continue;
@@ -710,7 +710,7 @@ void* SimulationResultsCmp_compareResults(int runningTestsuite, const char *file
710710
data = getData(var1,filename,size,&simresglob_c);
711711
if (data.n==0) {
712712
if (data.data) free(data.data);
713-
fprintf(stderr, "Get Data of Var %s from file %s failed\n",var,filename);
713+
fprintf(stderr, "Get Data of Var %s from file %s failed\n",var,runningTestsuite ? SystemImpl__basename(filename) : filename);
714714
c_add_message(-1, ErrorType_scripting, ErrorLevel_warning, gettext("Get Data of Var failed!\n"), msg, 0);
715715
ngetfailedvars++;
716716
continue;

0 commit comments

Comments
 (0)