Skip to content

[panden] SSM registration guard cannot dedupe when riv_from_oppervlakte_pwn is called twice on one gwf #69

Description

@bdestombe

panden.py:93-96:

if ds.transport:
    ssm_sources = list(ds.attrs.get("ssm_sources", []))
    if riv.package_name not in ssm_sources:
        ds.attrs["ssm_sources"] = [*ssm_sources, riv.package_name]

flopy assigns a fresh unique package_name to each ModflowGwfriv instance — riv_0 for the first, riv_1 for the second (verified on flopy 3.11.0.dev0). So on a second call against the same gwf, riv.package_name is a name never seen before, the guard cannot match, and ssm_sources grows to ['riv_0', 'riv_1'].

The guard does work in the scenario it was presumably written for — rerunning the script with a freshly built flow model, where the name resets to riv_0.

The larger problem behind it: a second call on the same gwf silently attaches a second RIV package carrying the same stress-period data, doubling the pond conductance, with no warning. Guarding the SSM list does not prevent that.

Suggested direction: detect an existing RIV package on gwf and either replace it or raise, rather than deduplicating by name after the fact.

Found while writing the test suite; the test pins the fresh-model scenario (one entry after two builds), not the same-gwf one.

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