Opened 6 years ago

Last modified 6 years ago

#5494 new discussion

RemoveSimpleEquations module should remove simple equations with parametric coefficients

Reported by: Maksimov Doe Owned by: Lennart Ochel
Priority: high Milestone: Future
Component: Backend Version:
Keywords: Cc:

Description

RemoveSimpleEquations module cannot remove equations like a = k * b where a and b are some component references and k is a parameter expression. Because of that in the example below compiler cannot deduce that the value of z is zero.

model TestFactorSimpleRemoval
  Real x = time;
  Real y = 2 * time;
  Real z;
equation
  z = 2 * x - y;
end TestFactorSimpleRemoval;

Currently this model produce following equation system

########################################
dumpindxdae
######################################## 
unspecified partition
======================================== Variables (3)
========================================
1: z:VARIABLE() TestFactorSimpleRemoval type: Real 
2: y:VARIABLE() TestFactorSimpleRemoval type: Real 
3: x:VARIABLE() TestFactorSimpleRemoval type: Real  
Equations (3, 3)
========================================
1/1 (1): z = 2.0 * x - y   [dynamic |0|0|0|0|]
2/2 (1): x = time   [binding |0|0|0|0|]
3/3 (1): y = 2.0 * time   [binding |0|0|0|0|] 
Matching
========================================
3 variables and equations
var 1 is solved in eqn 1
var 2 is solved in eqn 3
var 3 is solved in eqn 2 
StrongComponents
========================================
{3:2}
{2:3}
{1:1} 

BackendDAEType: simulation 

Module RemoveSimpleEquations already handles negative sign and work with parametric coefficients could be done in the same manner.

Change History (3)

comment:1 by Martin Sjölund, 6 years ago

I believe the example is bad. time is never considered a simple equation. If it was some other expression it would show a valid enhancement. The thing is that the runtime system does not know about these things (and the simulation result file does not support these kinds of things). For a variable x = 5, we can simply put it in the simulation results as 5 (like a parameter), and for x = y we put it as part of the same column. We also have a special case to invert a variable x = -y.

Tiller and Harman proposed not only this to have aliases:

  • x = alias(y)
  • x = inv(y)

But also the affine transformation:

  • x = aff(y,s,o) (x = y*s + o)

You could of course add such a transformation and simply make the result-files output these in every step.

comment:2 by Maksimov Doe, 6 years ago

I don't think that time variable has a matter, we can replace it with any other component reference.

Considering the affine transformations aliasing, arent that supported in OpenModelica?

Last edited 6 years ago by Maksimov Doe (previous) (diff)

in reply to:  2 comment:3 by Francesco Casella, 6 years ago

Replying to gossen:

Considering the affine transformations aliasing, arent that supported in OpenModelica?

I'm not aware of that, only a = +/-b

Note: See TracTickets for help on using tickets.