Skip to content
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

Creating empty packages results in unguided errors #333

Open
bdestombe opened this issue Apr 8, 2024 · 3 comments
Open

Creating empty packages results in unguided errors #333

bdestombe opened this issue Apr 8, 2024 · 3 comments

Comments

@bdestombe
Copy link
Collaborator

bdestombe commented Apr 8, 2024

I have a modelscript up and running for a specific model extent.

However, when I change the model extent so that several boundary condition definitions completely fall outside the model extent. The packages that configure those boundary conditions should not be added to the MF6 simulation.

For example
I am configuring the well package and depending on the extent I select, wells need to be configured or not. In the current implementation and all wells fall outside the extent, nlmod gladly configures via flopy a well-package with stress-period-data of length 0. No problem so far. However when we write and run the simulation results in the following error:

Resources Software User Rights Notice for complete use, copyright, 
and distribution information.

 
 Run start date and time (yyyy/mm/dd hh:mm:ss): 2024/04/08 10:58:44
 
 Writing simulation list file: mfsim.lst
 Using Simulation name file: mfsim.nam
 

ERROR REPORT:

  1. Required block "DIMENSIONS" not found.  Found end of file instead.

UNIT ERROR REPORT:

  1. Error occurred while reading file
     '/workspaces/NHFLO/models/modelscripts/09pwnmodel2/model_ws/pwn_gwt.cnc'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/workspaces/nlmod/build/__editable__.nlmod-0.7.2-py3-none-any/nlmod/sim/sim.py", line 63, in write_and_run
    assert sim.run_simulation(silent=silent)[0], "Modflow run not succeeded"
AssertionError: Modflow run not succeeded

The same error message comes from zero-length stress-period-data for the CNC package.

Desired behavior
Zero-length stress-period-data does not result in the crashing of MF6.

Solution

  • Should we replace a zero-length stree-period-data with None in all the package creation routines? Would that solve our problem? (results in cnc.stress_period_data.data is None)
  • Alternatively, if the length of the stress-period-data is zero, don't create the flopy package.
  • Or, in the nlmod.sim.write_and_run(sim, ds) function, remove packages from the simulation that have zero-length stress-period-data.

The error message given by mf6 is not so helpfull..

@bdestombe
Copy link
Collaborator Author

bdestombe commented Apr 8, 2024

Currently, I have in my modelscripts the following code. It works, is not pretty and not intuitively implented by the end-user.

if cnc.stress_period_data.data is None:
    gwt.remove_package(cnc.name[0])

@dbrakenhoff
Copy link
Collaborator

Checking for zero length stress_period_data makes sense to me. The least we should do is log a warning, but I think it also makes sense to prevent the package from being added/created in that situation.

@bdestombe
Copy link
Collaborator Author

Thus using the example of the initiation of the CNC package:

    cnc = nlmod.gwt.cnc(
        ds,
        gwt,
        da_mask=(ds["northsea"] == 1).expand_dims({"layer": [ds.layer.data[0]]}),
        da_conc=ds["chloride"].isel(layer=slice(0, 1)),
    )

this code produce a zero-length stress_period_data because idomain, stored in ds, is false for all relevant cells.

Running this line of code should:

  • Not raise an error
  • Add a warning to the log that the package will not be added to the simulation because there is no stress_period_data
  • Do not add the package to gwt
  • Return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants