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

Always require 'Basin / state' as an initial condition #977

Merged
merged 3 commits into from
Jan 23, 2024
Merged

Conversation

visr
Copy link
Member

@visr visr commented Jan 22, 2024

Before we put a volume of 1 m3 in if no initial condition was given. But since this will not always work well, and there is no other number that makes a good default, it is best to remove this feature and request an explicit initial condition.

Upgrade information

Users that wish to upgrade can use the following Python script to add a basic initial condition to their model. The initial levels can be altered to fit the model.

import ribasim
import pandas as pd

# load a model without Basin / state
model = ribasim.Model(filepath="ribasim.toml")
basin = model.basin

# set initial level to (for example) 1 meter above Basin bottom
basin.state.df = pd.DataFrame(
    (basin.profile.df.groupby("node_id").min("level").level) + 1.0
).reset_index()

# write it back
model.write("ribasim.toml")

Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated change, but this was dead code that is unlikely to be used in such form.

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

state_length = length(levels)
basin_length = length(basin.level)
if state_length != basin_length
@error "Unexpected 'Basin / state' length." state_length basin_length
Copy link
Collaborator

Choose a reason for hiding this comment

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

Had a look at what adding the variables at the end does, very nice

Copy link
Collaborator

@SouthEndMusic SouthEndMusic left a comment

Choose a reason for hiding this comment

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

Looks good to me (y)

@visr visr merged commit ec7234d into main Jan 23, 2024
19 checks passed
@visr visr deleted the stateless branch January 23, 2024 09:44
@visr visr added the breaking A change that breaks existing models label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A change that breaks existing models
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants