-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluation at translation time and compliance with Modelica Specification #39
Comments
See https://doi.org/10.3384/ecp21181141, section 2.1.1:
Footnotes |
As for your second inquiry. It is also dealt by recent publication https://doi.org/10.3384/ecp21181141, section 2.1.3:
For Dymola, you need to explicitly call the read functions (of ExternData ≥ v3.0.0) when determing array dimensions. model 'Dymola Workaround'
parameter ExternData.JSONFile dat(
fileName=Modelica.Utilities.Files.loadResource(
"modelica://ExternData/Resources/Examples/test.json"));
parameter Integer n = ExternData.Functions.JSON.readArraySize1D(
fileName=Modelica.Utilities.Files.loadResource(
"modelica://ExternData/Resources/Examples/test.json"),
varName="vector") "Cannot use the record member function here";
parameter Real array[n] = dat.getRealArray1D(varName="vector", n=n);
end 'Dymola Workaround'; Footnotes |
Closing as duplicates. |
We are trying to use the JSON interface of ExternData and have a few questions.
The first one pertains to the compliance with the Modelica Language Specification, see https://specification.modelica.org/maint/3.5/class-predefined-types-and-declarations.html#specialized-classes where it is stated
So we wonder whether the construction of
Types.ExternJSONFile json
within the recordExternData.JSONFile
is valid or not (although Dymola and Optimica do not complain). We noticed that a related issue is left open at modelica-3rdparty/Modelica_DeviceDrivers#93.The second one is how to trigger the evaluation of some parameters which are assigned through calls to ExternData functions and used during flattening or symbolic processing, such as array size, and min, max or nominal attributes.
We noticed that the class annotation
annotation(__Dymola_translate=true)
was added in recent versions of the library. However, the following model still fails to translate with Dymola (version 2022), unless a literal value is assigned to the parametern
.We did some tests (see
TestModel
below) with a previous version of ExternData (2.5.0 which is compatible with MSL 3.2.3) and it seems that the only case whereannotation(__Dymola_translate=true)
effectively triggers the evaluation at translation is when the external object is constructed within the function, as inloadAndGetReal
. Otherwise we get warnings with Dymola that non-literal values are used in nominal attribute forp
andr
.So is there a recommended way to force the evaluation at translation time, without resorting to a construct such as
loadAndGetReal
which does not seem optimal in terms of resource utilization?The text was updated successfully, but these errors were encountered: