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

Posts

Posts

Sep-15-13 21:14:35
problems with simulation result intervals. Streaming wrong values

Thanks Adrian.  It's helpful

Sep-15-13 20:20:33
problems with simulation result intervals. Streaming wrong values

I see.  Ma bad.  Thank you very much.  I had fixed stepSize.
Is there any technical documentation or reference you may suggest me to look into?

Sep-15-13 19:52:15
problems with simulation result intervals. Streaming wrong values

Thank you Adrian.  I mean from the download link, I had this version   OpenModelica-1.9.0-BETA4-revision-15030

I don't have annotation that could modify the simulation parameters

Code:

if you don't change it via the simulation/buildModel command

Is this different from the mos script?  Was not the mos supposed to stream the same value and omc result in the same simulation options information.  The same way, changing stepSize value is also modifying numberOfIntervales. 

I am working on windows 7 and couldn't figure out why it is such a serious issue

Sep-15-13 18:39:52
problems with simulation result intervals. Streaming wrong values

Hello,

I was lately trying to run test mo files through script.  I downloaded the very recent version of omo 1.9.0.  However, I just notice that the simulation result is streaming wrong 'numberOfIntervals' value as you can see below:

This the default.  The first line is from my mos, the second line is from simulation result.  This is ok.

Code:

startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500

startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500

Here, I change the stopTime from 1.0 (above) to 10.0.  The simulation result changes numberOfItervals to 5000 (by a factor of 10)

Code:

startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500

startTime = 0.0, stopTime = 10.0, numberOfIntervals = 5000

Here the stop time is  5, the numberofIntervals is changed to 2500.

Code:

startTime = 0.0, stopTime = 5.0, numberOfIntervals = 500

startTime = 0.0, stopTime = 5.0, numberOfIntervals = 2500

Below is the format of the simulation options of my mos using default settings except trying to change stop time:

Code:

loadFile("my.mo"); 

simulate(my, startTime = 0, stopTime = 5, numberOfIntervals = 500);

Can anyone advise me what went wrong or if the latest version uses a different scripting syntax?

Feb-02-13 22:06:09
Category: Programming

I would like to know if there is any modelica scripting that converts any mo file to xml format. (or create equivalent xml  from mo file)

Jan-16-13 22:11:57
For modelling modelling time-delay in physical computations
Category: Programming

sjoe, I have for the following feedback:

for a single parameter simulation, it works BUT when I change the simulation time to anything above 1, it prints NaN.  One parameter with stopTime=1.0 is ok. 

for multiple parameters, the second model can't process data from the first model even if simulation time is set to 1.0.  If time is above 1.0, the same way it prints NaN.  The record keeps a stopTime of 1


Look at the models and the results below:

Code:

model M

Real x, y1,y2;
equation
    der(x) = 2;
    y1 = x;
    y2 = 2*x;
end M;

model N
  parameter Real y1,y2;
  Real z1 = sin(y1); // f(y)
  Real z2 = sin(y2); // f(y)
end N;

Results (simulation time 1):

Code:


record SimulationResult
    resultFile = "M_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50
0, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'M', storeInTemp = f
alse, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*'
, measureTime = false, cflags = '', simflags = ''",
    messages = "",
    timeFrontend = 0.00632564799369095,
    timeBackend = 0.0052462182423628,
    timeSimCode = 0.00283488596844051,
    timeTemplates = 0.548435656583297,
    timeCompile = 1.49165812579071,
    timeSimulation = 1.64479135634378,
    timeTotal = 3.69934957640679
end SimulationResult;
1.0
2.0
4.0

record SimulationResult
    resultFile = "N_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50
0, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'N', storeInTemp = f
alse, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*'
, measureTime = false, cflags = '', simflags = '-overridefile N.override'",
    messages = "",
    timeFrontend = 0.00677093252141672,
    timeBackend = 0.00439515979274317,
    timeSimCode = 0.00358519237318874,
    timeTemplates = 0.0135766343759655,
    timeCompile = 1.53475471420793,
    timeSimulation = 0.343025548347943,
    timeTotal = 1.90614690201291
end SimulationResult;
NaN
NaN

Results (stopeTime=10) but the script doesn't seem to pass this time.  Instead, we always see the default simulation time 1.0

Code:


record SimulationResult
    resultFile = "M_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50
0, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'M', storeInTemp = f
alse, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*'
, measureTime = false, cflags = '', simflags = ''",
    messages = "",
    timeFrontend = 0.00602576249542665,
    timeBackend = 0.00445403059543273,
    timeSimCode = 0.0028285642715074,
    timeTemplates = 0.0140187580552248,
    timeCompile = 4.64686487293784,
    timeSimulation = 0.345604405590593,
    timeTotal = 5.01983788008215
end SimulationResult;

10.0
NaN
NaN

record SimulationResult
    resultFile = "N_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50
0, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'N', storeInTemp = f
alse, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*'
, measureTime = false, cflags = '', simflags = '-overridefile N.override'",
    messages = "",
    timeFrontend = 0.00647934425037713,
    timeBackend = 0.00441214935325089,
    timeSimCode = 0.00388468276539472,
    timeTemplates = 0.0128057824561847,
    timeCompile = 1.77746204413651,
    timeSimulation = 0.63764823391543,
    timeTotal = 2.4427305621648
end SimulationResult;
NaN
NaN

Jan-16-13 16:42:45
For modelling modelling time-delay in physical computations
Category: Programming

sjoelund, thank you very much.  I will try out the last one.

Jan-16-13 13:52:52
For modelling modelling time-delay in physical computations
Category: Programming

The mos execution went fine.  Very helpful.  With your last code (to add results to output),  is this to be executed with a separate .mos or a commandLine istruction? In addition, I thought of using omc from local directory path. 

Code:

$ omc a.mos

/home/marsj/trunk/build/bin/omc 1.9.0 Beta2 (r14687)

Just one more question if you bear with me

(Can also be done using -overrideFile if you have many parameters to set)

Could you provide me an example based on the above M & N models? 
For instance, if I were to pass an array of a variable, say y[:] in model M to z[:] = f(y[:], stopTime in model N)

Again, thank you.

Jan-15-13 22:45:33
For modelling modelling time-delay in physical computations
Category: Programming

Thanks sjoelund. Yes, indeed they are separate experiments.  I didn't use the appropriate term.  Now where can I put this piece of code? Is it as a *.mos or inline call through the loadString function? 
I have got a scripting function for loadString :

Code:


function loadString
  input String data;
  input String filename = "<interactive>";
  input String encoding = "UTF-8";
  output Boolean success;
end loadString;

Let me take the following two experiments each based on the corresponding model below (the model M is for experiment 1 and model N be for experiment 2):

Code:

model M  //from experiment 1

  Real x;
  Real y;
equation
  der(x) = 2;
  y = x;
  Outoing_Connector = y;
end M;

and

Code:

model N  //from experiment 2

   Real y;
equation
    y = Incoming_connector;
end M;

Now I have to create a third experiment, Experiment 3 that connects Experiment 1 and Experiment 2
How can I use your code based on this situation?

Jan-15-13 21:03:41
For modelling modelling time-delay in physical computations
Category: Programming

sjoelund.se wrote:

For a horizontal line based on stop-time... use some other tool for post-processing the data. OpenModelica plotting functionality is limited as the project is more focused on simulation results. ...

In fact, I used the graphical plot analog to explain the problem.  But my point of interest is to to get the the final simulation output of a dynamic system and plug that as constant input to a static model through a connector.  Consider the above example, der(x)=2 with y=f(x), and if I connect this model to a static model that requires only the final value of der(x), I observe two things: one erroneous output and the other a failed simulation

1) the first model (component) has to be simulated for a time t, say t=10
2) the second model being static, the simulation time can be anything. 

Now, the two models being connected, when I run the composite model for a simulation time of 1, der(x) sends only the value x that corresponds to t=1.  Since the second model needs only der(x) value at t=10, the whole result  is thus false.  Now, when I use a simulation time of t=10, the the simulation fails.  Because, at time t=10 the input to model2 is rather variable instead of a constant input through the connector.

I am sure there must  be a workaround to handle this issue.  In other programming languages, it is easy to grab a variable result in a given time t and pass it to any other operation.  With Modelica, it is very strange that there is no such a thing to grab or if any, I am just looking for it to know how to do that.

I do hope that you would get my point.

Jan-15-13 19:14:27
For modelling modelling time-delay in physical computations
Category: Programming

sjoelund.se wrote:

delay()

sjoelund,

Is there any similar function to get only the value of a given variable at the END of simulation can consider that as fixed.  For instance in the example der(x)=2, I would like to get Y(x(endTime)) and fix that value as constant throughout the simulation.  Y will be a horizontal plot over the entire simulation period.  In the chart, since the final simulation value of X = 10, I would like to get Y as 10, means Y plot will be a horizontal line of value 10.

