SPF-OST / pytrnsys

Package that provides functionality to run and process, plot and report TRNSYS simulations
https://pytrnsys.readthedocs.io
GNU General Public License v3.0
11 stars 8 forks source link

Add option to always define output temperature default variable name #133

Closed zuckerruebe closed 2 years ago

zuckerruebe commented 2 years ago

Context

E.g. in our collector we have the following statement:

@temp(Out, TCollOut) = [42,7]

In "GUI mode", i.e. when we're not just using the default, TCollOut won't be defined. If that variable is referenced somewhere else in the ddck we'll get an error. The same holds if it's referenced somewhere outside the ddck (and the hydraulics ddck as it shouldn't be referenced there because that file is under the GUI's control), say in the control ddck.

Additionally defining TCollOut like so

TCollOut = [42,7]
@temp(Out, TCollOut) = TCollOut

or so

@temp(Out, TCollOut) = [42,7]
TCollOut = [42,7]

seems to solve the problem for GUI mode but it looks confusing and, worse, it breaks when using the "no-GUI mode" as there TCollOut would be defined twice.

Proposed solution

We should add the option to additionaly define the output temperature variable when in GUI mode (note the !)

@temp!(Out, TCollOut) = [42,7]

which is replaced by

TCollOut = [42, 7]

in the no-GUI case and

TCollOut = [42, 7]
TCollector = TCollOut

in the GUI case (TCollector is the automatically created/connected name).

Outlook / interoperability with "local and global variables"

In the near future we should have "local" and "global" variables in ddcks. Most likely a local variable X in a component's ddck will just be prefixed with the component's name. Let's say the component's name is "Collector" than the local variable will be replaced by CollectorX. Global variables will be left as is: Y will remain Y.

For the sake of this discussion let's assume a local variable is designated by prefixing it with a colon :, i.e. :X in the ddck will be replaced by CollectorX in the dck file (other implementations are possible, e.g. prefixing global variables with $).

Then we can support different use cases.

  1. Using the latest & greatest features while being backwards compatible (note the missing ! in @temp)
:TOut = [42, 7]
@temp(Out, TCollOut) = :TOut

... = ... * :TOut ...
  1. Being lazy and changing ddcks as little as possible (also appropriate for a component that can every only be included once in a system, but I'd say never say never...)
@temp!(Out, TCollOut) = [42,7]

... = ... * TCollOut ...
zuckerruebe commented 2 years ago

@danielcarbonell @ignasigurruchagagarcia: What do you think? It would mean having to add ! in the relevant ddcks...

@martin-neugebauer Any passionate opinions? :D

zuckerruebe commented 2 years ago

We've decided to pursue a different direction: https://github.com/SPF-OST/pytrnsys/issues/134