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

Posts

Posts

Dec-02-13 14:12:39
Openmodelica & Netbeans on Mac OSX Mavericks

It seems to work now.
Thanks again for your help.

Dec-02-13 13:51:44
Openmodelica & Netbeans on Mac OSX Mavericks

I added an osType in OMCProxy.java to consider TMPDIR environment variable for OSX.
There also was an issue regarding my firewall which blocked Corba connection between Java and omc.

Do you know if it is possible to use Corba interface without completely switching off my firewall ?

Dec-02-13 12:40:28
Openmodelica & Netbeans on Mac OSX Mavericks

Hello,
Thanks for your reply.
The Java library includes workarounds to try and find omc executable.

It finds :
omcBinary = /opt/openmodelica/bin/omc
omcWorkingDirectory = /opt/openmodelica

I checked the library and it tries to create a file named "/tmp/openmodelica." + username + ".objid." + corbaSessionName
But when I check in the tmp folder, there is no openmodelica.xxx file.
It seems omc fails creating tmp file :

Code:

int ticks = 0;

    while(!f.exists())
    {
      try
      {
        Thread.sleep(100);
      }
      catch(InterruptedException e)
      {
        /* ignore */
      }
      ticks++;

      /* If we've waited for around 5 seconds, abort the wait for OMC */
      if(ticks > 50)
      {
        logOMCStatus("No OMC object reference file created after " +
        "approximately 5 seconds.");
        logOMCStatus("It seems OMC does not want to come up, giving " +
        "up.");
        throw new ConnectException
        ("Unable to start the Open Modelica Compiler. Waited for 5"
            +" seconds, but it didn't respond.");
      }
    }

Is it an issue regarding permissions for the tmp folder which currently are:

lrwxr-xr-x@  1 root  wheel       11 26 oct 21:28 tmp -> private/tmp

And private/tmp :
drwxrwxrwt  11 root  wheel   374  2 déc 09:54 tmp

Thanks in advance.

Best,

Dec-01-13 22:59:26
Openmodelica & Netbeans on Mac OSX Mavericks

Hello,

I'm trying to use the OpenModelica Java interface on my Macbook Air running Mac OS X 10.9 Mavericks.
I use OpenModelica release 17983 (1.9.1+dev) and I'm programming using Netbeans IDE with JDK 1.7 update 45.

I tried the following code to check if everything works:

Code:


package javaapplication1;

import org.openmodelica.corba.ConnectException;
import org.openmodelica.corba.OMCProxy;

public class JavaApplication1 {

    /**
     * @param args the command line arguments
     * @throws org.openmodelica.corba.ConnectException
     */
    public static void main(String[] args) throws ConnectException {
        // TODO code application logic here
        OMCProxy omc = new OMCProxy("bdezhohidhoz");
        omc.sendExpression("cd()");
        omc.stopServer();
    }   
}

When I run the application, I get the following error :

Code:


run:
Warning: 'Mac OS X' not officialy supported OS
Exception in thread "main" org.openmodelica.corba.ConnectException: Unable to start the Open Modelica Compiler. Waited for 5 seconds, but it didn't respond.
    at org.openmodelica.corba.OMCProxy.startServer(OMCProxy.java:336)
    at org.openmodelica.corba.OMCProxy.init(OMCProxy.java:421)
    at org.openmodelica.corba.OMCProxy.sendExpression(OMCProxy.java:497)
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:25)
Java Result: 1
BUILD SUCCESSFUL (total time: 5 seconds)

OPENMODELICAHOME variable is set to "/opt/openmodelica/bin".

Could you pls help me fixing this error ?

Thanks in advance, best,

Oct-22-13 10:04:40
Error while compiling rml on Mac OS X

Hi,

I'm using OM 1.9.0 revision.
I cannot setup lpsolve because it seems not to be available to OS X version above 10.3 and not available for x64.

Do you have any Mac OSX package from a recent OM distribution ?

The last revision available on the website is the revision 14584 from December 2012.

Thanks in advance.

Regards,

Oct-21-13 18:03:32
Error while compiling rml on Mac OS X

Thanks for your reply.
When using the command you provided, "./configure --without-rml", I get the following warning : configure: WARNING: unrecognized options: --without-rml

Oct-21-13 17:28:06
Error while compiling rml on Mac OS X

Hi,
I'm on Mac OS X 10.8 and I'm trying to build OpenModelica from sources because the OpenModelica OS X build seems old...
To perform the compilation, I need to install rml+mmc.
When I'm using the make command I get the following error :

Code:

[loading (sources.cm):Main.sml]

$Execute: required privileges are:
  primitive
