Skip to content

Commit

Permalink
Only use literal nominal values for now (#10969)
Browse files Browse the repository at this point in the history
  • Loading branch information
phannebohm committed Jul 14, 2023
1 parent 1088818 commit 17eda33
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion OMCompiler/Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -15848,7 +15848,12 @@ algorithm

case DAE.CREF(componentRef = cr) algorithm
v := cref2simvar(cr, getSimCode());
then Util.getOptionOrDefault(v.nominalValue, DAE.RCONST(1.0));
// for now only use nominal value if it's a literal
nom1 := match v.nominalValue
case SOME(DAE.RCONST(real = nom1)) then nom1;
else 1.0;
end match;
then DAE.RCONST(nom1);

// a + b = (A*as) + (B*bs) = A*(as + B/A*bs) = B*(A/B*as + bs)
// if A >> B then a+b has nominal value A
Expand Down Expand Up @@ -15977,6 +15982,7 @@ algorithm
then DAE.RCONST(1.0);

// for these just calculate the value
// f(a) = f(A*as) = f(A + A*(as-1)) = f(A) + o(A*(as-1))
case DAE.CALL(path = Absyn.IDENT(name = "sinh"), expLst = {e1}) algorithm
DAE.RCONST(nom1) := getExpNominal(e1);
then DAE.RCONST(sinh(nom1));
Expand All @@ -15989,14 +15995,17 @@ algorithm
DAE.RCONST(nom1) := getExpNominal(e1);
then DAE.RCONST(tanh(nom1));

// exp(a) = exp(A*as) = exp(A)^as
case DAE.CALL(path = Absyn.IDENT(name = "exp"), expLst = {e1}) algorithm
DAE.RCONST(nom1) := getExpNominal(e1);
then DAE.RCONST(exp(nom1));

// log(a) = log(A*as) = log(A) + log(as)
case DAE.CALL(path = Absyn.IDENT(name = "log"), expLst = {e1}) algorithm
DAE.RCONST(nom1) := getExpNominal(e1);
then DAE.RCONST(log(nom1));

// log10(a) = log10(A*as) = log10(A) + log10(as)
case DAE.CALL(path = Absyn.IDENT(name = "log10"), expLst = {e1}) algorithm
DAE.RCONST(nom1) := getExpNominal(e1);
then DAE.RCONST(log10(nom1));
Expand Down

0 comments on commit 17eda33

Please sign in to comment.