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

Recalling values from previous timestep

4 Posts
3 Users
0 Reactions
126 Views
0
Topic starter

Hello everybody. 

 

I am trying to model a battery in which I start with a maximum state of charge and then, according to the usage and request, the state of charge decreases. I have already done this in MATLAB environment, but when I come to TRNSYS I face some difficulties. For modelling the battery I am using the Type Equation because I have to model the battery degradation according the equation we have developed within our group. 

For each time-step I check the availability to charge and according to the index value I should compute

State_of_charge = State_of_charge_previous + power*time;

where State_of_charge_previous = max value at timestep = 0.

 

The same stands for another variable which is the battery capacity that should start at timestep = 0 equal to max value and than decrease in time.

 

I cannot understand how to say to TRNSYS to save the variable at the previous timestep but with a specific starting value, not zero. 

 

I know the existance of Type 150 or 93-2 but how to set a value different than zero at the beginning?

 

 

Thanks in advance.

 

 

Maja

 

 

2 Answers
0

Dear Maja,
Type 150 has a parameter called "Initial Function Value". Doesn't that do what you want?
Best,
Xenia

majadanovska Topic starter 14/11/2024 10:05 am

@xenia-kirschstein Dear Xenia, you are right. I will try to use Type 150 with the initial value. Thanks a lot.

0

Thank you @xenia-kirschstein! That was going to be my first suggestion as well.

I don't know how complicated your battery model is, but another option would be to create a new TRNSYS Type for your battery model. There are TRNSYS functions available to Types that make it easy to store and recall values from previous timesteps. You can also use If statements, Do loops, and other programming concepts within Types that are somewhat more difficult to replicate within the TRNSYS equation block. More information about writing user Types is provided in the ProgrammersGuide.pdf in the Documentation folder of your main TRNSYS directory.

majadanovska Topic starter 14/11/2024 10:08 am

@a_weiss Dear A_Weiss, thanks a lot for your reply. The model at this moment is quite simple to be honest, maybe in the future if we developed a more complex one I will try to create a new Type as you suggested.

Share: