respec / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
43 stars 17 forks source link

Bug in HYDR-INIT parser #109

Closed rburghol closed 1 year ago

rburghol commented 1 year ago

IT looks like the HYDR-INIT block should follow a format where the OPNID parameters occupy 10 columns, but ParseTable.csv has 12 allocated. This seems to go without causing problems in many cases, however, when the initial VOL parameter is rather large (like in a super large reservoir), the warm-up period for the model can be greatly extended, as the left-most digit of the VOL parameter is cut off, and therefore, a million (or couple hundred thousand) or so acre feet are missing at initial conditions.

Example:

  HYDR-INIT
    RCHRES  Initial conditions for HYDR section     ***
    # -  #       VOL       Initial value of COLIND  ***  Initial value of OUTDGT
             (ac-ft)       for each  possible exit  ***  for each  possible exit
                 VOL      CEX1 CEX2 CEX3 CEX4 CEX5  *** DEX1 DEX2 DEX3 DEX4 DEX5
    1      279231.00
  END HYDR-INIT

The simulation begins with a VOL of 79231.00 rather than a VOL of 279231.00

I shifted all columns over 2 in ParseTable.csv and all runs correctly )see below). Pull Request at #108

Table 1: New ParseTable.csv entries for HYDR-INIT

1523,RCHRES,HYDR-INIT,HYDR,STATES,OPNID,C,0,10,
1524,RCHRES,HYDR-INIT,HYDR,STATES,VOL,R,10,21,0
1525,RCHRES,HYDR-INIT,HYDR,STATES,ICAT,R,21,25,-1
1526,RCHRES,HYDR-INIT,HYDR,STATES,COLIN1,R,25,30,4
1527,RCHRES,HYDR-INIT,HYDR,STATES,COLIN2,R,30,35,4
1528,RCHRES,HYDR-INIT,HYDR,STATES,COLIN3,R,35,40,4
1529,RCHRES,HYDR-INIT,HYDR,STATES,COLIN4,R,40,45,4
1530,RCHRES,HYDR-INIT,HYDR,STATES,COLIN5,R,45,50,4
1531,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG1,R,55,60,0
1532,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG2,R,60,65,0
1533,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG3,R,65,70,0
1534,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG4,R,70,75,0
1535,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG5,R,75,80,0

Table 2: Old ParseTable.csv entries for HYDR-INIT

1523,RCHRES,HYDR-INIT,HYDR,STATES,OPNID,C,0,12,
1524,RCHRES,HYDR-INIT,HYDR,STATES,VOL,R,12,23,0
1525,RCHRES,HYDR-INIT,HYDR,STATES,ICAT,R,23,27,-1
1526,RCHRES,HYDR-INIT,HYDR,STATES,COLIN1,R,27,32,4
1527,RCHRES,HYDR-INIT,HYDR,STATES,COLIN2,R,32,37,4
1528,RCHRES,HYDR-INIT,HYDR,STATES,COLIN3,R,37,42,4
1529,RCHRES,HYDR-INIT,HYDR,STATES,COLIN4,R,42,47,4
1530,RCHRES,HYDR-INIT,HYDR,STATES,COLIN5,R,47,57,4
1531,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG1,R,57,62,0
1532,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG2,R,62,67,0
1533,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG3,R,67,72,0
1534,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG4,R,72,77,0
1535,RCHRES,HYDR-INIT,HYDR,STATES,OUTDG5,R,77,82,0

Image 1: HYDR-INIT Tale description in HSPF Manual V12 image

PaulDudaRESPEC commented 1 year ago

Yeah, thank you for pointing that out! I'm sure you have the correct fix. I'm planning to take a closer look to see how this error got in there, and make sure there aren't other places where something similar needs to be fixed.

PaulDudaRESPEC commented 1 year ago

Found and fixed similar occurrences with OPNID of wrong length, now all consistently length 10.