-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Summary of Issue:
While working with a large MODFLOW-2005 model, I noticed significant differences between the mass balance in constant head boudaries reported in the main output file and the balance calculated using fluxes from the Cell-by-Cell (CBC) file. This discrepancy occurs when constant head cells have both inflows and outflows from neighboring cells.
Steps to Reproduce:
Create a model with constant head cells that have both inflow and outflow from adjacent cells.
Compare:
- Mass balance reported in the main output file (reported using CHIN and CHOUT in the code).
- Mass balance calculated from fluxes in the CBC file (repored using RATE in teh code).
Observed Behavior:
Output File (A): Adds both inflow and outflow through the constant head boundary:
Example: 10 L³/T entering from the left, 11 L³/T leaving to the right → adds 10 L³/T in and adds 11 L³/T out.
CBC File (B): Reports only the net flow for the cell:
Example: Same scenario → reports 1 L³/T leaving the model.
Expected Behavior:
I think the correct way to report mass balance should be B but maybe there are reasons I do not know for using A. In any case I think it is a problem to have differences in the way the balance is reported in output file and CBC file.
Proposed Fix
Modify gwf2lpf7.f to define two new variables RATE_IN and RATE_OUT and update as follows:
CHARACTER*16 TEXT
DOUBLE PRECISION HD,CHIN,CHOUT,XX1,XX2,XX3,XX4,XX5,XX6
DOUBLE PRECISION RATE_IN,RATE_OUT ! added line
DATA TEXT /' CONSTANT HEAD'/
! Initialize before loop
RATE_IN = ZERO ! added line
RATE_OUT = ZERO ! added line
! Inside loop after BUFF(J,I,K)=RATE:
RATE = CHCH1+CHCH2+CHCH3+CHCH4+CHCH5+CHCH6
BUFF(J,I,K)=RATE
IF (RATE > 0) THEN ! added line
RATE_IN = RATE_IN + RATE ! added line
ELSE ! added line
RATE_OUT = RATE_OUT - RATE ! added line
ENDIF ! added line
! Further down, replace CHIN and CHOUT with RATE_IN and RATE_OUT:
CIN = RATE_IN
COUT = RATE_OUT
I can also copy the entire modified gwf2lpf7.f if this makes it easier or share a model where we can see this issue.
Let me know what you think! Thanks!!