NREL / BioproductTransitionDynamics

A system dynamics decision support tool for bioproduct industry stakeholders who want to investigate how their decisions can impact the process of bioproducts gaining U.S. market share.
https://bioenergymodels.nrel.gov/models/14/
1 stars 0 forks source link

feedstocks corn stover and generic perennial lead to floating point error in smoothed NPV deviation #26

Closed rjhanes closed 4 years ago

rjhanes commented 4 years ago

this bug appeared after solving issue #23 in branch feedstockarray

rjhanes commented 4 years ago

in feedstockarray branch, prior to merging pull request

rjhanes commented 4 years ago

in master branch after merging pull request

rjhanes commented 4 years ago

this bug first appeared in commit d6ace32

sample results: latest-commit is with commodity sugar feedstock, latest-commit-local is with corn stover feedstock (smoothed NPV deviation is the one with the floating point error) image

latest-commit is commodity sugar, latest-commit-local is perennial (floating point error occurs earlier than with corn stover): image

calculation structure: image

bwbush commented 4 years ago

@rjhanes, this was caused by the argument of the SQRT function in smoothed NPV deviation becoming very slightly negative due to round-of errors. In 3283715757cf34dba74d5a4def8e9075b8fbaea3, I added a guard against this. I also reviewed the code and found no other uses of SQRT.

Please retest a couple of the problematic cases to verify that this change fixes all of them. (Because some of the round-off errors didn't appear on my Windows VM, I couldn't test every case you mentioned as being problematical. I mostly focused on testing the perennial case with RK4 auto.)

rjhanes commented 4 years ago

I verified that under default model settings, corn stover and generic perennial are both error-free