Skip to content

Add sy pertubation method#2

Draft
HendrikKok wants to merge 12 commits into
add_bmifrom
add_sy_pertubation_method
Draft

Add sy pertubation method#2
HendrikKok wants to merge 12 commits into
add_bmifrom
add_sy_pertubation_method

Conversation

@HendrikKok

@HendrikKok HendrikKok commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Add Daisy-specific API layer with perturbation_tick support

Builds on top of add_bmi to expose a DaisyAPI class that inherits
the standard BMI interface and adds Daisy-specific coupling methods not
covered by BMI 2.0.

What's in this branch

DaisyAPI class (include/programs/daisy_api.h, src/programs/daisy_api.C)

  • Inherits BMI — all standard BMI methods are available
  • Adds perturbation_tick(dh_cm): re-runs Richards with a raised groundwater
    table and returns the perturbed (theta, flux, h) arrays, then restores
    Daisy to the real post-tick state via a RAII guard. Used by the caller to
    estimate specific yield (Sy) externally.

RichardsSnapshots (include/daisy/richards_snapshots.h)

  • General pre/post snapshot mechanism for Richards solver state (h, Theta, S_sum, groundwater table)
  • Snap before and after movement->tick(); restore in either direction
  • Adding a new snapshotted variable requires one member + one line — no other changes

GroundwaterApi (src/daisy/lower_boundary/groundwater_api.C)

  • New Groundwater subtype whose table depth is written each coupling step from Python
  • Replaces the need to reach into the column internals to set the lower boundary

Python bindings (src/programs/api_bindings.cpp)

  • BMI registered as "BMI" (was "DaisyBMI")
  • DaisyAPI registered as "API"
  • get_value_array exposed for array variables

__init__.py

  • Imports both BMI and API from the .pyd

Example (python/examples/daisy_api_example.py, renamed from daisy_bmi_example.py)

  • Updated docstring to reflect extended API usage

- Add RichardsSnapshots helper class (include/daisy/richards_snapshots.h)
  General pre/post snapshot mechanism using pointer-to-member to avoid
  code duplication. Replaces individual h_pretick_/theta_pretick_/etc. fields.

- Refactor column_std.C to use RichardsSnapshots
  snap_pre() called just before movement->tick(), snap_post() just after.
  perturbation_tick() uses RAII guard to restore post-tick state atomically.

- Rename estimate_sy_perturbation -> perturbation_tick throughout
  Return type changes from {double Sy, vec, vec} to {vec, vec, vec}.
  Sy computation moves to the Python caller.

- Add DaisyAPI class (include/programs/daisy_api.h, src/programs/daisy_api.C)
  Inherits DaisyBMI (pure BMI 2.0), adds non-standard extensions.
  perturbation_tick() lives here, not on DaisyBMI.

- Rename DaisyPythonController -> DaisyController
  Name no longer implies Python-specific; it is an internal C++ wrapper.

- Rename bmi_bindings.cpp -> api_bindings.cpp
  Binds both DaisyBMI and DaisyAPI. DaisyAPI is the recommended class
  for Python coupling.

- Update CMakeLists.txt, __init__.py to reflect new files and DaisyAPI export
# Conflicts:
#	python/src/daisy/__init__.py
@HendrikKok HendrikKok closed this Jun 29, 2026
@HendrikKok HendrikKok reopened this Jun 29, 2026
# Conflicts:
#	include/programs/bmi.h
#	src/programs/api_bindings.cpp
#	src/programs/daisy_bmi.C
# Conflicts:
#	include/daisy/column.h
#	include/daisy/daisy.h
#	src/daisy/column_std.C
#	src/daisy/daisy.C
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

Successfully merging this pull request may close these issues.

1 participant