phaehnel / mfpatbc

Phase-averaged tidal boundary condition for numerical groundwater flow models in flopy with MODFLOW-2005, SEAWAT, and MODFLOW 6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mfpatbc

Version 2.0.1

DOI

Introduction

mfpatbc is a Python module to create input data for a phase-averaged tidal boundary (PA-TBC) condition for MODFLOW models created with flopy. The PA-TBC is explained in detail in

Haehnel, P., Greskowiak, J., Robinson, C. E., Schuett, M., & Massmann, G. (2023). Efficient representation of transient tidal overheight in a coastal groundwater flow model using a phase-averaged tidal boundary condition. Advances in Water Resources, 104538. https://doi.org/10.1016/j.advwatres.2023.104538

Supported versions of MODFLOW are MODFLOW-2005, MODFLOW-NWT, SEAWAT, and MODFLOW 6 (constant density). The module defines stress period based input data for the General Head Boundary (GHB) and the Drainage Boundary (Package) as required for the PA-TBC. For MODFLOW-2005, defining freshwater heads for the GHB package as required by the Seawater Intrusion Package (SWI2) is supported.

For use with SEAWAT, the GHB input for the Source and Sink Mixing (SSM) package of MT3DMS can be defined.

Should you find any error or have ideas for improvements, I would be very grateful if you let me know in 'Issues' or 'Discussions' or write me an Email (patrick.haehnel@uol.de).

Installation

Python module

Please download the source code. Place it:

  • in a directory where Python looks for modules (sys.path)
  • local in the directory of the script that loads the module
  • in any directory which is added to the sys.path in your script
>>> sys.path.append('path/to/your/directory')

Or any other, more elegant method you may know.

Compiling Fortran code

The module has a functionality to write GHB and DRN input files independent of flopy (mfpatbc.write_ghb() and mfpatbc.write_drn()) using some Fortran code to write the stress period data. The looping through the stress periods while writing input files is still in Python but the writing of the cell information per stress period is outsourced to Fortran. This is especially time-saving for models with many PA-TBC cells and/or many stress periods. Depending on the model the runtime savings can be around 50 % compared to the flopy writing utilities for the respective input files.

If you do not want to use the Fortran file writing capability please comment the line

>>> from .write_bc import *

in the file '_init_.py'.

The connection between Python and Fortran is obtained by numpy.f2py (documentation). The Fortran script "mfpatbc/write_spd_fort.f90" needs to be compiled on the users operating system in order for the file writing capabilities of mfpatbc to work. This needs some work on the console or terminal.

Steps:

  1. Open terminal or console of your operating system
  2. Navigate to the folder 'mfpatbc/' that contains the scripts of this module
  3. Compile the Fortran script by entering (if there are any problems on Windows there is some information on numpy.f2py with windows in the documentation)
$ python -m numpy.f2py -c write_spd_fort.f90 -m write_spd_fort

The resulting file provides an interface between Python and Fortan so that the subroutine in the Fortran script, that does the heavy lifting, can be accessed just as a normal Python module by mfpatbc. All this is only tested on an Ubuntu system, so errors may (or should?) occur elsewhere.

Documentation

Is provided within the methods, functions, and classes as docstring. Access e.g. via

help(mfpatbc.PATBC)
?mfpatbc.PATBC
??mfpatbc.PATBC

Getting started

The folder 'examples' provides Jupyter Notebooks showcasing the use of the module for MODFLOW-2005, SEAWAT, and MODFLOW 6 with flopy.

How to cite

Haehnel, Patrick (2023). mfpatbc v2.0.0 [Software] URL: https://github.com/phaehnel/mfpatbc

About

Phase-averaged tidal boundary condition for numerical groundwater flow models in flopy with MODFLOW-2005, SEAWAT, and MODFLOW 6

License:Other


Languages

Language:Python 98.3%Language:Fortran 1.7%