Welcome to the TRNSYS Users Forum.

The forum is a place where people can interact and have discussions about different topics involving the use of the TRNSYS software package. Here you can post topics for discussion or questions on using TRNSYS and get advice from other users or TRNSYS experts. This forum is not intended for detailed technical support. Users should contact their distributor’s hotline for such assistance.

Some tips for success on using the forum:

  • Follow the Forum Rules posted in Forum Administration.
  • There are categories for different types of topics and questions. Post your topic or question into the proper category.
  • Before posting a topic or question search the existing topics  (and the TRNSYS Users listserv archive or Post archive) to see if a similar topic or question has already been answered.
  • Use a descriptive topic name. Don’t use attention getting subjects, they don’t get attention and only annoy people.
  • State the version of TRNSYS and which add-ons your are using.
  • Include enough specific details for your topic of question to be answered. Just posting “Why am I getting an error?” without describing the specific error and what you are trying to do when you get the error will not receive a response that fixes your issue.
  • Remember when people help you, they are doing you a favor. Be patient, help people out by posting good descriptions of what you need help with, and be polite even if a response does not solve your issue.
  • Moderators may edit your post for clarity or move your topic to a more appropriate category.

Notifications
Clear all

[Solved] Confusion about naming of setDynamicArrayValueThisIteration()

3 Posts
2 Users
0 Reactions
465 Views
0
Topic starter

Hi there

The name setDynamicArrayValueThisIteration confuses me, because I can't really think of a case where I want to carry over information from one iteration to the next (within one unit). I was always under the impression that only inputs and outputs are supposed to change within one timestep/from one iteration to the next, but not the internal state of the units. And only once the system has converged to we "commit" to that state by updating the units' state variables (e.g. only change the temperature of your storage tank based on the final inputs into it after the system has converged).

 

So either

1) My assumptions are wrong

or

2)

setDynamicArrayValueThisIteration(), doesn't mean save the values from this iteration so that they're available in the next iteration, but rather save these values and if this iteration turns out to be this timestep's last one, then make them available to the next time step as initial values, otherwise discard them.

The fact that the only way to get at these dynamic values is by using the function called getDynamicArrayValueLastTimestep() points quite strongly to 2), now that I think about it.

 

Am I correct?

 

Thanks for your help,

Damian

 

 

This topic was modified 1 year ago by baumstrunk
1 Answer
0
Topic starter

To answer my own question, the documentation is quite clear that it's 2) (RTFM, myself!):

7.4.4.18.1.2. Dynamic Storage

In the “dynamic storage” situation arises when not only do we wish to use an initial value in calculations but at the end of the time step, we wish to set the final calculated value as the new initial value for the next time step. Any component that solves a differential equation is almost invariably going to use dynamic storage because it needs to predict a final value not based on the final value from the previous iteration but the final value from the previous time step. The Type therefore needs to store the final value from the previous time step somewhere safe. In TRNSYS v.16, this would have been accomplished by reserving two spots in the global storage structure. One spot would be updated at the end of each iteration with the “proposed” final value. Then, during the “end of time step” manipulations section, the last calculated “proposed” final value would have been saved into the other global storage spot as the “real” final value. At the next time step, the Type would read and base its calculations on the “real” final value, repeatedly calculating a new “proposed” final value. With the development of TRNSYS v17, it was felt that the “end of timestep” manipulations were too cumbersome and the concept of “dynamic” global storage was proposed. In this case, only one storage spot is required. The Type calls the setDynamicArrayValue() AccessFunction at the end of each iteration and bases its calculations on what it retrieves from a call to the getDynamicArrayValue() function. The TRNSYS kernel takes care of swapping the two values automatically at the end of a time step.

DavidBradley 21/09/2023 4:20 pm

@baumstrunk I'm glad you posted the question! Others will benefit from it. I'm also really glad that the documentation helped you answer it!! Please don't hesitate to add to the thread if you have follow-up questions!

baumstrunk Topic starter 25/09/2023 1:47 pm

@DavidBradely, thanks I'm flattered. 🙂

Share: