Skip to content
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

Split vertical fluxes on basin #1300

Merged
merged 20 commits into from
Mar 28, 2024
Merged

Split vertical fluxes on basin #1300

merged 20 commits into from
Mar 28, 2024

Conversation

SouthEndMusic
Copy link
Collaborator

Fixes #661.

@SouthEndMusic SouthEndMusic marked this pull request as draft March 21, 2024 14:19
@SouthEndMusic
Copy link
Collaborator Author

@visr let me know whether you think this is going in the right direction. The vertical fluxes get integrated now but they are not yet saved. Something about this also feels a bit silly, since this does an approximation of the integral while we could easily obtain the exact value.

@SouthEndMusic
Copy link
Collaborator Author

In fact, for forward fill we don't need vertical_flux_prev at all, we just have to make sure the integration is computed before vertical_flux is updated.

@SouthEndMusic SouthEndMusic force-pushed the split_vertical_fluxes branch from f20390f to 560f695 Compare March 25, 2024 13:08
@SouthEndMusic
Copy link
Collaborator Author

SouthEndMusic commented Mar 25, 2024

Left to do:

  • Add/update docstrings, move function(s) to utils.jl;
  • Update documentation;
  • Add tests of Basin output.

@SouthEndMusic
Copy link
Collaborator Author

SouthEndMusic commented Mar 26, 2024

Maybe #1084 can also be picked up in this PR, just expose vertical_flux_integrated in stead of vertical_flux values. One thing we need to think about as discussed with @HendrikKok is what happens when a basin dries out.

Edit: it might not be that easy. We might need yet another copy of the vertical fluxes for the same reason we need realized_bmi, i.e. vertical_flux_integrated is set to all 0 after averaging. Also, the mean flows coming in via BMI have to somehow end up in the instantaneous vertical fluxes used in water_balance! without being overwritten before use.

end

# Forget about vertical fluxes before basin update
copyto!(vertical_flux_prev, vertical_flux)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be most accurate, maybe an exception should be made for vertical fluxes which are not set by the Basin \ time table.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically only some of the vertical fluxes will be in Basin \ time. Could you make an issue about this? I don't fully oversee the error introduced in this case.

@SouthEndMusic SouthEndMusic marked this pull request as ready for review March 26, 2024 14:15
@SouthEndMusic SouthEndMusic requested a review from visr March 26, 2024 15:23
docs/core/usage.qmd Outdated Show resolved Hide resolved
docs/core/usage.qmd Show resolved Hide resolved
core/test/time_test.jl Outdated Show resolved Hide resolved
core/test/time_test.jl Outdated Show resolved Hide resolved
core/test/time_test.jl Outdated Show resolved Hide resolved
core/src/callback.jl Show resolved Hide resolved
core/src/callback.jl Outdated Show resolved Hide resolved
end

# Forget about vertical fluxes before basin update
copyto!(vertical_flux_prev, vertical_flux)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically only some of the vertical fluxes will be in Basin \ time. Could you make an issue about this? I don't fully oversee the error introduced in this case.

core/src/util.jl Outdated Show resolved Hide resolved
core/src/allocation_optim.jl Outdated Show resolved Hide resolved
@visr visr merged commit db46d1e into main Mar 28, 2024
24 checks passed
@visr visr deleted the split_vertical_fluxes branch March 28, 2024 15:18
visr added a commit that referenced this pull request Apr 8, 2024
This was missed from #1300. We don't store vertical flows anymore. Doing
this was the only reason for `formulate_flows!` for Terminal nodes.

What I don't fully understand is why tests did not fail on this. Any
test model with a Terminal should have failed since the 3-arg
`add_flow!(graph, id, -q)` it called was removed in #1300. This PR also
removes the 4-arg version that is no longer used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combined vertical fluxes on Basin
2 participants