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

Posts

Posts

Oct-15-13 17:19:04
Category: Developer

Thanks for adding this library to the tests. It's one I'd like to keep an eye on.

Mar-27-12 15:57:24
unable to simulate examples

I've seen the same symptoms. I don't think it's the wrong results. The solution just fails prematurely with no error messages. Modelica.Electrical.Analog.Examples.DifferenceAmplifier also stops simulating prematurely.

For Modelica.Electrical.Machines.Examples.AIMC_DOL example, I tried removing the IdealClosingSwitch, the CurrentQuasiRMSSensor, and changed the QuadraticSpeedDependentTorque to a constant torque, but the simulation still ended prematurely.

- Tom

I installed it, I think. I'll investigate and provide more details at the jmodelica.org forum.

Johan, I was unable to run pyfmi or assimulo. I installed the win32 binaries of both on win32 python 2.7 on 64-bit windows 7. Here are some errors:

Code:


>>> import pyfmi
>>> import pyfmi.examples.fmi_bouncing_ball
>>> pyfmi.examples.fmi_bouncing_ball.run_demo()
WARNING:root:Could not find Assimulo package. Check jmodelica.check_packages()
WARNING:root:Could not load Assimulo module. Check pyfmi.check_packages()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\apps\Python27\lib\site-packages\pyfmi\examples\fmi_bouncing_ball.py",
line 35, in run_demo
    res = model.simulate(final_time=2.)
  File "C:\apps\Python27\lib\site-packages\pyfmi\fmi.py", line 1496, in simulate options)
  File "C:\apps\Python27\lib\site-packages\pyfmi\common\core.py", line 196, in _exec_simulate_algorithm
    alg = algorithm(start_time, final_time, input, self, options)
  File "C:\apps\Python27\lib\site-packages\pyfmi\fmi_algorithm_drivers.py", line
180, in __init__
    'Could not find Assimulo package. Check jmodelica.check_packages()')
Exception: Could not find Assimulo package. Check jmodelica.check_packages()



>>> from pyfmi.simulation.assimulo_interface import FMIODE
WARNING:root:Could not find Assimulo package. Check jmodelica.check_packages()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\apps\Python27\lib\site-packages\pyfmi\simulation\assimulo_interface.py", line 94, in <module>
    class FMIODE(Explicit_Problem):
NameError: name 'Explicit_Problem' is not defined


>>> pyfmi.check_packages()

Performing pyfmi package check
==============================

Platform...................... win32

Python version:............... 2.7.2



Dependencies:

Package                        Version
-------                        -------
numpy......................... 1.6.1                          Ok

scipy......................... 0.10.0                         Ok

matplotlib.................... 1.1.0                          Ok

lxml.......................... 2.3.0                          Ok

assimulo...................... n/a                            Ok

wxPython...................... 2.8.12.1                       Ok

pyreadline.................... 1.7.1                          Ok

setuptools.................... 0.6c12                         Ok

Here's a "deeper" example in Modelica.Thermal.FluidHeadFlow.Examples.SimpleCooling. It has a pump (Modelica.Thermal.FluidHeatFlow.Sources.VolumeFlow) with a parameter "medium" with a dropdown box.

Modelica.Thermal.FluidHeatFlow.Sources.VolumeFlow inherits from Modelica.Thermal.FluidHeatFlow.Interfaces.Partials.TwoPort where that parameter is defined as:

  parameter FluidHeatFlow.Media.Medium medium=FluidHeatFlow.Media.Medium()
    "Medium in the component"
    annotation(__Dymola_choicesAllMatching=true);

Here's how Medium is defined:

record Medium "Record containing media properties"
  extends Modelica.Icons.Record;
  parameter Modelica.SIunits.Density rho = 1 "Density";
  parameter Modelica.SIunits.SpecificHeatCapacity cp = 1
    "Specific heat capacity at constant pressure";
  parameter Modelica.SIunits.SpecificHeatCapacity cv = 1
    "Specific heat capacity at constant volume";
  parameter Modelica.SIunits.ThermalConductivity lamda = 1
    "Thermal conductivity";
  parameter Modelica.SIunits.KinematicViscosity nue = 1 "kinematic viscosity";
end Medium;

In addition to a dropdown box, you get a button next to the dropdown to specify the object's parameters.

Dymola also offers dropdown boxes for the following situation. Look at Modelica.Electrical.Digital.Examples.Multiplexer.

The MUX component has a q0 parameter with a dropdown box. The parameter is defined in Modelica.Electrical.Digital.Examples.Multiplexer as:

parameter D.Interfaces.Logic q0=L.'0' "initial value";

This is defined in  Modelica.Electrical.Digital.Interfaces.Logic as:

type Logic = enumeration(
    'U' "U  Uninitialized",
    'X' "X  Forcing Unknown",
    '0' "0  Forcing 0",
    '1' "1  Forcing 1",
    'Z' "Z  High Impedance",
    'W' "W  Weak    Unknown",
    'L' "L  Weak    0",
    'H' "H  Weak    1",
    '-' "-  Don't care")
  "Logic values and their coding according to IEEE 1164 STD_ULOGIC type"

