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
  • Index
  • » Users
  • » BobF
  • » Profile

Posts

Posts

Hi,

Are there any compile flags (or any other method) that would make it possible to re-simulate a model with a conditional component (e.g. Modelica.Electrical.Analog.Basic.Resistor resistor1(R=R) if incRes) without the need to re-compile if the the Boolean "incRes" changes?

Thanks, Bob

Hi,

How can I find which variables OpenModelica selected as state variables?

Is there an option to output only the state variables to the results file?

Thank you, Bob

Hello,

I'd like to know the most efficient way to use a large(ish) matrix within a model, but keep the matrix data hidden inside the compiled executable, rather than reading the data from an external file that contains sensitive IP.

There are about 10 tables in the model, declared as below and used in CombiTable2D look-up tables
constant Real table1[10,200] = [ ... ; ...; ...;]
constant Real table2[10,200] = [ ... ; ...; ...;]
...

When using the "tableOnFile = true" option for the CombiTable2D (no arrays declared in the model), the model compiles quickly, but not so if the arrays are embedded in the *.mo file like "constant Real table1[10,200] = [ ... ; ...; ...;]" and the  "tableOnFile = false" option is used.

I tried setting some compiler flags a=true, v=5000, rml=true, but no reduction to the compile time.

Any suggestions?

Thanks Bob

Dec-06-17 17:34:08
Share input signal causes more state events than are required

The setup in the attached file "correctNumberOfStateEvents" is:
A sine source feeds a zeroCrossing block with a booleanExpression defining its "enable" port; the output from the zeroCrossing block is connected to the "set" port of an rSFlipFlop block. This configuration is repeated, the first has the "enable" booleanExpression as "time>0.2 and time<0.3", the repeated configuration has "time>1.2 and time<1.3". The model is simulated for 2 seconds and produces the expected number of state events in the output log file (about 8). All's good.

The setup in the attached file "tooManyStateEvents" is:
Exactly the same as above except the 2 configurations share the same sine source block. This leads to a state event being triggered at every zero crossing event throughout the simulation (about 40+) with the "enable" port signals apparently being ignored.

Any thoughts as to whether this is expected behaviour or a bug?

Thanks, Bob

correctNumberOfStateEvents.mo

tooManyStateEvents.mo

Hello,

I notice that in this directory:

C:\OpenModelica1.9.4-dev\lib\omlibrary\Modelica trunk\Math

The file "FastFourierTransform.mo" appears to have some useful looking FFT capabilities. And documented here http://www.ep.liu.se/ecp/118/053/ecp15118491.pdf

Will this be coming to OpenModelica any time soon?

Thanks, Bob

Jan-14-16 14:58:56
Trouble compiling usertab external function

Hello,

I don't know C/C++ coding, but Googling here gives a possible clue. I searched for "usertab" within *.h and *.c files in the OpenModelica install directory.