[New bindings added.]
[autoloading]
[autoloading done]
ls -l rml.
ls: rml.: No such file or directory
make[2]: *** [rml.] Error 1
make[1]: *** [compiler] Error 2
make: *** [default] Error 2

How can I solve this error ?

My configure file is the following :

Code:

#!/bin/sh


makeconfigureneeded=
TARGET=
PREFIX=
DESTDIR=/usr/local
SMLCM=
MLLEX=/usr/local/bin/mllex
MLYACC=/usr/local/bin/mlyacc
HEAP_SUFFIX=
DEBUGLIB=librml_g.a
PROFLIB=librml_p.a
TRACLIB=librml_t.a

if [ -r ./config.cache ]; then
  . ./config.cache
fi

while [ "$#" != 0 ]; do
    arg=$1
    shift
    case "$arg" in
    --build=*)
    TARGET=`echo $arg | sed 's/--build=//'`
    if [ ! \( -d "config/$TARGET" -a -r "config/$TARGET/config.h" \) ]; then
      echo ./configure: You have indicated target "'$TARGET'".
      echo This software does not directly support that configuration.
      echo For a list of supported configurations, see the directory config/.
      exit 1
    fi
    makeconfigureneeded=1
    ;;
    --prefix=*)
    PREFIX=`echo $arg | sed 's/--prefix=//'`
    ;;
    --destdir=*)
    DESTDIR=`echo $arg | sed 's/--destdir=//'`
    ;;
    --nosmlnj)
    SMLCM=nosmlnj
    MLLEX=mllex
    MLYACC=mlyacc
    HEAP_SUFFIX=nosmlnj
    ;;
    --disable-debug)
    DEBUGLIB=
    ;;
    --enable-debug)
    DEBUGLIB=librml_g.a
    ;;
    --disable-profile)
    PROFLIB=
    ;;
    --enable-profile)
    PROFLIB=librml_p.a
    ;;
    --disable-tracing)
    TRACLIB=
    ;;
    --enable-tracing)
    TRACLIB=librml_t.a
    ;;
    *)
    echo ./configure: bad option "'$arg'"
    echo usage: ./configure [options]
    echo valid options are:
    echo '--build=<cpu-os-compiler>'
    echo '--prefix=<path>'
    echo '--destdir=<path>'
    echo '--nosmlnj'
    echo '--{disable,enable}-{debug,profile}'
    exit 1
    esac
done

if [ -z "$TARGET" ]; then
  TARGET=`etc/config.guess`
  if [ "$?" != 0 ]; then
    echo ./configure: etc/config.guess failed to classify current host
    exit 1
  fi
  eval $TARGET
  echo ./configure: TARGET is $TARGET
  makeconfigureneeded=1
fi

# SML/NJ configuration
# Note: --nosmlnj MUST be given if SML/NJ isn't available

if [ -z "$SMLCM" ]; then
  makeconfigureneeded=1
  PATH=/usr/lib/smlnj/bin:$PATH
  MLLEX=`etc/which ml-lex` || MLLEX=`etc/which mllex` || MLLEX=`etc/which ml-lex.bat`
  if [ "$?" != 0 ]; then
    echo ./configure: unable to locate ml-lex or mllex in '$PATH'.
    exit 1
  fi
  SMLCM=`echo $MLLEX | sed 's,ml-lex,sml-cm,'`
  if [ ! -x $SMLCM ]; then
    SMLCM=`echo $MLLEX | sed 's,ml-lex,sml,'`
    if [ ! -x $SMLCM ]; then
      SMLCM=`echo $MLLEX | sed 's,mllex,sml,'`
      if [ ! -x $SMLCM ]; then
        echo ./configure: unable to locate sml-cm or sml.
        exit 1
      fi
    fi
  fi
  MLYACC=`echo $MLLEX | sed 's,ml-lex,ml-yacc,'`
  if [ ! -x $MLYACC ]; then
    MLYACC=`echo $MLLEX | sed 's,mllex,ml-yacc,'`
    if [ ! -x $MLYACC ]; then
      MLYACC=`echo $MLLEX | sed 's,mllex,mlyacc,'`
      if [ ! -x $MLYACC ]; then
        echo ./configure: unable to locate ml-yacc or mlyacc.
        exit 1
      fi
    fi
  fi
  echo ./configure: SMLCM is $SMLCM
  case "$TARGET" in
  x86-cygwin-gcc|x86-mingw32-gcc|x86_64-mingw32-gcc)
    HEAP_SUFFIX=x86-win32
    ;;
  *)
    if [ -z "$SMLNJ_HOME" ]; then
      echo ./configure: unable to determine SML/NJ installation directory
          echo Please set the SMLNJ_HOME environment variable as it is different on all platforms
      exit 1
    fi
    BIN_DIR=$SMLNJ_HOME/bin/
    if [ "$?" != 0 -o -z "$BIN_DIR" ]; then
      echo ./configure: unable to determine SML/NJ installation directory
          echo $SMLNJ_HOME/bin/ does not exist
      exit 1
    fi
    ARCH_OPSYS_HEAPSUFFIX=`$BIN_DIR/.arch-n-opsys`
    if [ "$?" != 0 ]; then       
      echo ./configure: unable to determine SML/NJ heap suffix
      exit 1
    fi
    echo $ARCH_OPSYS_HEAPSUFFIX
    eval $ARCH_OPSYS_HEAPSUFFIX
  esac
  echo ./configure: SML/NJ heap suffix is $HEAP_SUFFIX
