Skip to content

Commit

Permalink
[NF] Only add smooth when need to actualStream.
Browse files Browse the repository at this point in the history
- Only add smooth when the flow direction is unknown when evaluating
  actualStream.
  • Loading branch information
perost committed Oct 8, 2019
1 parent fa6b8e7 commit 294d057
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions OMCompiler/Compiler/NFFrontEnd/NFConnectEquations.mo
Expand Up @@ -818,9 +818,9 @@ algorithm
// Select a branch if we know the flow direction, otherwise generate the whole
// if-equation.
if flow_dir == 1 then
rel_exp := evaluateInStream(streamCref, sets, setsArray, ctable);
exp := evaluateInStream(streamCref, sets, setsArray, ctable);
elseif flow_dir == -1 then
rel_exp := Expression.fromCref(streamCref);
exp := Expression.fromCref(streamCref);
else
flow_exp := Expression.fromCref(flow_cr);
stream_exp := Expression.fromCref(streamCref);
Expand All @@ -829,12 +829,12 @@ algorithm
rel_exp := Expression.IF(
Expression.RELATION(flow_exp, op, Expression.REAL(0.0)),
instream_exp, stream_exp);
end if;

// actualStream(stream_var) = smooth(0, if flow_var > 0 then inStream(stream_var)
// else stream_var);
exp := Expression.CALL(Call.makeTypedCall(NFBuiltinFuncs.SMOOTH,
{DAE.INTEGER(0), rel_exp}, Expression.variability(rel_exp)));
// actualStream(stream_var) = smooth(0, if flow_var > 0 then inStream(stream_var)
// else stream_var);
exp := Expression.CALL(Call.makeTypedCall(NFBuiltinFuncs.SMOOTH,
{DAE.INTEGER(0), rel_exp}, Expression.variability(rel_exp)));
end if;
end evaluateActualStream;

function evaluateFlowDirection
Expand Down
4 changes: 2 additions & 2 deletions testsuite/flattening/modelica/scodeinst/ActualStreamMinMax.mo
Expand Up @@ -56,8 +56,8 @@ end ActualStreamMinMax;
// a.s3.r = a.s4.r;
// a.s2.f + a.s1.f = 0.0;
// a.s4.f + a.s3.f = 0.0;
// actual_stream_s1 = smooth(0, a.s2.s);
// actual_stream_s2 = smooth(0, a.s2.s);
// actual_stream_s1 = a.s2.s;
// actual_stream_s2 = a.s2.s;
// actual_stream_s3 = smooth(0, if a.s3.f > 0.0 then a.s4.s else a.s3.s);
// actual_stream_s4 = smooth(0, if a.s4.f > 0.0 then a.s3.s else a.s4.s);
// end ActualStreamMinMax;
Expand Down

0 comments on commit 294d057

Please sign in to comment.