modelica / ModelicaSpecification

Specification of the Modelica Language
https://specification.modelica.org
Creative Commons Attribution Share Alike 4.0 International
98 stars 42 forks source link

Structural parameters in Modelica? #2457

Open mestinso opened 4 years ago

mestinso commented 4 years ago

Is there any plan or intention to support variable array sizes via structural parameters in the future? My understanding is that this is something FMI 3.0 is planning to support, but, as far as I know, this doesn't automatically mean Modelica and Modelica tools support this feature, is that correct?

HansOlsson commented 4 years ago

You understanding is correct. It is important to consider that allowing structural parameters imply a number of different cases:

  1. Attributes like min/max that currently are evaluated in some tools for internal reasons in implementations, but allowing changes to those attributes doesn't require any major effort.
  2. Sizes for parameter-arrays. Similar to the next case, but possibly easier to support.
  3. Sizes for arrays that are treated separately and homogenously. Basically viewing the array as one variable assigned to one array equation. That may require fundamental redesign of tools.
  4. ...

However, it seems this is evaluation of structural parameters is outside the current specification as https://specification.modelica.org/master/Ch1.html#scope-of-the-specification states

In order to allow this structural analysis, a tool may reject simulating a model if parameters cannot be evaluated during translation - due to calls of external functions or initial equations/initial algorithms for fixed=false parameters. Accepting such models is a quality of implementation issue.