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

CombiTimeTable and time values

CombiTimeTable and time values

Hello!

I want to run simulations where the input values have discontinuities. Therefor I want to use Modelica.Blocks.Sources.CombiTimeTable. The Sources.mo file says, that the time in the first column in the table need to be only increasing and not strictly increasing. The model is the following (test.mo):

Code:

model test "Test"

    import Modelica.Blocks.Sources;
    import Modelica.Blocks.Continuous;
    import Modelica.Blocks.Math;
    import Modelica.Blocks.Tables;
    Sources.CombiTimeTable input1(tableOnFile=true,fileName="data01.txt",tableName="tab1");
    Math.Gain gain1(k=2);
equation
    connect(input1.y[1],gain1.u);
end test;

The file data01.txt is

Code:

#1

double tab1(7,2)   # comment line
  0   0
  1   0
  1   1
  2   1
  3   4
  4   9
  5  16

When I run the simulation, the output is

Code:

>>> simulate(test,startTime=0,stopTime=6,outputFormat="mat")

record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 6.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'test', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = ''",
    messages = "Simulation execution failed for model: test
TimeTable: Column with time variable not monotonous: 1 >= 1.
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;

Does anyone know, why it does not work with the used data file.


Thank and best regards!

Re: CombiTimeTable and time values

I am not sure, but it seems that because your table has two rows that have in the first column the value 1:

0 0
1 0
1 1

Re: CombiTimeTable and time values

Yes, tables need to have monotonically increasing values.
We added now a check for that and it should report a warning for it.

Cheers,
Adrian Pop/

Re: CombiTimeTable and time values

Hi, doing the code written on the first post with OpenModelica 1.8.1 I get the following error:

simulate(test,startTime=0,stopTime=6,outputFormat="mat")

Code:

record SimulationResult

    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 6.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'test', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "Simulation failed for model: test
[<interactive>:6:3-6:89:writable] Error: Class Sources.CombiTimeTable not found in scope test.
Error: Error occurred while flattening model test
",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;

It seems the Source.om is not found or read ? any hints ? Is it OpenModelica specific ?
Thanks in advance,
Sam

Re: CombiTimeTable and time values

Solved by adding a input and evaluating it at the beginning:

Code:

loadModel(Modelica)

Sam

Re: CombiTimeTable and time values

adrpo,
hi,

   I saw you replay, so i want to help to uplaod data (ambiante temperature and external temperature)  to timetable
can you help me please



Re: CombiTimeTable and time values



   Hi,

   can you please help me to show me how to uplaod txt file in CombiTimeTable ?

thanks in advance

Edited by: Abderezakabidi - May-03-20 13:27:46
There are 0 guests and 0 other users also viewing this topic
You are here: