-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modflowapi interface #8
Conversation
@jdhughes-usgs @langevin-usgs @spaulins-usgs Draft pull request for the modflowapi interface methods. The previous one had a sticky CI issue that required the repository to be recreated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlarsen-usgs, this is a great contribution. You've clearly put a lot of work and thought into this design, and I like where it's headed. I have only one small comment, and that is I wonder if it would be beneficial to rename some of the classes. For example, you have Simulation, Model, and PackageBase classes. Would it be worth considering ApiSimulation, ApiModel, and ApiPackageBase? I'm not completely sold on this renaming, but I can see people (mostly me) getting confused looking at a script that has a mix of flopy and modflowapi objects. To complicate things further for mf6 developers, we have yet another Simulation class/object, which has been confusing for us, and is on our list for refactoring.
@mjr-deltares and @w-bonelli |
Hey @jlarsen-usgs , nice job! I am pretty sure that people have been waiting for this capability. A couple of things came to mind when looking at the current implementation, first more at the design level:
Some minor things:
If it's more convenient to iterate on these points in a meeting, I am available. |
I've looked through your comments and made some updates to the draft PR.
I think it'd be worth having a meeting to discuss the other comments on the design level review and where/how to best implement some of this. |
@jlarsen-usgs wondering if
could be made to work so that it uses the first model name/id if a model name or id is not specified. This is what we have done for the solution groups in xmpy, |
@jdhughes-usgs I could update:
to return the first model name/id if a model isn't specified. |
@jlarsen-usgs
I get:
The model does not have any of the advanced packages. Is it intended that these objects are created even if they are not in a model? |
* add stress_period_start, stress_period_end Callbacks * fix ApiModel __repr__ * added Exchanges, TDIS, ATS, and SLN support * added ScalarInput and ScalarPackage support * update autotests
* added parallel testing support through pytest-xdist * updated markers and split the extensions tests from the mf6 examples tests * added a test for ATS
@jlarsen-usgs could we add a |
@jlarsen-usgs I think there is also a need for a |
modflowapi/extensions/runner.py
Outdated
except Exception: | ||
raise RuntimeError("MF6 simulation failed, check listing file") | ||
|
||
print("SUCCESSFUL TERMINATION OF THE SIMULATION") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better if this string were Normal termination of simulation.
in order to be consistent with the MODFLOW 6 normal termination message.
@jlarsen-usgs How can I get and set |
@jdhughes-usgs auxiliary variables are now included in the stress period data recarray when they exist (naux > 0) within a modflow package. |
@jlarsen-usgs The
An enhancement would be to use the actual |
@jdhughes-usgs I agree that the actual |
Hey @jlarsen-usgs, you should be able to get a copy of AUXNAME_CST through the xmipy, I think. |
@jlarsen-usgs Would be nice to be able to get
to get this data from the MODFLOW model. Seems something similar to the way stress period data is accessed would work here as well. |
…ses for a package
* added a `totim` property on `ApiSimulation` and `ApiModel` * added docstrings to ApiModel property methods * updated termination message in run_simulation * added a finalize callback to Callbacks and run_simulation
Hey @jlarsen-usgs, here is a test of the new functionality for getting a string array (in this case it is BOUNDNAME_CST): |
It looks like xmipy is working correctly for getting a string array. I tested it with BOUNDNAME_CST and it works well. |
Hi @jlarsen-usgs, I just ran a minimal example with a GWF model + WEL with 2 aux variables. It looks like the |
@mjr-deltares updated my libmf6.dll and I am now able to access |
excellent! |
* ApiModel: adjust X based on nodetouser * ApiPackage: enforce lower cased variable names in get_advanced_var * ArrayPointer: trap for arrays that are not adjusted by reduced node numbers (ex. idomain)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet
* Fix typo in README (#4) * modflowapi interface (#8) * update package: manual variable address assembly updated to use xmipy get_variable_addr() * update additional manual variable address assembly statements * Refactor code and added functionality: * add stress_period_start, stress_period_end Callbacks * fix ApiModel __repr__ * added Exchanges, TDIS, ATS, and SLN support * added ScalarInput and ScalarPackage support * update autotests * added parallel testing support through pytest-xdist * updated markers and split the extensions tests from the mf6 examples tests * added a test for ATS * update setup.cfg * update ci.yml * update(ListInput): add auxvar to stress_period_data when auxiliary variables are used * Allow None to be passed to stress_period_data.values to disable stresses for a package * updates: ApiModel, ApiSimulation, run_simulation * added a `totim` property on `ApiSimulation` and `ApiModel` * added docstrings to ApiModel property methods * updated termination message in run_simulation * added a finalize callback to Callbacks and run_simulation * add support for AUXNAME_CST * add(Head Monitor Example): Add a head monitor example application * ApiModel: adjust X based on nodetouser * ApiPackage: enforce lower cased variable names in get_advanced_var * ArrayPointer: trap for arrays that are not adjusted by reduced node numbers (ex. idomain) * update setup.cfg * try reformatting the xmipy installation instructions * fix(get value): fixed error handling when modflowapi fails to get a pointer to a value from the API (#9) Co-authored-by: scottrp <[email protected]> * update(rhs, hcof, AdvancedInput): bug fixes for setting variable values for advanced inputs * update rhs and hcof to copy values to pointer instead of overwriting the pointer * add a check for AdvancedInput variables that do not have pointer support in xmipy * update setting routine for AdvancedInput * refactor(EOL): change CRLF to LF line endings for source files (#12) * Use pyproject.toml for project metadata, add citation info (#11) * add(test_rhs_hcof_advanced): add additional test (#13) * added test for getting and setting rhs, hcof, and advanced variable values * update project to use unix line separators * use np.testing.assert_allclose() instead of AssertionError * Add missing RIV support to modflowapi (#16) * add(test_rhs_hcof_advanced): add additional test * added test for getting and setting rhs, hcof, and advanced variable values * update project to use unix line separators * use np.testing.assert_allclose() instead of AssertionError * Add missing riv package to modflowapi * release: v0.1.0 --------- Co-authored-by: Hofer-Julian <[email protected]> Co-authored-by: Joshua Larsen <[email protected]> Co-authored-by: spaulins-usgs <[email protected]> Co-authored-by: scottrp <[email protected]> Co-authored-by: Mike Taves <[email protected]>
Interface code and unit tests for modflowapi python package
Includes the addition of:
Simulation
: container for wrapping modflow simulations and allows users to access underlying dataModel
: model container that allows user to access model data and is a container that loads and provides access to packagesArrayPackage
,ListPackage
,AdvancedPackage
: Containers for storing package information and loading/editing package dataArrayInput
,ArrayPointer
,ListInput
: Containers for package data that allow the user to dynamically edit and set modflow stress data.run_model
: a simulation runner for the modflowapiCallbacks
: an enumeration scheme for creating custom callback functions to adjust model data