Skip to content

Dynamic Update of Hydraulic Conductivity During Simulation Has No Effect (MODFLOW API) #86

@zongxunchai

Description

@zongxunchai

Description

I am working on reactive transport modeling where chemical reactions alter the hydraulic conductivity (K) of the porous medium during simulation.

To explore this, I coupled MODFLOW 6 with PhreeqcRM, verified several PHT3D benchmark cases, and attempted to dynamically update k11 using the modflowapi interface. However, modifying k11 during runtime does not appear to affect the simulation results.

Minimal Example

A minimal reproducible 1D example:

import time
import flopy
import numpy as np
import modflowapi
import matplotlib.pyplot as plt

initial_k = np.ones((1, 1, 50)) * 10.0

sim = flopy.mf6.MFSimulation(sim_name='model', sim_ws='./mymodel', exe_name='mf6')
tdis = flopy.mf6.ModflowTdis(sim, nper=1, perioddata=[(365, 100, 1.0)])
ims = flopy.mf6.ModflowIms(sim)
gwf = flopy.mf6.ModflowGwf(sim, modelname='gwf_model', save_flows=True)
dis = flopy.mf6.ModflowGwfdis(gwf, nrow=1, ncol=50)
ic = flopy.mf6.ModflowGwfic(gwf)
npf = flopy.mf6.ModflowGwfnpf(gwf, k=initial_k, save_specific_discharge=True)
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=[[(0, 0, 0), 1.], [(0, 0, 49), 0.]])
oc = flopy.mf6.ModflowGwfoc(gwf,
    budget_filerecord='gwf_model.bud',
    head_filerecord='head.hds',
    saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')])

sim.write_simulation()
sim.run_simulation()

Then, attempting to update k11 dynamically:

modflow_api = modflowapi.ModflowApi("C:\\ProgramFiles\\MODFLOW\\libmf6.dll", working_directory="./mymodel")
modflow_api.initialize()
sim = modflowapi.extensions.ApiSimulation.load(modflow_api)
gwf_model = sim.get_model('gwf_model')
npf = gwf_model.get_package("npf")

hk = npf.get_array("k11")
current_time = modflow_api.get_current_time()
end_time = modflow_api.get_end_time()

while current_time < end_time:
    dt = modflow_api.get_time_step()
    modflow_api.prepare_time_step(dt)
    modflow_api.update()

    hk[0, 0, 0:10] += 1  # increase K in first 10 cells
    npf.set_array("k11", hk)

    current_time = modflow_api.get_current_time()

modflow_api.finalize()

Expected Behavior

Changes to k11 during runtime should alter flow results (e.g., head distribution).

Actual Behavior

The simulation results remain identical regardless of modifications to k11.

Additional Context

The following statement from Hughes et al., 2022 (Environmental Modelling & Software) may be relevant:

“… modifying k11 after initialization would have no effect on the simulation results. Other parameters, such as those related to the dimensionality of the coefficient matrices or to the time discretization, should probably not be modified to avoid undefined behavior and possible program failure.”

This suggests that k11 may be fixed after initialization, preventing runtime updates.

Questions

Is it currently possible to dynamically update hydraulic conductivity during a simulation using modflowapi (e.g., within each time step)?

Has any new mechanism been introduced—perhaps via the Time-Varying Hydraulic Conductivity (TVK) capability or another feature—that would allow K to evolve dynamically according to an external process (e.g., chemical reactions computed by PhreeqcRM)?

If not, is there any recommended workaround for coupling reactive transport processes that alter flow properties mid-simulation?

Any guidance or documentation references would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions