Coder Social home page Coder Social logo

modelica / modelica-compliance Goto Github PK

View Code? Open in Web Editor NEW
15.0 17.0 14.0 993 KB

A semantics compliance suite for the Modelica language

License: Other

Modelica 93.02% C 0.23% TeX 1.54% XSLT 0.26% Shell 0.05% Motoko 4.90%
modelica modelica-library

modelica-compliance's Introduction

compliance

modelica-compliance's People

Contributors

adrpo avatar beutlich avatar choeger avatar dietmarw avatar frenkelj avatar hansolsson avatar harmanpa avatar maltelenz avatar miscco avatar perost avatar sjoelund avatar tbeu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modelica-compliance's Issues

ModelicaCompliance.Algorithms.Break

Reported by frenkel on 26 Nov 2013 13:50 UTC
The break-statement breaks the execution of the innermost while or for-loop enclosing the break-statement and continues execution after the while- or for-loop. It can only be used in a while- or for-loop in an algorithm section.

but:

function f
  input Real x;
  output Real r;
algorithm
  r := 2.0 * x;
  if r>20 then 
    break; 
  end if;
  r := r * x;
end f;

hence the test should have shouldPass = false.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1364

ModelicaCompliance.Scoping.InnerOuter.MissingInnerAdded

Reported by eldjillali.talbi on 19 Dec 2013 16:51 UTC
This test example checks that missing "inner" is added automatically during translation, if an annotation for it is specified. But the specification says "the tool may also temporarily automatically add the corresponding inner component during translation" (3.3 section 18.7). So the tool is not forced to add this inner prefix during translation, and this test should not be present in the compliance test suite.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1385

Wrong status for ModelicaCompliance.Redeclare.ClassExtends.{ClassExtendsChain,ClassExtendsClassTypes}

Reported by hansolsson on 30 Sep 2013 14:01 UTC
The models ModelicaCompliance.Redeclare.ClassExtends.{ClassExtendsChain,ClassExtendsClassTypes} have shouldPass=false but seem correct as far as I can tell.

The texts of the models even state:
Checks that it's possible to have a chain of class extends
Tests that class extends can be used with the different types of specialized classes


Migrated-From: https://trac.modelica.org/Modelica/ticket/1298

ModelicaCompliance.Equations.For.VariableRange is incorrect

The test ModelicaCompliance.Equations.For.VariableRange is incorrect, as the supposedly false behavior seems in agreement with the spec.

	Integer x[3];
	Integer y[3]={1, 2, 3};
	equation
		for i in y loop
		  x[i] = y[i]; 
		end for;

As ModelicaSpec 8.3.2. states explicitely in example 3 this is legal. Similar to the test ModelicaCompliance.Algorithms.For.VariableRange

Is it meant, that the array y should change its size, which is indeed invalid?

External Tables in ModelicaCompliance

Reported by hansolsson on 26 Sep 2013 13:23 UTC
Since some people complained about too long ticket.

Still issue with: ModelicaCompliance.Functions.ExternalObjects.ExternalObjectTable -

The ExtObj.c is included twice without a guard which is not nice; so should either change the C-file (preferred) to have guards (as is normal in headers) or put this into the Include-part (less nice):
Include="#ifndef ExtObjC
#define ExtObjC
#include "ExtObj.c"
#endif"

And there is no magic for finding URIs in the c-code, so the solution would be:

MyTable myTable = MyTable(ModelicaServices.ExternalReferences.loadResource("modelica://ModelicaCompliance/Resources/Data/Tables/testTables.txt"), "table1", {1, 2, 3});

(but then the test-suite becomes dependent on ModelicaServices).


Migrated-From: https://trac.modelica.org/Modelica/ticket/1290

LICENSE template needs update

Currently the repo only contains the default LICENSE template from the MA, in order to use it one needs to at least fill out <name of Licensor>

ModelicaCompliance.Connections.Expandable.{AugmentNonEmpty,PresentInExp} remaining issue

Reported by hansolsson on 3 Oct 2013 15:54 UTC
This was previously reported, and after analyzing it further I can only conclude the the model is not correct:

(PresentInExp also has the slight issue that there is no instance of M, i.e. we are simulating an empty model.)

The model and has an output connector (ro) connected to the bus. The expandable connector should thus be the source of the signal (i.e. variable in connector should declared with input-prefix).

According to: 9.1.3:
"If the variable on the other side of the connect-equation is input or output the new component will be either input or output to satisfy the restrictions in Section 9.3."

The idea is that this should uniquely define whether it is input or output; and it is clear that having it as "input" in the expandable connector is ok. Unfortunately it is a bit messy for "output" - will open a ticket.

But the source is missing (instead ro has an equation):
9.1.3:
"If a variable appears as an input in one expandable connector, it should appear as a non-input in at least one other expandable connector instance in the same augmentation set."
--
Proposed change:

Base them on ModelicaCompliance.Connections.Expandable.AugmentScalar and just add an unused variable in the expandable connector for AugmentNonEmpty, and add 'x' in expandable connector and add another variable Real y=ec.x; for PresentInExp.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1304

Array indexing with dimension error

I'd like to see some test case that the following model should fail with a dimension error.

model A
  Real x[:,1]=[2,3];
end A;

Where should such a model go?

Must not use exit() in ExtObj.c

Calling exit() in initMyTable and interpolateMyTable is not a good idea since this entirely closes the simulation environment. The solution is to replace printf/exit by ModelicaError from the ModelicaUtilities.

Testcase: Redeclarations: Order of Evaluation

Reported by choeger on 13 Aug 2014 09:07 UTC
Consider the following small model:

model Test2
  model C
    constant Real k = 1;
    constant Real p = 0;
  end C;

  model D
    constant Real k = 2;
    constant Real p = 2;
  end D;    

  model E
    replaceable model C2 = C;
    replaceable model C3 = C2(k = C2.p + 10);
      
    Real x;
    equation
     x = C3.k;   
  end E;

  model F = E(redeclare model C3 = D, redeclare model C2 = D);

  F e;
end Test2;

I wonder whether this is actually legal? C2 is certainly not transitively non-replacable, so can I have a "redeclaration chain" like that? Dymola accepts this. OpenModelica complains about a field not found.

Assuming it is legal, how about the modifications?

Basically, there are 3 ways to deal with the modification of C2:

  1. evaluate before redeclaration of C3 takes effect (i.e. C3=D, x=2)
    This may also be the case when the modification is discarded.
  2. evaluate after redeclaration of C3 takes effect, but before C2 (i.e. C3=C(k=C.p+2), x=10)
  3. evaluate after redeclaration of C3 and after C2 (i.e. C3=D(k=D.p+10), x=12)

AFAIK, modifications are "merged" according to the spec, i.e. the modification inside E is never lost. When we also assume that redeclarations are always applied before modifications, the only legal answer should be 3.

However we decide, I propose to add this as a test case to the compliance suite.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1552

ModelicaCompliance.Classes.Predefined.AttributeStateSelect

Reported by jfrenkel on 2 Apr 2015 07:53 UTC
The Model ModelicaCompliance.Classes.Predefined.AttributeStateSelect test that all defined values of StateSelect can be used. But there is a mistake vor Real v(stateSelect = StateSelect.always) = 5.0;. This variable have to be always "Do use it as a state.". But this is not possible because it is bind to be 5.0.
The tool should reject it with a massage like:

Error In ModelicaCompliance.Classes.Predefined.AttributeStateSelect
The equation:
v=5.;
 constrains the continuous time variables:
v
 requiring them to be continuous time state variables. It is necessary to modify the stateSelect attributes or the model.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1692

ModelicaCompliance.Classes.Balancing.CorrectBalance{3,4} lack values

Reported by hansolsson on 30 Sep 2013 10:56 UTC
ModelicaCompliance.Classes.Balancing.CorrectBalance3 has external inputs p and h, and nothing is specified for them. Using zero will not work for simulations.

ModelicaCompliance.Classes.Balancing.CorrectBalance4 has fixed=true for p and T, without any specified start-value (the default is thus zero). Using zero will not work for simulations.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1297

Checking models in models?

Reported by hansolsson on 13 Dec 2013 16:40 UTC
There is an inconsistency in the test-suite influencing the design of many test-cases:

  • In several cases the error is not in the model itself, but in a class within the model, e.g. ModelicaCompliance.Classes.Enumeration.EnumDuplicateLiteral
  • However, also many correct test-cases contain bad models (e.g ModelicaCompliance.Components.Conditional.CompRemovalBalanced.A is unbalanced).
  • And in some cases checking sub-models will (unless we do something really odd) detect an error without checking for the actual issue, e.g. ModelicaCompliance.Components.Variability.DiscreteSubCompBlock. This seems less urgent.

I assume the intent is that no model used in a correct test-case should have any relevant issues.

Here is a partial list of the models with issues (mostly balancing):
ModelicaCompliance.Classes.Specialized.BlockInputOutput.B
ModelicaCompliance.Components.Conditional.CompRemovalBalanced.A
ModelicaCompliance.Components.Conditional.CompRemovalBalancedParam.A
ModelicaCompliance.Components.Prefixes.DiscreteValidClassType.M
ModelicaCompliance.Components.Prefixes.FlowValidClassType.M
ModelicaCompliance.Connections.Declarations.ArrayEquations.M
ModelicaCompliance.Connections.Declarations.ConnectArrays.M
ModelicaCompliance.Connections.Declarations.ConnectParamSubscript.M
ModelicaCompliance.Connections.Declarations.ConnectWholeDim.M
ModelicaCompliance.Connections.Declarations.OperatorRecordEquations.M
ModelicaCompliance.Connections.Declarations.SimpleEquations.M
ModelicaCompliance.Connections.Expandable.AugmentComplex.M
ModelicaCompliance.Connections.Expandable.FlowInConnectorInExpandable.M
ModelicaCompliance.Connections.Restrictions.ConnectConstants.M
ModelicaCompliance.Connections.Restrictions.ConnectParameters.M
ModelicaCompliance.Connections.Stream.InStreamTwoInside.A
ModelicaCompliance.Operators.Special.Cardinality.M
ModelicaCompliance.Scoping.MemberAccess.AccessAlgorithm.A
(and similarly for all cases in MemberAccess).
ModelicaCompliance.Scoping.InnerOuter.DifferentPrefixes.A has a constant bound to a parameter!

---
Also found the following:
Isn't ModelicaCompliance.Components.Prefixes.DiscreteValidClassType incorrect due to using when into a model?

ModelicaCompliance.Connections.Expandable.ConnectDisjointExpandables lacks content!


Migrated-From: https://trac.modelica.org/Modelica/ticket/1383

Modified files after checkout

If I clone this repo and immediately switch to a new branch I see a bunch of modified files. Why?

$ git checkout -b test
M       ModelicaCompliance/Scoping/InnerOuter/Array1.mo
M       ModelicaCompliance/Scoping/InnerOuter/Array2.mo
M       ModelicaCompliance/Scoping/InnerOuter/Array3.mo
M       ModelicaCompliance/Scoping/InnerOuter/Array4.mo
M       ModelicaCompliance/Scoping/InnerOuter/Array5.mo
M       ModelicaCompliance/Scoping/InnerOuter/Array6.mo
M       ModelicaCompliance/Scoping/InnerOuter/ComplicatedNameLookup.mo
M       ModelicaCompliance/Scoping/InnerOuter/DifferentPrefixes.mo
M       ModelicaCompliance/Scoping/InnerOuter/Enumeration.mo
M       ModelicaCompliance/Scoping/InnerOuter/EnumerationWrong.mo
M       ModelicaCompliance/Scoping/InnerOuter/FunctionSelection.mo
M       ModelicaCompliance/Scoping/InnerOuter/MissingInner.mo
M       ModelicaCompliance/Scoping/InnerOuter/MissingInnerAdded.mo
M       ModelicaCompliance/Scoping/InnerOuter/ModificationOnOuter1.mo
M       ModelicaCompliance/Scoping/InnerOuter/ModificationOnOuter2.mo
M       ModelicaCompliance/Scoping/InnerOuter/ModificationOnOuter3.mo
M       ModelicaCompliance/Scoping/InnerOuter/Nested.mo
M       ModelicaCompliance/Scoping/InnerOuter/OuterInPackage.mo
M       ModelicaCompliance/Scoping/InnerOuter/PartialInner.mo
M       ModelicaCompliance/Scoping/InnerOuter/PartialOuter.mo
M       ModelicaCompliance/Scoping/InnerOuter/PartialOuterWrong.mo
M       ModelicaCompliance/Scoping/InnerOuter/Record.mo
M       ModelicaCompliance/Scoping/InnerOuter/RecordWrong.mo
M       ModelicaCompliance/Scoping/InnerOuter/SimpleNameLookup.mo
M       ModelicaCompliance/Scoping/InnerOuter/SimultaneousDeclarations.mo
M       ModelicaCompliance/Scoping/InnerOuter/WrongSubType.mo
Switched to a new branch 'test'

No check for when f(initial())

There is no test testing that when f(initial()) then is disallowed in 3.2r1. There is even one test using when not initial() then (WhenPriority.mo).

Ambiguous test ModelicaCompliance.Connections.Restrictions.SizeOverconstrainedInvalid

In model ModelicaCompliance.Connections.Restrictions.SizeOverconstrainedInvalid the modifier to r does not have the correct dimension value. The model, however, seem to be testing whether the number of flow variables is equal to the number of "other" variables for overdetermined connectors.
I suggest we change the modifier to r from {1, 2, 3} to {1, 2} to resolve the ambiguity.

ModelicaCompliance.Connections.Declarations.OperatorRecordEquations does not test that operator records are handled

Reported by hansolsson on 11 Oct 2013 09:58 UTC
The testing for operator records in connections is a bit counter-intuitive.

The functionality is tested - but not in the way one would assume.

The details are: Assume that the part about operator records in 9.2 is ignored. One would assume that OperatorRecordEquations test-case would fail, since it is intended to test that this functionality is implemented.

However, if one ignores operator record part of 9.2 the operator record will be split into primitive elements for OperatorRecordEquations; and since Complex use cartesian coordinates this will generate the correct flow-equations!

Thus the test-case OperatorRecordEquations does in fact not test that operator records generate operator-record-equations.
However, it tests that if operator-record-equations are generated they are the correct ones.

Instead the test-cases OperatorRecordMissing... will instead detect this issue (at least it is highly likely).

It might be ok to keep this as it is.

Changing the Complex functions to detect it will result a non-additive group, which would make the model incorrect (and not something that a tool is likely to detect).

The only alternative I could see would be to switch to Polar coordinates, but addition in Polar coordinates is a bit messy.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1321

Missing compliance tests for external function annotations IncludeDirectory, Library and LibraryDirectory

The models in ModelicaCompliance.Functions.ExternalObjects assume that ExtObj.c is found in the default InludeDirectory. There also should be a test (either there or in ModelicaCompliance.Functions.External) that utilizes the IncludeDirectoty annotation according to MLS 3.2r2 section 12.9.4.

There is no single test that utilizes the Library and LibraryDirectory annotations for custom libraries (except ModelicaCompliance.Functions.External.FortranLapack for tool vendor provided Lapack library).

ModelicaCompliance.Arrays.Functions.Size.ArrayDimSizeIncorrectArgument3 is incorrect

The test

ModelicaCompliance.Arrays.Functions.Size.ArrayDimSizeIncorrectArgument3

appears to be incorrect. In section "10.3.1 Array Dimension and Size Functions" Table 10-3 it is stated, that

ndims(A)    Returns the number of dimensions k of array expression A, with k >= 0.
size(A)     Returns a vector of length ndims(A) containing the dimension sizes of A.

Therefore, size(A) of an scalar should return an empty vector (with length ndims(A)==0), but would still be a valid statement.

Bad tests for reserved identifiers

The following test models do not test that the Modelica tool does not allow declaring classes that use reserved names because some Modelica tools (OpenModelica in particular) assume that any use of a reserved identifier points to the built-in class (which is sort of true since there cannot be any elements with the reserved names):

  • ModelicaCompliance.Classes.Predefined.ReservedBooleanClass
  • ModelicaCompliance.Classes.Predefined.ReservedIntegerClass
  • ModelicaCompliance.Classes.Predefined.ReservedRealClass
  • ModelicaCompliance.Classes.Predefined.ReservedStringClass

Perhaps the test name needs to be ModelicaCompliance.Classes.Predefined.Boolean in order to force instantiation of this class (perhaps add it in addition to the existing ones). Anyone have any other ideas?

In ModelicaCompliance.Operators.Overloading.ConstructorPriority, the call to the default constructor would be invalid anyway.

This test verifies that the overloaded constructor shadows the automatically generated constructor.
The call to the constructor uses a single positional argument. This makes the potential call to the default constructor invalid. Therefore, the ambiguity is lifted by there being a single valid constructor.

I suggest we move the default binding from re to im:

Integer re;
Integer im = 1;

instead of:

Integer re = 1;
Integer im;

In this case, both calls are valid, and we test that the overloaded constructor properly shadows the automatically generated one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.