Opened 9 years ago
Closed 3 years ago
#3860 closed defect (fixed)
If +std=3.3 is set there are issues when using Modelica.Blocks.Sources.Clock
Reported by: | anonymous | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Frontend | Version: | |
Keywords: | Cc: |
Description
Consider the following model:
model Test Modelica.Blocks.Sources.Clock clock1; Modelica.Blocks.Logical.Greater greater1; Modelica.Blocks.Sources.RealExpression realExpression1(y=time - 1); equation connect(realExpression1.y, greater1.u2); connect(greater1.u1, clock1.y); end Test;
When checked it generates the following error message:
[Test: 7:3-7:33]: Failed to instantiate equation connect(greater1.u1, clock1.y);
This seems to be a bug.
OMEdit v1.10.0-dev-95-gdcd1258
Connected to OpenModelica v1.10.0-dev-324-g50cddbb
Change History (11)
comment:1 by , 9 years ago
follow-up: 4 comment:2 by , 9 years ago
It does work fine. I tested it with this script:
loadModel(Modelica); getErrorString(); loadFile("Test.mo"); getErrorString(); instantiateModel(Test); getErrorString(); simulate(Test); getErrorString();
using omc from command line:
> OpenModelica/build/bin/omc +locale=C t.mos > trace.txt 2>&1
and got trace.txt
below:
true "" true "" "class Test Real clock1.y \"Connector of Real output signal\"; parameter Real clock1.offset(quantity = \"Time\", unit = \"s\") = 0.0 \"Offset of output signal\"; parameter Real clock1.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Output = offset for time < startTime\"; Real greater1.u1 \"Connector of first Boolean input signal\"; Real greater1.u2 \"Connector of second Boolean input signal\"; Boolean greater1.y \"Connector of Boolean output signal\"; Real realExpression1.y = -1.0 + time \"Value of Real output\"; equation clock1.y = clock1.offset + (if time < clock1.startTime then 0.0 else time - clock1.startTime); greater1.y = greater1.u1 > greater1.u2; greater1.u2 = realExpression1.y; clock1.y = greater1.u1; end Test; " "" record SimulationResult resultFile = "C:/bin/cygwin/home/adrpo/dev/OMTesting/bugs/3860/Test_res.mat", simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", messages = "", timeFrontend = 0.9757279834193317, timeBackend = 0.03233599874351548, timeSimCode = 0.00591094357984143, timeTemplates = 0.05809200669509155, timeCompile = 14.76922298134829, timeSimulation = 0.1907762333488854, timeTotal = 16.03756673149265 end SimulationResult; ""
I guess you might have +std=3.3 which activates Clock as a type with synchronous features!
Check your OMEdit settings.
comment:3 by , 9 years ago
Component: | *unknown* → Frontend |
---|---|
Owner: | changed from | to
Status: | new → accepted |
I guess we should be able to handle Modelica.Blocks.Sources.Clock even with +std=3.3
, so I'll keep this ticket open.
comment:4 by , 9 years ago
I checked my OMEdit settings.
The issue is present in case I load, as Modelica Library, "trunk".
The issue is not there if I load "default".
Every other setting, I think, is equal to its default value in my OMEdit.
Thanks for showing me the way!
Replying to adrpo:
It does work fine. I tested it with this script:
loadModel(Modelica); getErrorString(); loadFile("Test.mo"); getErrorString(); instantiateModel(Test); getErrorString(); simulate(Test); getErrorString();using omc from command line:
> OpenModelica/build/bin/omc +locale=C t.mos > trace.txt 2>&1and got
trace.txt
below:
true "" true "" "class Test Real clock1.y \"Connector of Real output signal\"; parameter Real clock1.offset(quantity = \"Time\", unit = \"s\") = 0.0 \"Offset of output signal\"; parameter Real clock1.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Output = offset for time < startTime\"; Real greater1.u1 \"Connector of first Boolean input signal\"; Real greater1.u2 \"Connector of second Boolean input signal\"; Boolean greater1.y \"Connector of Boolean output signal\"; Real realExpression1.y = -1.0 + time \"Value of Real output\"; equation clock1.y = clock1.offset + (if time < clock1.startTime then 0.0 else time - clock1.startTime); greater1.y = greater1.u1 > greater1.u2; greater1.u2 = realExpression1.y; clock1.y = greater1.u1; end Test; " "" record SimulationResult resultFile = "C:/bin/cygwin/home/adrpo/dev/OMTesting/bugs/3860/Test_res.mat", simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", messages = "", timeFrontend = 0.9757279834193317, timeBackend = 0.03233599874351548, timeSimCode = 0.00591094357984143, timeTemplates = 0.05809200669509155, timeCompile = 14.76922298134829, timeSimulation = 0.1907762333488854, timeTotal = 16.03756673149265 end SimulationResult; ""I guess you might have +std=3.3 which activates Clock as a type with synchronous features!
Check your OMEdit settings.
comment:5 by , 9 years ago
Summary: | Fail to instantiate connect equation → When +std=3.3 is set usage of Modelica.Blocks.Sources.Clock does not work |
---|
Ok, it seems we do set +std=3.3 for Modelica trunk version. I didn't expect that.
Anyhow, I guess it should be possible to handle Clock as a type/operator and Clock as a class in another scope than top.
comment:6 by , 9 years ago
Summary: | When +std=3.3 is set usage of Modelica.Blocks.Sources.Clock does not work → If +std=3.3 is set there are issues when using Modelica.Blocks.Sources.Clock |
---|
comment:8 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:9 by , 7 years ago
Milestone: | 1.12.0 → Future |
---|
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
comment:10 by , 7 years ago
I also had this problem. The following model does not work:
model testClockGain Modelica.Blocks.Math.Gain thegain(k = 1); Modelica.Blocks.Sources.Clock theclock; equation connect(theclock.y, thegain.u); end testClockGain;
and fails compilation with the error
[1] 08:19:54 Translation Error [testClockGain: 5:3-5:33]: Failed to instantiate equation connect(theclock.y, thegain.u);. [2] 08:19:54 Translation Error Error occurred while flattening model testClockGain
Currently working in Windows installation of OMEdit v1.12.0 (64-bit)
comment:11 by , 3 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Seems to work with
model testClockGain Modelica.Blocks.Math.Gain thegain(k = 1); Modelica.Blocks.Sources.Clock theclock; equation connect(theclock.y, thegain.u); annotation( __OpenModelica_commandLineOptions = "--matchingAlgorithm=PFPlusExt --indexReductionMethod=dynamicStateSelection -d=initialization,NLSanalyticJacobian -d=newInst,infoXmlOperations,backenddaeinfo --std=3.3"); end testClockGain;
and omc v1.19.0-dev.417+g7c3ddb9cac.
May I ask if someone has had a look at this ticket?
Just to know whether it will be addressed or not in the coming weeks.
It seems rather important: it is a so basic example!
Unless there is something wrong that I cannot see.