-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Precision loss when calculating the TotalDuration, as a result, the last report result may not be added in output file #219
Conversation
…ast report result may be added in output file
Hi, If you are using the Delphi SWMM5 GUI - does this happen if you save the date changes to the inp file before running the model? |
@dickinsonre I was using official SWMM installed from https://www.epa.gov/sites/production/files/2018-08/swmm51013_setup_1.exe. Yes, I saved the date changes to the inp file and run the model. I found the issue from the UI operations, So I debugged into the code, and then I verified my thought. |
Thanks for the clarification, @WaterDesk and thanks for finding a fix. |
@WaterDesk, Thanks for reporting this issue. @LRossman / @dickinsonre , do you have an opinion on this? |
I am having trouble duplicating this problem. I change the date,/time run the model and see the new ending date. I am still checking. |
I can reproduce the problem. I believe this fix will also work:
|
Sounds good Lew, I still cannot duplicate this in other models. I seem to be able to change the date at will. |
@WaterDesk 's fix is better than mine because the numbers being subtracted from one another are closer in value. |
@WaterDesk (and @michaeltryby) this change is going to require us to update the benchmarks for the regression tests. @michaeltryby, Is there perhaps a side discussion we can have to improve the workflow for updating the benchmarks? |
Aha, it would be better to have a simpler process to run and update the benchmarks. |
@bemcdonnell opened up Issue #221 for side discussion on reg testing workflow. |
@WaterDesk I have made some changes in |
@WaterDesk I don't have permission to merge upstream develop into your branch. You can grant me permission or do it yourself, either way is fine with me. Let me know what you decide. Thanks! |
@WaterDesk disregard my last message I found a workaround. Thanks for your bug fix! |
@michaeltryby Thanks for you merge! |
Precision loss when calculating the TotalDuration, as a result, the last report result may not be added in output file
SWMM version: 5.1.013
Reproduce Steps:
Analysis:
The Start/End Date and Time is stored as text in INP file, after parsing them from INP file, they will be converted to double values.
The EndTime “11:30:00’’ converts to 0.47916666666666669, when it is added with EndDate “01/02/1998” (35797.000000000000), the new EndDateTime is 35797.479166666664.
Use the below method to calculate the TotalDuration, the result is 127799.0.
From the INP file, the StartDateTime is 01/01/1998 00:00:00, and the EndDateTime is 01/02/1998 11:30:00. The duration is 1 day and 11:30:00, it has 127800 seconds.
1 second precision losses now! So the last time result will never been reported in output file.
Solution:
The precision loss usually happens when a large double value plus a small double value. So, we need to avoid such calculations.
Change the calculation method of TotalDuration to be: