Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

extrapolation for a table

extrapolation for a table

I have a model "Driver" which uses a CombiTable "table".

In Driver I defined
parameter Modelica.Blocks.Types.Extrapolation myExtrapolation

that I pass to table.

For OpenModelica extrapolation in CombiTables is structural, and therefore cannot be changed for re-runs.

However, when run Driver, from OMEdit myExtrapolation appears to be modifiable. If I modify it, however, the simulation does not change because the table does not accept changes in its extrapolation when re-simulating.

Is there a way allowing to avoid myExtrapolation to appear modifiable from OMEdit plotting perspective?

Thanks

Edited by: ceraolo - Apr-30-21 07:06:00

Re: extrapolation for a table

How did you pass the parameter in your model?

using the code below the parameter became structural and thus cannot be changed when re-simulating

Code:


parameter Modelica.Blocks.Types.Extrapolation myExtrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint ;
  Boolean isOne;

equation
  if myExtrapolation == Modelica.Blocks.Types.Extrapolation.HoldLastPoint then
    isOne = true;
  end if;

Re: extrapolation for a table

Excellent!
I did as you recommended and solved my issue.

But your solution requires the definition of a new variable. Smart tools can drop it from the equations considering that its defining equation is trivial.
But probably better is defining isOne as a parameter (here I use the name dummy):

  parameter Modelica.Blocks.Types.Extrapolation myExtrapolation = Modelica.Blocks.Types.Extrapolation.LastTwoPoints "Extrapolation of data outside the definition range";
protected
  parameter Boolean dummy( fixed=false);
public
[...]
initial equation
  if myExtrapolation == Modelica.Blocks.Types.Extrapolation.HoldLastPoint then
    dummy = true;
  end if;



Edited by: ceraolo - Jun-07-21 13:30:42

Re: extrapolation for a table

Or could we use final prefix for the parameter? Modelica Langage Spec 3.4 chapter 7.2.6

Code:

final parameter Modelica.Block.Type.Extrapolation myExtrapolation = ... 

my first idea was a bit hacky and i didn't like it  current/big_smile

Edited by: Arinomo23 - Jun-08-21 04:42:11

Re: extrapolation for a table

This won't do the job, since it hides extrapolation from the final user.
I want the final user to be able to choose which extrapolation to apply.

There are 0 guests and 0 other users also viewing this topic