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

Posts

Posts

@yzh89: you're right, using the new model it works. I must have made some mistake during testing.

Thank you all for your feedback!

For clarity: I updated the model to the following code

Code:

model breakableElasticConnection

  extends Modelica.Mechanics.Translational.Interfaces.PartialCompliant;
  parameter Modelica.SIunits.Area contactArea;
  parameter Modelica.SIunits.Stress adhesiveStrength = 250000000.0 "Yield strength";
  parameter Modelica.SIunits.ModulusOfElasticity E = 1500000000.0 "Young's modulus";
  parameter Modelica.SIunits.Length t = 0.0005 "Glue layer thickness";
  Real broken(start = -1.0) "adhesive state variable";
equation
  der(broken) = 0.0;
  when f / contactArea > adhesiveStrength then
      reinit(broken, 1.0); 
  end when;
  f = if broken < 0.0 then (s_rel * E * contactArea) / t else 0 "Hooke's law or zero";
end breakableElasticConnection;

The complaint about a lacking equation is still there...

So, I would have to add

Code:

der(broken) = 0;

?

Or is there any other Modelica language item that I could use to set the state of a model? (I mean, to assign a state and to change it at a certain event)

Using a Boolean type just seems to be more "right" to me, but Modelica forces me to use a Real in this case.

Thanks for your feedback!
I think I could replace the Boolean 'broken' with a Real (and check if it is larger or smaller than zero for example) to solve one of the problems.

However, I want to assign a value to it which *lasts* and which only is changed at certain events. For example, I don't want the 'broken' variable to depend directly on the force, because then the link would magically heal itself when the force would be small enough again.

Maybe a person with modeling experience has an idea for this? Unfortunately I couldn't find an example for this in the MSL.

I'm trying to model the breakable connection of two Translational Mechanics blocks. This can be a layer of glue for example, that breaks when the applied stress / force in the connection is higher than the adhesiveStrength parameter. I know that the stress-strain curve of real materials like glue is not only linear, but this is a simple example.

The idea is that I have two states: broken = true and broken = false. When broken, the "connection" should give no resistance, hence the f=0. When not broken, the connection behavior should be elastic (force depending on elongation). In this sense, you could call it a "breakable spring".

The broken state is initialized to 'false' and set to 'true' when the force becomes to high.

However, the compiler tells me I'm lacking one equation (there is one more variable) when I'm testing the block below. The test is as follows. I connected the following parts in the following order: Fixed block - Spring - Mass - Force.

I connected the Force block to a "Ramp"-signal. This test works.

When I replace the default spring model by the block below, the compiler complains about a missing equation. Could you tell me what I'm overlooking?

Code:


model breakableElasticConnection
  extends Modelica.Mechanics.Translational.Interfaces.PartialCompliant;
  parameter Modelica.SIunits.Area contactArea;
  parameter Modelica.SIunits.Stress adhesiveStrength = 250000000.0 "Yield strength";
  parameter Modelica.SIunits.ModulusOfElasticity E = 1500000000.0 "Young's modulus" ;
  parameter Modelica.SIunits.Length t = 0.0005 "Glue layer thickness";
  Boolean broken(start = false) "adhesive state variable";
equation
  when f / contactArea > adhesiveStrength then
      reinit(broken, true);
  end when;
  f = if not broken then ((s_rel * E * contactArea) / t) else 0 "Hooke's law or zero";
end breakableElasticConnection;

I found the error. Apparently, it is not possible to use stdout redirecting for omc when it tries to call the mingw compiler. The first few calls from my script (load modelica library, model and cd into executable folder) ran flawlessly, but the simulate command did not work because omc wants to redirect the stdout from mingw. Maybe a "double redirect" (mingw -> omc -> my program) is not possible???

At least, when I removed the code related to stdout redirection ("p.StartInfo.RedirectStandardOutput = true;", etc) it succeeds in compiling a simulation executable, whereas before it only generated the c code but not the executable.

I'm running the nightly build from 20 December, it's the latest one.

I'm trying to generate a simulation executable from a C# application. I do the following:


    create a temp folder
    copy the model to simulate (dcmotor example) in the temp folder
    create a mos-script that loads the modelica library, enters the temp folder, loads the model, enters the executable directory and calls simulate(...)
    execute omc using mos-script


When running my program, omc runs, but upon calling the simulate(...) statement, the following error is returned:

Code:

the process cannot access the file because it is being used by another process

Because of this, the executable is not generated (the other files are succesfully put into the executable folder). However, when I manually call the generated mos-script from the command line (from the same working directory as my program), it works flawlessly.

Does anybody have ideas what might cause the access error? My code is below (uploading attachments does not work):

Code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;

namespace modelicasimulation
{
    public partial class Form1 : Form
    {
        String OPENMODELICAHOME;
        String baseDir;
        String execDir;

        public Form1()
        {
            setupPaths();
            File.Copy(Directory.GetCurrentDirectory() + "\\DCMotorCircuit.mo", baseDir + "\\DCMotorCircuit.mo", true);
            createMos();
            setupExec();
           
            InitializeComponent();
        }

        void setupPaths()
        {
            OPENMODELICAHOME = Environment.GetEnvironmentVariable("OPENMODELICAHOME");
            baseDir = "c:\\temp";
            DirectoryInfo execDirInfo = Directory.CreateDirectory(baseDir + "\\executable");
            execDir = execDirInfo.FullName;
        }

        void createMos()
        {
            StreamWriter file = File.CreateText(Directory.GetCurrentDirectory() + "\\startScript.mos");
            file.WriteLine("loadModel(Modelica);");
            baseDir = Regex.Replace(baseDir, @"\\", @"\\");
            execDir = Regex.Replace(execDir, @"\\", @"\\");
            file.WriteLine("cd(\"" + baseDir + "\");");
            file.WriteLine("loadFile(\"DCMotorCircuit.mo\");");
            file.WriteLine("cd(\"" + execDir + "\");");
            file.WriteLine("simulate(DCMotorCircuit,outputFormat=\"csv\");");
            file.Close();
        }
       
        void setupExec()
        {
            // Start the child process.
            Process p = new Process();
            // Redirect the output stream of the child process.
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = OPENMODELICAHOME + "bin\\omc";
            p.StartInfo.Arguments = "startScript.mos";
            p.Start();
            // Do not wait for the child process to exit before
            // reading to the end of its redirected stream.
            // p.WaitForExit();
            // Read the output stream first and then wait.
            Console.WriteLine(p.StandardOutput.ReadToEnd());

            p.WaitForExit();       
        }
    }
}

This crash also occurs in the Windows version (nightly build of 19 November).

Dec-08-11 18:15:51
Modeling mistake or modelica error?
Category: Programming

Yes, I am using the Student Edition. It would be quite sad if even models of 5 or 6 blocks would be restricted...

I'll look into it, thanks!

Dec-08-11 17:57:09
Modeling mistake or modelica error?
Category: Programming

Thank you for your explanation! Is this then also the reason that SimulationX refuses to simulate this model?

Dec-08-11 17:31:43
Modeling mistake or modelica error?
Category: Programming

I made a model of a bodyshape of which frame_a is connected to the world via two prismatic joints and one spherical joints. These joints are serial. There are 5 degrees of freedom. See the model at http://dl.dropbox.com/u/720632/joints.mo (the upload functionality of this forum doesn't work).

I get some warnings when simulating the model in OpenModelica and SimulationX doesn't even simulate it (it says "The maximum number of states was exceeded").

The openmodelica warnings are:

Check of joints completed successfully.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/Joints.mo:1322:5-1325:115:writable] Warning: Variable spherical1.Q: Non-array modification 'if spherical1.enforceStates and spherical1.useQuaternions then StateSelect.prefer else StateSelect.never' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/Joints.mo:1333:5-1335:57:writable] Warning: Variable spherical1.phi: Non-array modification 'if spherical1.enforceStates and not spherical1.useQuaternions then StateSelect.always else StateSelect.never' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/Joints.mo:1336:5-1338:19:writable] Warning: Variable spherical1.phi_d: Non-array modification 'if spherical1.enforceStates and not spherical1.useQuaternions then StateSelect.always else StateSelect.never' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/Joints.mo:1342:5-1346:99:writable] Warning: Variable spherical1.w_rel: Non-array modification 'if spherical1.enforceStates and spherical1.useQuaternions then StateSelect.always else StateSelect.never' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:975:5-978:76:writable] Warning: Variable bodyshape1.r_0: Non-array modification 'if bodyshape1.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:979:5-982:76:writable] Warning: Variable bodyshape1.v_0: Non-array modification 'if bodyshape1.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:600:5-603:76:writable] Warning: Variable bodyshape1.body.r_0: Non-array modification 'if bodyshape1.body.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:604:5-607:76:writable] Warning: Variable bodyshape1.body.v_0: Non-array modification 'if bodyshape1.body.enforceStates then StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:682:5-686:65:writable] Warning: Variable bodyshape1.body.w_a: Non-array modification 'if bodyshape1.body.enforceStates then if bodyshape1.body.useQuaternions then StateSelect.always else StateSelect.never else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:697:5-700:119:writable] Warning: Variable bodyshape1.body.Q: Non-array modification 'if bodyshape1.body.enforceStates then if bodyshape1.body.useQuaternions then StateSelect.prefer else StateSelect.never else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:708:5-711:69:writable] Warning: Variable bodyshape1.body.phi: Non-array modification 'if bodyshape1.body.enforceStates then if bodyshape1.body.useQuaternions then StateSelect.never else StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.

[C:/OpenModelica1.8.0/lib/omlibrary/Modelica 3.1/Mechanics/MultiBody/parts.mo:712:5-714:42:writable] Warning: Variable bodyshape1.body.phi_d: Non-array modification 'if bodyshape1.body.enforceStates then if bodyshape1.body.useQuaternions then StateSelect.never else StateSelect.always else StateSelect.avoid' for array component, possibly due to missing 'each'.

Could you give a hint what I did wrong?

On Linux, revision 10468, OMEdit correctly builds. However, the interactive simulation crashes after the following steps:

    load model
    click "Interactive Simulation"
    select variables to plot
    click "Initialize"


I can't get the debugging from QtCreator to work - I changed the qmake options in the project settings to build both a Release and Debug executable. However, when clicking "Start debug" the following error is shown in the application output console (within QtCreator):

&"warning: GDB: Failed to set controlling terminal: Invalid argument\n"

Could you help me getting debugging to work, and is the segfaulting interactive simulation a known bug?

Nov-12-11 16:15:57
Error: not a data constructor: stringDelimitList
Category: Developer

10464 did not work for me (even after I removed the trunk folder and checked out svn again), but 10468 does.

Nov-11-11 21:59:04
Error: not a data constructor: stringDelimitList
Category: Developer

Unfortunately I have the same problem there. I removed my trunk directory, checked out using

svn co https://openmodelica.org/svn/OpenModelica/trunk/ -r 10442

Then I ran './configure --with-omniORB' and 'make -j2 omc'.

Nov-11-11 21:39:34
Error: not a data constructor: stringDelimitList
Category: Developer

I'm running Ubuntu and I have rml-mmc version 222-1. My openmodelica SVN revision is 10454 and when trying to compile, I get the following error:

omi_Calculation.cpp:25:30: fatal error: simulation_delay.h: No such file or directory

This makes the omc compilation to fail. Is this a known bug?

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