Skip to content

Commit

Permalink
merge develop into transport (#469)
Browse files Browse the repository at this point in the history
* fix(uzf): fix indexing error in UZF (#274)

* Error introduced as part of recent UZF refactoring
* Closes #273

* fix(memory): some variables not deallocated (#278)

Implemented new check in develop mode so code bombs with error if memory manager variable not deallocated

* refactor(budobj): new budget object for advanced packages (#279)

* single code base for writing binary budget files for advanced packages
* single code base for creating and writing budget tables to list file for advanced packages
* implemented for MAW, UZF, LAK, SFR, and MVR
* closes #277
* update mf6exes from 2.0 to 3.0
* will allow generalized transport calculations for advanced packages

* refactor(advanced packages): read static data as part of df() (#281)

* refactor(advanced packages): modify advanced packages to read all static data as part of df()
* modify setup_budobj to include the connectivity so that it is available to other models

* fix(budterm): initialize nlist to zero (#283)

* initialize nlist to zero (#284)

* fix(lak): initialize chdratin and chdratout to zero (#286)

* fix(lak): added sign checks for user specified lak flow terms (#288)

* User-specified values for RAINFALL, EVAPORATION, RUNOFF, INFLOW, and WITHDRAWAL must be positive.  The program worked if these values were negative, but that doesn't necessarily make sense and is probably an input error.
* Updated definition file to reflect these changes
* Corrected minor typo in lake definition file
* Updated release notes to reflect this change
* Close #287

* feat(sfr): add storage term to sfr budget (#293)

* Also includes a reach volume term written as an aux variable.  This is needed for transport.
* initialize str so non-ascii characters don't show up in output files
* updated notes for these changes

* * fix(csub): Fix CSUB binary budget data saved as IMETH=6 datatype

closes #290

* refactor(sfr): Refactor SFR Package to remove use of Geometry objects (#296)

* refactor(sfr): Refactor SFR Package to remove use of Geometry objects

* doc(pak-ts): update description of package timeseries variables. 

* ci(yml): update yml to clone shallow copy of flopy and pymake repos

* doc(release): Update release notes

* Closes #276, and #289

* refactor(xt3d): accumulate flowja instead of set (#306)

This change is required for transport, which accumulates terms in flowja

* fix(dis): corrected connection vector error in DIS package (#308)

Code was incorrectly calculating cell center elevations when nozee was .false.  This error would have affected XT3D simulations with unconfined flow and non-zero values specified for ANGLE2 in the NPF Package.  It also would affect dispersive transport with XT3D for unconfined conditions.

* Update sln-ims-example.dat

* refactor(maw): refactor MAW conductance calculation for issue 305 (#310)

Add traps to catch 1) skin factors that are <= 0 when using the SKIN
conductance equation and 2) and negative saturated conductances values.

Closes #305

* feat(tableobj): Add a generic table object for lst file output (#303)

Full implementation for SFR package. Partial implementation for LAK, MAW, and UZF packages.

* feat(tableobj): update MAW package to use tableobj for data output (#315)

Also fix some budget reporting issues in the MAW package

* fix(auxmult): auxmult fix when auxmult and bound are in time series (#316)

* change order of time series interpolation so aux is done first in case it is an auxmult column
* partially addresses #314
* updated release notes

* refactor(BoundaryPackage): Add use of TableObject for print_flows option (#317)

* feat(lnf): update n-point geometry package data

* Revert "feat(lnf): update n-point geometry package data"

This reverts commit 3460cfb.

* fix(lak): revise the way outlet to-mvr flows are stored in budobj (#321)

* fix(lak): revise the way outlet to-mvr flows are stored in budobj

* updated release notes

* refactor(lak/maw/sfr): for CONSTANT features write fixed value instead of DHNOFLO to binary file (#329)

* refactor(lak/maw/sfr): for CONSTANT features write fixed value instead of DHNOFLO to binary file

* update release notes

* fix(maw): new headtable corrected to have mawwells rows instead of maxbound (#332)

* fix(sfr): Remove upstream_fraction check from PACKAGEDATA block (#334)

closes #324

* feat(transport): update develop with some general routines needed for transport (#339)

* feat(transport): update develop with some general routines needed for transport
* fix(mover): correct typo in error message
* closes #336
* refactor(disu): correct type in disu error message
* closes #635

* fix(csub): Allow interbed observations when no interbeds specified (#338)

DNODATA values reported if 1) delay interbed observations are specified
and no delay interbeds are specified and 2) interbed observations are
specified and the number of interbeds is zero. Added test of all
observation types to test_gwf_csub_sk01.py which has no interbeds.

closes #298

* ci(travis): update travis.yml to install miniconda instead of apt python (#346)

* refactor(mf6): standardize output to STDOUT to use istdout variable

* refactor(mf6): standardize output to STDOUT to use istdout variable

Modify mf5to6 to use standard SimVariables.f90 in mf6 src and add
ListType variables in original mf5to6 SimVariables.f90 file to
SimListVariables.f90 and update use statements.

* feat(npf): add save saturation option to NPF (#351)

* changed some things to public in lak, uzf, sfr
* fixed minor bug in uzf
* updated release notes and dfn files
* modified lak to store hlak and clak in the bound array

* refactor(sim_message): Refactor to have independent sim_message (#353)

* bug(csub): Write better cellid format to strain csv files (#355)

Write integer cellids to csv files instead of string. Add method
to discretization classes to return array of user indices. Refactored
table output to use table object instead of UWWORD.

closes #299

* fix(csub): Add additional inelastic- and elastic-compaction-cell obs. (#356)

Closes #302

* fix(csub): Report NODATA for CSUB observ. not calculated in steady-state (#359)

CSUB source has been modified to report NODATA values for observations
that are not calculated during steady-state stress periods.
Observations that are not calculated for steady-state stress
periods include SKE, SK, SKE-CELL, SK-CELL, DELAY-HEAD,
DELAY-PRECONSTRESS, DELAY-GSTRESS, DELAY-ESTRESS, PRECONSTRESS-CELL.
Update mfio to reflect these changes.

Also modified CSUB observations so that thick-cell observation is
correctly calculated during steady-state stress periods.

Closes #300

* Merge refactor-src into develop (#361)

* refactor(ListReader): Refactor ListReader to use table object (#362)

* fix(npf): remove isavsat hardwire (#364)

* refactor(src): remove unused variables (#366)

* update mkdist.py to copy additional MSVS solutions and projects

* refactor(uzf): refactor uzf to use table object instead of UWWORD (#367)

* refactor(uzf): refactor uzf to use table object instead of UWWORD

Also simplify table object to write tables of unknown length.

* refactor(uzf): refactor uzf to use table object instead of UWWORD

Simplify table object to write tables of unknown length. Update
observations to use table object when PRINT_INPUT (iprpak=1) is
specified to write input observation data.

* fix(uzf): flowjaface is not ordered for uzf (#372)

* fix(bnd_cf): make another call to bnd_cf routines in gwf bnd_bd (#378)

* boundary budgets were being calculated using hcof and rhs values from the previous iteration.  This could cause drain flows to be into the aquifer, for example. This fix recalculates the package hcof and rhs values in bd using the final head solution.

* update release notes to reflect this change

* docs(sfr/lak): couple minor doc changes (#380)

* refactor(src): remove unused variables

* update mkdist.py to copy additional MSVS solutions and projects

* docs(sfr/lak): couple minor doc changes

* feature(ims): add additional solver output (#375)

Closes #375

* refactor(lak package dfn - perioddata): combined all perioddata into one recarray (#381)

* refactor(lak package dfn - perioddata): combined lakeperioddata and outletperioddata into perioddata

* refactor(lak stress period data): updated dfn

* feature(ims): refactor package convergence check (#382)

* Introduce end-of-line normalization (#386)

* refactor(xt3d): update develop with minor changes needed for transport (#388)

* feature(ims): update inner iteration summary (#389)

* refactor(NumericalSolution): refactor csv output (#395)

* refactor(NumericalSolution): refactor csv output

Refactor csv output to save at the end of the each outer iteration. Add
options to save separate outer and inner iteration data.

closes #172

* refactor(NumericalSolution): refactor *_cc() methods (#396)

Refactor *_cc() methods to pass package integer (ipak) location
information and the total number of inner iterations. The ipak
variable simplifies construction of the solution outer iteration
information for the csv file. The total number of inner iterations
makes package convergence csv files consistent with the outer iteration
csv file.

Update the release notes to reflect recent changes to csv convergence
output. Also moved changes for previous versions to release notes
appendix (Appendix A).

* refactor(Sim): Add MessageModule to containerize message functionality (#399)

Add generic message functionality (in Message.f90) to standardize messages
(errors, warnings, notes) written at the end of the simulation. Added initial 
warning messages in mf6. Warning messages and notes are not written if
the 'SUMMARY' level command line switch is specified.

Refactor IMS package to replace outer_hclose and inner_hclose with
outer_dvclose and inner_dvclose. Using outer_hclose and inner_hclose
will return warning messages. Added error messages for outer_rclosebnd
and csv_output.

* docs(gwf-mvr.dfn): clarify mvrtype definition (#408)

Closes #393

* refactor(misc): bringing in changes made on transport branch (#409)

* implemented table writer for mvr flows
* turned on fpp preprocessing in vfproj for compilerversion.fpp
* modifed obs table header in tex file
* minor changes to budget and budgetobject to support transport

* Output in bmi
- writing stdout to file or screen is now configurable through bmi

(cherry picked from commit ba98a37)

* Cleaning up the bmi a bit...

(cherry picked from commit 798afe9)

* Introduced option to update storage (sc2) for each timestep

(cherry picked from commit 93b5cc9)

* and also update flag for sc1 now

(cherry picked from commit c4ff085)

* refactor(misc): add deprecated tag to dfn, refactor budget.f90 (#413)

* refactor(misc): add deprecated tag to dfn, refactor budget.f90

* updated mf6ivar readme.md to included deprecated description

* fix for maw02 failure resulting from flopy updates

* feat(DRN): add option for scaling drainage discharge

* feat(DRN): add option for scaling drainage discharge

Add autotest (test_gwf_drn_ddrn02) that compares cubic scaled drain
discharge to groundwater seepage calculated by the UZF package.

* feat(DRN): add option for scaling drainage discharge

Add autotest (test_gwf_drn_ddrn01) that compares scaled drain
discharge to calculated values. Update release notes with scaled
drainage discharge option.

* feat(sim): add standard subroutine for deprecation warnings

* feat(sim): add standard subroutine for deprecation warnings

* feat(sim): add standard subroutine for deprecation warnings

Modify get_filename() subroutine to trim filename path based on OS.

* feat(sim): add standard subroutine for deprecation warnings

Modify get_filename() subroutine to trim filename path based on OS.

* BMI work: writing bmi messages through generic utils

* sorry, forgot width specifier...

* docs(gwf-sfr.dfn): clarify 2nd idv definition (#418)

Close #417

* ci(update): update to travis yml - patterned after flopy

* ci(update): update to travis yml - patterned after flopy

* ci(update): update to travis yml - patterned after flopy

* ci(update): update to travis yml - patterned after flopy

* ci(update): update to travis yml - patterned after flopy

* ci(update): update to travis yml - patterned after flopy

* ci(update): update to travis yml - patterned after flopy

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): rework travis.yml

* ci(update): cleanup

* refactor(lak): refactor timeseries to use read_value_or_time_series()

* refactor(lak): refactor timeseries to use read_value_or_time_series()

* refactor(lak): refactor timeseries to use read_value_or_time_series()

* refactor(lak): refactor timeseries to use read_value_or_time_series()

* refactor(advanced packages): minor changes to support buoyancy package (#422)

* refactor(advanced packages): add minor changes to support buoyancy package

* add change to boundarypackage.f90 to support the noupdateauxvar variable

* fix for latests flopy changes

* refactor(lak): refactor timeseries to use read_value_or_time_series()

* refactor(lak): refactor timeseries to use read_value_or_time_series()

* refactor(lak): refactor timeseries to use read_value_or_time_series()

Fixed issue in HashTable when key does not exist and return from
function with uninitialized indx. With gfortran indx was initialized
by default to a value greater than 0.

* refactor(lak): refactor timeseries to use read_value_or_time_series()

Cleanup of error messages.

* fix(exg-mvr): dis object not associated for binary save flows (#425)

* refactoring of the budget object resulted in an unassociated dis object when writing flows for exchange water mover
* dis is no longer optional for mvr_cr()
* closes #423

* refactor(sfr): use read_value_or_time_series_adv() for timeseries (#424)

* refactor(uzf): use read_value_or_time_series_adv() for timeseries (#429)

* docs(gwf-uzf.dfn): fix typo (#431)

* refactor(maw): use read_value_or_time_series_adv() for timeseries (#430)

* refactor(Memory): remove unused MemoryTSType (#434)

* fix(sfr): fix error in upstream factor check with diversions (#435)

Initialize diversion flow (divflow) to zero in the event that they are
not defined in the first stress period.

* fix(uzf): fix memory leak in UzfCellGroup (#437)

close #436

* refactor(lak/sfr): changes for future support of density variations (#441)

* feat(sfr): Add picard iteration loop in sfr_fc() (#440)

Also cleanup sparse and remove as a sfrtype variables.

* docs(gwf-drn.dfn): fix typo (#439)

* refactor(csub): use read_value_or_time_series_adv() for timeseries (#442)

Also error message cleanup.

* docs(gwf-drn.dfn): offer clarification to AUXDEPTHNAME definition (#443)

* refactor(mvr): implement provider mapping array for mvr budget (#450)

* mvr budget now contains lake number instead of outlet number when lake is a provider
* added first cut of maw density routine

* refactor(bmi):  clean up modflow 6 code structure to refine bmi implementation (#454)

- add do_timestep() to the ami
- remove prepareIteration(), moved logic to *_rp()
- remove subtiming
- removed kpicard from sln_ca and further subroutines (*_ad())
- Additional refactoring and cleaning of the code structure

* refactor(MemoryManager): Add specified length sting and string array (#449)

Remove TdisModule dependency in table object. Revise memory 
manager output to use table object. Add table source files to 
mf5to6 converter `extrafiles.txt`. Use table object to print lake 
stages. Add logical size to kind (LGP) for future use.

* fix(maw): initialize xsto and add test (#456)

* fix(NumericalSolution): add counter for time step iteration total (#457)

Refactor iteration total for time step and simulation to clarify
data stored in these variables. Updated test_gwf_npf03_sfr.py and
test_gwf_ts_sfr01.py to output inner and outer iteration convergence
information to listing and csv files for evaluation of proper output.
Also evaluated results for test_gwf_npf02_rewet.py autotest since it
has more than 1 time step.

Closes #410

* feat(validate): validate MODFLOW 6 simulation mode.

* docs: fix typo in developer guide (#464)

* refactor(model_ad): revert the model advance back to numerical model (#462)

* allocate auxname to size 0 and then reallocate when auxiliary detected

* Further refactoring BMI for upcoming release (#465)

* - finished refactoring *_ad back to sln_ca in the shape of a prepareSolve call (c.f. #462)
- changed prepare_iteration to prepare_solve, etc.
- style change in ami functions, e.g. perform_time_step instead of perform_timestep

* - add safety check: multiple solution groups are not supported for use with BMI.

* refactor(bmi): refactor grid routines (#460)

* refactor(bmi): refactor grid routines

Previously we used the 'save' attribute to allocate the memory and
persist over the call to the routine.
This is not fool proof (multiple calls before using the results will mess things up).
After this commit, the caller has to allocate the appropriate memory,
similar to get_var_shape.

* refactor(bmi): change i6 to i0

* feat(maw): add defined flow correction option (#463)

* feat(maw): add defined flow correction option

* feat(validate): validate MODFLOW 6 simulation mode.

* feat(validate): validate MODFLOW 6 simulation mode.

* feat(validate): validate MODFLOW 6 simulation mode.

* ci(bmi): update rch02 autotest and add sto01 autotest

Co-authored-by: Hughes, J.D <[email protected]>
Co-authored-by: spaulins-usgs <[email protected]>
Co-authored-by: Eric Morway <[email protected]>
Co-authored-by: mjr-deltares <[email protected]>
Co-authored-by: mjr-deltares <[email protected]>
Co-authored-by: Hofer Julian <[email protected]>
  • Loading branch information
7 people committed Jun 4, 2020
1 parent 2ca3d26 commit 94ac8bb
Show file tree
Hide file tree
Showing 35 changed files with 1,731 additions and 574 deletions.
5 changes: 5 additions & 0 deletions autotest/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def target_pth(target, pth):
ttarg = os.path.join(bindir, tprog)
target_dict['libmf6'] = ttarg

# create MODFLOW 6 so/dll target name
tprog = 'libmf6{}'.format(target_so)
ttarg = os.path.join(bindir, tprog)
target_dict['libmf6'] = ttarg

# add MODFLOW 5 to 6 converter to dictionary of valid executable targets
tprog = 'mf5to6{}'.format(target_ext)
ttarg = os.path.join(bindir, tprog)
Expand Down
52 changes: 37 additions & 15 deletions autotest/test_gwf_libmf6_rch02.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"""

import os
import io
import sys
import numpy as np
from amipy import AmiWrapper

Expand Down Expand Up @@ -42,7 +40,7 @@
avg_rch = 0.001

# calculate recharge rates
dx = 1/20
dx = 1 / 20
rad = np.arange(0, 1 + dx, dx) * 2. * np.pi
f = np.sin(rad)
rch_rates = avg_rch + f * avg_rch
Expand Down Expand Up @@ -76,7 +74,7 @@

# build chd stress period data
chd_spd = {0: [[(0, 0, 0), h1],
[(0, 0, ncol-1), h2]]}
[(0, 0, ncol - 1), h2]]}

# build recharge spd
rch_spd = {}
Expand All @@ -87,6 +85,7 @@
nouter, ninner = 100, 300
hclose, rclose, relax = 1e-9, 1e-3, 0.97


def build_model(ws, name, rech):
sim = flopy.mf6.MFSimulation(sim_name=name, version='mf6',
exe_name='mf6',
Expand All @@ -96,7 +95,8 @@ def build_model(ws, name, rech):
nper=nper, perioddata=tdis_rc)

# create iterative model solution and register the gwf model with it
ims = flopy.mf6.ModflowIms(sim, print_option='SUMMARY',
ims = flopy.mf6.ModflowIms(sim,
print_option='SUMMARY',
outer_dvclose=hclose,
outer_maximum=nouter,
under_relaxation='DBD',
Expand Down Expand Up @@ -137,16 +137,16 @@ def build_model(ws, name, rech):
('BUDGET', 'ALL')])
return sim

def get_model(idx, dir):

def get_model(idx, dir):
# build MODFLOW 6 files
ws = dir
name = ex[idx]
sim = build_model(ws, name, rech=rch_spd)

# build comparison model
ws = os.path.join(dir, 'libmf6')
mc = build_model(ws, name, rech=avg_rch)
mc = build_model(ws, name, rech=0.)

return sim, mc

Expand All @@ -159,8 +159,8 @@ def build_models():
mc.write_simulation()
return

def bmifunc(exe, idx, model_ws=None):

def bmifunc(exe, idx, model_ws=None):
success = False

name = ex[idx].upper()
Expand All @@ -178,10 +178,11 @@ def bmifunc(exe, idx, model_ws=None):
return bmi_return(success, model_ws)

# time loop
start_time = mf6.get_start_time()
current_time = mf6.get_current_time()
end_time = mf6.get_end_time()
simulation_length = end_time - current_time

# maximum outer iterations
max_iter = mf6.get_value_ptr("SLN_1/MXITER")

# get recharge array
cdata = "{} RCHA/BOUND".format(name)
Expand All @@ -191,17 +192,37 @@ def bmifunc(exe, idx, model_ws=None):
# model time loop
idx = 0
while current_time < end_time:

# get dt and prepare for non-linear iterations
dt = mf6.get_time_step()
mf6.prepare_time_step(dt)

# convergence loop
kiter = 0
mf6.prepare_solve(1)

# update recharge
trch[:] = rch_spd[idx] * area
recharge[:, 0] = trch[:]

# run timestep
try:
mf6.update()
except:
while kiter < max_iter:
has_converged = mf6.solve(1)
kiter += 1

if has_converged:
msg = "Component {}".format(1) + \
" converged in {}".format(kiter) + " outer iterations"
print(msg)
break

if not has_converged:
return bmi_return(success, model_ws)

# update time
# finalize time step
mf6.finalize_solve(1)

# finalize time step and update time
mf6.finalize_time_step()
current_time = mf6.get_current_time()

# increment counter
Expand All @@ -220,6 +241,7 @@ def bmifunc(exe, idx, model_ws=None):
# cleanup and return
return bmi_return(success, model_ws)


# - No need to change any code below
def test_mf6model():
# initialize testing framework
Expand Down
Loading

0 comments on commit 94ac8bb

Please sign in to comment.