fi

if [ -z "$PREFIX" ]; then
  PREFIX=`pwd`/$TARGET
  echo ./configure: PREFIX is $PREFIX
fi

echo TARGET=$TARGET > ./config.cache
echo PREFIX=$PREFIX >> ./config.cache
echo DESTDIR=$DESTDIR >> ./config.cache
case "$TARGET" in
  x86-mingw32-gcc|x86_64-mingw32-gcc)
    #SMLDIR=`etc/which_dir sml.bat`
    SMLDIR=$SMLNJ_HOME
    # transform c:\a\b -> '/c/a/b'
    SMLDIR=`echo $SMLDIR | sed 's/://g'`
    SMLDIR=`echo $SMLDIR | sed 's|\\\|/|g'`
    HEAPDIR=$SMLNJ_HOME
    HEAPDIR=`echo $HEAPDIR | sed 's|\\\|/|g'`
    SMLDIR=/$SMLDIR/bin
    SMLRUN=$SMLDIR/.run/run.x86-win32.exe
    echo SMLCM=\`echo \"$SMLRUN @SMLload=$HEAPDIR/bin/.heap/sml\"\` >> ./config.cache
    echo MLLEX=\`echo \"$SMLRUN @SMLload=$HEAPDIR/bin/.heap/ml-lex\"\` >> ./config.cache
    echo MLYACC=\`echo \"$SMLRUN @SMLload=$HEAPDIR/bin/.heap/ml-yacc\"\` >> ./config.cache
    ;;
  *)
    echo SMLCM=$SMLCM   >> ./config.cache
    echo MLLEX=$MLLEX   >> ./config.cache
    echo MLYACC=$MLYACC >> ./config.cache

esac
echo HEAP_SUFFIX=$HEAP_SUFFIX >> ./config.cache
echo DEBUGLIB=$DEBUGLIB >> ./config.cache
echo PROFLIB=$PROFLIB >> ./config.cache
echo TRACLIB=$TRACLIB >> ./config.cache

echo ./configure: updated config.cache
if [ ! -z "$makeconfigureneeded" ]; then
  echo ./configure: make configure
  make configure
fi
echo ./configure: done
exit 0

Thanks in advance.

Regards,

Mar-20-13 17:31:30
Issue regarding the OPENMODELICAHOME environment variable

Thanks for your advices...
I changed getOmcBinaryPath() as follows:

Code:

private File[] getOmcBinaryPaths() throws ConnectException

  {
    String binaryName = "omc";

    if (os == osType.WINDOWS)
    {
      binaryName += ".exe";
    }

    File omcBinary = null;
    File omcWorkingDirectory = null;
 
    //String openModelicaHome = System.getenv("OPENMODELICAHOME");
   
    String[] subdirs = { "", "bin", "Compiler" };
       
    File[] Roots = File.listRoots();
    //List the different Roots (C:\, D:\ for Windows, / for UNIX)
   
    for(File file:Roots){
            \\List folders from RootDir

        File[] dir = file.listFiles(new FileFilter() {
            public boolean accept(File f) {
                return f.isDirectory();
            }
        });
   
        for (File sd : dir){
                        //For each directories, I check if ***/bin/omc[.exe] or ***/omc[.exe] or ***/Compiler/omc[.exe] exists

            for(String sdir : subdirs)
            {
                String path = sd.getAbsolutePath() + File.separator;               
                path += sdir + File.separator + binaryName;
                               
                File f = new File(path);
                               
                if (f.exists())
                {
                                     //File exists ==> Set omcBinary and omcWorkingDirectory variables with the given paths
                         omcBinary = f;
                            omcWorkingDirectory = sd;
                         System.out.println(f.getAbsolutePath());
                         break;
                }               
            }
            if(omcBinary != null){
                                //Stops if found
                break;
            }
        }
        if(omcBinary != null){
                        //Stops if found
            break;
        }
    }
   
    if (omcBinary == null)
    {
      logOMCStatus("Could not fine omc-binary on the OPENMODELICAHOME path");
      throw new ConnectException("Unable to start the OpenModelica Compiler, binary not found");
    }

    return new File[] {omcBinary, omcWorkingDirectory};
}

It is working with Windows and Linux... I was unable to check on Mac OS.

Thanks for your help...

Mar-20-13 14:35:04
Issue regarding the OPENMODELICAHOME environment variable

This is what I changed in the getOmcBinaryPaths() method...

Code:

String openModelicaHome = null;

     
    if (os == osType.WINDOWS)
    {
         openModelicaHome = System.getenv("OPENMODELICAHOME");
    }
    else
    {
        openModelicaHome = "/usr";
    }

Mar-20-13 14:32:05
Issue regarding the OPENMODELICAHOME environment variable

Hi,
Thanks for your reply.
I changed the getenv() method to the System.getProperty method, and I set the path with System.setProperty...

Does the OPENMODELICAHOME have any other objective than locate the "omc" executable ?
If so, how can I edit the OMCProxy.java file to simply use the "omc" shell command instead in Linux ?

Best,

Mar-20-13 14:31:56
Issue regarding the OPENMODELICAHOME environment variable

Hi,
Thanks for your reply.
I changed the getenv() method to the System.getProperty method, and I set the path with System.setProperty...

Does the OPENMODELICAHOME have any other objective than locate the "omc" executable ?
If so, how can I edit the OMCProxy.java file to simply use the "omc" shell command instead in Linux ?

Mar-20-13 12:38:42
Issue regarding the OPENMODELICAHOME environment variable

Hi,

I'm developing a software in Java using Eclipse IDE.
For this application, I need to interface OpenModelica with my Java application.
My computer is running on Linux Debian Squeeze (the last version) and OpenModelica 1.9.0.

To do this, I'm using the Corba interface from the java_modelica.jar library.

I registered the java_modelica.jar library and the $OPENMODELICAHOME environment using the following command

Code:

export OPENMODELICAHOME=/usr

source ~/.bashrc

My problem is the following: when I run OMNotebook, it works like a charm, as suggested in https://www.openmodelica.org/index.php/ … pic?id=137

But when I run my eclipse application, I get the following error:

Code:

Exception in thread "main" org.openmodelica.corba.ConnectException: Environment variable OPENMODELICAHOME not set

    at org.openmodelica.corba.OMCProxy.getOmcBinaryPaths(OMCProxy.java:215)
    at org.openmodelica.corba.OMCProxy.startServer(OMCProxy.java:274)
    at org.openmodelica.corba.OMCProxy.init(OMCProxy.java:419)
    at org.openmodelica.corba.OMCProxy.sendExpression(OMCProxy.java:495)
    at modelica.Modelica.simulateModel(Modelica.java:14)
    at optimizationToolbox.OptimizationToolbox.main(OptimizationToolbox.java:21)

My modelica.Modelica.simulateModel method simply executes the cd() command using the org.openmodelica.corba.sendExpression method. (I created this method to check the Corba interface and the OMC environment using a simple command).

It seems that the System.getenv() method used to check the environment variable does not work on Linux.
Running the command "System.out.println(System.getenv("OPENMODELICAHOME"));" displays "null".

Could you pls tell me how I can solve this problem ?

Thanks in advance.
Regards,

Nov-30-11 00:53:43
PRBS generator

Hi,

I have found a library where the PRBS generator is included : the FuelCellLib one.
This library is available on : https://www.modelica.org/libraries/FuelCellLib (See documentation page 7).

I extracted the code I needed:

Code:

model PRB_Load

   
    extends inter.OnePort;
    SI.Resistance R(start=1);
    parameter SI.Resistance HighVal=1 "High Value Resistance";
    parameter SI.Resistance LowVal=0.01 "Low Value Resistance";
    parameter SI.Time Period=10 "Maximum period of oscillation";
   
    Real sig;
    Real tevent;
equation
   
    //The value of resistance will oscillate aleatorily between
    //"HighVal" and "LowVal" with a maximum period of "Period"   
   
    when time > pre(tevent) then
      sig = 1 - pre(sig);
      tevent = time + (RandomUniform(time))/Period;
      R = ((HighVal - LowVal)*sig) + LowVal;
    end when;
   
    R*i = v;
end PRB_Load;

But when I compile the program, it fails because the following types are missing
- SI.Resistance. Should I change it to Modelica.SIunit.Resistance ?
- inter.OnePort : Is there an equivalent in OpenModelica ?
- RandomUniform (I suppose it is include in inter.OnePort)

Thanks in advance, for your reply.

Best,
DC

Nov-28-11 11:56:48
PRBS generator

Hi,

I need to create or use a PRBS (Pseudo-Random Binary Signal), which is based on a logical shift register, in Modelica.

Do you know if is it an existing Modelica function to do that or not ?

Thanks in advance.

Best regards,
DC

Nov-14-11 14:22:08
Modelica-based state space identification

Hi,

I change my .mo file in order to specify my states and my input/output.
Here is the code:

Code:

class Systeme_MRA3 "Systeme_MRA3.mo"

  input Real u1(start = 2);
  input Real u2(start = 10);
  output Real y1;
  output Real y2;
  Real x1(stateSelect = StateSelect.always);
  Real x2(stateSelect = StateSelect.always);
  Real x3(stateSelect = StateSelect.always);
  Real x4(stateSelect = StateSelect.always);
  annotation(Diagram());
  Modelica.Mechanics.Translational.Sources.Force force1(useSupport = false) annotation(Placement(visible = true, transformation(origin = {-61,1}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Sources.Force force(useSupport = true) annotation(Placement(visible = true, transformation(origin = {-61,-69}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.Fixed fixed annotation(Placement(visible = true, transformation(origin = {-6,81}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Mechanics.Translational.Components.SpringDamper springDamper(stateSelect = StateSelect.never, s_nominal = 0.1, c = 5, d = 1300, s_rel0 = 0) annotation(Placement(visible = true, transformation(origin = {-6,51}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(stateSelect = StateSelect.never, s_nominal = 0.1, c = 3, d = 1000, s_rel0 = 0) annotation(Placement(visible = true, transformation(origin = {-6,-29}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Components.Mass mass(m = 120, stateSelect = StateSelect.never, L = 0.2) annotation(Placement(visible = true, transformation(origin = {-6,11}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Components.Mass mass1(m = 70, stateSelect = StateSelect.never, L = 0.2) annotation(Placement(visible = true, transformation(origin = {-6,-59}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor annotation(Placement(visible = true, transformation(origin = {49,-4}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor1 annotation(Placement(visible = true, transformation(origin = {44,-74}, extent = {{10,10},{-10,-10}}, rotation = 180)));

equation
  connect(positionSensor1.flange,mass1.flange_b) annotation(Line(points = {{54,-74},{29,-74},{-6,-74},{-6,-69}}));
  connect(positionSensor.flange,mass.flange_b) annotation(Line(points = {{59,-4},{34,-4},{-6,-4},{-6,1}}));
  connect(force.flange,mass1.flange_b) annotation(Line(points = {{-51,-69},{-6,-69}}));
  connect(mass1.flange_a,springDamper1.flange_b) annotation(Line(points = {{-6,-49},{-6,-39}}));
  connect(force1.flange,mass.flange_b) annotation(Line(points = {{-51,1},{-6,1}}));
  connect(mass.flange_b,springDamper1.flange_a) annotation(Line(points = {{-6,1},{-6,-19}}));
  connect(springDamper.flange_b,mass.flange_a) annotation(Line(points = {{-6,41},{-6,21}}));
  connect(force.support,springDamper1.flange_a) annotation(Line(points = {{-61,-79},{-59,-79},{-59,-19},{-6,-19}}));
  connect(fixed.flange,springDamper.flange_a) annotation(Line(points = {{-6,81},{-6,61}}));
  force.f = u1;
  force1.f = u2;
  y1 = positionSensor.s;
  y2 = positionSensor1.s;
  x1 =  positionSensor.s;
  x2 = positionSensor1.s;
  x3 = der(positionSensor.s);
  x4 = der(positionSensor1.s);
end Systeme_MRA3;

The simulation runs perfectly, but when I linearize my model using the "-l 0" arguments, I get the following state matrix:

Code:


model linear_Systeme_MRA3
  parameter Integer n = 4; // states
  parameter Integer k = 2; // top-level inputs
  parameter Integer l = 2; // top-level outputs
  parameter Real x0[4] = {0,0,0,0};
  parameter Real u0[2] = {0,0};
  parameter Real A[4,4] = [1.654246805958327e-307,7.000521832679948e-307,3.097696738820614e-317,0;0,7.435092989896573e-307,0,2.121995790965272e-314;0,0,1.086461844974219e-311,0;0,3.13092364163473e-317,0,7.050757112236943e-307];
  parameter Real B[4,2] = [1.653832599999293e-307,NaN;NaN,NaN;8.487983163367024e-314,NaN;NaN,7.0885689109885e-251];
  parameter Real C[2,4] = [1.653832592379931e-307,0,0,0;0,0,0,0];
  parameter Real D[2,2] = [2.54639495098637e-313,0;0,0];
  Real x[4](start=x0);
  input Real u[2](start= u0);
  output Real y[2];

  Real x_Px1 = x[1];
  Real x_Px2 = x[2];
  Real x_Px3 = x[3];
  Real x_Px4 = x[4];
    Real u_Pu1 = u[1];
  Real u_Pu2 = u[2];
    Real y_Py1 = y[1];
  Real y_Py2 = y[2];
 
equation
  der(x) = A * x + B * u;
  y = C * x + D * u;
end linear_Systeme_MRA3;

I can see that there's something wrong because my C matrix should be [1,0,0,0;0,1,0,0].

What's wrong in my model?

Thanks for your reply.

Best regards,
DC

Nov-11-11 16:20:41
Modelica-based state space identification

Hi,

Thanks for your help.

Is it possible to write something like that ?

Code:


input Real u1;
...
Modelica.Mechanics.Translational.Sources.Force force1(useSupport = false);
...
connect(u1, force1.f);
...

A last question : is it possible to specify which variables should be set as my state vector?
I want to get A, B, C and D state matrixes where dX = AX+Bu // Y=CX+Du, and specify my X vector.

Thanks in advance,

Best,
DC

Nov-10-11 19:28:04
Modelica-based state space identification

Hi,
Thank you for your reply.

I tried your proposal using my own model (I used the standard library) but the size of my C matrix seems to be null.
This maybe is because I didn't set any parameter as input or output.
In my model, input variables should be force1.f and force.f and outputs positionSensor.s and positionSensor1.s.

How can I set these parameters as input or output without setting the whole block as input or output (if I do this I get errors).
I tried to use the realinput/realoutput blocks but I can't connect them to the force.f port.

Thanks in advance.

Best,

Nov-10-11 16:27:00
Modelica-based state space identification

Hi,

I'm working on the design of linear optimal controller for Modelica-based systems.
In order to do that, I need to get a linearized model of my system which is modeled using OpenModelica.
I want to get the state-space representation of this model.

I would like to know if it is a way to get all dynamic equations of my Modelica model (created using the Standard Library) or link OpenModelica with symbolic solver softwares like Maxima.

Another question: I am using Scilab for designing my optimal controller. Is it possible to link the OM compiler and Scilab (I know there is the OpenModelica Toolbox for Scilab which only works on Linux OS but I am using Windows!)

Thanks in advance for your replies.

Best,
DC

Oct-27-11 17:49:57
Problem using the OMOptim application

Thanks for your reply.
I indeed saw that the txt file has been replaced with the xml file since the 1.8 version regarding the FMI interface, but I still use the 1.7 version.

Oct-27-11 15:59:59
Problem using the OMOptim application

Hi,
I would like to use the OMOptim under Windows 7 OS but I have some issues with it!
I checked how this program works and I see that OMOptim creates a lot of MyModel.exe processes.
It seems like if OMOptim executes the "MyModel.exe -f MyModel_init.txt" command but it doesn't wait the application has ended (using the waitFor() Java instruction).

How may I solve this problem ?

Best,

Jun-10-11 17:30:42
Setting parameters to Modelica model using Corba interface

Thank you again for that.
I will try with the simulate function first in order to check if everything is working fine.
Than I will try it by using a txt or a xml file.
I indeed don't need to compile the model for thousand times : I just need to do it once in my class constructor !
Best,

Jun-10-11 17:01:31
Setting parameters to Modelica model using Corba interface

Thank you very much for your reply that solved my problem.
I indeed saw that all block components were considered as parameters when I checked the "full" modelica code using the instantiate model function in OMEdit!

Now I know how I may set only a few components as parameters.

Once again, thanks.
Best,

Jun-10-11 13:15:00
Setting parameters to Modelica model using Corba interface

Hi,

Thanks for your reply.
I tried what you said by adding the following lines:

Code:

executeCommand("setParameterValue(MyModel, PIctrl.k,"+k+")");

and in my Modelica model, I changed from

Code:

Modelica.Blocks.Continuous.PI PIctrl(k=1, T=0.01, initType=Modelica.Blocks.Type.Init.NoInit);

to

Code:

parameter Modelica.Blocks.Continuous.PI PIctrl(k=1, T=0.01, initType=Modelica.Blocks.Type.Init.NoInit);

But, when I try to simulate, it says that the model is now overdetermined: 62 unknowns and 68 equations.

Warning: Parameter PIctrl.u has neither value nor start value, and is fixed during initialization (fixed=true)
Warning: Parameter PIctrl.y has neither value nor start value, and is fixed during initialization (fixed=true)
Warning: Parameter PIctrl1.u has neither value nor start value, and is fixed during initialization (fixed=true)
Warning: Parameter PIctrl1.y has neither value nor start value, and is fixed during initialization (fixed=true)


Should I add u(start=0, fixed=false)?
Best,

Jun-10-11 09:52:15
Setting parameters to Modelica model using Corba interface

Hi,

In my model, I would like to optimize parameters from the PI controllers by minimizing the sum of quadratic errors:
I'm currently using the JMetal package (I may develop my own algorithm in the future) and I would like to do the following thing as my optimization problem:
- Setting PI parameters (calculated by my optimization algorithm)
- Simulate the model with those parameters (it's ok for the simulation process with the simulate() function)
- Get the values from the feedback.y and feedback1.y variables that are containing the error values.
- Calculate the sum of errors using a java function (ok for that too)

I would like to know how I can set the parameters that are calculated by my algorithm to my Modelica model (PIctrl.k, PIctrl.T, Pictrl1.k and PIctrl1.T variables) and get simulation results (feedback.y and feedback1.y).

My question is the following : How can I set parameters to my modelica model using the corba interface and how can I get the simulation results contained in the feedback.y and feedback1.y variables?

Is it possible ?

Thank you in advance for your kindly reply.

Best,

Jun-09-11 17:25:22
Error in initialization while using OMC with Corba

Hi,
I just have an another question regarding OMC and Corba.
How can I set parameters to my modelica model using the corba interface and how can I get the simulation results?

In my model, I would like to optimize parameters from the PI controllers by minimizing the sum of quadratic errors:
I'm currently using the JMetal package (I may develop my own algorithm in the future) and I would like to do this as my optimization problem:
- Setting PI parameters (calculated by my optimization algorithm)
- Simulate the model with those parameters
- Get the values from the feedback.y and feedback1.y variables that are containing the error values.
- Calculate the sum of errors using a java function

I would like to know how I can set the parameters that are calculated by my algorithm to my Modelica model (PIctrl.k, PIctrl.T, Pictrl1.k and PIctrl1.T variables) and get simulation results.


Is it possible ?
Best,

Jun-09-11 14:56:05
Error in initialization while using OMC with Corba

Hi,
Thanks for your kindly answer.
I edited the model as you suggested and it works perfectly.
Best,

Jun-08-11 17:29:13
Error in initialization while using OMC with Corba

Dear all,
I created a model for a double mass-damper-spring system with PI controllers using OpenModelica.
I would like to use the Corba interface in order to optimize it using an homemade Java application or using the JMetal one (in the future).

I started with simple proportional controllers. It works fine.
But when I add the integrator part (the PI controller from the Modelica library) I get the following error :

Code:


Sending expression:runScript("Systeme_MRA.mos")
Got reply:"true
true
record SimulationResult
    resultFile = \"\",
    simulationOptions = \"startTime = 0.0, stopTime = 10.0, numberOfIntervals = 1000, tolerance = 0.0001, method = 'dassl', fileNamePrefix = 'Systeme_MRA', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = ''\",
    messages = \"Simulation execution failed for model: Systeme_MRA
Error in initialization. System of initial equations are not consistent.
(Least Square function value is 0.07)
Error in initialization. Solver iterated 100 times without finding a solution
residual[0] = 0.1
residual[7] = 0.1
residual[8] = -0.2
residual[9] = -0.1
Initialization of the current initial set of equations and initial guesses fails!
Try with better Initial guesses for the states.
Error in initialization. Storing results and exiting.

Simulation terminated while the initialization. Could not find suitable initial values.\",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;
false

My MOS file is :

Code:

loadModel(Modelica);

loadFile("Systeme_MRA.mo");
simulate(Systeme_MRA,startTime=0.0,stopTime=10.0,numberOfIntervals = 1000,tolerance = 1e-04);
plot({const.y,const1.y,positionSensor.s,positionSensor1.s});

where "Systeme_MRA" is my double mass-spring-damper modelica model, created using OMEdit.

My modelica model:

Code:

model Systeme_MRA

  annotation(Diagram(graphics), uses(Modelica(version = "3.2")), Diagram(graphics));
  Modelica.Mechanics.Translational.Components.SpringDamper springDamper(stateSelect = StateSelect.default, s_nominal = 0.1, s_rel(fixed = true, start = 0), v_rel(fixed = true, start = 0), c = 5, d = 1300, s_rel0 = 0) annotation(Placement(visible = true, transformation(origin = {88,50}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Components.Fixed fixed annotation(Placement(visible = true, transformation(origin = {88,82}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Mechanics.Translational.Components.Mass mass(m = 120, s(fixed = true), L = 0.2, v(fixed = true), a(fixed = true), stateSelect = StateSelect.default) annotation(Placement(visible = true, transformation(origin = {88,10}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sources.Force force1(useSupport = true) annotation(Placement(visible = true, transformation(origin = {32,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(stateSelect = StateSelect.default, s_nominal = 0.1, s_rel(fixed = true, start = 0), v_rel(fixed = true, start = 0), c = 3, d = 1000, s_rel0 = 0) annotation(Placement(visible = true, transformation(origin = {88,-28}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor(s(start = 0, fixed = true)) annotation(Placement(visible = true, transformation(origin = {-4,-16}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Mechanics.Translational.Components.Mass mass1(m = 70, s(fixed = true), L = 0.2, v(fixed = true), a(fixed = true), stateSelect = StateSelect.default) annotation(Placement(visible = true, transformation(origin = {88,-62}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sources.Force force(useSupport = true) annotation(Placement(visible = true, transformation(origin = {32,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Continuous.PI PIctrl1(k = 1, T = 0.01) annotation(Placement(visible = true, transformation(origin = {-20,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Continuous.PI PIctrl(k = 1, T = 0.01) annotation(Placement(visible = true, transformation(origin = {-32,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Math.Feedback feedback1 annotation(Placement(visible = true, transformation(origin = {-62,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Math.Feedback feedback annotation(Placement(visible = true, transformation(origin = {-68,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor1(s(start = 0, fixed = true)) annotation(Placement(visible = true, transformation(origin = {58,-92}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Blocks.Sources.Constant const1(k = 2) annotation(Placement(visible = true, transformation(origin = {-100,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Sources.Constant const(k = 1) annotation(Placement(visible = true, transformation(origin = {-104,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));

equation
  connect(const.y,feedback.u1) annotation(Line(points = {{-93,0},{-76,0}}));
  connect(feedback1.u1,const1.y) annotation(Line(points = {{-70,-72},{-89,-72}}));
  connect(feedback1.u2,positionSensor1.s) annotation(Line(points = {{-62,-80},{-62,-91.9},{47,-91.9}}));
  connect(positionSensor1.flange,mass1.flange_b) annotation(Line(points = {{68,-92},{104,-92},{112,-72},{88,-72}}));
  connect(PIctrl.u,feedback.y) annotation(Line(points = {{-44,0},{-59,0}}));
  connect(feedback.u2,positionSensor.s) annotation(Line(points = {{-68,-8},{-68,-15.9},{-15,-15.9}}));
  connect(PIctrl1.u,feedback1.y) annotation(Line(points = {{-32,-72},{-53,-72}}));
  connect(PIctrl.y,force1.f) annotation(Line(points = {{-21,0},{20,0}}));
  connect(PIctrl1.y,force.f) annotation(Line(points = {{-9,-72},{20,-72}}));
  connect(force.support,springDamper1.flange_a) annotation(Line(points = {{32,-82},{32,-18},{88,-18}}));
  connect(force.flange,mass1.flange_b) annotation(Line(points = {{42,-72},{88,-72}}));
  connect(mass1.flange_a,springDamper1.flange_b) annotation(Line(points = {{88,-52},{88,-38}}));
  connect(positionSensor.flange,mass.flange_b) annotation(Line(points = {{6,-16},{108,-16},{108,-5.55112e-16},{88,-5.55112e-16}}));
  connect(mass.flange_b,springDamper1.flange_a) annotation(Line(points = {{88,-5.55112e-16},{88,-18}}));
  connect(force1.support,springDamper.flange_a) annotation(Line(points = {{32,-10},{32,60},{88,60}}));
  connect(force1.flange,mass.flange_b) annotation(Line(points = {{42,0},{88,0}}));
  connect(springDamper.flange_b,mass.flange_a) annotation(Line(points = {{88,40},{88,20}}));
  connect(fixed.flange,springDamper.flange_a) annotation(Line(points = {{88,82},{88,60}}));
end Systeme_MRA;

It seems to be an issue with the initialisation of my PI controllers.

Could you please tell me how I can solve it?

Thanks in advance for your kindly reply.
Best,

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