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

Posts

Posts

Oct-16-13 22:06:16
What are the means by which Modelica handles file i/o?

I have seen nothing of the sort and I've been reading OpenModelica/Dymola/System Modeler/Modelica documents and the book I mentioned.  Argh.

Thank you again, sjoelund.se!  You are immensely helpful.

Oct-16-13 17:49:35
What are the means by which Modelica handles file i/o?

So there is no file i/o in the traditional programming sense in Modelica?

Oct-16-13 17:31:22
What are the means by which Modelica handles file i/o?

I've been reading through Peter Fritzson's Introduction to Modeling and Simulation of Technical and Physical Systems with Modelica.

On page 38 of this text, in section 2.1.3 Constants, the following is stated:

"Parameter constants can be declared without a declaration equation since their value can be defined, for example, by reading from a file, before simulation starts."

I know that another .mo file can instantiate parameter values when an object is instantiated.  Is that what Peter is referring to here?  Or is there some other means by which files can be used to assign parameter values?

If you had to state the difference between parameters and constants in Modelica, how would you word it?

As always, thank you for your time.  current/smile

Oct-09-13 19:22:17
What is the point of start, min, & max on parameters?
Category: Programming

I did some testing in OMEdit.

I can check (without errors/warnings) and run code with the following line:

  CelestialBody moon(name = "moon", mass(unit="kg, start = 7000)= 7.382e+22, radius = 1738000.0);

The actual moon.mass will be 7.382e+22 at start.  If I change the line to:

  CelestialBody moon(name = "moon", mass(unit="kg", start = 7000), radius = 1738000.0);

The checker will complain that there aren't enough equations (implying that moon.mass isn't defined?).

Am I to conclude that, for parameters, start does nothing?  Is this an error in OpenModelica?  Do min and max have any  meaning here?

Oct-08-13 19:23:03
What is the point of start, min, & max on parameters?
Category: Programming

I'm trying to get a complete grasp on the syntax of variable declarations.

If the keyword "parameter" is used, like this:

parameter Modelica.SIunits.Length d(unit="unit", start=1.0, min=0) = 0.06 "diameter of shell";

OpenModelica does not throw any warnings or errors when I check the model.

What is the point of specifying a start or a min for a parameter?

Assuming start is the same thing as assignment with an equals sign, which one takes priority here?

But would it be a safe assumption to say that engineering users are familiar and utilize .mos files?

Hello all, I'm designing an application which invokes simulation via batch mode.  I'm wondering whether .mos files are the standard means by which Open Modelica simulations are run.

That is, do most (engineering) users utilize:

C:\>omc myMOS.mos

Would it be safe to make the assumption that OpenModelica users will be familiar with and utilize .mos scripts?

Aug-18-13 21:58:44
Time step 0 has the correct velocity, but it abruptly drops...?
Category: Programming

For what it's worth, I think the problem was the two conversion equations

Code:


  n = x * Modelica.Math.cos(azimuth / 1000) - z * Modelica.Math.sin(azimuth / 1000);
  e = x * Modelica.Math.sin(azimuth / 1000) + z * Modelica.Math.cos(azimuth / 1000);

should only happen once, as part of the impact algorithm.  Moving this seems to have fixed the problem.

Is there some way to define an equation to determine the "start" attribute of a time variable?

For example, I want Vx.start = v*cos(angle) and Vz.start = v*sin(angle).

Is the initial algorithm/equation used for this?  Is it the same thing?

Thanks.

Aug-16-13 22:54:45
Time step 0 has the correct velocity, but it abruptly drops...?
Category: Programming

Code:


model Mortar3D "Point Mass Mortar Shell Trajectory in Three Dimensions"
  parameter Modelica.SIunits.Acceleration g = 9.8 "gravity";
  parameter Modelica.SIunits.Density p = 1.2041 "air density";
  parameter Modelica.SIunits.Mass m = 6.35 "mass of shell";
  parameter Real Cd = 0.9 "coefficient of drag";
  parameter Modelica.SIunits.Length d = 0.06 "diameter of shell";
  parameter Modelica.SIunits.Velocity Wx = 0.0 "velocity of wind in the X direction";
  parameter Modelica.SIunits.Velocity Wz = 0.0 "velocity of wind in the Z direction";
  parameter Modelica.SIunits.Velocity Wy = 0.0 "velocity of wind in the Y direction";
  parameter Modelica.SIunits.Angle declination = 1000.0 "angle from the ground in mils";
  parameter Modelica.SIunits.Angle azimuth = 0 "angle from North in mils (clockwise)";
  parameter Modelica.SIunits.Length targetAltitude = 0.0 "elevation of target";
  discrete Boolean shellHasImpacted "whether the shell has hit";
  discrete Modelica.SIunits.Time timeOfImpact "time when y == targetY";
  discrete Modelica.SIunits.Length impactN "distance North from launch to impact";
  discrete Modelica.SIunits.Length impactE "distance East from launch to impact";
  Modelica.SIunits.Length x(start = 0) "Meters the shell has traveled in the X direction";
  Modelica.SIunits.Length z(start = 0) "Meters the shell has traveled in the Z direction";
  Modelica.SIunits.Length y(start = 0) "Altitude of the shell relative to the canon";
  Modelica.SIunits.Velocity v(start = 220) "scalar velocity of the shell";
  Modelica.SIunits.Length n(start = 0) "Meters the shell has traveled North";
  Modelica.SIunits.Length e(start = 0) "Meters the shell has traveled East";
  //Modelica.SIunits.Position a(start=200) "Meters the shell has traveled Vertically";
  Modelica.SIunits.Velocity Vx(start = 185) "velocity of shell in the X direction";
  Modelica.SIunits.Velocity Vz(start = 0) "velocity of shell in the Z direction";
  Modelica.SIunits.Velocity Vy(start = 118) "velocity of shell in the Y direction";
  Real Drag(start = 0) "drag force opposing velocity";
//initial equation
//    Vx = v * Modelica.Math.cos(declination / 1000);
//    Vy = v * Modelica.Math.sin(declination / 1000);
equation
  Drag = ((p * Modelica.Constants.pi) / 8) * (Cd / (m / d ^ 2));
  n = x * Modelica.Math.cos(azimuth / 1000) - z * Modelica.Math.sin(azimuth / 1000);
  e = x * Modelica.Math.sin(azimuth / 1000) + z * Modelica.Math.cos(azimuth / 1000);
  der(x) = Vx;
  der(y) = Vy;
  der(z) = Vz;
  v = sqrt((Vx - Wx) ^ 2 + (Vz - Wz) ^ 2 + (Vy - Wy) ^ 2);
  der(Vx) = -Drag * v * (Vx - Wx);
  der(Vz) = -Drag * v * (Vz - Wz);
  der(Vy) = -Drag * v * (Vy - Wy) - g;
algorithm
  when y < targetAltitude and not shellHasImpacted then
      timeOfImpact:=time;
    impactN:=n;
    impactE:=e;
    shellHasImpacted:=true; 
  end when;
end Mortar3D;

The main problem is that the start values don't seem to be holding after the initial timestep 0.

My .csv output (First few lines) is:

"time","Vy","Vz","Vx","y","z","x","der(Vy)","der(Vz)","der(Vx)","der(y)","der(z)","der(x)","e","n","v","impactE","impactN","timeOfImpact","Drag","shellHasImpacted",

0,118,0,185,0,0,0,-482029.0344807348,0,-755708.1218553894,118,0,185,0,0,219.4288039433292,0,0,0,18.616100955647,0,

0.1,-0.1917142436531548,0,0.4946236127748513,0.1504328022527183,0,0.2754381554269071,-7.906739153869569,0,-4.884621516867643,-0.1917142436531548,0,0.4946236127748513,0,0.2754381554269071,0.5304779632877762,0,0,0,18.616100955647,0,

0.2,-0.6464381605952849,0,0.16650213084609,0.1032450377464333,0,0.3063460609543107,-1.766757758910391,0,-2.069110445943552,-0.6464381605952849,0,0.16650213084609,0,0.3063460609543107,0.667536706893414,0,0,0,18.616100955647,0,


If there's a better way to format this, let me know.  But to extract the information I think is relevant, here is the scalar velocity and timestep data:

time     v
0           140.23...
0.1        0.3623...
0.2        0.6307...
0.3       0.7169...

I would expect the velocity to remain in line with the first step (around 140 m/s), but it drops off abruptly.  Am I doing something wrong in my Modelica code?

Anything I'm leaving out, or that I should format better?

Thanks to whoever takes the time to help me with this issue, hopefully it's something obvious.

Jul-16-13 23:50:49
Does OpenModelica have an API?

Can you use the contents of an FMU to modify a simulation configuration (start time, stop time, increment, initial values of variables, parameters, etc.),  run that simulation, and then get the output (i.e. a csv)?  And all of this outside of the context of ANY tool?  (FMU's include the solvers used for a simulation, right?  Even if they're hidden in .dll's?)

Thanks for your help sjoelund!

Jul-16-13 23:39:15
Does OpenModelica have an API?

"Scripting" is basically putting omc commands into an .mos file and running it with omc right?

Jul-16-13 23:38:04
Does OpenModelica have an API?

Is FMI relevant here?  OpenModelica exports FMU's, and I'm also wondering if an FMU can be used to simulate a model outside of the context of any tools by using the .dll's or source code?

I'm looking at the FMI documentation, but any heads-up would be appreciated in terms of whether or not FMI can do what I hope it does.  current/smile

Thanks again!

Jul-16-13 23:33:33
Does OpenModelica have an API?

I know OpenModelica has omc, which essentially serves as a batch mode for a variety of tasks.

I'm wondering if OpenModelica also has an API?  Any documentation on this would be greatly appreciated.

Thank you!

Thanks for your help guys!

Also, just to give an idea what I'm trying to do (unsuccessfully) is run the following .mos:

Code:

loadModel(Modelica);

loadFile("C:/Program Files/Wolfram Research/SystemModeler 3.0.2/Libraries/BioChem 1.1/Constants.mo");
loadFile("proprietarySystemModeler.mo");
simulate(proprietarySystemModeler,outputFormat="csv", stopTime=60.0, stepSize=0.1);

So, I'm loading Modelica standard libraries.  Then I'm attempting to load the Constants.mo package from the specified directory.  Is my syntax wrong here?  I'm using Windows XP.

The .mo file is a trivial academic example, but I'll show it if you're interested:

Code:

model proprietarySystemModeler "testing proprietary libraries of System Modeler"

  Real radius(start=1.2);
  Real circumference;
  Real area;
equation
  circumference=2*BioChem.Constants.pi*radius;
  area=Modelica.Constants.pi*radius^2;
  der(radius)=1 + radius;
  annotation(Diagram(coordinateSystem(extent={{-148.5,-105.0},{148.5,105.0}}, preserveAspectRatio=true, initialScale=0.1, grid={5,5})));
end proprietarySystemModeler;

The purpose is simply to test whether another tool's library can be used in OpenModelica.  Does my implementation make sense?  I have no idea what that last line (annotation) is about.  It looks like graph settings, perhaps for System Modeler.  Is that an example of non-Modelica code, or is "annotation" supported in this way?

Thank you for your help.

sjoelund.se wrote:

Some of the commercial libraries use copy protection (encryption). And only tools with the secret keys can decrypt them. OpenModelica cannot open these libraries.

Where can I find more information on this?  At what point in the "buy a library, import a library, create a model, run a simulation" process does the unencryption take place?  Do owners of the commercial libraries have access to the unencrypted libraries or does unencryption take place during the compilation?

Confused about this.  I have been searching for information regarding precisely this concept (encrypting commercial libraries) but have had no luck.

Thanks again.

So there are free libraries, commercial libraries, etc.  But looking into them, it seems they are all simply .mo files?  What is to prevent someone from simply giving away commercial libraries? (Can developers protect their creation somehow with licenses or something?)

Am I understanding what libraries/packages are:  .mo files defining the mathematical model of a given system?  (i.e. just normal Modelica code organized in a unique and meaningful way)

If that is the case, it leads me to my next question: Can my copy of OpenModelica simulate a model which uses libraries/packages I don't own?  Can I use loadFile(PathToSomeLIbrary) on any library?

And lastly, the other simulation environments (Dymola, SystemModeler, MapleSim, etc.) also work with Modelica.  When they generate .mo files, is there anything particularly special about them that wouldn't allow OpenModelica to simulate them as well?

Thanks for the help!

Jun-20-13 20:55:32
Can OpenModelica work with models generated using commercial libraries

I want to use OpenModelica to run simulations of .mo files regardless of where they came from.  Is this feasible?

What situations might I run into where this wouldn't be possible?

Can OpenModelica open commercial libraries and run associated models even if I don't have the license for the libraries used to make the models?

Thanks current/smile

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