flopyrw


Nameflopyrw JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryPython interface based on FloPy to configure input files for MODPATH-RW
upload_time2023-08-07 16:30:07
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords modpath-rw hydrogeology rwpt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## flopyrw
An extension of [FloPy](https://github.com/modflowpy/flopy) to write input simulation files for [MODPATH-RW](https://gitub.com/upc-ghs/modpath-rw) with Python.

### Overview
Provides classes extended from the `modpath` module in `flopy` adapted to specific structures required by MODPATH-RW. Also introduces new package writers required by the program, consistent with the [Documentation of Input-Output](https://github.com/upc-ghs/modpath-rw/blob/develop/doc/modpath-rw_IO_v100_.pdf). 


### Quickstart
**Install**

To install the package from source, clone the repository:

```
git clone https://github.com/upc-ghs/flopyrw
```
and install 

```
pip install -e /the/path/to/flopyrw/
```

You can also install the current release from [PyPI](https://pypi.org/project/flopyrw/):

```
pip install flopyrw
```

**Use it**

Classes follow the same logic than `flopy`, configuring packages on top of a MODFLOW flow-model object. For example, the `flopy` quickstart case: 

```py
import os
import flopy
from flopyrw import modpathrw

ws   = './mymodel'
name = 'mymodel'
sim  = flopy.mf6.MFSimulation(sim_name=name, sim_ws=ws, exe_name='mf6')
tdis = flopy.mf6.ModflowTdis(sim)
ims  = flopy.mf6.ModflowIms(sim)
gwf  = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)
dis  = flopy.mf6.ModflowGwfdis(gwf, nrow=10, ncol=10)
ic   = flopy.mf6.ModflowGwfic(gwf)
npf  = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True)
# Same than in flopy quickstart,
# but with an aux var for concentration.
chd  = flopy.mf6.ModflowGwfchd(
        gwf,
        auxiliary=['CONCENTRATION'],
        stress_period_data=[
            [(0, 0, 0), 1.,1.],
            [(0, 9, 9), 0.,0.]
        ]
    )
budget_file = name + '.bud'
head_file   = name + '.hds'
oc = flopy.mf6.ModflowGwfoc(gwf,
        budget_filerecord=budget_file,
        head_filerecord=head_file,
        saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')]
    )
sim.write_simulation()
sim.run_simulation()

# Create a modpathrw model
# By default executable is 'mpathrw'
mprw = modpathrw.ModpathRW(flowmodel=gwf)

# Random walk options
modpathrw.ModpathRWOpts(
        mprw,
        timestep = 'min',
        ctdisp   = 0.1,
        courant  = 0.1,
        dimensionsmask=[1,1,0], # Random walk in x,y and not in z
    )

# Dispersion parameters 
modpathrw.ModpathRWDsp( mprw, alphal=0.1, alphat=0.01,  dmeff=0.0 )

# Basic package
modpathrw.ModpathRWBas( mprw, porosity=0.3 )

# Define the solute source
# In forward tracking, only cells with injecting flow-rate release particles
modpathrw.ModpathRWSrc(
        mprw,
        sources=(
            'CHD', # package name
            [            
                [
                    'CONCENTRATION', # aux variable
                    0.001,           # particlesmass
                    (4,4,1)          # template
                ], 
            ],
        ),
    )

# Configure the simulation 
simconfig = {
    'simulationtype'    : 'rwendpoint', 
    'trackingdirection' : 'forward',
    'weaksinkoption'    : 'stop_at',
    'weaksourceoption'  : 'pass_through',
    'stoptimeoption'    : 'specified',
    'stoptime'          : 20.0,
}
mprwsim = modpathrw.ModpathRWSim( mprw,  **simconfig )

# Write the input files
mprw.write_input()

# And run 
mprw.run_model()

# Get output and plot
head   = gwf.output.head().get_data()
bud    = gwf.output.budget()
epoint = flopy.utils.EndpointFile( os.path.join( ws, mprwsim.endpointfilename ) ) 
spdis  = bud.get_data(text='DATA-SPDIS')[0]
qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spdis, gwf)
pmv = flopy.plot.PlotMapView(gwf)
pmv.plot_array(head)
pmv.plot_grid(colors='white')
pmv.contour_array(head, levels=[.2, .4, .6, .8], linewidths=3.)
pmv.plot_vector(qx, qy, normalize=True, color="white")
pmv.plot_endpoint( epoint.get_alldata(), zorder=10, s=4, linewidth=0.5, edgecolor='k' )
```
<img src="img/quickstart.png" alt="plot" style="width:30;height:30">

**Note**: In order to run a model via the interface a [MODPATH-RW](https://gitub.com/upc-ghs/modpath-rw) executable is required. 


### Testing
A suite of [automated tests](autotest/) is available verifying different aspects of the interface and the program. In order to run these tests, some additional dependencies are required, which can be installed with:

```
pip install ".[test]"
```

You can follow the [FloPy test guidelines](https://github.com/modflowpy/flopy/blob/develop/DEVELOPER.md#running-tests) for running and debugging tests. 

Run the complete test suite from the folder ``autotest`` with the command:

```
pytest -s -v 
```

## Resources
* [flopy](https://github.com/modflowpy/flopy)
* [MODPATH-RW](https://github.com/upc-ghs/modpath-rw)
* [MODPATH](https://www.usgs.gov/software/modpath-particle-tracking-model-modflow)
* [modpath-v7](https://github.com/MODFLOW-USGS/modpath-v7)
* [modpath-omp](https://github.com/upc-ghs/modpath-omp)

MIT License

Copyright (c) 2023 Hydrogeology Group - Universitat Politècnica de Catalunya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "flopyrw",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "MODPATH-RW,hydrogeology,rwpt",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/5c/85/d1593f132976ffc82c3b000651d8ef47834e954880a4d28c0631df9c50df/flopyrw-1.0.0.tar.gz",
    "platform": null,
    "description": "## flopyrw\nAn extension of [FloPy](https://github.com/modflowpy/flopy) to write input simulation files for [MODPATH-RW](https://gitub.com/upc-ghs/modpath-rw) with Python.\n\n### Overview\nProvides classes extended from the `modpath` module in `flopy` adapted to specific structures required by MODPATH-RW. Also introduces new package writers required by the program, consistent with the [Documentation of Input-Output](https://github.com/upc-ghs/modpath-rw/blob/develop/doc/modpath-rw_IO_v100_.pdf). \n\n\n### Quickstart\n**Install**\n\nTo install the package from source, clone the repository:\n\n```\ngit clone https://github.com/upc-ghs/flopyrw\n```\nand install \n\n```\npip install -e /the/path/to/flopyrw/\n```\n\nYou can also install the current release from [PyPI](https://pypi.org/project/flopyrw/):\n\n```\npip install flopyrw\n```\n\n**Use it**\n\nClasses follow the same logic than `flopy`, configuring packages on top of a MODFLOW flow-model object. For example, the `flopy` quickstart case: \n\n```py\nimport os\nimport flopy\nfrom flopyrw import modpathrw\n\nws   = './mymodel'\nname = 'mymodel'\nsim  = flopy.mf6.MFSimulation(sim_name=name, sim_ws=ws, exe_name='mf6')\ntdis = flopy.mf6.ModflowTdis(sim)\nims  = flopy.mf6.ModflowIms(sim)\ngwf  = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)\ndis  = flopy.mf6.ModflowGwfdis(gwf, nrow=10, ncol=10)\nic   = flopy.mf6.ModflowGwfic(gwf)\nnpf  = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True)\n# Same than in flopy quickstart,\n# but with an aux var for concentration.\nchd  = flopy.mf6.ModflowGwfchd(\n        gwf,\n        auxiliary=['CONCENTRATION'],\n        stress_period_data=[\n            [(0, 0, 0), 1.,1.],\n            [(0, 9, 9), 0.,0.]\n        ]\n    )\nbudget_file = name + '.bud'\nhead_file   = name + '.hds'\noc = flopy.mf6.ModflowGwfoc(gwf,\n        budget_filerecord=budget_file,\n        head_filerecord=head_file,\n        saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')]\n    )\nsim.write_simulation()\nsim.run_simulation()\n\n# Create a modpathrw model\n# By default executable is 'mpathrw'\nmprw = modpathrw.ModpathRW(flowmodel=gwf)\n\n# Random walk options\nmodpathrw.ModpathRWOpts(\n        mprw,\n        timestep = 'min',\n        ctdisp   = 0.1,\n        courant  = 0.1,\n        dimensionsmask=[1,1,0], # Random walk in x,y and not in z\n    )\n\n# Dispersion parameters \nmodpathrw.ModpathRWDsp( mprw, alphal=0.1, alphat=0.01,  dmeff=0.0 )\n\n# Basic package\nmodpathrw.ModpathRWBas( mprw, porosity=0.3 )\n\n# Define the solute source\n# In forward tracking, only cells with injecting flow-rate release particles\nmodpathrw.ModpathRWSrc(\n        mprw,\n        sources=(\n            'CHD', # package name\n            [            \n                [\n                    'CONCENTRATION', # aux variable\n                    0.001,           # particlesmass\n                    (4,4,1)          # template\n                ], \n            ],\n        ),\n    )\n\n# Configure the simulation \nsimconfig = {\n    'simulationtype'    : 'rwendpoint', \n    'trackingdirection' : 'forward',\n    'weaksinkoption'    : 'stop_at',\n    'weaksourceoption'  : 'pass_through',\n    'stoptimeoption'    : 'specified',\n    'stoptime'          : 20.0,\n}\nmprwsim = modpathrw.ModpathRWSim( mprw,  **simconfig )\n\n# Write the input files\nmprw.write_input()\n\n# And run \nmprw.run_model()\n\n# Get output and plot\nhead   = gwf.output.head().get_data()\nbud    = gwf.output.budget()\nepoint = flopy.utils.EndpointFile( os.path.join( ws, mprwsim.endpointfilename ) ) \nspdis  = bud.get_data(text='DATA-SPDIS')[0]\nqx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spdis, gwf)\npmv = flopy.plot.PlotMapView(gwf)\npmv.plot_array(head)\npmv.plot_grid(colors='white')\npmv.contour_array(head, levels=[.2, .4, .6, .8], linewidths=3.)\npmv.plot_vector(qx, qy, normalize=True, color=\"white\")\npmv.plot_endpoint( epoint.get_alldata(), zorder=10, s=4, linewidth=0.5, edgecolor='k' )\n```\n<img src=\"img/quickstart.png\" alt=\"plot\" style=\"width:30;height:30\">\n\n**Note**: In order to run a model via the interface a [MODPATH-RW](https://gitub.com/upc-ghs/modpath-rw) executable is required. \n\n\n### Testing\nA suite of [automated tests](autotest/) is available verifying different aspects of the interface and the program. In order to run these tests, some additional dependencies are required, which can be installed with:\n\n```\npip install \".[test]\"\n```\n\nYou can follow the [FloPy test guidelines](https://github.com/modflowpy/flopy/blob/develop/DEVELOPER.md#running-tests) for running and debugging tests. \n\nRun the complete test suite from the folder ``autotest`` with the command:\n\n```\npytest -s -v \n```\n\n## Resources\n* [flopy](https://github.com/modflowpy/flopy)\n* [MODPATH-RW](https://github.com/upc-ghs/modpath-rw)\n* [MODPATH](https://www.usgs.gov/software/modpath-particle-tracking-model-modflow)\n* [modpath-v7](https://github.com/MODFLOW-USGS/modpath-v7)\n* [modpath-omp](https://github.com/upc-ghs/modpath-omp)\n\nMIT License\n\nCopyright (c) 2023 Hydrogeology Group - Universitat Polit\u00e8cnica de Catalunya\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python interface based on FloPy to configure input files for MODPATH-RW",
    "version": "1.0.0",
    "project_urls": null,
    "split_keywords": [
        "modpath-rw",
        "hydrogeology",
        "rwpt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7c591ca22dee0fb877424a223c3e91ff12f4aec0baec814c4a96b438250f9d7",
                "md5": "fcd40397c06e5d9e453189b03db4f586",
                "sha256": "fcfc12c9beb019152e446f56477629ee2e84f68d278aeb3d7a3efb7f887876dc"
            },
            "downloads": -1,
            "filename": "flopyrw-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fcd40397c06e5d9e453189b03db4f586",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5131,
            "upload_time": "2023-08-07T16:30:06",
            "upload_time_iso_8601": "2023-08-07T16:30:06.275618Z",
            "url": "https://files.pythonhosted.org/packages/b7/c5/91ca22dee0fb877424a223c3e91ff12f4aec0baec814c4a96b438250f9d7/flopyrw-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c85d1593f132976ffc82c3b000651d8ef47834e954880a4d28c0631df9c50df",
                "md5": "c5f31c6e235c55835dd0aeb8cefdc9e1",
                "sha256": "c63ccd20f238b4f969dd4a3ae49490b03333e4b58274a12e529668914d4e8dda"
            },
            "downloads": -1,
            "filename": "flopyrw-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c5f31c6e235c55835dd0aeb8cefdc9e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4414,
            "upload_time": "2023-08-07T16:30:07",
            "upload_time_iso_8601": "2023-08-07T16:30:07.909128Z",
            "url": "https://files.pythonhosted.org/packages/5c/85/d1593f132976ffc82c3b000651d8ef47834e954880a4d28c0631df9c50df/flopyrw-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-07 16:30:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "flopyrw"
}
        
Elapsed time: 0.09859s