-
Notifications
You must be signed in to change notification settings - Fork 5
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
Run allocation first after BMI stop #1390
Conversation
Some pretty large allocation test differences suggest we don't call allocation correctly yet.
|
This might have to do with the fact that allocation uses the flows from the last |
It actually ran allocation on the wrong times, that is fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left some small comments
@@ -146,6 +146,17 @@ function sorted_table!( | |||
return table | |||
end | |||
|
|||
function valid_config(config::Config)::Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you have this, can it be removed below?
Lines 50 to 53 in e10f657
t_end = seconds_since(config.endtime, config.starttime) | |
if t_end <= 0 | |
error("Model starttime is not before endtime.") | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I forgot, thanks.
core/src/model.jl
Outdated
# set over BMI at time t before calling this function. | ||
# Also, don't run allocation at t = 0 since there are no flows yet (#1389). | ||
ntimes = t / config.allocation.timestep | ||
if ntimes > 0 && round(ntimes) ≈ ntimes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say the more common way to do this is
if t % config.allocation.timestep ≈ 0.0
...
end
and the other check could just be t > 0
if you actually need that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the comparison tolerances work out differently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would only work if the t is right after, but not right before, right?
julia> prevfloat(3.0) % 0.5
0.49999999999999956
lol |
This allows allocation over period
(t, t + dt)
to use variables set over BMI at timet
.We no longer run allocation as a callback, but call it ourselves, such that we can control that BMI runs allocation first before running the physical layer.