Those enumerations give the dropdown parameters.

I'm not sure what tabs/groups means, but I second the idea of dropdown menus for choosing the right component. That would help a lot.

- ts

I compiled your branch and tried it. So far, it's working well on my bigger model. Thank you very much.

- Tom

Thanks! I'll give that a try. - Tom

I installed OpenModelica from SVN on a Ubuntu machine and tried the model above. I got the same errors, so I think that rules out compiler issues. It seems there's something wrong with my model, or there's a bug somewhere.

- Tom

Thanks to sjoelund.se, I've been able to replicate my problem on a reduced model. Here is my model:

model mod1
  parameter Integer n=3;
  Real Z[n, n];
  Real V[n], I[n];
algorithm
  for i in 1:n loop
    Z[i,i] := i^3;
    for k in (i+1):n loop
      Z[i,k] := i * k;
      Z[k,i] := Z[i,k];
    end for;
  end for;
equation
  I = fill(1.0,n);
  V = Z * I;
end mod1;

model mod3
  mod1 mymod;
  Real V2[mymod.n];
equation
  V2 = 2.0 * mymod.V;
end mod3;

"mod1" flattens and simulates fine. "mod3" flattens okay but fails during simulations. The error messages start with the following:

mod3.cpp: In function `int functionDAE_output()':
mod3.cpp:678: error: expected primary-expression before "struct"
mod3.cpp:678: error: expected `)' before "struct"
mod3.cpp:683: error: expected primary-expression before "struct"
mod3.cpp:683: error: expected `)' before "struct"

Here is some of the code the errors point to:

677      tmp41 = get_memory_state();
678      (*struct _array_element_addr(&(*struct _array_element_addr(&$Pmymod$PZ, 2, (modelica_integer)$Pi, (modelica_integer)$Pi)), 2, (modelica_integer)$Pi, (modelica_integer)$Pi)) = ((modelica_real)pow((modelica_real)(modelica_integer)$Pi, (modelica_real)3));
679      tmp38 = (1 + (modelica_integer)$Pi); tmp39 = (1); tmp40 = (modelica_integer)$Pmymod$Pn;
680      {
681        for(modelica_integer $Pk = (1 + (modelica_integer)$Pi); in_range_integer($Pk, tmp38, tmp40); $Pk += tmp39) {
682          tmp37 = get_memory_state();
683          (*struct _array_element_addr(&(*struct _array_element_addr(&$Pmymod$PZ, 2, (modelica_integer)$Pi, (modelica_integer)$Pk)), 2, (modelica_integer)$Pi, (modelica_integer)$Pk)) = ((modelica_real)((modelica_integer)$Pi * (modelica_integer)$Pk));

If I change the algorithm part of mod1 to the following, it simulates correctly.

  Z := {{1,2,3},{4,5,6},{7,8,9}};

I'm on windows XP. These results are on a fairly recently downloaded daily (OpenModelica-revision-6338.msi).

- Tom

Perfect. Thanks much! It simulates properly for me with that, too.

Hello everyone.

I've got a modelica package I'm trying to get to work. To replicate an error, I'm trying a reduced model. I haven't been able to replicate the problem, but I'm running into other issues. Here's my reduced model:

model mod2
  constant Integer n=3;
  output Real Z[n, n];
  Real V[n], I[n];
  Integer i=1, k=1;
algorithm
  for i in 1:n loop
    for k in 1:n loop
      Z[i,k] := i * k;
    end for;
  end for;
equation
  I = fill(1.0,n);
  V = Z * I;
end mod2;

Here are the issues:

(*) I needed to add the "=1" to i and k to make the equations and variables balance (17 of each according to omc). I'm not sure why. The model looks balanced without that.

(*) The model flattens, but it fails during simulation. Here are the errors:

mod2.cpp: In function `int functionDAE_output()':
mod2.cpp:663: error: expected initializer before '->' token
mod2.cpp:667: error: expected initializer before '->' token
mod2.cpp: In function `int function_updateDependents()':
mod2.cpp:837: error: expected initializer before '->' token
mod2.cpp:841: error: expected initializer before '->' token
mod2.cpp: In function `int function_updateDepend(int&)':
mod2.cpp:882: error: expected initializer before '->' token
mod2.cpp:886: error: expected initializer before '->' token
mingw32-make: *** [mod2] Error 1

The code generated looks like this:

663    for(modelica_integer $Pi = 1; in_range_integer($Pi, tmp6, tmp8); $Pi += tmp7) {
664      tmp5 = get_memory_state();
665      tmp2 = 1; tmp3 = (1); tmp4 = 3;
666      {
667        for(modelica_integer $Pk = 1; in_range_integer($Pk, tmp2, tmp4); $Pk += tmp3) {
668          tmp1 = get_memory_state();

I'm wondering if I'm somehow getting the wrong compiler version or something.

If I change the algorithm part to the following, it simulates correctly. Also, if I move the algorithm part to a separate function and call it from the model, it simulates correctly.

  Z := {{1,2,3},{4,5,6},{7,8,9}};

I'm on windows XP. These results are on a fairly recently downloaded daily (OpenModelica-revision-6338.msi).

- Tom

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