The files "ModelicaStandardTables.c" and the "usertab.c" files both have an int declaration "usetab" i.e. int usertab(char *tableName, int nipo, int dim[], int *colWise,
            double **table) {...

I tried making the "int" in usetab.c a "static int", which enabled the model to be compiled, but then simulation output gives the error message:

Function "usertab" is not implemented
Process crashed
Simulation process failed. Exited with code -1.

Thanks, Bob

Jan-13-16 23:05:21
Trouble compiling usertab external function

Hello,

The Modelica.Blocks.Tables library info, describes "Special interest topic: Statically stored tables for real-time simulation targets". these use  "usertab.c" and "usertab.h" files, and an example of how to use them is given. I've had to modify the example slightly (one too many / in the url and initial clock values required), as shown below. When compiled, the following error is displayed (next below). Any suggestions as what should be changed to get this to compile?

Thanks, Bob

C:/OpenModelica1.9.4-dev//lib//omc/libModelicaStandardTables.a(ModelicaStandardTables.o): In function `usertab':
c:\dev\OpenModelica\OMCompiler\3rdParty\ModelicaExternalC\BuildProjects\autotools/../../C-Sources/ModelicaStandardTables.c:4526: multiple definition of `usertab'
Test25_usertab_v2_functions.o:Test25_usertab_v2_functions.ccurrent/sad.text+0x1a4): first defined here
collect2: ld returned 1 exit status
\MinGW\bin\mingw32-make: *** [omc_main_target] Error 1
Compilation process failed. Exited with code 2.



model Test25_usertab_v2
  extends Modelica.Icons.Example;
public
  Modelica.Blocks.Sources.RealExpression realExpression(y=getUsertab(t_new.y))
    annotation (Placement(transformation(extent={{-40,-34},{-10,-14}})));
  Modelica.Blocks.Tables.CombiTable1D t_new(tableOnFile=true, tableName="TestTable_1D_a")
    annotation (Placement(transformation(extent={{-40,0},{-20,20}})));
  Modelica.Blocks.Sources.Clock clock(offset = 0, startTime = 0) annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
protected
  encapsulated function getUsertab
    input Real dummy_u[:];
    output Real dummy_y;
   
    external "C" dummy_y=  mydummyfunc(dummy_u);
    annotation(IncludeDirectory="modelica://Modelica/Resources/Data/Tables",
           Include = "#include \"usertab.c\"
double mydummyfunc(const double* dummy_in) {
        return 0;
}
");
  end getUsertab;
equation
  connect(clock.y,t_new. u[1]) annotation (Line(
      points={{-59,10},{-42,10}},
      color={0,0,127},
      smooth=Smooth.None));
  annotation (experiment(StartTime=0, StopTime=5), uses(Modelica(version="3.2.1")));
end Test25_usertab_v2;

Jan-09-16 08:50:25
Array of CombiTable2d combined with interpolate function to make 3d table

Thanks Matthis,

It certainly looks very useful and I will have a play when I've had more Modelica experience.

Regards, Bob

Jan-04-16 17:39:46
Array of CombiTable2d combined with interpolate function to make 3d table

Hello Matth,

There seems to be no content in the library and include directories, just ".gitignore" files. Otherwise it does look like a useful package, but I'm weary at this stage (with my limited Modelica experience) of spending too much time on something with such little documentation. But thanks very much for the pointers, and I may well follow them up when I've gained a few more Modelica flying hours.

Regards, Bob

Jan-04-16 11:58:34
Array of CombiTable2d combined with interpolate function to make 3d table

Hello matth,

Thanks for the links, they look very interesting.

External C code libraries are possibly a bit beyond my current abilities and I didn't see any spoon fed examples. But definitely one for the future.

Regards, Bob

Jan-03-16 17:10:17
Array of CombiTable2d combined with interpolate function to make 3d table

Hello,
I'm trying to make a 3d look-up table component, by using several CombiTable2d tables whose output will populate an array of ordinates that can be used by the Modelica.Math.Vectors.interpolate function, to give a single Real output.

The CombiTable2d table's data will not be read from file but instead hardwired from values in declared arrays.

I'm using the following sources as guidance:

http://book.xogeny.com/components/subsy … s/#index-0
https://www.modelica.org/events/modelic … sion5a.pdf
Peter Fritzson book (2nd Ed.)

The code below is as far as I've got, but when run in OM the "y" output from each of the two CombiTable2d tables is the same (both 2.63) whereas one should be 1.36. Clicking the "Instantiate Model" button in OMEdit, it confirms that both tables are being feed the same array data.

I haven't used Modelica before so I'm seeking a bit of guidance as to how best to go about this. I have used causal block diagram software before and soon felt the pain and its limitation when is came to model modifications and maintenance. Modelica's equation based components seem like wizardry in comparison.

Thanks for any help,  Bob Flandard

______________________________________________________________________________________________________________________
!!! Start of my sample model code !!!
model testArrays2

Modelica.Blocks.Interfaces.RealInput x1 annotation(Placement(visible = true, transformation(origin = {-100, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-94, 58}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));

Modelica.Blocks.Interfaces.RealInput x2 annotation(Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-92, -2}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));

Modelica.Blocks.Interfaces.RealInput x3 annotation(Placement(visible = true, transformation(origin = {-100, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-92, -58}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));


parameter Integer nTabs=2;
parameter Real MyTable1[4,4]=[0, 0 , 5, 10;
                            0, 1.36, 10, -10;
                            5, 2, 20, -20;
                            10, 3, 30, -30];
                           
parameter Real MyTable2[4,4]=[0, 0 , 5, 10;
                            0, 2.63, 13, -1;
                            5, 3, 15, -6.5;
                            10, 4, 21, -21.2];
                                                   
encapsulated record LUT
      Real table[4,4];
end LUT;


parameter LUT[nTabs] MyLUTs={LUT(MyTable1),LUT(MyTable2)};

Modelica.Blocks.Tables.CombiTable2D My2DTables[nTabs](table= array(MyLUTs[i].table for i in 1:nTabs));
                                                 
equation
for i in 1:nTabs loop
   My2DTables[i].u1 = abs(x1);
   My2DTables[i].u2 = abs(x2);
end for;
end testArrays2;
!!! End of my sample model code !!!

______________________________________________________________________________________________________________________
!!! Start code snippets from "Instantiate Model" !!!
protected Modelica.Blocks.Types.ExternalCombiTable2D My2DTables[1].tableID = Modelica.Blocks.Types.ExternalCombiTable2D.constructor("NoName", "NoName", {{0.0, 0.0, 5.0, 10.0}, {0.0, 2.63, 13.0, -1.0}, {5.0, 3.0, 15.0, -6.5}, {10.0, 4.0, 21.0, -21.2}}, Modelica.Blocks.Types.Smoothness.LinearSegments) "External table object";
  protected parameter Real My2DTables[1].tableOnFileRead(fixed = false) "= 1, if table was successfully read from file";

  protected Modelica.Blocks.Types.ExternalCombiTable2D My2DTables[2].tableID = Modelica.Blocks.Types.ExternalCombiTable2D.constructor("NoName", "NoName", {{0.0, 0.0, 5.0, 10.0}, {0.0, 2.63, 13.0, -1.0}, {5.0, 3.0, 15.0, -6.5}, {10.0, 4.0, 21.0, -21.2}}, Modelica.Blocks.Types.Smoothness.LinearSegments) "External table object";
  protected parameter Real My2DTables[2].tableOnFileRead(fixed = false) "= 1, if table was successfully read from file";
!!! End code snippets from "Instantiate Model" !!!
______________________________________________________________________________________________________________________

  • Index
  • » Users
  • » BobF
  • » Profile
You are here: