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

Nash Cascade based surface runoff #112

Merged
merged 6 commits into from
Apr 23, 2024
Merged

Conversation

ajkhattak
Copy link
Contributor

Added a new scheme for the surface runoff that is based on Nash Cascade approach. The CFE will now support two schemes for surface runoff: 1) GIUH-based scheme, and 2) NASH_CASCADE-based scheme. Also, with these changes we will have now one Nash cascade model for the surface and one for the subsurface lateral flow. The two Nash models are slight different and hence implemented differently, but the hope is to merge them later. The changes in this PR don't change results of the existing tests.

Additions

  • Added Nash Cascade model for surface runoff

Removals

  • None

Changes

  • BMI variable name change GIUH_RUNOFF to SURFACE_RUNOFF
  • The model requires a new parameter surface_runoff_scheme as an input in the config file

Testing

  1. All existing tests passed

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • New functions are documented (with a description, list of inputs, and expected output)
  • Reviewers requested with the Reviewers tool ➡️

… var name 'giuh_runoff' with a more generic name 'surface_runoff', bug fix in the volume, end surface and other related changes.
…ated, add example config file for Nash cascade based surface runoff, updated README.md
documented surface runoff schemes and Nash parameters for the surface runoff.

model->giuh_ordinates = malloc(sizeof(double) * model->num_giuh_ordinates);
// Work with copy of the string pointer to make sure the original pointer remains unchanged, so mem can be freed at end
copy = giuh_originates_string_val;
Copy link
Member

Choose a reason for hiding this comment

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

This is not a string copy, and these comments should probably reflect that. This is a copy of the pointer so that the beginning of the string isn't lost. The following loop will set value = copy, and then changes , to \0 so that strtod converts the right bytes for the ordinate value. I think the full string copy is misleading, that would require something like strcpy or some other allocation of a buffer and copy of the string values. This is just a reference copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. it has been there for a while but probably nobody caught it. I agree we are just copying one pointer to another, and not a full string copy, to preserve the original pointer to giuh_ordinates. I will update the comment to help clearly explain it, please have a look afterward.

… for the subsurface lateral flow N_nash and K_Nash.
@madMatchstick madMatchstick merged commit c492368 into master Apr 23, 2024
4 checks passed
This was referenced May 1, 2024
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.

3 participants