mtiller / ModelicaBook

Source for my new Modelica Book
https://mbe.modelica.university
Other
95 stars 68 forks source link

Bad signals in some interactive figures #421

Closed mtiller closed 5 years ago

mtiller commented 5 years ago

For example, the PI control example at:

http://localhost:3000/components/architectures/thermal_control/

has NaN for the desired temperature?!?

mtiller commented 5 years ago

Turns out that the signal that was missing was from a protected variable and the server wasn't saving protected variables.

I enabled writing out protected variables. This will impact performance slightly. There were two other alternatives I considered and dismissed. First, I thought about making a public variable in the example. But I didn't like that because this is an architecture example and the implementation details really should be made protected to prevent leaking implementation details. Another option was to add a flag to the request indicating protected variables should be saved for that one particular case. The problem here is how is the interactive simulation component to know when protected variables are needed? It would have to come from specs.py which would mean expanding the data model of each case. This could be done, but would be more involved.

So I took the simplest course of action which is simply to default to outputting protected variables. But I'll have to see if this has a significant impact on performance. For most models, there aren't any protected variables, so I expect no impact. But for the component and architecture cases, it could lead to slightly longer simulation times and more time spent parsing results. So I may revisit this at some point.

mtiller commented 5 years ago

Note, although I only noticed one example where this was an issue, there are probably others and that is why I took the approach of exposing all protected variables (vs. having to identify each case one by one).