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
  • » dael
  • » Profile

Posts

Posts

Mar-09-12 20:22:53
standardization of "Flat Modelica" ?
Category: Programming

My coworkers will be delighted to hear that!

So you know, if OpenModelica's flavor of flat would then be similar to Dymola's flavor of flat code? Or are there other differences between the tools? (Thoroughness of substitution in loop indices, etc)

Mar-08-12 21:18:09
standardization of "Flat Modelica" ?
Category: Programming

You mean the sections 5.6.1 - 5.6.3 of the Modelica specification? Those are very terse indeed.

Too bad there isn't one standard though. We have a couple of tools at our institute that work on flat Modelica code, but only on the Dymola flavor. I recently looked at whether we could also use OpenModelica's flavor of Flat Modelica in place, but since OpenModelica breaks arrays and matrices into lots of scalar variables it would be a terrible chore to make it work.

I was a bit puzzled as to why OpenModelica breaks them up this way. With Dymola, it's quite easy to take a Dymola-flavored flat model, replace the dots in the variable names, and re-insert the code into any Modelica tool where it will, again, be a proper Modelica model. With the OpenModelica flavor, it seems a little more involved, since you'd have to piece the matrices back together. Or replace the brackets as well, but then you'd get a totally scalarized Modelica model which, to me, seems not nearly as useful (for any purpose outside C-code generation) as one that keeps the basic data structures intact?

Regards,
David

Mar-08-12 15:26:58
standardization of "Flat Modelica" ?
Category: Programming

Hello,

Is there a documentation available anywhere that lays out the rules by which the "flat" code is generated from a given Modelica model?

(I.e. when you press the "Instantiate Model" button in the OpenModelica Connection Editor)

The code is quite different from what Dymola gives you as flat code.

Regards,
David

I just checked on Wikipedia for free XML editors, and "CAM editor" as well as "Serna XML" came up high on their lists.

Can you recommend either one, or another freely available XML editor?

Oops! Now I see it too.

My text editor highlighted everything that came after "<ScalarVariable" with red and I did not notice the closing >. so I thought there was something wrong with the XML.

Sorry!

Hi Adrpo,

But the code you posted has the same thing. Isn't the "Scalarvariable" opening tag supposed to have < in front and > at the end? Or am I wrong about what XML is supposed to look like?

As in:

Code:


<ScalarVariable>
    name = "y"
    ...

Feb-09-12 17:40:54
Error when trying to simulate in OMEdit
Category: Developer

Or is that a problem with the compiler? If so, how can I swap the compiler for something else?

Feb-09-12 17:39:12
Error when trying to simulate in OMEdit
Category: Developer

Hi there,

I started looking at OM today as an alternative to Dymola, for a mechanical engineering class in which I teach Modelica (as a TA).

Is it correct that OM cannot handle non-ASCII characters (ü, ä, ö, ß and so on) in path names, file names, variable annotations or any place?? When I load and check a model, everything is fine, but when I press the little green button to start a simulation I get an error message that reads:

"Process crashed throw    | [line] 255 | [file] simulation/simulation_input_xml.cpp | simulation_input_xml.cpp: Error: failed to read the XML file Exercise4.MainModel_init.xml: not well-formed (invalid token) at line 171"

where line 171 of the respective file is description = "Ůderung der Federl寧e m"

That line contained a German text that said "Änderung der Federlänge m" and is displayed correctly in the OMEdit model editor window. Somewhere though the program that wrote the XML file screwed up the non-ASCII characters Ä and ä.

It seems to me that this should be rather easy to fix, no?

It may be a trivial issue on one hand from a programming point of view ("just don't use those characters"), but on the other hand, it's extremely annoying from a user point of view when you already ~100 exercises that all have such characters somewhere. I thought the days where you should stick to ASCII characters and limit file names to 8 characters were long gone. current/sad

All the opening XML tags in the _init.xml files are missing their closing bracket, too, like the "ScalarVariable" tag in this snippet:

  <ScalarVariable
    name = "pendel2.x0"
    valueReference = "1026"
    description = "x-Position des Lagers in m"
    ...
  </ScalarVariable>

Latest Release version, 1.8.1

That's not supposed to be missing, is it? Same cause as the issue mentioned in the initial post?

Nov-11-11 12:58:31
Category: Programming

We also got the "Introduction" book in our institute's library. It is indeed more like a "light" course book intended for Modelica beginners, mostly with examples from the 2001 "Principles" book. My version (Wiley / IEEE press) is 211 page long (not 232 as announced on Amazon for a probably slightly different version?)

However it definitely does not replace "Principles" as a day-to-day reference work for experienced users.

Nov-10-11 17:52:32
Modelling a changing mechanical system
Category: Programming

Hi,

The Modelica language has no way to add components (= variables and equations) at runtime.

You can however define prior to the start of simulation for example 1000 tether elements, and change their state variables during runtime from being fixed at zero to whatever you need in your simulation.

You need to define events in your simulation that are triggered whenever a new tether element is supposed to become "active" or "inactive". Upon triggering the event, the states of the activated element would change from being fixed states to being governed by a dynamic equation (i.e. become part of the DAE system).

The Dymola simulator  can handle this and I assume that OpenModelica can do so too. However events will slow down the simulation no matter how efficiently you have programmed them, so whether this is an option for you is something you'd have to find out for yourself.

Aug-19-11 11:13:01
Category: Programming

I have never used OpenModelica but the Standard Modelica library comes with documentation included. It is not so hard if you read that.

From the documentation of CombiTimeTable (Modelica Standard Library as delivered with Dymola 7.1):


This block generates an output signal y[:] by linear interpolation in a table. The time points and function values are stored in a matrix table[i,j], where the first column table[:,1] contains the time points and the other columns contain the data to be interpolated.

Via parameter columns it can be defined which columns of the table are interpolated. If, e.g., columns={2,4}, it is assumed that 2 output signals are present and that the first output is computed by interpolation of column 2 and the second output is computed by interpolation of column 4 of the table matrix. The table interpolation has the following properties:

    * The time points need to be monotonically increasing.
    * Discontinuities are allowed, by providing the same time point twice in the table.
    * Values outside of the table range, are computed by extrapolation according to the setting of parameter extrapolation:

Code:

        extrapolation = 0: hold the first or last value of the table,

                           if outside of the range.
                      = 1: extrapolate through the last or first two
                           points of the table.
                      = 2: periodically repeat the table data
                           (periodical function).

* Via parameter smoothness it is defined how the data is interpolated:

Code:


        smoothness = 0: linear interpolation
                   = 1: smooth interpolation with Akima Splines such
                        that der(y) is continuous.

* If the table has only one row, no interpolation is performed and the table values of this row are just returned.
    * Via parameters startTime and offset the curve defined by the table can be shifted both in time and in the ordinate value. The time instants stored in the table are therefore relative to startTime. If time < startTime, no interpolation is performed and the offset is used as ordinate value for all outputs.
    * The table is implemented in a numerically sound way by generating time events at interval boundaries, in order to not integrate over a discontinuous or not differentiable points.
    * For special applications it is sometimes needed to know the minimum and maximum time instant defined in the table as a parameter. For this reason parameters t_min and t_max are provided and can be access from the outside of the table object.

Example:

Code:

   table = [0  0

            1  0
            1  1
            2  4
            3  9
            4 16]; extrapolation = 1 (default)
If, e.g., time = 1.0, the output y =  0.0 (before event), 1.0 (after event)
    e.g., time = 1.5, the output y =  2.5,
    e.g., time = 2.0, the output y =  4.0,
    e.g., time = 5.0, the output y = 23.0 (i.e. extrapolation via last 2 points).

The table matrix can be defined in the following ways:

   1. Explicitly supplied as parameter matrix "table", and the other parameters have the following values:

Code:

         tableName is "NoName" or has only blanks,

         fileName  is "NoName" or has only blanks.

2. Read from a file "fileName" where the matrix is stored as "tableName". Both ASCII and binary file format is possible. (the ASCII format is described below). It is most convenient to generate the binary file from Matlab (Matlab 4 storage format), e.g., by command

Code:

         save tables.mat tab1 tab2 tab3 -V4

when the three tables tab1, tab2, tab3 should be used from the model.
   3. Statically stored in function "usertab" in file "usertab.c". The matrix is identified by "tableName". Parameter fileName = "NoName" or has only blanks.

Table definition methods (1) and (3) do not allocate dynamic memory, and do not access files, whereas method (2) does. Therefore (1) and (3) are suited for hardware-in-the-loop simulation (e.g. with dSpace hardware). When the constant "NO_FILE" is defined in "usertab.c", all parts of the source code of method (2) are removed by the C-preprocessor, such that no dynamic memory allocation and no access to files takes place.

If tables are read from an ASCII-file, the file need to have the following structure ("-----" is not part of the file content):

Code:

-----------------------------------------------------

#1
double tab1(6,2)   # comment line
  0   0
  1   0
  1   1
  2   4
  3   9
  4  16
double tab2(6,2)   # another comment line
  0   0
  2   0
  2   2
  4   8
  6  18
  8  32
-----------------------------------------------------

Note, that the first two characters in the file need to be "#1". Afterwards, the corresponding matrix has to be declared with type, name and actual dimensions. Finally, in successive rows of the file, the elements of the matrix have to be given. Several matrices may be defined one after another.

Parameters

Type    Name    Default    Description
Integer    nout    max([size(columns, 1); size(...    Number of outputs
table data definition
Boolean    tableOnFile    false    = true, if table is defined on file or in function usertab
Real    table[:, :]    fill(0.0, 0, 2)    Table matrix (time = first column; e.g. table=[0,2])
String    tableName    "NoName"    Table name on file or in function usertab (see docu)
String    fileName    "NoName"    File where matrix is stored
table data interpretation
Integer    columns[:]    2:size(table, 2)    Columns of table to be interpolated
Smoothness    smoothness    Modelica.Blocks.Types.Smooth...    Smoothness of table interpolation
Extrapolation    extrapolation    Modelica.Blocks.Types.Extrap...    Extrapolation of data outside the definition range
Real    offset[:]    {0}    Offsets of output signals
Time    startTime    0    Output = offset for time < startTime [s]

Connectors

Type    Name    Description
output RealOutput    y[nout]    Connector of Real output signals

Aug-11-11 12:28:38
Category: Programming

Hello,

I am also very interested in an updated version of Prof. Fritzson's book ("Principles of Object-Oriented Modeling and Simulation with Modelica"). However is the new book linked by matth intended to be an update to "Principles", or is it something else?

I'm asking because the name is different ("Introduction to Modeling and Simulation of Technical and Physical Systems with Modelica") and it says it's "only" 232 pages, whereas "Principles" was around 900 pages.

I find "Principles" to be extremely useful as a day-to-day reference manual for Modelica. Especially the very detailed explanation of functions, data types, and the very advanced examples.

Will there be an updated version for "Principles" some time, too?

Jul-19-11 13:49:47
Category: Programming

Hi,

Why don't you just add the relevant formulae by hand into your model? Just adding the code by hand, without using any part of the library...

Like this:

model MyCircuit
  ... (stuff)
  Real integ_iv(start=0) "Integral over current and voltage at node X";
equation
  ...(stuff)
  der(integ_iv) = Submodel.Subsubmodel.p.i * Submodel.Subsubmodel.p.v ;
end MyCircuit;

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