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

What happens when flows are not saved for every time step? #28

Open
RyanConway91 opened this issue Nov 10, 2021 · 8 comments
Open

What happens when flows are not saved for every time step? #28

RyanConway91 opened this issue Nov 10, 2021 · 8 comments

Comments

@RyanConway91
Copy link

Im saving flows every 10th timestep. However, MP7 is reporting results for every time step. Is it interpolating the flow field or doing a "forward fill" or what?

@aprovost-usgs
Copy link
Collaborator

@RyanConway91 MODPATH reads new information from the budget only when it finds information for the current stress period and time step. If there's no information for the current stress period and time step in the budget, it should keep using the last information it read, which I assume is what you meant by "forward fill." If it doesn't appear to be doing that in your simulation, please let me know.

@RyanConway91
Copy link
Author

Looking at the .lst file, its not clear if this is happening or not. In the first stress period, there are 20 timesteps and I am saving timestep 1, 10, and 20. Looking at the Volumetric water balance summary (is there something I should check to see what budget information is being use?), it does not appear that budget is being "forward filled". Here are the volume errors for the 20 timesteps in stress period 1:

Line 120: 1889471 cells had errors less than or equal to 0.01 percent (this is SP1, TS1 (real data in cbb in hds))
Line 185: 78111 cells had errors less than or equal to 0.01 percent
Line 250: 78111 cells had errors less than or equal to 0.01 percent
Line 315: 78111 cells had errors less than or equal to 0.01 percent
Line 380: 78111 cells had errors less than or equal to 0.01 percent
Line 445: 78111 cells had errors less than or equal to 0.01 percent
Line 510: 78111 cells had errors less than or equal to 0.01 percent
Line 575: 78111 cells had errors less than or equal to 0.01 percent
Line 640: 78111 cells had errors less than or equal to 0.01 percent
Line 705: 1677993 cells had errors less than or equal to 0.01 percent (this is SP1, TS10 (real data in cbb in hds))
Line 770: 225432 cells had errors less than or equal to 0.01 percent
Line 835: 225432 cells had errors less than or equal to 0.01 percent
Line 900: 225432 cells had errors less than or equal to 0.01 percent
Line 965: 225432 cells had errors less than or equal to 0.01 percent
Line 1030: 225432 cells had errors less than or equal to 0.01 percent
Line 1095: 225432 cells had errors less than or equal to 0.01 percent
Line 1160: 225432 cells had errors less than or equal to 0.01 percent
Line 1225: 225432 cells had errors less than or equal to 0.01 percent
Line 1290: 225432 cells had errors less than or equal to 0.01 percent
Line 1355: 1809775 cells had errors less than or equal to 0.01 percent (this is SP1, TS20 (real data in cbb in hds))

@langevin-usgs
Copy link

Though I have not looked into this very deeply, I feel that MODPATH should terminate with an error if it determines that not all flows were saved. I suppose there could be some exceptions, but in general, particle tracking with an incomplete set of flows seems problematic.

@RyanConway91
Copy link
Author

Noted. I will try simulations with every TS saved and compare. Thanks

@aprovost-usgs
Copy link
Collaborator

@RyanConway91 Thanks very much for following up on that. Based on the information you sent and a subsequent discussion with Chris (@langevin-usgs), it seems clear that there's an issue with how MODPATH is handling (or apparently not handling) the situation in which the stored budget information doesn't correspond one-for-one with the time discretization of the simulation. I agree with Chris that MODPATH should terminate if not all the flows were saved. A preliminary look at the relevant code suggests that it might not be as simple as just inserting a line to write an error message and stop, but I should be able to address this relatively quickly and will post an update as soon as possible.

@aprovost-usgs
Copy link
Collaborator

@RyanConway91 To avoid unintended consequences of simulating particle tracks based on incomplete budget information, MODPATH has been updated (commit a2c53c7) to terminate with an error message if it does not find output in the budget file for the current time step. An updated provisional executable has been posted in modpath-v7/msvs/bin_PROVISIONAL/ -- please see the accompanying README_provisional.txt file for relevant disclaimers.

@aprovost-usgs aprovost-usgs added this to the Version 7.2.02 milestone Dec 15, 2021
@scantle
Copy link

scantle commented Jun 21, 2023

Related to this issue, am I correct that MODPATH erroneously fails when reading the model if heads are not written for the first time step? See the loop exit on line 244:

do n = 1, this%RecordCount
period = this%RecordHeaders(n)%StressPeriod
step = this%RecordHeaders(n)%TimeStep
layer = this%RecordHeaders(n)%Layer
layerCellCount = 1 + this%RecordHeaders(n)%LastCellNumber - this%RecordHeaders(n)%FirstCellNumber
if((period .ne. 1) .or. (step .ne. 1)) exit
if(layer .eq. nextLayer) then
layerCount = layerCount + 1
nextLayer = layerCount + 1
cellCount = cellCount + layerCellCount
else
layerCount = 0
cellCount = 0
return
end if
end do

Looking at the logic here, if the first stress period and time step in the budget aren't 1 it will exit the loop early. layerCount and cellCount both remain zero, obviously causing some issues not long after!

I'm fine with the solution that the model requires you to write the very first step to the budget file. An error message when this happens would be nice then. Another way to do it would be just by making sure the loop doesn't advance to the next time step, e.g.,

  first_period = this%RecordHeaders(1)%StressPeriod
  first_step = this%RecordHeaders(1)%TimeStep
  do n = 1, this%RecordCount
      period = this%RecordHeaders(n)%StressPeriod 
      step = this%RecordHeaders(n)%TimeStep 
      if (period.gt.first_period .or. step.gt.first_step) exit
      
      layer = this%RecordHeaders(n)%Layer
      layerCellCount = 1 + this%RecordHeaders(n)%LastCellNumber - this%RecordHeaders(n)%FirstCellNumber
      
  !    if((period .ne. 1) .or. (step .ne. 1)) exit
      if(layer .eq. nextLayer) then
          layerCount = layerCount + 1
          nextLayer = layerCount + 1
          cellCount = cellCount + layerCellCount
      else
          layerCount = 0
          cellCount = 0
          return
      end if
  end do

@aprovost-usgs
Copy link
Collaborator

@scantle The provisional code was updated (commit a2c53c7) to intentionally stop with an error message if the budget does not contain information for every time step, including the very first step (please see the comment just above yours in this issue). Have you observed failure without a corresponding error message in the case of incomplete budget information when running that updated executable?

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

No branches or pull requests

4 participants