Skip to content

bug: Headfile.reverse() changes time-step indices #2459

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

Closed
shundt opened this issue Feb 24, 2025 · 2 comments · Fixed by #2460
Closed

bug: Headfile.reverse() changes time-step indices #2459

shundt opened this issue Feb 24, 2025 · 2 comments · Fixed by #2460
Assignees
Labels
Milestone

Comments

@shundt
Copy link

shundt commented Feb 24, 2025

Bug Description
I am attempting to use the Headfile.reverse() method to facilitate backwards particle tracking using PRT in sequence after GWF. PRT is crashing with the following error:

ERROR REPORT: 1. TIME STEP NUMBER IN HEAD FILE DOES NOT MATCH TIME STEP NUMBER IN TRANSPORT MODEL. IF THERE IS MORE THAN ONE TIME STEP IN THE HEAD FILE FOR A GIVEN STRESS PERIOD, HEAD FILE TIME STEPS MUST MATCH GWT MODEL TIME STEPS ONE-FOR-ONE IN THAT STRESS PERIOD.

It appears that the .reverse() method is adding 1 to all of the time-step indices for each stress period except for the first (which becomes the last in the reversed). The GWF model has 1 time step per stress period. Here is a screenshot showing how the time-step indices have changed:

Image

It is possible this issue is present in the budget file too, but I am having an issue (potentially related) loading the reversed budget file with flopy.

Possible Diagnosis
I was able to fix the behavior in the Headfile by changing header["kstp"] to (header["ktsp"] - 1) in the following function, but am not sure if that is a complete fix.

Image

System & versions

  • OS: Windows
  • Flopy version 3.9.1
@wpbonelli
Copy link
Member

Thanks for reporting @shundt and for suggesting the fix. We didn't check before that kstpkper is the same after reversal.

I think we still need to add some tests for models with irregular tdis, I will come back to that.

@shundt
Copy link
Author

shundt commented Feb 26, 2025

Looks good. Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants