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

Floating Point Division by Zero Error in New TRNSYS Component

3 Posts
2 Users
0 Reactions
16 Views
0
Topic starter

Hello TRNSYS Users,

I have created a new component in TRNSYS and successfully compiled it following the instructions in the Programmer's Guide. The component functions properly under most conditions, and everything appears to work as intended.

However, I am encountering an issue with the simulation start time. When I set the simulation start time between January 1st and January 15th, the component works without any problems. But if the start time is outside this range, I receive the following error message:

Floating point division by zero.

Has anyone experienced a similar issue or have any suggestions for troubleshooting this?

I would greatly appreciate any insights or advice to resolve this problem.

Thank you,
Ali

2 Answers
0

Ali, @alish If you are writing your component using Microsoft Visual Studio and the Intel Visual Fortran compiler then you can run TRNSYS input files directly from the Visual Studio and put breakpoints in your code, stop on them, and the walk one line at a time through the code in order to see what equation is causing the division by zero. There is a tutorial available here: https://www.youtube.com/watch?v=fZ5-zSC094Q

If you are writing your component using the TypeStudio that is built into Trnsys then unfortunately it doesn't have the ability to run in debug mode and step through code. Sometimes a careful look through the code will be enough to find the problem. For instance if you have: myResult = variable1/variable2 then you can replace it with myResult = variable1/max(variable2,0.0001) and solve the problem.

Other times you have to get a little more clever and do something like calling the messages routine to write a "notice" in the list file that tells you that your code got to a particular line. You then look at the list file after running the simulation; if the notice got written then the divide by zero error occurred after that point in the code. If the notice didn't get written before the divide by zero then you know that the error in the code is before where you called messages. The form of the call might be: call messages(-1,'got to line 30','notice',currentUnit,currentType).

david

 

0
Topic starter

Dear David,

Thank you for your detailed response and the helpful suggestions.

I have written my component using Microsoft Visual Studio. I followed the debugging process you described. Running the TRNSYS input file directly from Visual Studio and stepping through the code helped me identify the reason for the division by zero error.

I truly appreciate your guidance and the resources you shared. Thank you again for your support!

Kind regards,
Ali

DavidBradley 02/12/2024 4:12 pm

@alish You are very welcome; I am glad to hear that you were able to find the cause of the problem!
best, david

Share: