modelica / ModelicaSpecification

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

Not possible to test for being a simulation model #3436

Open henrikt-ma opened 1 year ago

henrikt-ma commented 1 year ago

Breaking out this concern from https://github.com/modelica/ModelicaSpecification/pull/2999: It is currently not possible for a tool to know for sure when a model is intended to be a simulation model. This means that it is not until the user requests an operation such as simulating the model that the tool can know for sure that the model is supposed to be treated as a simulation model. Drawbacks of this include:

Having factored out https://github.com/modelica/ModelicaSpecification/issues/3435 as a separate issue, the suggested solution from the discussion in https://github.com/modelica/ModelicaSpecification/pull/2999 for turning simulation model into something that tools can check would be to define it as a class that:

Considering the amount of discussion we've had around this topic, the specification should clarify that it is not forbidden to simulate models even if they don't fulfill the requirements of a simulation model.

HansOlsson commented 1 year ago

Breaking out this concern from #2999: It is currently not possible for a tool to know for sure when a model is intended to be a simulation model. This means that it is not until the user requests an operation such as simulating the model that the tool can know for sure that the model is supposed to be treated as a simulation model. Drawbacks of this include:

  • If the user asks the tool to "validate" all models in a package, the tool doesn't know which of these that should meet the higher standards of a simulation model.
  • The tool cannot automatically compile a list of all simulation models in a library.

Having factored out #3435 as a separate issue, the suggested solution from the discussion in #2999 for turning simulation model into something that tools can check would be to define it as a class that:

  • is a model or block
  • is not partial
  • has StopTime

Considering the amount of discussion we've had around this topic, the specification should clarify that it is not forbidden to simulate models even if they don't fulfill the requirements of a simulation model.

That doesn't correspond to the current use of simulation model, but to something else (see the end).

Instead simulation model is currently used to define a list of requirement for a model in order that it can be simulated, such as used constants having a value, discrete variables being assigned in when-clauses, outer/inner requirement, virtual connection graph having proper roots etc. It doesn't make sense to simulate models that don't satisfy those requirements.

Thus the proper alternative (that still needs to be analyzed) is that if the model or block has StopTime and is not partial, it is required to be a simulation model. That implies that tools can still check (including simulating) the same models as proposed - but also that the current uses of simulation model remain valid.

With that definition there might be additional models that satisfy the requirement of a simulation model, and even can be simulated. E.g., Modelica.Blocks.Sources.Step However, they are not that interesting, and it doesn't make sense to e.g., test and compute coverage based on them.

We could introduce a different term than simulation model to indicate a model or block that has StopTime and is not partial; such as "model proposed to be simulated" and say that "a model proposed to be simulated must be a simulation model, but to simulate a model it is only necessary that it satisfies the requirements for a simulation model"; but to me that it is getting too verbose.

HansOlsson commented 11 months ago

Thinking more we could, of course, also introduce another name for the current "simulation model" - and instead call the new concept "simulation model"; but to me that seems likely to lead to more confusion.

As I see we can then either close this one without change, or introduce a term for "model proposed to be simulated" as above.

henrikt-ma commented 9 months ago

I kind of like the idea of introducing another name for the current "simulation model", but in order to even start thinking of what could be a suitable name I'd need to first understand what it is that this concept captures. Is it that the model is syntactically correct, globally balanced, and free of structural singularities? Then we could perhaps call them translatable models.

What are the situations where this concept would be used? If we add the rule a simulation model shall be translatable, what else is there to say?