I do not know if a combination of delay function and something else can solve that

Dec-13-12 12:44:23
plot at the Intersection of two functions
Category: Programming

Hi, I am wondering if modelica has the magic to plot a horizontal line through the intersection point of two functions.  Any idea?

Dec-12-12 20:04:56
Two stop times
Category: Programming

I have a variable Var1 that I plot until a specified stop time,say StopTime1.  My question is that whether it is possible to add a second stomTime2 (i.e StopTime2 = StopTime1 + deltaTime) so that the value Var1 at  StopTime1 and up to StopTime2 will be constant (plot as straight line between this time range).  Just like breaking the simulation time into two, the first part plotting as normal var1 function and the second part as a constant value which is equal to the value of Var1 at the end of the first part of the simulation.

Nov-08-12 13:14:41
Variable(start=StartValue, then??)
Category: Programming

sjoelund.se wrote:

variable(min=minValue,max=maxValue,start=initialGuess)

Thank you sjoelund.  I tied that but it didn't stop the variable from breaching the max value.  I just wanted the simulation to be performed with in the range as noted above.

Nov-08-12 12:30:24
Variable(start=StartValue, then??)
Category: Programming

Is there any syntax to hold low and upper value of variable simulation.  We have lower bound to initiate a variable with Variable(start=StartValue) but I would like to know if there is upper bound to be used in conjunction with the start value something like: Variable(start=StartValue, end=EndValue)?

Hi Adrian,

Many thanks for your prompt action.  Now, I have opened the model without any issue both in OpenModelica and Dymola(demo).  However, I was not able to simulate it with any of the two tools as OpenModelica prints 'Symbolic' error when I tried to simulate and Dymola demo found the model too complicated to run under the demo version.  So, it would be nice to simulate the model rather with OpenModelica when the issue (bug) you have identified is fixed. 

Thanks once more and I look forward to reading OpenModelica update related to this issue,

Hi Adrian, Thank you.  I followed your instructions and got the following error:  Error: The file was not encoded in UTF-8:

I was trying to run the 'SmallPlant' model at WasteWater.ASM1.Examples.SmallPlant

The mos file is like this:
loadModel(Modelica,{"2.2.1"}); getErrorString();
loadFile("F:/OMODs/WasteWater/WasteWater/package.mo"); getErrorString();
simulate(ASM1.Examples.SmallPlant); getErrorString();


Below is the complete information on the command line run

F:\OMODs\WasteWater\WasteWater\ASM1> C:\OpenModelica1.8.1\bin\omc +std=2.x myScript.mos
true
""
true
"[F:/OMODs/WasteWater/WasteWater/../WasteWater/ASM2d/package.mo:202:14-202:79:wr
itable] Error: The file was not encoded in UTF-8:
  "Concentration of effective substance in precipitant flow   [g/m?]".
  To change encoding when loading a file: loadFile(encoding="ISO-XXXX-YY").
  To change it in a package: add a file package.encoding at the top-level.
  Note: The Modelica Language Specification only allows files encoded in UTF-8.
"
record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50
0, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'ASM1.Examples.SmallPl
ant', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat',
variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "Simulation Failed. Model: ASM1.Examples.SmallPlant does not exis
t! Please load it first before simulation.",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;
""

I haven't tried Nightly-builds yet.  Should I uninstall OpenModelica1.8.1 and replace it with Nightly-builds?  Or I can install it separately?

Thank you Julian.  I tied OMShell commande but couldn't see the any of the models doing something.  For example, I tried to see ASM1 example of SmallPlant with small_asm1.mos script.  Below are the steps I tired (root drive path is truncated):

>> loadModel(Modelica)
true

>> loadFile("WasteWater/WasteWater/package.mo")
true
[WasteWater/WasteWater/../WasteWater/ASM2d/package.mo:202:14-202:79:writable] Error: The file was not encoded in UTF-8:
  "Concentration of effective substance in precipitant flow   [g/m?]".
  To change encoding when loading a file: loadFile(encoding="ISO-XXXX-YY").
  To change it in a package: add a file package.encoding at the top-level.
  Note: The Modelica Language Specification only allows files encoded in UTF-8.


Then I also tried to see one of the examples of ASM1 with the following command.  The shell returned me false.

>> loadFile("F:/OMODs/WasteWater/WasteWater/AMS1/package.mo")
false

>>


I have OpenModelica 1.8.1 installed.  What version of OpenModelica with OMShell do you use to have it working?  By the way, what is the difference between using omc.exe commands and OMShell commands?  As omc is a compiler, is OMShell using omc.exe at the background or it has its own compiler?

CombiTimeTable doesn't seem available in the Dymola demo 2012 version.

julian.wyszynski wrote:

Hey,
tried it today and it works perfectly.

Thank you very much!

How did you run Wastewater model from OpenModelica?  I just tried to open it with OMEdit but couldn't see details of the model except the folder wastewater. 

I installed the demo version of Dymola and tried to open it.  Well I see the details of the model but it doesn't seem to run as time related inputs are missing like CombiTableTime for the WWsource, FixedDelay function for a Limiter library, etc. 

I would be glad if you or anyone here can tell me how to fix the missing components and to run it preferably from OpenModelica.  I am not sure if the demo version of Dymola can simulate that even if it helps to visualize the components.

Oct-04-12 17:17:21
Tried to run *.mo from comandline but simulation outputs are thrown to

Thanks a lot. Very helpful.

Oct-04-12 13:07:37
Tried to run *.mo from comandline but simulation outputs are thrown to

adrpo, excuse me for initiating this thread.  The above mos and command line instructions work for a simple text based model.  How about if the mo file is a package containing several models and if we want to run a specific experiment?

Oct-03-12 17:22:13
Any modelica syntax to export _res.mat to readable text file?
Category: Developer

Hi adrpo, Thats excellent, thanks a lot!

Oct-03-12 17:09:19
Any modelica syntax to export _res.mat to readable text file?
Category: Developer

Is there any built-in modelica syntax to export _res.mat to readable text file? If yes, how.  If no, is there any experience of reading (viewing) without going through Matlab?

Oct-01-12 20:36:51
Tried to run *.mo from comandline but simulation outputs are thrown to

adrpo, very nice,  thank you very much.

Sep-30-12 17:25:00
Tried to run *.mo from comandline but simulation outputs are thrown to

I did the following in the cmlScript.mos but it failed to process

// -start script
cd(e:/OM/Tests/); 
loadFile("cmlTest.mo"); getErrorString();
simulate(cmlTest, stopTime=2); getErrorString();
// -- end script

It appears working if I put the mos in a batchfile


AMong the files generated, I see one file 'Output' which is empty.  Why is that?

Sep-30-12 15:05:17
Tried to run *.mo from comandline but simulation outputs are thrown to

odrpo, thanks.  This time outputs are sent to the omc bin\ folder instead of the working directory at e:\OM\Tests\. .  My be something is wrong with the file path declarations in the script

Here is what I have:
mo path : E:\OM\Tests\cmlTest.mo
mos path: E:\OM\Tests\cmlScript.mo

cmlScript.mos file content:
// -start script
cd();  // display the current directory
loadFile("e:\OM\Tests\cmlTest.mo"); getErrorString();
simulate(cmlTest, stopTime=2); getErrorString();
// -- end script


When I run commandline, everything is thrown to bin\ of omc. 

What I have done is this:
path/to/omc e:\OM\Tests\cmlScript.mos .  On windows console, I have to provide the full path of the mos file to generate the output. otherwise, it couldn't find the file

Sep-30-12 13:42:18
Tried to run *.mo from comandline but simulation outputs are thrown to

I tried to run a simple *.mo file from commandline using omc but the simulation outputs are thrown to the temp folder than my working directory where the myTest.mo file is located.  Can anyone advise me how to set that.

Sep-29-12 21:59:21
Compiling C-Code with Visual Studio / C++ ?

odrpo, thank you for your prompt comment and update.  I would be glad to try it If I find some guide on how to proceed.  By the way, I couldn't open the links you provided, it requests password which I don't have.
Again, thanks

Sep-29-12 21:41:48
Compiling C-Code with Visual Studio / C++ ?

adrpo,

I took the adventure to try the first project but it appears that a VS 2003 version.  I was trying with 2008 version.  Is there any work around if you can provide me further hint?

Thanks in advance

Sep-28-12 22:39:33
What is the start time and stop time syntax to use
Category: Programming

sjoelund.se, thanks.  I had tried that before but forgot to translate.

Sep-28-12 17:08:39
What is the start time and stop time syntax to use
Category: Programming

Does anyone know how to use start time and stop time within the modelica editor? The idea is to manage the simulation time within the program instead of doing it manually from the setup dialog..

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